]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-299 Изменить подсчёт продаж в личном кабинете сотрудника
authormarina <m.zozirova@gmail.com>
Thu, 30 Jan 2025 06:51:28 +0000 (09:51 +0300)
committermarina <m.zozirova@gmail.com>
Thu, 30 Jan 2025 06:51:28 +0000 (09:51 +0300)
erp24/helpers/SalaryHelper.php
erp24/services/SalesService.php

index 862205c3d1e92ebacb03adbda55ce3fc7965cf13..7482db5e0acd980ac794328b3a54775de3ae06a7 100755 (executable)
@@ -192,6 +192,53 @@ class SalaryHelper
             ]
         );
 
+        if ($dateFrom > '2025-01-01') {
+            $command = $connection->createCommand("
+            SELECT
+                sales.id,
+                sales.number,
+                sales.date,
+                sales.operation,
+                sales.seller_id,  
+                SUM(p.summ) as bonus 
+            FROM  
+                sales_products as p, 
+                sales 
+            WHERE  
+                $whereProducts
+                
+                $where_p 
+              
+            AND 
+                sales.id = p.check_id 
+            AND 
+                p.type_id = 1
+            AND 
+                (p.component_parent_id = '' OR p.component_parent_id = '0' OR p.component_parent_id IS NULL)
+            
+                $where_old_matrix
+            
+            AND 
+                sales.date >= :date_from 
+            AND 
+                sales.date <= :date_to  
+            GROUP BY 
+                sales.id, 
+                sales.number,
+                sales.date,
+                sales.seller_id, 
+                sales.operation
+            ORDER BY 
+                sales.date ASC
+            
+            ",
+                [
+                    ':date_from' => DateHelper::getDateTimeStartDay($dateFrom, $dateTimeStartDay, $adminId),
+                    ':date_to' => DateHelper::getDateTimeEndDay($dateTo, $dateTimeEndDay, $adminId),
+                ]
+            );
+        }
+
         $data2 = $command->queryAll();
 
 
index e33e4296cb35fd5a5256378272a40c97bfa7d6b8..39d27885a895763733625362d977d09152531172 100755 (executable)
@@ -92,7 +92,7 @@ class SalesService
     /**
      * @throws \Exception
      */
