magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Divide By Zero error when Refund Create API is used.

Open srinivasanithin opened this issue 9 years ago • 3 comments

Preconditions

  1. Magento 2.1.5
  2. Php 5.6.21

Steps to reproduce

  1. Create an order using freeshipping method and cost of shipping is zero.
  2. create an invoice that order
  3. Use api request to create an Refund POST /V1/invoice/{invoiceId}/refund using that invoiceId

Expected result

  1. It should be creating the refund successfully.

Actual result

  1. 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.

srinivasanithin avatar Mar 06 '17 13:03 srinivasanithin

Hi, @srinivasanithin, thanks for reporting. I've created internal ticket (MAGETWO-65582).

YevSent avatar Mar 06 '17 15:03 YevSent

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.

YevSent avatar Apr 05 '17 11:04 YevSent

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.

YevSent avatar Apr 19 '17 12:04 YevSent