From: Alexander Smirnov Date: Mon, 14 Oct 2024 09:27:22 +0000 (+0300) Subject: [ERP-220] дефект с поставки целиком идёт на Аэродромную, оставляя остальные магазины... X-Git-Tag: 1.6~36^2~3 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=241e6537dee3a9fc06899b0b58a24e004841aa0a;p=erp24_rep%2Fyii-erp24%2F.git [ERP-220] дефект с поставки целиком идёт на Аэродромную, оставляя остальные магазины пустыми 2 --- diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index ef9d8f8d..1b8427ce 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -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);