From 7ad6a30a54e1270c5f4f7f33463a4d3713fbd71d Mon Sep 17 00:00:00 2001 From: marina Date: Mon, 16 Dec 2024 14:52:31 +0300 Subject: [PATCH] =?utf8?q?ERP-259=20=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?utf8?q?=D1=82=D0=BA=D0=B0=20=D0=B2=D1=82=D0=BE=D1=80=D0=BE=D0=B3=D0=BE?= =?utf8?q?=20=D1=88=D0=B0=D0=B3=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4?= =?utf8?q?=D0=B0=D1=87=D0=B8=20=D1=81=D0=BC=D0=B5=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/records/WaybillIncomingProducts.php | 16 +++++++++------- erp24/records/WaybillWriteOffsProducts.php | 16 ++++++++-------- 2 files changed, 17 insertions(+), 15 deletions(-) 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 { -- 2.39.5