]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-220] дефект с поставки целиком идёт на Аэродромную, оставляя остальные магазины...
authorAlexander Smirnov <fredeom@mail.ru>
Mon, 14 Oct 2024 09:27:22 +0000 (12:27 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Mon, 14 Oct 2024 09:27:22 +0000 (12:27 +0300)
erp24/services/MotivationService.php

index ef9d8f8d0c397238f01476a5c1bcdd119870b86d..1b8427cee4ba95582c45a712cd289a6e358ce475 100644 (file)
@@ -495,7 +495,7 @@ class MotivationService
                 foreach (MotivationCostsItem::getWriteOffsItems() as $key) {
 
                     if ($key == WriteOffsErp::WRITE_OFFS_TYPE_DELIVERY_BRAK) {
-                        if ($store_id == 4) {
+                        if ($store_id == 4 /* Аэродромная */ ) {
                             $writeOffsResult = WriteOffs::find()->alias('wo')->select(['wo.type', 'wo.date', 'wop.product_id', 'wop.quantity', 'wop.price'])
                                 ->rightJoin('write_offs_products wop', 'wop.write_offs_id = wo.id')
                                 ->where(['between', 'wo.date', $weekStart, $weekEnd])
@@ -1335,8 +1335,21 @@ class MotivationService
                 }
 
                 foreach (MotivationCostsItem::writeOffsToMotivationItemArray() as $key => $motivationItemType) {
+                    if ($key == WriteOffsErp::WRITE_OFFS_TYPE_DELIVERY_BRAK) {
+                        if ($store_id == 4 /* Аэродромная */) {
+                            $writeOffsResult = $writeOffs = WriteOffs::find()->alias('wo')->select(['wo.type', 'wo.date', 'wop.product_id', 'wop.quantity', 'wop.price'])
+                                ->rightJoin('write_offs_products wop', 'wop.write_offs_id = wo.id')
+                                ->where(['between', 'wo.date', $monthStart, $monthEnd])
+                                ->asArray()->all();
+                        } else {
+                            $writeOffsResult = [];
+                        }
+                    } else {
+                        $writeOffsResult = $writeOffs;
+                    }
+
                     $sum = 0;
-                    foreach($writeOffs as $data) {
+                    foreach($writeOffsResult as $data) {
                         if (($data['type'] ?? '') == $key) {
                             $value = ($selfCostProductMap[date("Y-m-d", strtotime($data['date']))][$data['product_id']] ?? 0)
                                 * ($data['quantity'] ?? 0);