]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Правки по расчету продаж товаров
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 23 Jul 2025 16:06:15 +0000 (19:06 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 23 Jul 2025 16:06:15 +0000 (19:06 +0300)
erp24/services/AutoPlannogrammaService.php
erp24/services/StorePlanService.php

index 052b814b45e5ea4c3c47a6c6bb41e828142ae76d..927a24d84e2cd007a73006963abf34cf30257080 100644 (file)
@@ -772,9 +772,9 @@ class AutoPlannogrammaService
     public function calculateFullGoalChain(array $filters): array
     {
         $datePlan = $filters['plan_date'];
-        $dateFromForCategory = (new \DateTime($datePlan))->modify('-' . (self::CATEGORY_LOOKBACK_MONTHS + self::LOOKBACK_MONTHS) . ' months')->format('Y-m-d');
+        //$dateFromForCategory = (new \DateTime($datePlan))->modify('-' . (self::CATEGORY_LOOKBACK_MONTHS + self::LOOKBACK_MONTHS) . ' months')->format('Y-m-d');
 
-        $monthCategoryShare = $this->getMonthCategoryShareOrWriteOff($dateFromForCategory, $filters);
+        $monthCategoryShare = $this->getMonthCategoryShareOrWriteOff($datePlan, $filters);
         $monthCategoryGoal = $this->getMonthCategoryGoal($monthCategoryShare, $datePlan, $filters['type']);
 
         $monthSubcategoryShare = $this->getMonthSubcategoryShareOrWriteOff($datePlan, $filters);
index bf9a12c355faac4ccf2ba66983128753a27f639d..2b70bf210786fb6f4105770ef85b06da46201fe7 100755 (executable)
@@ -323,7 +323,7 @@ class StorePlanService
      *
      * @return array
      */
-    private static function getSalesHistory($storeId, $periods, $category = null, $subcategory = null, $species = null)
+    public static function getSalesHistory($storeId, $periods, $category = null, $subcategory = null, $species = null)
     {
         $salesHistory = [];
 
@@ -338,7 +338,7 @@ class StorePlanService
                 $query = Sales::find()->alias('s')
                     ->select([
                         'p1c.id as product_guid',
-                        'COUNT(*) as sales_count',
+                        'SUM(sp.quantity) as sales_count',
                         'p1c.category',
                         'p1c.subcategory',
                         'p1c.species',
@@ -349,7 +349,7 @@ class StorePlanService
                     ->where(['s.store_id' => $storeId])
                     ->andWhere(['between', 's.date', $dateStart, $dateEnd])
                     ->andWhere(['order_id' => ['', '0']])
-                    ->andWhere(['p1.components' => ''])
+                    //->andWhere(['p1.components' => ''])
                     ->andWhere(['not in', 'p1c.category', ['', 'букет', 'сборка', 'сервис']])
                     ->andFilterWhere(['p1c.category'    => $category])
                     ->andFilterWhere(['p1c.subcategory' => $subcategory])