[FIX] account: reconcilation simplest case
The recent change (e130606602) broke the use case of an invoice/payment in the company currency without any secondary currency involved. Payment was recorded correctly but no full reconciliation was created (and it was not tested).
In order to fix that, we allow to test total_debit and total_credit also when currency has never been set (no secondary currency at all)
This commit is contained in:
@@ -1822,7 +1822,7 @@ class AccountPartialReconcile(models.Model):
|
||||
total_amount_currency = 0
|
||||
#make sure that all partial reconciliations share the same secondary currency otherwise it's not
|
||||
#possible to compute the exchange difference entry and it has to be done manually.
|
||||
currency = self[0].debit_move_id.currency_id or self[0].credit_move_id.currency_id
|
||||
currency = self[0].debit_move_id.currency_id or self[0].credit_move_id.currency_id or None
|
||||
more_than_1_currency = False
|
||||
maxdate = '0000-00-00'
|
||||
|
||||
@@ -1838,7 +1838,7 @@ class AccountPartialReconcile(models.Model):
|
||||
more_than_1_currency = True
|
||||
if partial_rec.currency_id != currency:
|
||||
#no exchange rate entry will be created
|
||||
currency = None
|
||||
currency = False
|
||||
for aml in [partial_rec.debit_move_id, partial_rec.credit_move_id]:
|
||||
if aml not in aml_set:
|
||||
if aml.amount_residual or aml.amount_residual_currency:
|
||||
@@ -1863,7 +1863,8 @@ class AccountPartialReconcile(models.Model):
|
||||
aml_ids = aml_set.ids
|
||||
#if the total debit and credit are equal, or the total amount in currency is 0, the reconciliation is full
|
||||
digits_rounding_precision = aml_set[0].company_id.currency_id.rounding
|
||||
if (currency and float_is_zero(total_amount_currency, precision_rounding=currency.rounding)) or (more_than_1_currency and float_compare(total_debit, total_credit, precision_rounding=digits_rounding_precision) == 0):
|
||||
if (currency and float_is_zero(total_amount_currency, precision_rounding=currency.rounding)) or \
|
||||
((currency is None or more_than_1_currency) and float_compare(total_debit, total_credit, precision_rounding=digits_rounding_precision) == 0):
|
||||
exchange_move_id = False
|
||||
if aml_to_balance:
|
||||
exchange_move = self.env['account.move'].create(
|
||||
|
||||
@@ -139,6 +139,7 @@ class TestPayment(AccountingTestCase):
|
||||
{'account_id': self.account_eur.id, 'debit': 300.0, 'credit': 0.0, 'amount_currency': 0, 'currency_id': False},
|
||||
{'account_id': inv_1.account_id.id, 'debit': 0.0, 'credit': 300.0, 'amount_currency': 00, 'currency_id': False},
|
||||
])
|
||||
self.assertTrue(payment.move_line_ids.filtered(lambda l: l.account_id == inv_1.account_id)[0].full_reconcile_id)
|
||||
|
||||
liquidity_aml = payment.move_line_ids.filtered(lambda r: r.account_id == self.account_eur)
|
||||
bank_statement = self.reconcile(liquidity_aml, 200, 0, False)
|
||||
|
||||
Reference in New Issue
Block a user