From: marina Date: Mon, 16 Dec 2024 11:52:31 +0000 (+0300) Subject: ERP-259 Доработка второго шага передачи смен X-Git-Tag: 1.7~160^2~4 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=7ad6a30a54e1270c5f4f7f33463a4d3713fbd71d;p=erp24_rep%2Fyii-erp24%2F.git ERP-259 Доработка второго шага передачи смен --- diff --git a/erp24/records/WaybillIncomingProducts.php b/erp24/records/WaybillIncomingProducts.php index ba72a66f..1708cf5e 100644 --- a/erp24/records/WaybillIncomingProducts.php +++ b/erp24/records/WaybillIncomingProducts.php @@ -71,18 +71,20 @@ class WaybillIncomingProducts extends \yii\db\ActiveRecord foreach ($items as $item) { $itemCount = abs($item->fact_and_1c_diff); - $er = EqualizationRemains::findOne([ - 'shift_transfer_id' => $shiftTransfer->id, - 'product_replacement_id' => $item->product_guid - ]); + $er = EqualizationRemains::find() + ->andWhere(['shift_transfer_id' => $shiftTransfer->id]) + ->andWhere(['product_id' => $item->product_replacement_guid]) + ->select('SUM(product_replacement_count) as sum') + ->scalar(); + $count = 0; if ($er) { - if ($er->product_count == $itemCount) { + if ($er == $itemCount) { continue; } - if ($itemCount > $er->product_count) { - $count = $itemCount - $er->product_count; + if ($itemCount > $er) { + $count = $itemCount - $er; } } else { diff --git a/erp24/records/WaybillWriteOffsProducts.php b/erp24/records/WaybillWriteOffsProducts.php index c5363573..508cc733 100644 --- a/erp24/records/WaybillWriteOffsProducts.php +++ b/erp24/records/WaybillWriteOffsProducts.php @@ -72,19 +72,19 @@ class WaybillWriteOffsProducts extends \yii\db\ActiveRecord foreach ($items as $item) { $itemCount = abs($item->fact_and_1c_diff); - $er = EqualizationRemains::findOne([ - 'shift_transfer_id' => $shiftTransfer->id, - 'product_id' => $item->product_guid - ]); - + $er = EqualizationRemains::find() + ->andWhere(['shift_transfer_id' => $shiftTransfer->id]) + ->andWhere(['product_id' => $item->product_guid]) + ->select('SUM(product_replacement_count) as sum') + ->scalar(); if ($er) { - if ($er->product_count == $itemCount) { + if ($er == $itemCount) { continue; } - if ($itemCount > $er->product_count) { - $count = $itemCount - $er->product_count; + if ($itemCount > $er) { + $count = $itemCount - $er; } } else {