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

Remove price precision in admin shop preferences #15084

Merged
merged 26 commits into from Oct 10, 2019
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
50f0274
replace use of deprecated method displayPrice in bo's product list page
matthieu-rolland Aug 1, 2019
db16555
remove unused price precision variable
matthieu-rolland Aug 7, 2019
960e95d
Add method helper to get price precision (max fraction digits)
matthieu-rolland Aug 12, 2019
60468d2
add missing phpdoc
matthieu-rolland Aug 12, 2019
9cd094e
remove price precision from shop preferences form
matthieu-rolland Aug 12, 2019
e3bc116
use default compute precision value instead of display price
matthieu-rolland Aug 12, 2019
5a4fef1
use price precision helper
matthieu-rolland Aug 12, 2019
3f4a0c9
remove display price precision constant
matthieu-rolland Aug 12, 2019
538298d
remove display price precision config sql query
matthieu-rolland Aug 13, 2019
dc9bfc5
cs fixer
matthieu-rolland Aug 13, 2019
35cf575
replace use of constant with helper method to get price precision
matthieu-rolland Aug 13, 2019
b005437
add and use service for getting price computing precision
matthieu-rolland Aug 16, 2019
a8b71cd
remove unused methods
matthieu-rolland Aug 16, 2019
1e4dd18
add test for ComputingPrecision class
matthieu-rolland Aug 16, 2019
337d0ac
change expectations due to greater computing precision
matthieu-rolland Aug 19, 2019
daa9b54
Update bahat tests due to greater precision in price calculations
matthieu-rolland Aug 20, 2019
559811f
update last behat tests for cldr precision increase
matthieu-rolland Aug 21, 2019
38b9a1b
fix update sql
matthieu-rolland Aug 21, 2019
cabafb3
add an interface, make class final
matthieu-rolland Aug 21, 2019
979c74a
add constant for minimum computing precision
matthieu-rolland Aug 21, 2019
3c51e3e
remove default price_display_precision in product form
matthieu-rolland Sep 23, 2019
53d3816
fix behat test message error, and fix behat test
matthieu-rolland Sep 24, 2019
8321790
remove tests that have been migrated in behat
matthieu-rolland Sep 25, 2019
ff2e862
cs fixer
matthieu-rolland Sep 25, 2019
51fd30c
Round seo metadata price value
matthieu-rolland Sep 25, 2019
e6606eb
remove price precision option in parameters
matthieu-rolland Oct 7, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Update bahat tests due to greater precision in price calculations

  • Loading branch information
matthieu-rolland committed Aug 20, 2019
commit daa9b5485c90b949b6d0036106ff8003cba79a88
@@ -42,7 +42,7 @@ Feature: Cart rule (percent) calculation with multiple cart rules
When I add 3 items of product "product1" in my cart
When I use the discount "cartrule2"
When I use the discount "cartrule3"
Then my cart total should be 33.75 tax included
Then my cart total should be 33.7462 tax included
#known to fail on previous
#Then my cart total using previous calculation method should be 33.75 tax included

@@ -14,16 +14,16 @@ Feature: Cart calculation with rounding type ITEM
Given specific shop configuration for "rounding type" is set to round each article
Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock
When I add 1 items of product "product1" in my cart
Then my cart total should be precisely 26.81 tax included
Then my cart total using previous calculation method should be precisely 26.81 tax included
Then my cart total should be precisely 26.812 tax included
Then my cart total using previous calculation method should be precisely 26.812 tax included

Scenario: one product in cart, quantity 3
Given I have an empty default cart
Given specific shop configuration for "rounding type" is set to round each article
Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock
When I add 3 items of product "product1" in my cart
Then my cart total should be precisely 66.43 tax included
Then my cart total using previous calculation method should be precisely 66.43 tax included
Then my cart total should be precisely 66.436 tax included
Then my cart total using previous calculation method should be precisely 66.436 tax included

Scenario: 3 products in cart, several quantities
Given I have an empty default cart
@@ -14,16 +14,16 @@ Feature: Cart calculation with rounding type LINE
Given specific shop configuration for "rounding type" is set to round each line
Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock
When I add 1 items of product "product1" in my cart
Then my cart total should be precisely 26.81 tax included
Then my cart total using previous calculation method should be precisely 26.81 tax included
Then my cart total should be precisely 26.812 tax included
Then my cart total using previous calculation method should be precisely 26.812 tax included

Scenario: one product in cart, quantity 3
Given I have an empty default cart
Given specific shop configuration for "rounding type" is set to round each line
Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock
When I add 3 items of product "product1" in my cart
Then my cart total should be precisely 66.44 tax included
Then my cart total using previous calculation method should be precisely 66.44 tax included
Then my cart total should be precisely 66.436 tax included
Then my cart total using previous calculation method should be precisely 66.436 tax included

Scenario: 3 products in cart, several quantities
Given I have an empty default cart
@@ -34,5 +34,5 @@ Feature: Cart calculation with rounding type LINE
When I add 2 items of product "product2" in my cart
When I add 3 items of product "product1" in my cart
When I add 1 items of product "product3" in my cart
Then my cart total should be precisely 162.41 tax included
Then my cart total using previous calculation method should be precisely 162.41 tax included
Then my cart total should be precisely 162.4 tax included
This conversation was marked as resolved by matthieu-rolland

This comment has been minimized.

Copy link
@jolelievre

jolelievre Sep 17, 2019

Contributor

Maybe use 162.40 to avoid confusion (it would seem the decimals is rounded to one digit)

Then my cart total using previous calculation method should be precisely 162.4 tax included
@@ -14,16 +14,16 @@ Feature: Cart calculation with rounding type TOTAL
Given specific shop configuration for "rounding type" is set to round cart total
Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock
When I add 1 items of product "product1" in my cart
Then my cart total should be precisely 26.81 tax included
Then my cart total using previous calculation method should be precisely 26.81 tax included
Then my cart total should be precisely 26.812 tax included
Then my cart total using previous calculation method should be precisely 26.812 tax included

Scenario: one product in cart, quantity 3
Given I have an empty default cart
Given specific shop configuration for "rounding type" is set to round cart total
Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock
When I add 3 items of product "product1" in my cart
Then my cart total should be precisely 66.44 tax included
Then my cart total using previous calculation method should be precisely 66.44 tax included
Then my cart total should be precisely 66.436 tax included
Then my cart total using previous calculation method should be precisely 66.436 tax included

Scenario: 3 products in cart, several quantities
Given I have an empty default cart
@@ -28,10 +28,10 @@ Feature: Check cart to order data copy
When I select address "address1" in my cart
When I select carrier "carrier1" in my cart
When I validate my cart using payment module fake
Then current cart order total for products should be 20.6 tax included
Then current cart order total for products should be 19.81 tax excluded
Then current cart order total discount should be 10.3 tax included
Then current cart order total discount should be 9.91 tax excluded
Then current cart order total for products should be 20.604480 tax included
This conversation was marked as resolved by matthieu-rolland

This comment has been minimized.

Copy link
@jolelievre

jolelievre Sep 17, 2019

Contributor

How come in some cases you have 6 digits and in other only 1 (or 2 or 3) Is it because the computation is exactly one digit or are there other rounding rules? If it's an exact value maybe add a pending 0 to avoid confusion?

This comment has been minimized.

Copy link
@matthieu-rolland

matthieu-rolland Sep 23, 2019

Author Contributor

Since we increased the precision, in this case we can have up to 6 digits, but that doesn't mean we will always have 6 digits, the end result of a calculation could still only have one digit, I believe this is normal 🤔

