Divide By Zero error when Refund Create API is used.
Preconditions
- Magento 2.1.5
- Php 5.6.21
Steps to reproduce
- Create an order using freeshipping method and cost of shipping is zero.
- create an invoice that order
- Use api request to create an Refund POST /V1/invoice/{invoiceId}/refund using that invoiceId
Expected result
- It should be creating the refund successfully.
Actual result
- stacktrace is the following Report ID: webapi-58b7d17c4d402; Message: Warning: Division by zero in /..../vendor/magento/module-sales/Model/Order/Creditmemo/Total/Discount.php on line 32' in /..../vendor/magento/framework/Webapi/ErrorProcessor.php:195
We find that $order->getBaseShippingAmount() is zero because of the shipping method and it is failing causing validation error in API call.
Thanks, Srinivasa Nithin.
Hi, @srinivasanithin, thanks for reporting. I've created internal ticket (MAGETWO-65582).
Hi, @srinivasanithin, please, provide additional steps or configuration, described case is strange because if you have free shipping for an order, the creditmemo also will have zero shipping amount and the specified condition in the code should not be executed.
We are closing this issue because it hasn’t been updated in more than two weeks.
If you still can reproduce the issue, please, provide additional details and be free to reopen it.