[FIX] account: cash basis taxis: allow full reconciliation of tax lines on cash basis final account without full payment of the invoice
To reproduce the issue before this fix: 1. Create accounts ACC TAX A, ACC TAX B, with reconcile = True, internal_type = other 2. Create Tax B, with tax_exigibilty = on_payment and account_id = ACC TAX B and cash_basic_account_id = ACC TAX A, 20% 3. Create invoice B, account_id = Tax B, unit_price = 1000, Valide invoice, 4. Register a payment of 600 for invoice B (so, that's half the invoice, when including the taxes). The cash basis tax creates a miscellaneous operation MISC A, containing a line on ACC TAX A. 5. Create a mis operation MISC TVA, like this: line 1 : account_id = ACC TAX A, credit = 100 line 2 : account_id = 401100, debit = 100 6. Reconcile the following move lines: line of MISC A with account ACC TAX A (100) line of MISC TVA with account ACC TAX A (100) ==> The lines should be fully reconciled To solve that without breaking the fix made here https://github.com/odoo/odoo/commit/c43acc34b873dc70cf792675fe1d58d8b0e116b1 , we rely on the tax_exigible field of account move lines. When all the reconcile lines are exigible, it means we're not reconciling the transition line of a cash basis entry, and so we can directly full reconcile. Fixes https://github.com/odoo/odoo/issues/58996 OPW 2350494 X-original-commit: b8ab3c78ff9354091f5154bb03a716c32a609de2
This commit is contained in:
@@ -1718,3 +1718,53 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
|
||||
|
||||
# Check full reconciliation
|
||||
self.assertTrue(all(line.full_reconcile_id for line in lines_to_reconcile), "All tax lines should be fully reconciled")
|
||||
|
||||
def test_caba_dest_acc_reconciliation_partial_pmt(self):
|
||||
""" Test the reconciliation of tax lines (when using a reconcilable tax account)
|
||||
for partially paid invoices with cash basis taxes.
|
||||
This test is especially useful to check the implementation of the use case tested by
|
||||
test_reconciliation_cash_basis_foreign_currency_low_values does not have unwanted side effects.
|
||||
"""
|
||||
|
||||
# Make the tax account reconcilable
|
||||
self.tax_account_1.reconcile = True
|
||||
|
||||
# Create an invoice with a CABA tax using the same tax account and pay half of it
|
||||
caba_inv = self.init_invoice('in_invoice', amounts=[900], post=True, taxes=self.cash_basis_tax_a_third_amount)
|
||||
|
||||
pmt_wizard = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=caba_inv.ids).create({
|
||||
'amount': 600,
|
||||
'payment_date': caba_inv.date,
|
||||
'journal_id': self.company_data['default_journal_bank'].id,
|
||||
'payment_method_id': self.env.ref('account.account_payment_method_manual_in').id,
|
||||
})
|
||||
pmt_wizard._create_payments()
|
||||
|
||||
partial_rec = caba_inv.mapped('line_ids.matched_debit_ids')
|
||||
caba_move = self.env['account.move'].search([('tax_cash_basis_rec_id', '=', partial_rec.id)])
|
||||
|
||||
# Create a misc operation with a line on the tax account, for full reconcile with the tax line
|
||||
misc_move = self.env['account.move'].create({
|
||||
'name': "Misc move",
|
||||
'journal_id': self.company_data['default_journal_misc'].id,
|
||||
'line_ids': [
|
||||
(0, 0, {
|
||||
'name': 'line 1',
|
||||
'account_id': self.tax_account_1.id,
|
||||
'credit': 150,
|
||||
}),
|
||||
(0, 0, {
|
||||
'name': 'line 2',
|
||||
'account_id': self.company_data['default_account_expense'].id, # Whatever the account here
|
||||
'debit': 150,
|
||||
})
|
||||
],
|
||||
})
|
||||
|
||||
misc_move.post()
|
||||
|
||||
lines_to_reconcile = (misc_move + caba_move).mapped('line_ids').filtered(lambda x: x.account_id == self.tax_account_1)
|
||||
lines_to_reconcile.reconcile()
|
||||
|
||||
# Check full reconciliation
|
||||
self.assertTrue(all(line.full_reconcile_id for line in lines_to_reconcile), "All tax lines should be fully reconciled")
|
||||
Reference in New Issue
Block a user