]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-259 Доработка второго шага передачи смен
authormarina <m.zozirova@gmail.com>
Mon, 16 Dec 2024 11:52:31 +0000 (14:52 +0300)
committermarina <m.zozirova@gmail.com>
Mon, 16 Dec 2024 11:52:31 +0000 (14:52 +0300)
erp24/records/WaybillIncomingProducts.php
erp24/records/WaybillWriteOffsProducts.php

index ba72a66fba502d1d97e1f97131e6b8b91f37fd01..1708cf5efeb9436583d43aad9be79157d1915822 100644 (file)
@@ -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 {
index c5363573f9ef9ab1ede31393ee70dbd4985fee0d..508cc733e46bac28507113b32077d05c21661ca8 100644 (file)
@@ -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 {