Skip to content
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
4 changes: 2 additions & 2 deletions l10n_jp_summary_invoice/models/account_billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def _get_tax_amount_groups_from_invoices(self):
("display_type", "=", "rounding"),
("tax_repartition_line_id", "!=", False),
],
fields=["tax_group_id", "balance"],
fields=["tax_group_id", "amount_currency:sum"],
groupby=["tax_group_id"],
)
return tax_amount_groups
Expand Down Expand Up @@ -190,7 +190,7 @@ def validate_billing(self):
tax_group_diff_dict = {}
for tax_amount_group in tax_amount_groups_invoices:
tax_group_id = tax_amount_group["tax_group_id"][0]
tax_amount_invoices = tax_amount_group["balance"]
tax_amount_invoices = tax_amount_group["amount_currency"]
tax_amount_bill = tax_group_amount_dict.get(tax_group_id, 0)
tax_diff = tax_amount_invoices - tax_amount_bill
if tax_diff:
Expand Down
22 changes: 21 additions & 1 deletion l10n_jp_summary_invoice/tests/test_l10n_jp_summary_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@ def setUpClass(cls):
}
)

def _create_invoice(self, amount, tax, move_type="out_invoice", bank=None):
def _create_invoice(
self, amount, tax, move_type="out_invoice", bank=None, currency_id=None
):
invoice = (
self.env["account.move"]
.with_company(self.company)
.create(
{
"move_type": move_type,
"partner_id": self.partner.id,
"currency_id": currency_id or self.company.currency_id.id,
"partner_bank_id": bank and bank.id,
"invoice_line_ids": [
Command.create(
Expand Down Expand Up @@ -194,3 +197,20 @@ def test_create_tax_adjustment_entry(self):
# The total tax amount should be 20 (204 * 0.1)
self.assertEqual(abs(billing_tax_amount), 20)
self.assertFalse(billing.tax_adjustment_entry_id)

def test_check_tax_adjustment_entry_with_different_currency(self):
self.assertEqual(self.env.company.currency_id, self.env.ref("base.JPY"))
currency_usd = self.env.ref("base.USD")
currency_usd.active = True
out_inv_1 = self._create_invoice(100, self.tax_10, currency_id=currency_usd.id)
out_inv_2 = self._create_invoice(100, self.tax_10, currency_id=currency_usd.id)
out_inv_3 = self._create_invoice(100, self.tax_10, currency_id=currency_usd.id)
invoices = out_inv_1 + out_inv_2 + out_inv_3
action = invoices.action_create_billing()
billing = self.env["account.billing"].browse(action["res_id"])
self.assertEqual(billing.state, "draft")
self.assertEqual(billing.currency_id, currency_usd)
billing.with_company(self.company).validate_billing()
billing_tax_amount = self._get_billing_tax_amount(billing)
self.assertEqual(abs(billing_tax_amount), 30)
self.assertFalse(billing.tax_adjustment_entry_id)
Loading