PrestaShop / PrestaShop

PrestaShop is the universal open-source software platform to build your e-commerce solution.
https://www.prestashop-project.org/
Other
8.23k stars 4.81k forks source link

Reduction error on invoice with amount reduction. #16491

Closed 202-ecommerce closed 4 years ago

202-ecommerce commented 4 years ago

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
  2. Add in your cart:

and add you discount to your cart.

Total : 104.60€

In your backoffice, you'll see

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 commented 4 years ago

Hi @202-ecommerce,

Thanks for your report. Isn't similar to this issue: https://github.com/PrestaShop/PrestaShop/issues/13809#issuecomment-492964528?

Thanks!

202-ecommerce commented 4 years ago

Hi @khouloudbelguith

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

khouloudbelguith commented 4 years ago

@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 commented 4 years ago

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

khouloudbelguith commented 4 years ago

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 commented 4 years ago

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!

clotairer commented 4 years ago

@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_COMPUTEPRECISION 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.

clotairer commented 4 years ago

@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 https://github.com/PrestaShop/PrestaShop/issues/16491#issuecomment-558646304 ? or is it already fixed or in an other issue ?

khouloudbelguith commented 4 years ago

@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 commented 4 years ago

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

Thanks!

matks commented 4 years ago

Fixed by https://github.com/PrestaShop/PrestaShop/pull/16531 for 1.7.7.x and https://github.com/PrestaShop/PrestaShop/pull/16616 for 1.7.6.x

Supplementstore commented 4 years ago

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 commented 4 years ago

Hi @Supplementstore,

Same issue reported here: https://github.com/PrestaShop/PrestaShop/issues/18065

Thanks!