|
|
|
|
|
|
|
|
$amountRemaining = $order->getAmount(Order::AMOUNT_REMAINING) ; |
|
|
$amountRemaining = $order->getAmount(Order::AMOUNT_REMAINING) ; |
|
|
$credit = Yii::$app->user->identity->getCredit($distribution->id_producer); |
|
|
$credit = Yii::$app->user->identity->getCredit($distribution->id_producer); |
|
|
|
|
|
|
|
|
if ($amountRemaining > $credit) { |
|
|
|
|
|
$amountRemaining = $credit; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($amountRemaining > 0) { |
|
|
if ($amountRemaining > 0) { |
|
|
$order->saveCreditHistory( |
|
|
$order->saveCreditHistory( |
|
|
CreditHistory::TYPE_PAYMENT, |
|
|
CreditHistory::TYPE_PAYMENT, |