Then current cart order total for products should be 19.812000 tax excluded
Then current cart order total discount should be 10.302240 tax included
Then current cart order total discount should be 9.906000 tax excluded
Then current cart order shipping fees should be 7.0 tax included
Then current cart order shipping fees should be 7.0 tax excluded
Then current cart order should have a discount in position 1 with an amount of 10.3 tax included and 9.91 tax excluded
@@ -65,10 +65,10 @@ Feature: Check cart to order data copy
When I select address "address1" in my cart
When I select carrier "carrier1" in my cart
When I validate my cart using payment module fake
Then current cart order total for products should be 20.6 tax included
Then current cart order total for products should be 19.81 tax excluded
Then current cart order total discount should be 15.45 tax included
Then current cart order total discount should be 14.86 tax excluded
Then current cart order total for products should be 20.604480 tax included
Then current cart order total for products should be 19.812000 tax excluded
Then current cart order total discount should be 15.453360 tax included
Then current cart order total discount should be 14.859000 tax excluded
Then current cart order shipping fees should be 7.0 tax included
Then current cart order shipping fees should be 7.0 tax excluded
Then current cart order should have a discount in position 1 with an amount of 10.3 tax included and 9.91 tax excluded
@@ -106,10 +106,10 @@ Feature: Check cart to order data copy
When I select address "address1" in my cart
When I select carrier "carrier1" in my cart
When I validate my cart using payment module fake
Then current cart order total for products should be 119.15 tax included
Then current cart order total for products should be 114.58 tax excluded
Then current cart order total discount should be 59.58 tax included
Then current cart order total discount should be 57.29 tax excluded
Then current cart order total for products should be 119.159040 tax included
Then current cart order total for products should be 114.576000 tax excluded
Then current cart order total discount should be 59.579520 tax included
Then current cart order total discount should be 57.288000 tax excluded
Then current cart order shipping fees should be 7.0 tax included
Then current cart order shipping fees should be 7.0 tax excluded
Then current cart order should have a discount in position 1 with an amount of 59.58 tax included and 57.29 tax excluded
@@ -149,14 +149,14 @@ Feature: Check cart to order data copy
When I select address "address1" in my cart
When I select carrier "carrier1" in my cart
When I validate my cart using payment module fake
Then current cart order total for products should be 119.15 tax included
Then current cart order total for products should be 114.58 tax excluded
Then current cart order total discount should be 89.36 tax included
Then current cart order total discount should be 85.94 tax excluded
Then current cart order total for products should be 119.159040 tax included
Then current cart order total for products should be 114.576000 tax excluded
Then current cart order total discount should be 89.369280 tax included
Then current cart order total discount should be 85.932000 tax excluded
Then current cart order shipping fees should be 7.0 tax included
Then current cart order shipping fees should be 7.0 tax excluded
Then current cart order should have a discount in position 1 with an amount of 59.58 tax included and 57.29 tax excluded
Then current cart order should have a discount in position 2 with an amount of 29.79 tax included and 28.65 tax excluded
Then current cart order should have a discount in position 2 with an amount of 28.64 tax included and 28.65 tax excluded
Then customer "customer1" should have 0 cart rules that apply to him

Scenario: 1 product in cart, 1 cart rule with too-much amount
@@ -184,10 +184,10 @@ Feature: Check cart to order data copy
When I select address "address1" in my cart
When I select carrier "carrier1" in my cart
When I validate my cart using payment module fake
Then current cart order total for products should be 20.6 tax included
Then current cart order total for products should be 19.81 tax excluded
Then current cart order total discount should be 20.6 tax included
Then current cart order total discount should be 19.81 tax excluded
Then current cart order total for products should be 20.604480 tax included
Then current cart order total for products should be 19.812000 tax excluded
Then current cart order total discount should be 20.604480 tax included
Then current cart order total discount should be 19.812000 tax excluded
Then current cart order shipping fees should be 7.0 tax included
Then current cart order shipping fees should be 7.0 tax excluded
Then current cart order should have a discount in position 1 with an amount of 20.6 tax included and 19.81 tax excluded
@@ -222,10 +222,10 @@ Feature: Check cart to order data copy
When I select address "address1" in my cart
When I select carrier "carrier1" in my cart
When I validate my cart using payment module fake
Then current cart order total for products should be 57.59 tax included
Then current cart order total for products should be 55.38 tax excluded
Then current cart order total discount should be 36.99 tax included
Then current cart order total discount should be 35.57 tax excluded
Then current cart order total for products should be 57.594160 tax included
Then current cart order total for products should be 55.379000 tax excluded
Then current cart order total discount should be 36.989680 tax included
Then current cart order total discount should be 35.567000 tax excluded
Then current cart order shipping fees should be 7.0 tax included
Then current cart order shipping fees should be 7.0 tax excluded
Then current cart order should have a discount in position 1 with an amount of 36.99 tax included and 35.57 tax excluded
@@ -260,10 +260,10 @@ Feature: Check cart to order data copy
When I select address "address1" in my cart
When I select carrier "carrier1" in my cart
When I validate my cart using payment module fake
Then current cart order total for products should be 94.58 tax included
Then current cart order total for products should be 90.94 tax excluded
Then current cart order total discount should be 36.99 tax included
Then current cart order total discount should be 35.57 tax excluded
Then current cart order total for products should be 94.583840 tax included
Then current cart order total for products should be 90.946000 tax excluded
Then current cart order total discount should be 36.989680 tax included
Then current cart order total discount should be 35.567000 tax excluded
Then current cart order shipping fees should be 7.0 tax included
Then current cart order shipping fees should be 7.0 tax excluded
Then current cart order should have a discount in position 1 with an amount of 36.99 tax included and 35.57 tax excluded
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.