[FIX] l10n_in_edi: rounding add in total
Rounding is considered in the total invoice value in JSON data. Task id: 3276310 closes odoo/odoo#119851 X-original-commit: 1280b3a21537f24b4928d1314b911398417a7a15 Signed-off-by: Josse Colpaert <jco@odoo.com> Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
This commit is contained in:
@@ -452,6 +452,8 @@ class AccountEdiFormat(models.Model):
|
||||
is_overseas = invoice.l10n_in_gst_treatment == "overseas"
|
||||
lines = invoice.invoice_line_ids.filtered(lambda line: line.display_type not in ('line_note', 'line_section', 'rounding'))
|
||||
tax_details_per_record = tax_details.get("tax_details_per_record")
|
||||
sign = invoice.is_inbound() and -1 or 1
|
||||
rounding_amount = sum(line.balance for line in invoice.line_ids if line.display_type == 'rounding') * sign
|
||||
json_payload = {
|
||||
"Version": "1.1",
|
||||
"TranDtls": {
|
||||
@@ -484,9 +486,9 @@ class AccountEdiFormat(models.Model):
|
||||
+ tax_details_by_code.get("state_cess_non_advol_amount", 0.00)),
|
||||
),
|
||||
"RndOffAmt": self._l10n_in_round_value(
|
||||
sum(line.balance for line in invoice.line_ids if line.display_type == 'rounding')),
|
||||
rounding_amount),
|
||||
"TotInvVal": self._l10n_in_round_value(
|
||||
(tax_details.get("base_amount") + tax_details.get("tax_amount"))),
|
||||
(tax_details.get("base_amount") + tax_details.get("tax_amount") + rounding_amount)),
|
||||
},
|
||||
}
|
||||
if invoice.company_currency_id != invoice.currency_id:
|
||||
|
||||
@@ -67,6 +67,14 @@ class TestEdiJson(AccountTestInvoicingCommon):
|
||||
"supplier_taxes_id": [(6, 0, cls.tax_purchase_a.ids)],
|
||||
"l10n_in_hsn_code": "02222",
|
||||
})
|
||||
rounding = cls.env["account.cash.rounding"].create({
|
||||
"name": "half-up",
|
||||
"rounding": 1.0,
|
||||
"strategy": "add_invoice_line",
|
||||
"profit_account_id": cls.company_data['default_account_expense'].id,
|
||||
"loss_account_id": cls.company_data['default_account_expense'].id,
|
||||
"rounding_method": "HALF-UP",
|
||||
})
|
||||
cls.invoice = cls.init_invoice("out_invoice", post=False, products=cls.product_a + product_with_cess)
|
||||
cls.invoice.write({
|
||||
"invoice_line_ids": [(1, l_id, {"discount": 10}) for l_id in cls.invoice.invoice_line_ids.ids]})
|
||||
@@ -115,6 +123,12 @@ class TestEdiJson(AccountTestInvoicingCommon):
|
||||
(1, cls.invoice_negative_more_than_max_line.invoice_line_ids[2].id, {"price_unit": -1100}),
|
||||
]})
|
||||
cls.invoice_negative_more_than_max_line.action_post()
|
||||
cls.invoice_cash_rounding = cls.init_invoice("out_invoice", post=False, products=cls.product_a + product_with_cess)
|
||||
cls.invoice_cash_rounding.write({
|
||||
"invoice_line_ids": [(1, l_id, {"discount": 10}) for l_id in cls.invoice_cash_rounding.invoice_line_ids.ids],
|
||||
"invoice_cash_rounding_id": rounding.id,
|
||||
})
|
||||
cls.invoice_cash_rounding.action_post()
|
||||
|
||||
def test_edi_json(self):
|
||||
json_value = self.env["account.edi.format"]._l10n_in_edi_generate_invoice_json(self.invoice)
|
||||
@@ -161,7 +175,7 @@ class TestEdiJson(AccountTestInvoicingCommon):
|
||||
}
|
||||
}
|
||||
self.assertDictEqual(json_value, expected, "Indian EDI send json value is not matched")
|
||||
|
||||
expected_copy_rounding = expected.copy()
|
||||
#=================================== Full discount test =====================================
|
||||
json_value = self.env["account.edi.format"]._l10n_in_edi_generate_invoice_json(self.invoice_full_discount)
|
||||
expected.update({
|
||||
@@ -265,3 +279,12 @@ class TestEdiJson(AccountTestInvoicingCommon):
|
||||
})
|
||||
json_value = self.env['account.edi.format']._l10n_in_edi_generate_invoice_json(self.invoice_negative_more_than_max_line)
|
||||
self.assertDictEqual(json_value, expected, "Indian EDI with negative value more than max line sent json value is not matched")
|
||||
|
||||
json_value = self.env["account.edi.format"]._l10n_in_edi_generate_invoice_json(self.invoice_cash_rounding)
|
||||
expected_copy_rounding.update({
|
||||
"DocDtls": {"Typ": "INV", "No": "INV/2019/00009", "Dt": "01/01/2019"},
|
||||
"ValDtls": {
|
||||
"AssVal": 1800.0, "CgstVal": 76.5, "SgstVal": 76.5, "IgstVal": 0.0, "CesVal": 46.59,
|
||||
"StCesVal": 0.0, "RndOffAmt": 0.41, "TotInvVal": 2000.00
|
||||
}})
|
||||
self.assertDictEqual(json_value, expected_copy_rounding, "Indian EDI with cash rounding sent json value is not matched")
|
||||
|
||||
Reference in New Issue
Block a user