magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Float value calculation not returning exact zero

Open mack4hack opened this issue 1 year ago • 20 comments

Preconditions and environment

  • Magento: 2.4.6-p4
  • PHP: 8.1
  • Simple product having price $83.99
  • A 100% discount coupon code also applicable on shipping amount
  • Flat shipping with rate $205.98

Steps to reproduce

Frontend/Backend

  1. Add the Simple Product which having price $83.99
  2. apply coupon code (100% discount)
  3. select flat shipping method ($205.98)
  4. Observe the order total it will be Zero
  5. Place the order

Backend

  1. Open the order detail page
  2. Click on the Invoice
  3. Select the checkbox to create a shipment
  4. fill the tracking details
  5. Submit the Invoice

Expected result

Order must be "Completed" State : complete and Status : Completed

Actual result

Order is getting "Closed" State : closed and Status : Closed

Additional information

File Path : vendor/magento/module-sales/Model/Order/Invoice/Total/Shipping.php Line no: 41 $invoice->setGrandTotal($invoice->getGrandTotal() + $orderShippingAmount);

$invoice->getGrandTotal() + $orderShippingAmount returns a float 2.8421709430404E-14

Release note

No response

Triage and priority

  • [X] 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”.

mack4hack avatar Feb 27 '24 11:02 mack4hack

Hi @mack4hack. 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. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: 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.

m2-assistant[bot] avatar Feb 27 '24 11:02 m2-assistant[bot]

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: :point_down:

  • [ ] 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.

m2-assistant[bot] avatar Feb 27 '24 11:02 m2-assistant[bot]

@magento give me 2.4-develop instance

engcom-Bravo avatar Feb 28 '24 05:02 engcom-Bravo

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

Hi @engcom-Bravo, here is your Magento Instance: https://71611cbd69c3dd715b84f59cfc2471c1.instances-prod.magento-community.engineering Admin access: https://71611cbd69c3dd715b84f59cfc2471c1.instances-prod.magento-community.engineering/admin_032e Login: e54890f2 Password: ef036e1ae257

Hi @mack4hack,

Thank you for reporting and collaboration.

Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

Steps to reproduce Frontend/Backend

Add the Simple Product which having price $83.99 apply coupon code (100% discount) select flat shipping method ($205.98) Observe the order total it will be Zero Place the order

Backend

Open the order detail page Click on the Invoice Select the checkbox to create a shipment fill the tracking details Submit the Invoice

Screenshot from 2024-02-28 11-47-36

Screenshot from 2024-02-28 11-48-09

Order is completed and status is also in completed state.

Kindly recheck the issue in Latest Magento 2.4-develop instance and elaborate the steps to reproduce if the issue is still reproducible.

Thanks.

engcom-Bravo avatar Feb 28 '24 09:02 engcom-Bravo

@magento give me 2.4-develop instance

mack4hack avatar Feb 28 '24 09:02 mack4hack

Hi @mack4hack. Thank you for your request. I'm working on Magento instance for you.

Hi @mack4hack, here is your Magento Instance: https://71611cbd69c3dd715b84f59cfc2471c1.instances-prod.magento-community.engineering Admin access: https://71611cbd69c3dd715b84f59cfc2471c1.instances-prod.magento-community.engineering/admin_44bd Login: f7a061b0 Password: 3ed71a6b835e

@magento give me 2.4.6-p4 instance

mack4hack avatar Feb 28 '24 10:02 mack4hack

Hi @mack4hack. Thank you for your request. I'm working on Magento instance for you.

Hi @mack4hack, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

Hi @engcom-Bravo , Thanks for checking the issue, I am not able to reproduce it on 2.4-develop instance. I will try to verify it on 2.4.6-p4 instance and share the details

mack4hack avatar Feb 28 '24 10:02 mack4hack

@magento give me 2.4.6-p4 instance

mack4hack avatar Feb 28 '24 13:02 mack4hack

Hi @mack4hack. Thank you for your request. I'm working on Magento instance for you.

Hi @mack4hack, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

@magento give me 2.4.6-p4 instance

mack4hack avatar Feb 29 '24 04:02 mack4hack

Hi @mack4hack. Thank you for your request. I'm working on Magento instance for you.

Hi @mack4hack, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

@engcom-Bravo can you please check this issue on Magento 2.4.6-p4 version ?

mack4hack avatar Feb 29 '24 07:02 mack4hack

Hi @mack4hack,

Thanks for your update.

It is recommended to verify the issues in latest Magento 2.4-develop instance.it might be possible issue has been fixed in Latest branch.

Thanks.

engcom-Bravo avatar Mar 01 '24 09:03 engcom-Bravo

@magento I am working on it

tushardatar7 avatar Mar 04 '24 08:03 tushardatar7

Hi @tushardatar7! :wave: Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

m2-assistant[bot] avatar Mar 04 '24 08:03 m2-assistant[bot]

@magento add to contributors team

tushardatar7 avatar Mar 04 '24 08:03 tushardatar7

Hi @tushardatar7! :wave: Thank you for joining. Please accept team invitation :point_right: here :point_left: and add your comment one more time.

m2-assistant[bot] avatar Mar 04 '24 08:03 m2-assistant[bot]

@magento I am working on it

tushardatar7 avatar Mar 04 '24 08:03 tushardatar7

@magento give me 2.4-develop instance

engcom-Bravo avatar Mar 05 '24 05:03 engcom-Bravo

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

Hi @engcom-Bravo, here is your Magento Instance: https://71611cbd69c3dd715b84f59cfc2471c1.instances-prod.magento-community.engineering Admin access: https://71611cbd69c3dd715b84f59cfc2471c1.instances-prod.magento-community.engineering/admin_2170 Login: 69ad5b54 Password: 46412399501c

Hi @tushardatar7,

Thanks for your contribution for creating the PR.

We have verified the issue in Latest 2.4-develop instance as it is recommended and the issue is not reproducible.kindly refer the screenshots.

Screenshot from 2024-03-05 11-30-26

Screenshot from 2024-03-05 11-30-40

The order status is completed.Could you please try to reproduce the issue in Magento 2.4-develop instance.

Thanks

engcom-Bravo avatar Mar 05 '24 06:03 engcom-Bravo