prevent discount to be higher than total

This commit is contained in:
Pavel 2020-04-23 15:42:39 +03:00 committed by GitHub
parent 5108111654
commit d4f9e0b762
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -884,6 +884,10 @@ class RetailcrmOrderBuilder
);
$crmOrder['discountManualAmount'] = round($order->total_discounts, 2);
if (((float) $crmOrder['discountManualAmount']) > ((float) $order_payment['amount'])) {
$crmOrder['discountManualAmount'] = $order_payment['amount'];
}
}
if (isset($order_payment)) {

View File

@ -500,9 +500,13 @@ class RetailCRM extends Module
'createdAt' => RetailcrmTools::verifyDate($params['order']->date_add, 'Y-m-d H:i:s')
? $params['order']->date_add : date('Y-m-d H:i:s'),
'delivery' => array('cost' => $params['order']->total_shipping),
'discountManualAmount' => $params['order']->total_discounts
'discountManualAmount' => round($params['order']->total_discounts, 2)
);
if (((float) $order['discountManualAmount']) > ((float) $params['order']->total_paid)) {
$crmOrder['discountManualAmount'] = $params['order']->total_paid;
}
try {
$orderdb = new Order($params['order']->id);
} catch (PrestaShopDatabaseException $exception) {