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

Reduction error on invoice with amount reduction. #16491

Closed
202-ecommerce opened this issue Nov 21, 2019 · 13 comments
Closed

Reduction error on invoice with amount reduction. #16491

202-ecommerce opened this issue Nov 21, 2019 · 13 comments

Comments

@202-ecommerce
Copy link
Contributor

@202-ecommerce 202-ecommerce commented Nov 21, 2019

Describe the bug
Reduction error on invoice with amount reduction.

To Reproduce

  1. Prepare a catalog with all following product VAT 20%

Product One: 46.90€
Product Two: 12,50€
Product Three: 12,50€
Product Four: 12,50€

  1. Prepare a discount with:
  • Information (all in Yes) > partial use: Yes
  • Condition : no specific conditions
  • Action
    • Free shipping: No
    • Apply a discount: amount
    • Amount 4.6€
    • Apply a discount to: Order (without shipping)
    • Send a free gift: No
  1. Add in your cart:
  • 1 x Product One: 46.90€
  • 2 x Product Two: 12,50€
  • 2 x Product Three: 12,50€
  • 1 x Product Four: 12,50€

and add you discount to your cart.

Total : 104.60€

In your backoffice, you'll see

  • Discount value = - €109.40 (Delete Voucher)
  • Products: €109.40
  • Discounts -€4.60
  • Shipping €0.00
  • Total €104.80

The bug is that in the "order_cart_rule" table, the value of the discount is the total amount of product.
You can note that a new discount is create with 0€ of discount.

We look for the origin of the bug and found there a bug with arround after the calculate classe of discounts on the PaymentModule classe.

We will propose to you a pull request.

Please note, if you add in your cart :
1x12.5€ + 1x12.5€ + 3x12.5€ + 1x27.9€ + 2x10€ + 1x1.0€ + 1x46,9€ with 10€ of discount you'll also have the bug

  1. See error

capture d'écran

Additional information
PrestaShop version: 1.7.6.x
PHP version: all

@khouloudbelguith

This comment has been minimized.

Copy link
Contributor

@khouloudbelguith khouloudbelguith commented Nov 21, 2019

Hi @202-ecommerce,

Thanks for your report.
Isn't similar to this issue: #13809 (comment)?

Thanks!

@202-ecommerce

This comment has been minimized.

Copy link
Contributor Author

@202-ecommerce 202-ecommerce commented Nov 21, 2019

Hi @khouloudbelguith

No, it's not the same bug.
It's due to remaining value on amount discount coupon.

@khouloudbelguith

This comment has been minimized.

Copy link
Contributor

@khouloudbelguith khouloudbelguith commented Nov 21, 2019

@202-ecommerce, thanks for your feedback.
I manage to reproduce the issue with PS1.7.6.1 & PS1.7.6.2build1.
https://drive.google.com/file/d/1eCvfK0duGnUzeuVTl64-e2MFSdC5u04-/view
It is ok with ps1.7.5.2 & ps1.7.5.0
image
it is a regression.
I’ll add this to the debug roadmap so that it’s fixed. If you have already fixed it on your end or if you think you can do it, please do send us a pull request!
Thanks!

@202-ecommerce

This comment has been minimized.

Copy link
Contributor Author

@202-ecommerce 202-ecommerce commented Nov 21, 2019

Thank you.
Yes we identify the origin of the bug and will publish a pull request.

@colinegin colinegin added this to Backlog in PrestaShop 1.7.6 via automation Nov 21, 2019
@colinegin colinegin moved this from Backlog to To be reviewed in PrestaShop 1.7.6 Nov 26, 2019
@marionf marionf added this to Backlog in PrestaShop 1.7.7 via automation Nov 26, 2019
@marionf marionf removed this from To be reviewed in PrestaShop 1.7.6 Nov 26, 2019
@marionf marionf moved this from Backlog to To be reviewed in PrestaShop 1.7.7 Nov 26, 2019
@khouloudbelguith

This comment has been minimized.

Copy link
Contributor

@khouloudbelguith khouloudbelguith commented Nov 26, 2019

Hi @marionf,

With PS1.7.6.0.
I have another exception not reproduced in the PS1.7.6.1 block the last step.
https://drive.google.com/file/d/1jFRvQu-eCKNwtC3lr3sL1mqBiipHvf6u/view
In the last step after clicking on "Place the order" button, an exception is displayed
image
If we check the order, the discount block is not displayed.
If we check the discounts page, a duplicate for the previous discount is created automatically.

Thanks!

@khouloudbelguith

This comment has been minimized.

Copy link
Contributor

@khouloudbelguith khouloudbelguith commented Nov 26, 2019

