Skip to content

Commit

Permalink
[IMP] account_reconcile_oca: Use receivable/payable account on statem…
Browse files Browse the repository at this point in the history
…ents with partner as suspense account
  • Loading branch information
etobella committed Dec 9, 2024
1 parent 1d00fe5 commit 69cf2d2
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
12 changes: 8 additions & 4 deletions account_reconcile_oca/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,17 @@ def _recompute_suspense_line(self, data, reconcile_auxiliary_id, manual_referenc
}
)
else:
account = self.journal_id.suspense_account_id
if self.partner_id and total_amount > 0:
can_reconcile = True
account = self.partner_id.property_account_receivable_id
elif self.partner_id and total_amount < 0:
can_reconcile = True
account = self.partner_id.property_account_payable_id
suspense_line = {
"reference": "reconcile_auxiliary;%s" % reconcile_auxiliary_id,
"id": False,
"account_id": [
self.journal_id.suspense_account_id.id,
self.journal_id.suspense_account_id.display_name,
],
"account_id": [account.id, account.display_name],
"partner_id": self.partner_id
and [self.partner_id.id, self.partner_id.display_name]
or (self.partner_name and (False, self.partner_name))
Expand Down
48 changes: 48 additions & 0 deletions account_reconcile_oca/tests/test_bank_account_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,3 +1162,51 @@ def test_invoice_foreign_currency_change(self):
self.assertFalse(f.add_account_move_line_id)
self.assertTrue(f.can_reconcile)
self.assertEqual(3, len(f.reconcile_data_info["data"]))

def test_receivable_line(self):
bank_stmt_line = self.acc_bank_stmt_line_model.create(
{
"name": "testLine",
"journal_id": self.bank_journal_euro.id,
"partner_id": self.partner_agrolait_id,
"amount": 100,
"date": time.strftime("%Y-07-15"),
}
)
self.assertTrue(bank_stmt_line.can_reconcile)
suspense_line = False
for line in bank_stmt_line.reconcile_data_info["data"]:
if line["kind"] == "suspense":
suspense_line = line
break
self.assertTrue(suspense_line)
self.assertEqual(
self.env["account.account"]
.browse(suspense_line["account_id"][0])
.account_type,
"asset_receivable",
)

def test_payable_line(self):
bank_stmt_line = self.acc_bank_stmt_line_model.create(
{
"name": "testLine",
"journal_id": self.bank_journal_euro.id,
"partner_id": self.partner_agrolait_id,
"amount": -100,
"date": time.strftime("%Y-07-15"),
}
)
self.assertTrue(bank_stmt_line.can_reconcile)
suspense_line = False
for line in bank_stmt_line.reconcile_data_info["data"]:
if line["kind"] == "suspense":
suspense_line = line
break
self.assertTrue(suspense_line)
self.assertEqual(
self.env["account.account"]
.browse(suspense_line["account_id"][0])
.account_type,
"liability_payable",
)

0 comments on commit 69cf2d2

Please sign in to comment.