-    public function getSalesSum($dateFrom, $dateTo, $salesDelivery = false, $salesTotal = false, $storeId1c = null, $payType = null) : array
+    public function getSalesSum($dateFrom, $dateTo, $salesDelivery = false, $salesTotal = false, $storeId1c = null, $payType = null): array
     {
         $query = Sales::find()
             ->alias('s')
@@ -125,8 +125,8 @@ class SalesService
         }
 
         if (!empty($payType)) {
-            if ($payType ==  '1') {
-                $payType = ['1', '3', '1,3', '3,1' ];
+            if ($payType == '1') {
+                $payType = ['1', '3', '1,3', '3,1'];
             }
 
             $query->andWhere(['s.pay_arr' => $payType]);
@@ -143,10 +143,11 @@ class SalesService
 
         return $query->asArray()->all();
     }
+
     /**
      * @throws \Exception
      */
-    public function getSalesShiftSum($dateFrom, $dateTo, $shiftType, $salesDelivery = false, $salesTotal = false, $storeId1c = null) : array
+    public function getSalesShiftSum($dateFrom, $dateTo, $shiftType, $salesDelivery = false, $salesTotal = false, $storeId1c = null): array
     {
         $shiftTypeValidate = [
             'day',
@@ -159,11 +160,11 @@ class SalesService
 
         }
         if ($shiftType == 'day') {
-            $dateFromPrepared =  DateHelper::getDateTimeStartSmen($dateFrom);
-            $dateToPrepared =  DateHelper::getDateTimeEndDaySmen($dateTo);
+            $dateFromPrepared = DateHelper::getDateTimeStartSmen($dateFrom);
+            $dateToPrepared = DateHelper::getDateTimeEndDaySmen($dateTo);
         } elseif ($shiftType == 'night') {
-            $dateFromPrepared =  DateHelper::getDateTimeStartNightSmen($dateFrom);
-            $dateToPrepared =  DateHelper::getDateTimeEndNightShift($dateTo);
+            $dateFromPrepared = DateHelper::getDateTimeStartNightSmen($dateFrom);
+            $dateToPrepared = DateHelper::getDateTimeEndNightShift($dateTo);
         }
         $query = Sales::find()
             ->select([
@@ -196,7 +197,7 @@ class SalesService
     /**
      * @throws \Exception
      */
-    public function getSalesType($dateFrom, $dateTo, $salesType = 1, $salesDelivery = false, $storeId1c = null) : array
+    public function getSalesType($dateFrom, $dateTo, $salesType = 1, $salesDelivery = false, $storeId1c = null): array
     {
         $query = Sales::find()
             ->select([
@@ -210,9 +211,9 @@ class SalesService
         $query->andWhere(['pay_arr' => $salesType]);
 
         if ($salesDelivery) {
-            $query->andWhere(['not in','order_id',['','0']]);
+            $query->andWhere(['not in', 'order_id', ['', '0']]);
         } else {
-            $query->andWhere(['order_id'=>['','0']]);
+            $query->andWhere(['order_id' => ['', '0']]);
         }
 
         if (!empty($storeId1c)) {
@@ -234,7 +235,7 @@ class SalesService
      * @return array
      * @throws \Exception
      */
-    public function getSalesByAdmin($adminGuid, $dateFrom, $dateTo, $isAdministrator, bool $salesDelivery = false, $storeId1c = null) : array
+    public function getSalesByAdmin($adminGuid, $dateFrom, $dateTo, $isAdministrator, bool $salesDelivery = false, $storeId1c = null): array
     {
         $adminsGuids = $this->adminsGuids;
 
@@ -277,14 +278,14 @@ class SalesService
         }
 
         $query->andWhere(['>=', 'date', DateHelper::getDateTimeStartDay($dateFrom, $dateTimeStartDay, $adminId)])
-        ->andWhere(['<=', 'date', $dateTimeEndDayPrepared])
-        ->andWhere(['seller_id' => $adminGuid]);
+            ->andWhere(['<=', 'date', $dateTimeEndDayPrepared])
+            ->andWhere(['seller_id' => $adminGuid]);
 
 
         if ($salesDelivery) {
-            $query->andWhere(['not in','order_id',['','0']]);
+            $query->andWhere(['not in', 'order_id', ['', '0']]);
         } else {
-            $query->andWhere(['order_id'=>['','0']]);
+            $query->andWhere(['order_id' => ['', '0']]);
         }
 
         if (!empty($storeId1c)) {
@@ -308,7 +309,7 @@ class SalesService
      * @return array
      * @throws \Exception
      */
-    public function getSalesByStore($storeId1c, $dateFrom, $dateTo, $isAdministrator, bool $salesDelivery = false) : array
+    public function getSalesByStore($storeId1c, $dateFrom, $dateTo, $isAdministrator, bool $salesDelivery = false): array
     {
         $adminId = null;
 
@@ -346,13 +347,13 @@ class SalesService
         }
 
         $query->andWhere(['>=', 'date', DateHelper::getDateTimeStartDay($dateFrom, $dateTimeStartDay, $adminId)])
-        ->andWhere(['<=', 'date', $dateTimeEndDayPrepared]);
+            ->andWhere(['<=', 'date', $dateTimeEndDayPrepared]);
 
 
         if ($salesDelivery) {
-            $query->andWhere(['not in','order_id',['','0']]);
+            $query->andWhere(['not in', 'order_id', ['', '0']]);
         } else {
-            $query->andWhere(['order_id'=>['','0']]);
+            $query->andWhere(['order_id' => ['', '0']]);
         }
 
         $query->andWhere(['store_id_1c' => $storeId1c]);
@@ -370,7 +371,7 @@ class SalesService
      * @return array
      * @throws \Exception
      */
-    public function getSalesCountSum(string $dateFrom, string $dateTo, $operation = Sales::OPERATION_SALE, $payType = null) : array
+    public function getSalesCountSum(string $dateFrom, string $dateTo, $operation = Sales::OPERATION_SALE, $payType = null): array
     {
         $connection = Yii::$app->getDb();
 
@@ -385,7 +386,6 @@ class SalesService
             ";
 
 
-
         $queryRow = "
             SELECT 
                 count(*) as cnt,
@@ -411,7 +411,7 @@ class SalesService
 
         if (!empty($payType)) {
 
-            if ($payType ==  '1') {
+            if ($payType == '1') {
                 $payType = "'1', '3', '1,3', '3,1' ";
             }
             $payArrCondition = "
@@ -440,7 +440,7 @@ class SalesService
             [
                 ':date_from' => DateHelper::getDateTimeStartDay($dateFrom, true),
                 ':date_to' => DateHelper::getDateTimeEndDay($dateTo, true),
-                ':operation' =>  $operation,
+                ':operation' => $operation,
             ]
         );
 
@@ -454,13 +454,13 @@ class SalesService
      * @return array
      * @throws \Exception
      */
-    public function getSalesCountCheck(string $dateFrom, string $dateTo, $storeId1c, $payType = null, string $operation = Sales::OPERATION_SALE) : array
+    public function getSalesCountCheck(string $dateFrom, string $dateTo, $storeId1c, $payType = null, string $operation = Sales::OPERATION_SALE): array
     {
         $payArrCondition = "";
 
         if (!empty($payType)) {
 
-            if ($payType ==  '1') {
+            if ($payType == '1') {
                 $payType = "'1', '3', '1,3', '3,1' ";
             }
             $payArrCondition = "
@@ -501,9 +501,9 @@ class SalesService
             ",
             [
                 ':date_from' => DateHelper::getDateTimeStartDay($dateFrom, true),
-                ':date_to' => DateHelper::getDateTimeEndDay($dateTo,true),
-                ':operation' =>  $operation,
-                ':store_id_1c' =>  $storeId1c,
+                ':date_to' => DateHelper::getDateTimeEndDay($dateTo, true),
+                ':operation' => $operation,
+                ':store_id_1c' => $storeId1c,
             ]
         );
 
@@ -513,14 +513,13 @@ class SalesService
     }
 
 
-
     /**
      * @param string $dateFrom
      * @param string $dateTo
      * @return array
      * @throws \Exception
      */
-    public function getSalesCount(string $dateFrom, string $dateTo, $storeId) : array
+    public function getSalesCount(string $dateFrom, string $dateTo, $storeId): array
     {
         $salesCountDaySale = $this->getSalesCountByDay($dateFrom, $dateTo, $storeId, true);
         $salesCountDayReturn = $this->getSalesCountByDay($dateFrom, $dateTo, $storeId, true, Sales::OPERATION_RETURN);
@@ -537,7 +536,7 @@ class SalesService
         ];
     }
 
-    public function calculateCount($salesCount, $salesCountDayReturn = []) : array
+    public function calculateCount($salesCount, $salesCountDayReturn = []): array
     {
         $resultSaleCount = [];
 
@@ -563,7 +562,7 @@ class SalesService
         return $resultSaleCount;
     }
 
-    public function getSalesCalculate($dateFrom, $dateTo, $payType = null) : array
+    public function getSalesCalculate($dateFrom, $dateTo, $payType = null): array
     {
         $salesCalculateByType = [];
 
@@ -580,7 +579,7 @@ class SalesService
         return $salesCalculateByType;
     }
 
-    public function salesCalculate($salesCount, $salesCountDayReturn) : array
+    public function salesCalculate($salesCount, $salesCountDayReturn): array
     {
         $salesCountByDate = [];
 
@@ -643,7 +642,7 @@ class SalesService
         ];
     }
 
-    public function getSalesCountByDay(string $dateFrom,string $dateTo, $storeId, bool $shiftTypeDay, string $operation = Sales::OPERATION_SALE) : array
+    public function getSalesCountByDay(string $dateFrom, string $dateTo, $storeId, bool $shiftTypeDay, string $operation = Sales::OPERATION_SALE): array
     {
         $connection = Yii::$app->getDb();
         if ($shiftTypeDay) {
@@ -710,15 +709,15 @@ class SalesService
             [
                 ':date_from' => DateHelper::getDateTimeStartDay($dateFrom),
                 ':date_to' => DateHelper::getDateTimeEndDay($dateTo),
-                ':operation' =>  $operation,
-                ':store_id' =>  $storeId,
+                ':operation' => $operation,
+                ':store_id' => $storeId,
             ]
         );
 
         return $command->queryAll();
     }
 
-    public function getSalesCountByDayHour(string $dateFrom,string $dateTo, $storeId, bool $shiftTypeDay) : array
+    public function getSalesCountByDayHour(string $dateFrom, string $dateTo, $storeId, bool $shiftTypeDay): array
     {
         $operation = Sales::OPERATION_SALE;
 
@@ -788,8 +787,8 @@ class SalesService
             [
                 ':date_from' => DateHelper::getDateTimeStartDay($dateFrom),
                 ':date_to' => DateHelper::getDateTimeEndDay($dateTo),
-                ':operation' =>  $operation,
-                ':store_id' =>  $storeId,
+                ':operation' => $operation,
+                ':store_id' => $storeId,
             ]
         );
 
@@ -807,15 +806,15 @@ class SalesService
         $sales_store_summ = [];
         $sales_store_summ_all = [];
 
-        foreach ($salesCount as $row)  {
+        foreach ($salesCount as $row) {
             $rowDateT = ArrayHelper::getValue($row, 'date_t');
             $rowStoreId = ArrayHelper::getValue($row, 'store_id');
             $rowCnt = ArrayHelper::getValue($row, 'cnt');
             $rowSumm = ArrayHelper::getValue($row, 'summ');
 
-            if(!empty($rowDateT)) {
-                $sales_store[$rowDateT][$rowStoreId]=$rowCnt;
-                $sales_store_summ[$rowDateT][$rowStoreId] = $rowCnt > 0 ? round($rowSumm/$rowCnt) : 0;
+            if (!empty($rowDateT)) {
+                $sales_store[$rowDateT][$rowStoreId] = $rowCnt;
+                $sales_store_summ[$rowDateT][$rowStoreId] = $rowCnt > 0 ? round($rowSumm / $rowCnt) : 0;
                 if (!empty(ArrayHelper::getValue($sales_store_summ_all, $rowDateT))) {
                     $sales_store_summ_all[$rowDateT] = $sales_store_summ_all[$rowDateT] + $rowSumm;
                 } else {
@@ -837,22 +836,22 @@ class SalesService
      * @return array
      * @throws \Exception
      */
-    public function salesSumCalculate(array $salesSum, $byDate = false) : array
+    public function salesSumCalculate(array $salesSum, $byDate = false): array
     {
         $sales_summ = [];
 
-        foreach ($salesSum as $row)  {
+        foreach ($salesSum as $row) {
             $rowOperation = ArrayHelper::getValue($row, 'operation');
             $rowStoreId1c = ArrayHelper::getValue($row, 'store_id_1c');
             $rowSummValue = ArrayHelper::getValue($row, 'summ');
 
             $modifier = 0;
 
-            if($rowOperation == Sales::OPERATION_SALE) {
+            if ($rowOperation == Sales::OPERATION_SALE) {
                 $modifier = 1;
             }
 
-            if($rowOperation == Sales::OPERATION_RETURN) {
+            if ($rowOperation == Sales::OPERATION_RETURN) {
                 $modifier = -1;
             }
 
@@ -886,7 +885,7 @@ class SalesService
      * @return array
      * @throws \yii\db\Exception
      */
-    public function getSalesProducts(string $check_id) : array
+    public function getSalesProducts(string $check_id): array
     {
         $connection = Yii::$app->getDb();
 
@@ -926,7 +925,7 @@ class SalesService
      * @return array
      * @throws \yii\db\Exception
      */
-    public function getAdminSalesProducts(string $adminGuid, string $dateFrom, string $dateTo, string $salesOperation = Sales::OPERATION_SALE) : array
+    public function getAdminSalesProducts(string $adminGuid, string $dateFrom, string $dateTo, string $salesOperation = Sales::OPERATION_SALE): array
     {
 
         $connection = Yii::$app->getDb();
@@ -952,7 +951,7 @@ class SalesService
                 sales.seller_id
             
             ",
-            [   ':admin_guid' => $adminGuid,
+            [':admin_guid' => $adminGuid,
                 ':sales_operation' => $salesOperation,
                 ':date_from' => DateHelper::getDateTimeStartDay($dateFrom),
                 ':date_to' => DateHelper::getDateTimeEndDay($dateTo),
@@ -1020,7 +1019,7 @@ class SalesService
     }
 
 
-     /**
+    /**
      * @return array
      */
     public function getAllowedByDate($dateFrom, $dateTo, $configStartStopDate): array
@@ -1102,7 +1101,7 @@ class SalesService
      * @return array
      * @throws \yii\db\Exception
      */
-    public function getMatrixSalesProducts(string $adminGuid, string $dateFrom, string $dateTo, $isAdministrator, $adminGuids = null) : array
+    public function getMatrixSalesProducts(string $adminGuid, string $dateFrom, string $dateTo, $isAdministrator, $adminGuids = null): array
     {
         $adminsGuids = $this->adminsGuids;
 
@@ -1178,6 +1177,53 @@ class SalesService
                     ':date_to' => DateHelper::getDateTimeEndDay($dateTo, $dateTimeEndDay, $adminId),
                 ]
             );
+        } else if ($dateFrom > '2025-01-01') {
+            $command = $connection->createCommand("
+                SELECT
+                    DISTINCT (sales.id),
+                    sales.seller_id,
+                    sales.date,
+                    sales.number,
+                    (p.summ) AS summ,
+                    p.product_id  AS product_guid,
+                    sales.summ AS sales_summ,
+                    sales.skidka,
+                    0 as bonus,
+                    order_id,
+                    sales.operation  
+                FROM  
+                    sales_products as p,
+                    sales 
+                WHERE 
+                    sales.seller_id IN ('$adminGuid')
+                AND 
+                    sales.id = p.check_id
+                AND
+                    p.product_id IN (
+                        SELECT 
+                            products_1c.id 
+                        FROM 
+                            products_1c 
+                        RIGHT JOIN products_class 
+                            ON 
+                                products_1c.parent_id = products_class.category_id 
+                            AND 
+                                products_class.tip = 'matrix' 
+                        WHERE 
+                            1 = 1
+                    )
+                AND
+                    sales.date >= :date_from
+                AND
+                    sales.date <= :date_to
+                ORDER BY
+                    sales.date ASC 
+            
+            ",
+                [
+                    ':date_from' => DateHelper::getDateTimeStartDay($dateFrom, $dateTimeStartDay, $adminId),
+                    ':date_to' => DateHelper::getDateTimeEndDay($dateTo, $dateTimeEndDay, $adminId),
+                ]);
         } else {
             $command = $connection->createCommand("
                     SELECT
@@ -1255,7 +1301,7 @@ class SalesService
                         sales.date <= :date_to
             
             ",
-                [   ':admin_guid' => $adminGuid,
+                [':admin_guid' => $adminGuid,
                     ':date_from' => DateHelper::getDateTimeStartDay($dateFrom, $dateTimeStartDay, $adminId),
                     ':date_to' => DateHelper::getDateTimeEndDay($dateTo, $dateTimeEndDay, $adminId),
                 ]
@@ -1275,7 +1321,7 @@ class SalesService
      * @return array
      * @throws \yii\db\Exception
      */
-    public function getMatrixSalesShiftByDays(string $adminGuid, string $entityCityStoreEmployeeSelect, string $dateFrom, string $dateTo, $isAdministrator) : array
+    public function getMatrixSalesShiftByDays(string $adminGuid, string $entityCityStoreEmployeeSelect, string $dateFrom, string $dateTo, $isAdministrator): array
     {
         $result = [];
 
@@ -1352,13 +1398,13 @@ class SalesService
                     sales.date <= :date_to
             
             ",
-                [   ':store_id_1c' => $entityCityStoreEmployeeSelect,
+                [':store_id_1c' => $entityCityStoreEmployeeSelect,
                     ':date_from' => DateHelper::getDateTimeStartDay($dateFrom, $dateTimeStartDay, $adminId),
                     ':date_to' => DateHelper::getDateTimeEndDay($dateTo, $dateTimeEndDay, $adminId),
                 ]
             );
 
-            $result =  $command->queryAll();
+            $result = $command->queryAll();
         }
 
         return $result;
@@ -1377,7 +1423,7 @@ class SalesService
      * @return array
      * @throws \yii\db\Exception
      */
-    public function getMatrixMakeProducts(string $adminGuid, string $dateFrom, string $dateTo,bool $isAdministrator, $adminGuids = null) : array
+    public function getMatrixMakeProducts(string $adminGuid, string $dateFrom, string $dateTo, bool $isAdministrator, $adminGuids = null): array
     {
         $adminsGuids = $this->adminsGuids;
 
@@ -1453,6 +1499,52 @@ class SalesService
                     ':date_to' => DateHelper::getDateTimeEndDay($dateTo, $dateTimeEndDay, $adminId),
                 ]
             );
+        } else if ($dateFrom > '2025-01-01') {
+            $command = $connection->createCommand("
+                SELECT
+                    DISTINCT (sales.id),
+                    p.seller_id,
+                    sales.date,
+                    sales.number,
+                    (p.summ) AS summ,
+                    p.product_id  AS product_guid,
+                    sales.summ AS sales_summ,
+                    sales.skidka,
+                    0 as bonus,
+                    order_id,
+                    sales.operation  
+                FROM  
+                    sales_products as p,
+                    sales 
+                WHERE 
+                    p.seller_id IN ('$adminGuid')
+                AND 
+                    sales.id = p.check_id
+                AND
+                    p.product_id IN (
+                        SELECT 
+                            products_1c.id 
+                        FROM 
+                            products_1c 
+                        RIGHT JOIN products_class 
+                            ON 
+                                products_1c.parent_id = products_class.category_id 
+                            AND 
+                                products_class.tip = 'matrix' 
+                        WHERE 
+                            1 = 1
+                    )
+                AND
+                    sales.date >= :date_from
+                AND
+                    sales.date <= :date_to                
+                ORDER BY
+                    sales.date ASC 
+            ", [
+                    ':date_from' => DateHelper::getDateTimeStartDay($dateFrom, $dateTimeStartDay, $adminId),
+                    ':date_to' => DateHelper::getDateTimeEndDay($dateTo, $dateTimeEndDay, $adminId),
+                ]
+            );
         } else {
             $command = $connection->createCommand("
                 SELECT
@@ -1550,14 +1642,14 @@ class SalesService
      * @return array
      * @throws \Exception
      */
-    public function getSalesItems(string $dateFrom, string $dateTo, array $productsArrayServices) : array
+    public function getSalesItems(string $dateFrom, string $dateTo, array $productsArrayServices): array
     {
-        $where_serv="";
-        $i=0;
+        $where_serv = "";
+        $i = 0;
 
-        foreach($productsArrayServices["services"] as $k => $pid) {
-            if ($i > 0) $where_serv .=" or ";
-            $where_serv .=" sales_items.id_1c='$pid'";
+        foreach ($productsArrayServices["services"] as $k => $pid) {
+            if ($i > 0) $where_serv .= " or ";
+            $where_serv .= " sales_items.id_1c='$pid'";
             $i++;
         }
 
@@ -1603,7 +1695,7 @@ class SalesService
      * @return array
      * @throws \Exception
      */
-    public function getSalesServices(string $dateFrom, string $dateTo) : array
+    public function getSalesServices(string $dateFrom, string $dateTo): array
     {
         $connection = Yii::$app->getDb();
 
@@ -1657,8 +1749,8 @@ class SalesService
         $countByDate = [];
         $salesByAdmin = 0;
 
-        foreach($salesArray as $row) {
-            $rowDate = date("Y-m-d",strtotime($row['date']));
+        foreach ($salesArray as $row) {
+            $rowDate = date("Y-m-d", strtotime($row['date']));
 
             if (!empty($timeTable)) {
                 if (!in_array($rowDate, $timeTable)) {
@@ -1672,13 +1764,13 @@ class SalesService
             if (!array_key_exists($rowDate, $countByDate)) {
                 $countByDate[$rowDate] = 0;
             }
-            if($row["operation"] == Sales::OPERATION_SALE) {
+            if ($row["operation"] == Sales::OPERATION_SALE) {
                 $sales[$rowDate] += $row["summ"];
                 $countByDate[$rowDate] += 1;
                 $salesByAdmin += $row["summ"];
             }
 
-            if($row["operation"] == Sales::OPERATION_RETURN) {
+            if ($row["operation"] == Sales::OPERATION_RETURN) {
                 $sales[$rowDate] -= $row["summ"];
                 $countByDate[$rowDate] -= 1;
                 $salesByAdmin -= $row["summ"];
@@ -1696,7 +1788,7 @@ class SalesService
     {
         $sales = [];
 
-        foreach($salesArray as $row) {
+        foreach ($salesArray as $row) {
             $rowDate = $row['date'];
             if ($numDayCalculate) {
                 $rowDate = $this->getRowDate($row['date']);
@@ -1706,11 +1798,11 @@ class SalesService
                 $sales[$rowDate] = 0;
             }
 
-            if($row["operation"] == Sales::OPERATION_SALE) {
+            if ($row["operation"] == Sales::OPERATION_SALE) {
                 $sales[$rowDate] += $row["summ"];
             }
 
-            if($row["operation"] == Sales::OPERATION_RETURN) {
+            if ($row["operation"] == Sales::OPERATION_RETURN) {
                 $sales[$rowDate] -= $row["summ"];
             }
         }
@@ -1729,7 +1821,7 @@ class SalesService
             $date = $dateToPrepared->format('Y-m-d 23:58:58');
         }
 
-        return date("Y-m-d",strtotime($date));
+        return date("Y-m-d", strtotime($date));
     }
 
 }