Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] l10n_ke_edi_tremol: discount sign #162193

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

dbkosky
Copy link
Contributor

@dbkosky dbkosky commented Apr 17, 2024

When sending an invoice with negative discount, the code responsible for serialising this discount applies a '+' plus sign to the discount. This is because the DiscAddP (Discount Addition Percentage) field on the device expects a negative amount for discounts (with a minus sign).

However, due to errors with our own device, we have detected that surcharges (or negative discounts), serialised with a '+' plus sign actually trigger an error on the fiscal device (5 Input registers overflow).

This commit adapts the serialisation to specify no sign in the case of negative discounts (surcharges), since a non-negative number in this field serves as a representation of a surcharge. Trailing zeros are stripped from the value and tests are updated to coincide with this change.

@dbkosky dbkosky requested a review from jco-odoo April 17, 2024 10:58
@robodoo
Copy link
Contributor

robodoo commented Apr 17, 2024

Pull request status dashboard.

@C3POdoo C3POdoo added the RD research & development, internal work label Apr 17, 2024
discount_sign = b'-' if discount_dict[line.id] > 0 else b'+'
discount = discount_sign + str(abs(discount_dict[line.id])).encode('cp1251')[:6]
discount_sign = b'-' if discount_dict[line.id] > 0 else b''
discount = discount_sign + ('%.2f' % abs(discount_dict[line.id])).rstrip('0').rstrip('.').encode('cp1251')[:6]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
discount = discount_sign + ('%.2f' % abs(discount_dict[line.id])).rstrip('0').rstrip('.').encode('cp1251')[:6]
discount = discount_sign + (str(abs(discount_dict[line.id]))).rstrip('0').rstrip('.').encode('cp1251')[:6]

When sending an invoice with negative discount, the code responsible for
serialising this discount applies a '+' plus sign to the discount. This
is because the DiscAddP (Discount Addition Percentage) field on the
device expects a negative amount for discounts (with a minus sign).

However, due to errors with our own device, we have detected that
surcharges (or negative discounts), serialised with a '+' plus sign
actually trigger an error on the fiscal device (5 Input registers
overflow).

This commit adapts the serialisation to specify no sign in the case of
negative discounts (surcharges), since a non-negative number in this
field serves as a representation of a surcharge. Trailing zeros are
stripped from the value and tests are updated to coincide with this
change.
@dbkosky dbkosky force-pushed the 16.0-l10n-ke-edi-tremol-fix-discount-sign-dako branch from eac340a to b87096a Compare April 17, 2024 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants