]> gitweb.erp-flowers.ru Git - yii-erp24/.git/commitdiff
правки по лк отключение расчёта категории нормасмены
authorAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Fri, 26 Apr 2024 06:51:57 +0000 (09:51 +0300)
committerAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Fri, 26 Apr 2024 06:51:57 +0000 (09:51 +0300)
erp24/services/RateStoreCategoryService.php

index 9446ef2c6720b434720e9a3733f0a86f8007141e..642fec73203076902ee3ebc6a4bed1eccbe51b74 100755 (executable)
@@ -36,44 +36,46 @@ class RateStoreCategoryService
 
     public function getRateInfo($employeeSelectStoreId, $employeeGroupId, $dateFrom, $dateTo): array
     {
-       $query = RateStoreCategory::find()
-            ->select(['category_id'])
-            ->andWhere(['<=', 'date_from', $dateFrom])
-            ->andWhere(['>=', 'date_to', $dateFrom])
-            ->andWhere(['<=', 'date_from', $dateTo])
-            ->andWhere(['>=', 'date_to', $dateTo])
-            ->andWhere(['store_id'=> $employeeSelectStoreId]);
+        $rateInfo = [];
+        if ($dateFrom <= '2024-01-01') {
+            $query = RateStoreCategory::find()
+                ->select(['category_id'])
+                ->andWhere(['<=', 'date_from', $dateFrom])
+                ->andWhere(['>=', 'date_to', $dateFrom])
+                ->andWhere(['<=', 'date_from', $dateTo])
+                ->andWhere(['>=', 'date_to', $dateTo])
+                ->andWhere(['store_id' => $employeeSelectStoreId]);
 
             $action = $query->createCommand()->getRawSql();
 
-             $storeCategoryId = $query->asArray()->scalar();
+            $storeCategoryId = $query->asArray()->scalar();
 
-        $rateDict = RateDict::find()
-            ->indexBy('id')
-            ->asArray()
-            ->all();
+            $rateDict = RateDict::find()
+                ->indexBy('id')
+                ->asArray()
+                ->all();
 
-        $normaSmena = RateCategoryAdminGroup::find()
-            ->andWhere(['admin_group_id'=> $employeeGroupId])
-            ->andWhere(['category_id'=> $storeCategoryId])
-            ->asArray()
-            ->one();
+            $normaSmena = RateCategoryAdminGroup::find()
+                ->andWhere(['admin_group_id' => $employeeGroupId])
+                ->andWhere(['category_id' => $storeCategoryId])
+                ->asArray()
+                ->one();
 
-        if (!empty($normaSmena)) {
-            $rate = (new NormaSmenaService())->getFormattedNormaSmena($normaSmena);
-        }
+            if (!empty($normaSmena)) {
+                $rate = (new NormaSmenaService())->getFormattedNormaSmena($normaSmena);
+            }
 
-        $rateInfo = [];
 
-        if (!empty($rate)) {
-            foreach ($rate as $key => $item) {
-                $rateInfo[] = [
-                    'id' => $key,
-                    'name' => $rateDict[$key]['name'],
-                    'condition' => $item,
-                    'value' => $rateDict[$key]['value'],
-                    'game_value' => $rateDict[$key]['game_value'],
-                ];
+            if (!empty($rate)) {
+                foreach ($rate as $key => $item) {
+                    $rateInfo[] = [
+                        'id' => $key,
+                        'name' => $rateDict[$key]['name'],
+                        'condition' => $item,
+                        'value' => $rateDict[$key]['value'],
+                        'game_value' => $rateDict[$key]['game_value'],
+                    ];
+                }
             }
         }