Skip to content

Commit 0987236

Browse files
[FIX] l10n_jp_summary_invoice: fix issue when the company currency and billing currency are different
1 parent add1cc9 commit 0987236

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

l10n_jp_summary_invoice/models/account_billing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _get_tax_amount_groups_from_invoices(self):
154154
("display_type", "=", "rounding"),
155155
("tax_repartition_line_id", "!=", False),
156156
],
157-
fields=["tax_group_id", "balance"],
157+
fields=["tax_group_id", "amount_currency:sum"],
158158
groupby=["tax_group_id"],
159159
)
160160
return tax_amount_groups
@@ -190,7 +190,7 @@ def validate_billing(self):
190190
tax_group_diff_dict = {}
191191
for tax_amount_group in tax_amount_groups_invoices:
192192
tax_group_id = tax_amount_group["tax_group_id"][0]
193-
tax_amount_invoices = tax_amount_group["balance"]
193+
tax_amount_invoices = tax_amount_group["amount_currency"]
194194
tax_amount_bill = tax_group_amount_dict.get(tax_group_id, 0)
195195
tax_diff = tax_amount_invoices - tax_amount_bill
196196
if tax_diff:

l10n_jp_summary_invoice/tests/test_l10n_jp_summary_invoice.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,17 @@ def setUpClass(cls):
5858
}
5959
)
6060

61-
def _create_invoice(self, amount, tax, move_type="out_invoice", bank=None):
61+
def _create_invoice(
62+
self, amount, tax, move_type="out_invoice", bank=None, currency_id=None
63+
):
6264
invoice = (
6365
self.env["account.move"]
6466
.with_company(self.company)
6567
.create(
6668
{
6769
"move_type": move_type,
6870
"partner_id": self.partner.id,
71+
"currency_id": currency_id or self.company.currency_id.id,
6972
"partner_bank_id": bank and bank.id,
7073
"invoice_line_ids": [
7174
Command.create(
@@ -194,3 +197,19 @@ def test_create_tax_adjustment_entry(self):
194197
# The total tax amount should be 20 (204 * 0.1)
195198
self.assertEqual(abs(billing_tax_amount), 20)
196199
self.assertFalse(billing.tax_adjustment_entry_id)
200+
201+
def test_check_tax_adjustment_entry_with_different_currency(self):
202+
currency_usd = self.env.ref("base.USD")
203+
currency_usd.active = True
204+
out_inv_1 = self._create_invoice(100, self.tax_10, currency_id=currency_usd.id)
205+
out_inv_2 = self._create_invoice(100, self.tax_10, currency_id=currency_usd.id)
206+
out_inv_3 = self._create_invoice(100, self.tax_10, currency_id=currency_usd.id)
207+
invoices = out_inv_1 + out_inv_2 + out_inv_3
208+
action = invoices.action_create_billing()
209+
billing = self.env["account.billing"].browse(action["res_id"])
210+
self.assertEqual(billing.state, "draft")
211+
self.assertEqual(billing.currency_id, currency_usd)
212+
billing.with_company(self.company).validate_billing()
213+
billing_tax_amount = self._get_billing_tax_amount(billing)
214+
self.assertEqual(abs(billing_tax_amount), 30)
215+
self.assertFalse(billing.tax_adjustment_entry_id)

0 commit comments

Comments
 (0)