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);
*
* @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 = [];
$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',
->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])