halfbyte / ruby-secretariat

A ZUGFeRD XML generator helper thing
Apache License 2.0
12 stars 11 forks source link

Support for multiple tax rates in one invoice #6

Open SubandiK opened 4 days ago

SubandiK commented 4 days ago

In Germany, there are two tax rates in use; 19% and the reduced 7% and invoices can contain line items with one or both of them. Currently, the Invoice only supports one tax rate.

Are there plans to extend this to support multiple tax rates? There should probably be a taxes attribute on the Invoice, and a new Tax Struct.

halfbyte commented 4 days ago

@SubandiK Good point. I've tried to read this up in the documentation and I am not super sure if I fully understand what we should do, but here's how I think it goes:

This is a pretty substantial change. I don't immediately plan to add this as we don't need it - Feel free to start working on this if you can find the time.

SubandiK commented 4 days ago

@halfbyte Thanks for the response. Looks like I will take a shot at this, as we do need it. You're right that we can infer all needed info from the existing line items in theory and that's probably better; the other way would have been easier because it would have meant basically duplicating my own "source" Invoice model.

halfbyte commented 4 days ago

You're right that we can infer all needed info from the existing line items in theory and that's probably better; the other way would have been easier because it would have meant basically duplicating my own "source" Invoice model.

Do as you wish, as I luckily really don't have any need for it. It would be good if you somehow could keep the API backwards compatible, but if not that's not a big deal either, as I imagine that to be a bit of a pain.

I'm beginning to think that this needs at least some form of documentation, not sure how to best do it, though.

SubandiK commented 4 days ago

cool, had a half-finished comment in here that I kinda need a Struct or I would have a Hash of Hashes (for summing per rate) which didn't look that great.

In my WIP it already ~works and is backwards compatible, one issue / decision is what to do about tax_reason and tax_category as we don't use those. Currently for the invoice.taxes to xml, it just takes it from the invoice, so no change. In theory we could also have them at the line_item level, and thus have them individual per tax rate as well, but that sounds like additional work nobody asked for, yet.

But for me, it will always be "no tax_reason" and tax_category is always standard, so no need to move them.