magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.3k forks source link

Divide By Zero error when Refund Create API is used. #8802

Closed srinivasanithin closed 7 years ago

srinivasanithin commented 7 years ago

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.

joni-jones commented 7 years ago

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

joni-jones commented 7 years ago

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.

joni-jones commented 7 years ago

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.