From: Vladimir Fomichev Date: Tue, 29 Jul 2025 08:07:18 +0000 (+0300) Subject: Merge branch 'refs/heads/develop' into feature_fomichev_erp_444_OS_autoplannogramm X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=5cd0d3bab046fbf42503bab6ccdde67874410d1e;p=erp24_rep%2Fyii-erp24%2F.git Merge branch 'refs/heads/develop' into feature_fomichev_erp_444_OS_autoplannogramm # Conflicts: # erp24/services/AutoPlannogrammaService.php --- 5cd0d3bab046fbf42503bab6ccdde67874410d1e diff --cc erp24/services/AutoPlannogrammaService.php index 04e286c8,39751ab9..a580d627 --- a/erp24/services/AutoPlannogrammaService.php +++ b/erp24/services/AutoPlannogrammaService.php @@@ -772,11 -846,36 +846,36 @@@ class AutoPlannogrammaServic 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($datePlan, $filters); - $monthCategoryGoal = $this->getMonthCategoryGoal($monthCategoryShare, $datePlan, $filters['type']); + //$monthCategoryShare = $this->getMonthCategoryShareOrWriteOff($dateFromForCategory, $filters); + + //$monthCategoryGoal = $this->getMonthCategoryGoal($monthCategoryShare, $datePlan, $filters['type']); + $monthCategoryGoal = []; + $categoryPlan = CategoryPlan::find() + ->where( + ['year' => date('Y', strtotime($datePlan)), + 'month' => date('m', strtotime($datePlan)), + 'store_id' => $filters['store_id']])->indexBy('category') + ->asArray() + ->all(); + foreach ($categoryPlan as $category) { + if ($category['category'] === 'Матрица') { + continue; + } + if ($filters['type'] == AutoPlannogrammaService::TYPE_SALES) { + $fullGoal = $category['offline'] + $category['internet_shop'] + $category['marketplace']; + } else { + $fullGoal = $category['write_offs']; + } + + $monthCategoryGoal[] = [ + 'category' => $category['category'], + 'store_id' => $filters['store_id'], + 'goal' => $fullGoal + ]; + } $monthSubcategoryShare = $this->getMonthSubcategoryShareOrWriteOff($datePlan, $filters); $monthSubcategoryGoal = $this->getMonthSubcategoryGoal($monthSubcategoryShare, $monthCategoryGoal);