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

(WIP) Initial Work to per-currency rounding feature. #1478

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Anuril
Copy link
Contributor

@Anuril Anuril commented Jul 27, 2023

This implements a "rounding precision" for currencies that don't round to two decimals. (Specifically, CHF)

In the field "Rounding precision", you can set the next decimal the program should round to.

Currently, only rounding down works, but implementing "bank" rounding is also on the to-do list.

I've decided to pause working on this and instead clean up the cart / order button functionality before, as currently, rounding not only happens in ServiceInvoiceItem.php (in the function getTotalWithTax), but also in the twig template of the checkout process.

It's important to have a set of core functionalities to process business logic, and the checkout process needs rewriting to make use of that. Before that isn't done, rounding isn't a pressing issue.

@tobsowo
Copy link

tobsowo commented Jul 27, 2023

Don't know if this also solve add comma to currencies and cart resetting for guests users when logged in?

@BelleNottelling
Copy link
Member

Don't know if this also solve add comma to currencies and cart resetting for guests users when logged in?

I assume the first part is this issue: #1344, which is separate from the intentions of this PR. But as I previously explained, the cart issue will remain a problem until we rewrite the behavior of the cart module

VALUES
(1,'US Dollar','USD',1,1.000000,'${{price}}','1','2022-12-01 12:00:00','2022-12-01 12:00:00');
(1,'US Dollar','USD',1,1.000000,'${{price}}','1','1','2022-12-01 12:00:00','2022-12-01 12:00:00');
Copy link
Member

Choose a reason for hiding this comment

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

USD should be rounded to 0.01

(2,'Euro','EUR',0,0.600000,'€{{price}}','1','2022-12-01 12:00:00','2022-12-01 12:00:00'),
(3,'Pound Sterling','GBP',0,0.600000,'{{price}} ₤','1','2022-12-01 12:00:00','2022-12-01 12:00:00');
(1,'US Dollar','USD',1,1.000000,'${{price}}','1','1','2022-12-01 12:00:00','2022-12-01 12:00:00'),
(2,'Euro','EUR',0,0.600000,'€{{price}}','1','1','2022-12-01 12:00:00','2022-12-01 12:00:00'),
Copy link
Member

Choose a reason for hiding this comment

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

Same here
and for pounds

If we want to add an test case we should add:
https://en.wikipedia.org/wiki/Hungarian_forint

As it should rounded to "whole" forint..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a remainder of before I cut a step in the calculations. It should be 0.01 ofc, but as I said, before the cart rewrite, I'm not touching this feature, as the cart / order currently calculate VAT in the template, instead of the business logic. This means f.Ex that the calculations would need to be changed in every theme.

@Anuril Anuril changed the title Initial Work to per-currency rounding feature. (WIP) Initial Work to per-currency rounding feature. Jul 29, 2023
@Anuril
Copy link
Contributor Author

Anuril commented Jul 29, 2023

This should also fix #1344 because of the format changes when it's done.

@BelleNottelling
Copy link
Member

This should also fix #1344 because of the format changes when it's done.

Does it actually? That issue said it only happens in some places, suggesting it's a front-end issue where the proper money formatting isn't being applied

@Anuril Anuril marked this pull request as draft July 30, 2023 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants