Magento2: Divide By Zero error when Refund Create API is used.

Created on 6 Mar 2017  路  3Comments  路  Source: magento/magento2


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.

Sales Ready for Work needs update bug report

Most helpful comment

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

All 3 comments

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鈥檛 been updated in more than two weeks.

If you still can reproduce the issue, please, provide additional details and be free to reopen it.

Was this page helpful?
0 / 5 - 0 ratings