1
0
mirror of synced 2024-11-22 13:26:10 +03:00

fix: don't remove payments after changes in retailCRM

This commit is contained in:
Pavel 2019-07-02 13:46:13 +03:00
parent 366e3e2b1d
commit 5eb64d9c84

View File

@ -1141,7 +1141,8 @@ class RetailCrmHistory
foreach ($paymentsCrm['payments'] as $paymentCrm) { foreach ($paymentsCrm['payments'] as $paymentCrm) {
if (isset($paymentCrm['externalId']) && !empty($paymentCrm['externalId'])) { if (isset($paymentCrm['externalId']) && !empty($paymentCrm['externalId'])) {
//find the payment //find the payment
$nowPayment = $paymentsList[RCrmActions::getFromPaymentExternalId($paymentCrm['externalId'])]; $nowPaymentId = RCrmActions::getFromPaymentExternalId($paymentCrm['externalId']);
$nowPayment = $paymentsList[$nowPaymentId];
//update data //update data
if ($nowPayment instanceof \Bitrix\Sale\Payment) { if ($nowPayment instanceof \Bitrix\Sale\Payment) {
$nowPayment->setField('SUM', $paymentCrm['amount']); $nowPayment->setField('SUM', $paymentCrm['amount']);
@ -1153,7 +1154,7 @@ class RetailCrmHistory
$nowPayment->setField('PAID', $optionsPayment[$paymentCrm['status']]); $nowPayment->setField('PAID', $optionsPayment[$paymentCrm['status']]);
} }
unset($paymentsList[$paymentCrm['externalId']]); unset($paymentsList[$nowPaymentId]);
} }
} else { } else {
$newHistoryPayments[$paymentCrm['id']] = $paymentCrm; $newHistoryPayments[$paymentCrm['id']] = $paymentCrm;