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

Issue with multiple percentage discounts #39036

Open
5 tasks
serhiikv opened this issue Aug 12, 2024 · 9 comments · May be fixed by #39683
Open
5 tasks

Issue with multiple percentage discounts #39036

serhiikv opened this issue Aug 12, 2024 · 9 comments · May be fixed by #39683
Assignees
Labels
Area: APIs Component: Api Use with concrete module component label E.g. "Component: Api" + "Catalog" Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: ready for dev Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@serhiikv
Copy link

Preconditions and environment

  • Magento 2

Steps to reproduce

1. Create new cart price rules with the following configuration

Rule 1:

Rule Name: 10% Fix Discount
Coupon: No Coupon
Conditions: Apply for all product
Action: 
    Apply: Percent of product price discount
    Discount Amount: 10

Rule 2:

Rule Name: 3% Fix Discount
Coupon: No Coupon
Conditions: Apply for all product
Action: 
    Apply: Percent of product price discount
    Discount Amount: 3
  1. Order product with price = $12
  2. Query REST endpoint orders/{id} for this order

Expected result

In API response receive discount_percent equals 12.7

Actual result

In API response receive discount_percent equals 13

Additional information

Screenshot 2024-08-12 at 11 14 55

Magento2 REST api for orders has one field for discount_percent. In case when order has multiple discounts they are just added. This results in incorrect calculation.

e.g.
order amount 12. discount1 = 10%, discount2 = 3%.
How magento2 does calculation:

12 - (12 * 0.1) = 10.8 // calculate 10%
10.8 - (10.8 * 0.03) = 10.476 // next calculate 3%
12 - 10.476 = 1.524 // total discount

But if API response is used to calculate discount - it will result in wrong discount amount:

12 - (12 * 0.13) = 10.44 // calculate 13% provided by API field `discount_percent`
12 - 10.44 = 1.56 // total discount is different

The correct discount_percent in this case would be 12.7:

12 - (12 * 0.127) = 10.476 
12 - 10.476 = 1.524 // correct discount amount

Is it possible to change logic behind discount_percent field in REST API response in case of multiple discounts?

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Copy link

m2-assistant bot commented Aug 12, 2024

Hi @serhiikv. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

Copy link

m2-assistant bot commented Aug 12, 2024

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Bravo engcom-Bravo added the Reported on 2.4.x Indicates original Magento version for the Issue report. label Aug 12, 2024
@engcom-Bravo
Copy link
Contributor

@magento give me 2.4-develop instance

Copy link

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

Copy link

@engcom-Bravo
Copy link
Contributor

Hi @serhiikv,

Thanks for your reporting and collaboration.

We have verified the issue in Latest 2.4-develop instance and the issue is reproducible.Kindly refer the screenshots.

Screenshot 2024-08-14 at 14 46 20

In API response receive discount_percent equals 13

Hence Confirming the issue.

Thanks.

@engcom-Bravo engcom-Bravo added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Component: Api Use with concrete module component label E.g. "Component: Api" + "Catalog" Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Priority: P3 May be fixed according to the position in the backlog. Area: APIs labels Aug 14, 2024
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-12754 is successfully created for this GitHub issue.

Copy link

m2-assistant bot commented Aug 14, 2024

✅ Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@engcom-Hotel engcom-Hotel moved this to Ready for Development in Low Priority Backlog Aug 19, 2024
quterorta added a commit to quterorta/magento2 that referenced this issue Feb 28, 2025
- fixed incorrect discount percent calculation
quterorta added a commit to quterorta/magento2 that referenced this issue Feb 28, 2025
@quterorta
Copy link
Contributor

@magento I'm working on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: APIs Component: Api Use with concrete module component label E.g. "Component: Api" + "Catalog" Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: ready for dev Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants