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);