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

Take tax_category from Line Items and Fix validation: rounding for subcent amounts #14

Merged
merged 3 commits into from
Jan 8, 2025

Conversation

SubandiK
Copy link
Contributor

@SubandiK SubandiK commented Dec 18, 2024

Now taking the tax_category, which is set per tax rate, from the line_items.
This is needed because different taxes can be on one invoice, and they aren't all guaranteed to be of the same category
(see #16)

See also my comment from there:

This would also render Invoice.tax_category nearly obsolete, which is then only really used in tax_reason_text, which is only used at the per-tax level, so that also could be changed to not use invoice.tax_category

I kept that part in place because I wanted to change as little as possible, but in theory I could also do that.

Also changing the rounding in the validation in two places:

  • on the invoice, use .round(2) instead of .round(2, :down). As far as I understand, in Germany there is no forced rounding down
  • on the invoice item, introduce .round(2) as well

the resulting invoice passes schematron and various online zugferd checkers.

fix #13
fix #16

@@ -130,27 +130,27 @@ def make_de_invoice_with_multiple_tax_rates
)
line_item = LineItem.new(
name: 'Depfu Starter Plan',
quantity: 1,
quantity: 2,
Copy link
Contributor Author

@SubandiK SubandiK Dec 18, 2024

Choose a reason for hiding this comment

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

I changed the quantity here, because I wanted a quantity of 1 for the 7% item, to show the rounding problem, but still keep a test with a quantity of > 1 around.

@SubandiK SubandiK changed the title Fix rounding for subcent amounts Fix validation: rounding for subcent amounts Dec 18, 2024
@SubandiK SubandiK changed the title Fix validation: rounding for subcent amounts Take tax_category from Line Items and Fix validation: rounding for subcent amounts Jan 3, 2025
@halfbyte halfbyte merged commit d251c68 into halfbyte:main Jan 8, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants