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

Error 'Unable to ship order' when creating a partial shipment #739

Closed
aartse opened this issue Jan 31, 2024 · 10 comments
Closed

Error 'Unable to ship order' when creating a partial shipment #739

aartse opened this issue Jan 31, 2024 · 10 comments
Assignees
Labels
Fixed and planned for next release Fix will be included in the next release. Investigating We are working on this issue together with the customer.

Comments

@aartse
Copy link

aartse commented Jan 31, 2024

Describe the bug
When i create a partial shipment, i get the following error:

Unable to ship order "1000020369" due to error: [2024-01-22T11:09:52+0000] Error executing API call (422: Unprocessable Entity): Line 0 contains invalid data. Invalid amount specified. Must be exactly €35.20, got: €35.52.. Field: lines.0.amount. Documentation: https://docs.mollie.com/reference/v2/shipments-api/create-shipment

Used versions

  • Magento Version number(eg 2.3.5): 2.4.5-p5
  • Open source/Enterprise/B2b: Open source
  • Mollie version number (Check configuration): v2.32.4

To Reproduce
Set method for payment method

  1. Go to Stores => Configuration => Molie => Payment method
  2. Click on a payment method
  3. Set 'Method' to 'Orders API'
  4. Save

Set magento tax settings

  1. Go to Stores => Configuration => Sales => Tax
  2. Set 'Apply Discount On Prices' to 'Excluding Tax'
  3. Save

Create order and create partial shipment

  1. Create order with 2 products in frontend and use the payment method which uses 'Orders API' and complete the transaction.
  2. Login to the admin
  3. Goto the created order
  4. Click on ship
  5. Ship 1 product
  6. Got the error

Expected behavior
Can create a partial shipment.

Actual behavior
Error and no shipment is created in magento or mollie

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Bug is caused at this line:
https://github.com/mollie/magento2/blob/master/Model/OrderLines.php#L222

When the setting 'Apply Discount On Prices' is set to 'Excluding Tax', the amount in the field 'base_discount_amount' is also excluding tax. so when you do $rowTotal = $orderItem->getBaseRowTotalInclTax() - $orderItem->getBaseDiscountAmount(); the $rowTotal misses the tax on the discount and causes the error.

@Frank-Magmodules Frank-Magmodules added the Investigating We are working on this issue together with the customer. label Jan 31, 2024
@Frank-Magmodules Frank-Magmodules self-assigned this Jan 31, 2024
@Frank-Magmodules
Copy link
Collaborator

Hi there @aartse ,

Thank you for opening this issue with detailed steps. We seem to be unable to reproduce this issue. Could you please describe what kinds of taxes and/or discounts are in play here? And do you have any extensions in place that add order totals (payment fees, extra discounts, etc)? Feel free to share this here or contact us directly.

@aartse
Copy link
Author

aartse commented Feb 2, 2024

@Frank-Magmodules i can give you admin access to the staging server with this problem so you can check the tax settings?

@Frank-Magmodules
Copy link
Collaborator

Yes please @aartse , that would be great, please share directly.

@patricksteenks
Copy link

patricksteenks commented Feb 7, 2024

I have the exact same issue. After some debugging it appears that in mollie/magento2/Model/OrderLines.php on orders with a discount a discount percentage is applied to the order line. This leads to a different price for the order line than what magento is expecting.

If I remove the $orderHasDiscount check, the order is shipped fine.

The discount code that is applied is a cart-wide percentage discount.

@Frank-Magmodules
Copy link
Collaborator

Thanks, @patricksteenks !
I've just received your email providing additional context. It seems we may have identified the problem and are currently investigating both the issue and the potential solution. We aim to implement these changes in the upcoming release.

@Frank-Magmodules
Copy link
Collaborator

We have resolved this issue and provided the fix to both @aartse and @patricksteenks . It will be merged into the upcoming release. Thank you for bringing this to our attention; I will keep the issue open until the release.

@Frank-Magmodules Frank-Magmodules added the Fixed and planned for next release Fix will be included in the next release. label Feb 8, 2024
@Celoain
Copy link

Celoain commented Feb 13, 2024

@Frank-Magmodules Could you clarify what was done in order to fix this issue in the new release?
We are struggling with the same issue and would like to review the change as well.

@Frank-Magmodules
Copy link
Collaborator

Hello @Celoain , of course! I'll share it in the upcoming days once we've finalized the testing phase on our end.

@Frank-Magmodules
Copy link
Collaborator

Hello @Celoain , as requested, here is the .diff file ahead of our upcoming release of the new version.

michielgerritsen added a commit to michielgerritsen/mollie-magento2 that referenced this issue Feb 22, 2024
@Frank-Magmodules
Copy link
Collaborator

Hello @Celoain and @aartse and @patricksteenks , I'm pleased to inform you that we have successfully implemented a solution for the issue you reported in our latest release. Thank you for providing the details and for your patience; it is greatly appreciated. Please feel free to share any comments or reopen the issue if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed and planned for next release Fix will be included in the next release. Investigating We are working on this issue together with the customer.
Projects
None yet
Development

No branches or pull requests

4 participants