From: Vladimir Fomichev Date: Wed, 23 Jul 2025 16:06:15 +0000 (+0300) Subject: Правки по расчету продаж товаров X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=3e8e11841433e0584f1baed2093901273fa17a59;p=erp24_rep%2Fyii-erp24%2F.git Правки по расчету продаж товаров --- diff --git a/erp24/services/AutoPlannogrammaService.php b/erp24/services/AutoPlannogrammaService.php index 052b814b..927a24d8 100644 --- a/erp24/services/AutoPlannogrammaService.php +++ b/erp24/services/AutoPlannogrammaService.php @@ -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); diff --git a/erp24/services/StorePlanService.php b/erp24/services/StorePlanService.php index bf9a12c3..2b70bf21 100755 --- a/erp24/services/StorePlanService.php +++ b/erp24/services/StorePlanService.php @@ -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])