Hi @202-ecommerce,

I reproduced a new problem with PS1.7.6.0 & PS1.7.6.2build1 & PS1.7.6.1 following previous steps:
-After creating the order, if we check the discounts page, a new cart rule is created automatically with no actions & limited to the customer.
image

With PS1.7.5.2 => OK.

Thanks!

@clotaire202

This comment has been minimized.

Copy link
Contributor

@clotaire202 clotaire202 commented Nov 26, 2019

@khouloudbelguith as explain on PR #16531 the first part of the bug was "here we generate a remaining reduction with a value 0€ (first effect of the bug)".
After arrounding, as we pull, if the remaining value == 0 the remaining discount sould not be generated. There a condition : $remainingValue > 0

I've not try after replacement PS_PRICE_COMPUTE_PRECISION and Context::getContext()->getComputingPrecision() (not available in 1.7.6.x)

It looks like there is some new unexpected problems with this new getComputingPrecision method...

i need to install a new environment from develop branch. My debug branch was 1.7.6.x But this part has changed.

@marionf marionf moved this from To be reviewed to To be tested in PrestaShop 1.7.7 Nov 26, 2019
@khouloudbelguith khouloudbelguith added Major and removed Minor labels Nov 26, 2019
@khouloudbelguith khouloudbelguith removed the To Do label Nov 27, 2019
@khouloudbelguith khouloudbelguith moved this from To be tested to To be merged in PrestaShop 1.7.7 Nov 27, 2019
@khouloudbelguith khouloudbelguith added this to the 1.7.7.0 milestone Nov 27, 2019
PrestaShop 1.7.7 automation moved this from To be merged to Done Nov 27, 2019
@clotaire202

This comment has been minimized.

Copy link
Contributor

@clotaire202 clotaire202 commented Nov 27, 2019

@khouloudbelguith so the bug is fix with our pull request ?
I think your last test was done with our PR.
Do you have a solution for #16491 (comment) ? or is it already fixed or in an other issue ?

@khouloudbelguith

This comment has been minimized.

Copy link
Contributor

@khouloudbelguith khouloudbelguith commented Nov 27, 2019

@clotaire202, yes absolutely, I checked all steps during testing this PR:

  1. The order checkout process is done ok without any exception
  2. In the Order details, page => discount is well displayed in the discount block
  3. In the discounts page => there is no cart rule added automatically after creating an order.

Thanks!

@khouloudbelguith

This comment has been minimized.

Copy link
Contributor

@khouloudbelguith khouloudbelguith commented Nov 27, 2019

@clotaire202, here's a screen record from the develop branch
https://drive.google.com/file/d/1xn6X_A6LfxqXnIjcnQ7Nr1mgv1yN85L5/view

Thanks!

@marionf marionf added the BO label Jan 22, 2020
@marionf marionf added this to Backlog in PrestaShop 1.7.6 via automation Feb 13, 2020
@marionf marionf moved this from Backlog to To be reviewed in PrestaShop 1.7.6 Feb 13, 2020
@Progi1984 Progi1984 reopened this Feb 13, 2020
PrestaShop 1.7.6 automation moved this from To be reviewed to In progress Feb 13, 2020
@colinegin colinegin moved this from In progress to To be tested in PrestaShop 1.7.6 Feb 18, 2020
@matks matks moved this from To be tested to Done in PrestaShop 1.7.6 Feb 21, 2020
@matks matks modified the milestones: 1.7.7.0, 1.7.6.4 Feb 21, 2020
@matks

This comment has been minimized.

Copy link
Contributor

@matks matks commented Feb 21, 2020

Fixed by #16531 for 1.7.7.x and #16616 for 1.7.6.x

@matks matks closed this Feb 21, 2020
@Supplementstore

This comment has been minimized.

Copy link

@Supplementstore Supplementstore commented Mar 10, 2020

Problemprestashop

Im having a issue with coupons, not the same as you mentioned above.
Am i doing something wrong or am i missunderstandning how coupon codes work?

The coupon Ayla30 gives my custumers 30% off but i do not want this coupon code to work on products that already have a discount on them.

You can see right now its not working the way i want it.
As long as my custumers also orders something that does not have a discount the 30% code will work on the intire order.

Could someone tell me if im doing something wrong?
Or maby this funtion that im looking for does not exist?

Thanks! ^^

@khouloudbelguith

This comment has been minimized.

Copy link
Contributor

@khouloudbelguith khouloudbelguith commented Mar 10, 2020

Hi @Supplementstore,

Same issue reported here: #18065

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

7 participants
You can’t perform that action at this time.