Skip to content

Commit 0448338

Browse files
committed
[FIX] l10n_vn_edi_viettel: signs on credit notes
Description of the issue/feature this PR addresses: - Viettel SInvoice will automatically change the signs of the amount values (except for unit price) we sent for credit notes (on accounts with data validation step). So the "right" values will appear in the portal. Currently (before the commit) the values have the wrong sign in the portal (because they are changed but we sent the right ones already). We need to retain the original signs of those values when submitting them to SInvoice. Current behavior before PR: - All the amount values, including itemTotalAmountWithoutTax, taxAmount, itemTotalAmountAfterDiscount and itemTotalAmountWithTax are sent to Viettel SInvoice in negative values for credit note. Viettel SInvoice changes the sign of these values to positive (which is not correct for credit note). Desired behavior after PR is merged: - Only the sign of unitPrice is changed when we send the credit note to SInvoice. Note: - The signs will not automatically be changed for accounts with data validation step removed. So this commit will break credit notes for them (since the signs are not automatically adjusted but our values have the wrong signs). closes odoo#201993 Signed-off-by: Nicolas Viseur (vin) <vin@odoo.com>
1 parent 8a6ea6f commit 0448338

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

addons/l10n_vn_edi_viettel/models/account_move.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,15 +695,15 @@ def _l10n_vn_edi_add_item_information(self, json_values):
695695
'unitPrice': line.price_unit * sign,
696696
'quantity': line.quantity,
697697
# This amount should be without discount applied.
698-
'itemTotalAmountWithoutTax': line.currency_id.round(line.price_unit * line.quantity) * sign,
698+
'itemTotalAmountWithoutTax': line.currency_id.round(line.price_unit * line.quantity),
699699
# In Vietnam a line will always have only one tax.
700700
# Values are either: -2 (no tax), -1 (not declaring/paying taxes), 0,5,8,10 (the tax %)
701701
# Most use cases will be -2 or a tax percentage, so we limit the support to these.
702702
'taxPercentage': line.tax_ids and line.tax_ids[0].amount or -2,
703-
'taxAmount': (line.price_total - line.price_subtotal) * sign,
703+
'taxAmount': (line.price_total - line.price_subtotal),
704704
'discount': line.discount,
705-
'itemTotalAmountAfterDiscount': line.price_subtotal * sign,
706-
'itemTotalAmountWithTax': line.price_total * sign,
705+
'itemTotalAmountAfterDiscount': line.price_subtotal,
706+
'itemTotalAmountWithTax': line.price_total,
707707
}
708708
if line.display_type in code_map:
709709
item_information['selection'] = code_map[line.display_type]

addons/l10n_vn_edi_viettel/tests/test_edi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ def test_adjustment_invoice(self):
197197
# 2. Check the itemInfo to ensure that the values make sense
198198
expected = {
199199
'unitPrice': -100.0,
200-
'itemTotalAmountWithoutTax': -100.0,
201-
'taxAmount': -10.0,
202-
'itemTotalAmountWithTax': -110.0,
203-
'adjustmentTaxAmount': -10.0,
200+
'itemTotalAmountWithoutTax': 100.0,
201+
'taxAmount': 10.0,
202+
'itemTotalAmountWithTax': 110.0,
203+
'adjustmentTaxAmount': 10.0,
204204
'isIncreaseItem': False,
205205
}
206206
actual = json_data['itemInfo'][0]

0 commit comments

Comments
 (0)