Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][IMP] account_reconcile_oca: Use receivable/payable account on statements with partner as suspense account #677

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -227,13 +227,17 @@ def _recompute_suspense_line(
}
)
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 @@ -1020,3 +1020,51 @@ def test_journal_foreign_currency(self):
self.assertTrue(bank_stmt_line.can_reconcile)
bank_stmt_line.reconcile_bank_line()
self.assertEqual(0, inv1.amount_residual)

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",
)
Loading