mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
Extract a function which is reused in account_statement_operation_rule_dunning_fees
This commit is contained in:
@@ -53,14 +53,26 @@ class AccountStatementOperationRule(models.Model):
|
|||||||
help="If several rules match, the first one is used.",
|
help="If several rules match, the first one is used.",
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
@staticmethod
|
||||||
def _balance_in_range(self, balance, currency):
|
def _between_with_bounds(low, value, high, currency):
|
||||||
if currency.compare_amounts(balance, self.amount_min) == -1:
|
""" Equivalent to a three way comparison: ``min <= value <= high``
|
||||||
|
|
||||||
|
The comparisons are done with the currency to use the correct
|
||||||
|
precision.
|
||||||
|
"""
|
||||||
|
if currency.compare_amounts(value, low) == -1:
|
||||||
return False
|
return False
|
||||||
if currency.compare_amounts(balance, self.amount_max) == 1:
|
if currency.compare_amounts(value, high) == 1:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def _balance_in_range(self, balance, currency):
|
||||||
|
amount_min = self.amount_min
|
||||||
|
amount_max = self.amount_max
|
||||||
|
return self._between_with_bounds(amount_min, balance,
|
||||||
|
amount_max, currency)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _is_multicurrency(self, statement_line):
|
def _is_multicurrency(self, statement_line):
|
||||||
currency = (statement_line.currency_id or
|
currency = (statement_line.currency_id or
|
||||||
|
|||||||
Reference in New Issue
Block a user