pickware / shopware

Shopware Repository
http://www.shopware.com
Other
0 stars 0 forks source link

Consistent single unit level price rounding #27

Open samuelvogel opened 7 years ago

samuelvogel commented 7 years ago

We created https://github.com/shopware/shopware/pull/847 before, which was not accepted. We wan't to split it up in multiple smaller PRs for smaller change sets and better understandability.

Generally we need to check which cases can actually happen in Shopware, depending on:

Then we should create a PR for every one of the problems with a (realistic) example and the fix.

We already have a couple of open PRs regarding rounding as well, which we should not overlap:

References:

fixpunkt commented 7 years ago

I'd suggest taking https://makandracards.com/makandra/1505-invoices-how-to-properly-round-and-calculate-totals with a grain of salt, since the author states right at the end of the second paragraph:

All other totals in your invoice will be some sum or difference of these two rounded numbers [line item total and VAT paid], so no further rounding is necessary.

Which is only correct if you don't take the fact that we're working on a machine with finite precision into account, cf. #26.

samuelvogel commented 7 years ago

That article is not really about our specific problem anyways, as it doesn't go deeper than "item level", which means a position of the invoice which might have a quantity higher than one compared to "unit level" (what we want). But it explains some of the general high-level rounding choices.