-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
Multiple taxes support in ot modules #6432
Multiple taxes support in ot modules #6432
Conversation
Looking at the test failure for Low Order Fee, it appears as though this new code is simply not charging any tax. The price mismatch is the amount of the tax: $43.49 instead of $46.01 ... the difference is $2.52 zencart/not_for_release/testFramework/FeatureStore/LowOrderFees/LowOrderFeeTest.php Lines 249 to 254 in dac1dbc
|
@piloujp Thanks for all your work on this. .... lots to review! |
I really don't know, I get 46.01 in my test cart, which is the actual GitHub ZC with only this PR applied. |
I found the problem. It is because of the reversed calculation of taxes 'Credit Note' <=> 'Standard' between original code and new one. The problem is probably the same with other test failing. When test is using 'Standard' recalculation, I get the same results if I use 'Credit Note'. |
Checking: do you have a potential fix in mind? |
Several configuration settings have been removed which previously allowed specific tax handling for GV/Coupon/GroupPricing, including the ability to turn tax off altogether for them. Is it accurate to say that now whatever tax rates apply to a customer's order, are also being applied to their GV's and coupons? The description now reads |
I've also shortened the scanned HTML for (several of) the Feature Tests to make it easier to find the relevant part of the HTML that's being asserted upon. |
Roughly yes, but your wording is not accurate, see below.
Both.
The second one. Well, I think the problem is that discounts are being seen as another item like those in cart or like charges added after, but in my opinion it is wrong. It is why I removed options like tax class, include tax and re-calculate 'none'. Actually, in ZC, tax class in discount modules were used to recalculate taxes (in Credit Note option) in a way they replace taxes already applied. Big problem here, if everything was at 7% tax rate and then a 20% rate is used, you get a discount very different from what was announced. Finally, option 'include tax' is still partially a mystery. It was only possible to activate it when re-calculate was set to 'none'. For options 'Credit Note' and 'Standard', wording could be better. To be precise, 'Credit Note' is when discount is applied before tax and 'Standard' is when discount is applied after tax of each item they apply to. I hope this clarifies things a bit. |
Very good idea. Looking at test results, I could not see what was the actual error. |
Test 1 and 2 easily fixed with a rounding: Test 3, I think, is wrong. Shipping cost has been discounted 100% and should be 0. Before I modified the code, shipping cost stayed untouched until the end, but what do you do when multiple discounts including shipping are applied? The second discount should be applied on shipping cost discounted from the first, if not you might end up with a discount on shipping higher than original shipping cost. Test 4 has the same problem as 3. The no tax calculation makes it looks like when set to Credit Note, but there might be some differences. Test 5 has a reversed option problem. I got 501 for discount if set to Credit Note, but 468.3767.... when set to Standard. Test 6 -> reversed option problem too. Test 7 free shipping calculation is a little different. Free shipping discount is added at the end to discount without shipping. Before, they were mixed together. I don't know where the test is taking discount amount, but value correspond at discount before adding shipping discount. Tests with fixed discount are mixed up by reversed options, but tests with no tax calculation option that does not exist are ok because treated as Credit Note option. |
I see what you're saying, but I don't think it's wrong. In accounting, it's important to (at least be able to) treat discounts as separate values, because they "could" (if the storeowner chose) be treated as marketing/advertising/promotion expenses. Aside: We've rewritten (offline) it in a way that makes orders super flexible and manageable, but haven't put it into core yet because every plugin that deals with orders and totals, possibly even payment, will be affected. |
So, you're saying with this PR "Credit Note" and "Standard" have new meanings: now they just mean "(apply discount) before tax" and "(apply discount) after tax"? |
More than the way discount are seen, I meant the consequences of it are wrong, looking at all these options actually available but not usable by store owners.
I completely agree with that and don't see any incompatibility here... ZC lacks a little bit of traceability for accounting, but I think my PRs go in the right direction.
It sounds too good to be true. |
Yes, and it is a meaning easy to understand for any store owner. After using ZC for years as a store owner and more recently digging deeply into its code, I still can't see any meaning in the following discount modules options: And I am pretty sure that I am not alone. |
f30a541
to
8ae67a8
Compare
a0f3afc
to
bc44cb4
Compare
Better that time is invested in progress than all the time I see invested/wasted in trying to polish an oSC t*rd that seems to be unfixable with all the price/discount/tax options available. Break plugins....listen to people complaining about what functionality they have lost....put it on a roadmap....ask people to take on those tasks. Organised progress. |
Modified calculation for free shipping and include shipping options in ot_coupon. Code optimisation in ot_coupon and ot_gv.
Typos corrections in ot_group_pricing module. Added new file update information.
This is not a major issue, just makes the code slightly easier to read.
... mainly because several new keys have been added to it
Co-authored-by: Chris Brown <[email protected]>
just reformatting lengthy array for clarity
FYI: There are 2 methods which populate the `$info` (and other) arrays in the `order` class: `cart()` and `query()`.
The tests are revealing that this `tax_subtotals` element is now a dependency. I'm not convinced yet whether initializing it here on-demand is adequate, or if it would be better done elsewhere. Or maybe just specify actual subtotals in the test mock, to test against those?
Updated tax default sort order. Corrected GV test.
Rewrite of Order Total modules, mainly discount modules, to support different modules options and multiple tax classes and rates.
Replace PR #6392
See issue #6425 for more details.
This PR needs PR #6411 and is complementary to PRs #6391 and #6393 and optionally #6394 .
All options concerning calculation have been tested thoroughly. Options for validation are partially tested.
It can't pass actual tests because there is a new array in 'order->info' and some options have been suppressed too.