From 010af185a67f46487d5e4e1ea4c8a2da75951ab3 Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Thu, 5 Sep 2024 11:45:05 +0300 Subject: [PATCH] =?utf8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF?= =?utf8?q?=D0=BE=20=D1=80=D0=B5=D0=B2=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/MotivationService.php | 29 +++++++++++++++++++++------- erp24/views/store/polnogramma.php | 1 + 2 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 erp24/views/store/polnogramma.php diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index 947d8c35..e09985f7 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -1772,22 +1772,23 @@ class MotivationService $storeId = (int)$storeId; + $startDate = date('Y-m-d', strtotime($startDate)); + $endDate = date('Y-m-d 23:59:59', strtotime($endDate)); + $salesRecords = Sales::find() ->select(['id', 'date']) - ->where(['store_id' => $storeId, 'operation' => 'Продажа']) + ->where(['store_id' => $storeId, 'operation' => Sales::OPERATION_SALE]) ->andWhere(['>=', 'date', $startDate]) ->andWhere(['<=', 'date', $endDate]) ->asArray() ->all(); - $startDate = date('Y-m-d', strtotime($startDate)); - $endDate = date('Y-m-d', strtotime($endDate)); - $endDatePlusThreeWeeks = date('Y-m-d', strtotime($endDate . ' +3 weeks')); + $endDatePlusThreeWeeks = date('Y-m-d 23:59:59', strtotime($endDate . ' +3 weeks')); $returnedSales = Sales::find() ->select(['sales_check']) - ->where(['store_id' => $storeId, 'operation' => 'Возврат']) + ->where(['store_id' => $storeId, 'operation' => Sales::OPERATION_RETURN]) ->andWhere(['>=', 'date', $startDate]) ->andWhere(['<=', 'date', $endDatePlusThreeWeeks]) // $endDate + 3 недели ->andWhere(['is not', 'sales_check', null]) // Проверяем, что поле sales_check не пустое @@ -1838,11 +1839,25 @@ class MotivationService $quantity = (float)$product['quantity']; $checkDate = date('Y-m-d', strtotime($saleDates[$product['check_id']])); - if (isset($selfCostsMap[$productId][$checkDate])) { - $totalSum += $selfCostsMap[$productId][$checkDate] * $quantity; + // Логирование отсутствующих данных о себестоимости + if (!isset($selfCostsMap[$productId][$checkDate])) { + + Yii::info("Не найдена себестоимость для продукта $productId на дату $checkDate", __METHOD__); + + + InfoLogService::setInfoLog(__FILE__, __LINE__, 'SelfCostProduct', "error_id_100: Продукт $productId на дату $checkDate не имеет себестоимости"); + + + $price = 0.0; + } else { + $price = $selfCostsMap[$productId][$checkDate]; } + + + $totalSum += $price * $quantity; } + return $totalSum; } diff --git a/erp24/views/store/polnogramma.php b/erp24/views/store/polnogramma.php new file mode 100644 index 00000000..b3d9bbc7 --- /dev/null +++ b/erp24/views/store/polnogramma.php @@ -0,0 +1 @@ +