[FIX] l10n_ke_edi_tremol: price decimal length

An update made to the tremol device has changed the expected content of
the price field. It now expects up to 15 characters in this position,
with a maximum of 5 decimal places.

At present we can send prices with a decimal position greater than 5,
doing so will result in an error from the fiscal device.

This commit adapts the content that gets serialised in order to ensure
that the decimal provided is no longer than 5 decimal places.

closes odoo/odoo#161804

Task-id: none
X-original-commit: 3373ac3a7945d25fee70d114816ce23a16d6e0ef
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Daniel Kosky (dako) <dako@odoo.com>
This commit is contained in:
Daniel Kosky (dako)
2024-04-14 21:02:42 +00:00
parent bad8b1e837
commit 4a522be2c1
2 changed files with 4 additions and 3 deletions
@@ -186,12 +186,13 @@ class AccountMove(models.Model):
price_total = abs(line_tax_details['base_amount_currency']) + abs(line_tax_details['tax_amount_currency'])
percentage = tax['tax'].amount
price = round(price_total / abs(line.quantity) * 100 / (100 - line.discount), 2) * currency_rate
price = ('%.5f' % price).rstrip('0').rstrip('.')
uom = line.product_uom_id and line.product_uom_id.name or ''
line_data = b';'.join([
self._l10n_ke_fmt(line.name, 36), # 36 symbols for the article's name
self._l10n_ke_fmt(item_code.tax_rate or 'A', 1), # 1 symbol for article's vat class ('A', 'B', 'C', 'D', or 'E')
str(price)[:13].encode('cp1251'), # 1 to 13 symbols for article's price
price[:15].encode('cp1251'), # 1 to 15 symbols for article's price with up to 5 digits after decimal point
self._l10n_ke_fmt(uom, 3), # 3 symbols for unit of measure
(item_code.code or '').ljust(10).encode('cp1251'), # 10 symbols for KRA item code in the format xxxx.xx.xx (can be empty)
self._l10n_ke_fmt(item_code.description or '', 20), # 20 symbols for KRA item code description (can be empty)
@@ -39,7 +39,7 @@ class TestKeMoveExport(AccountTestInvoicingCommon):
msg = b'1' + b';'.join([ # 0x31, command to add a line
line_dict.get('name', b''.ljust(36)), # 36 characters for the name
line_dict.get('vat_class', b'A'), # 1 symbol for vat class (a because the tax is 16.0%)
line_dict.get('price', b'1'), # up to 13 symbols for the unit price, tax included
line_dict.get('price', b'1'), # up to 15 symbols for the unit price, tax included (up to 5 decimal places)
line_dict.get('uom', b'Uni'), # 3 symbols for uom
line_dict.get('item_code', b''.ljust(10)), # 10 symbols for item code (only reported when the tax is not 16.0%)
line_dict.get('item_desc', b''.ljust(20)), # item description (only reported when the tex is not 16.0%)
@@ -221,7 +221,7 @@ class TestKeMoveExport(AccountTestInvoicingCommon):
generated_messages = multi_tax_line_invoice._l10n_ke_cu_lines_messages()
expected_sale_line = self.line_dict_to_bytes({
'name': b'Infinite Improbability Drive ',
'price': b'1160.0', # This is the unit price, tax included, but only the 16% VAT
'price': b'1160', # This is the unit price, tax included, but only the 16% VAT
'quantity': b'10.0',
'discount': b'-25.0%',
})