From: Alexander Smirnov Date: Thu, 22 Aug 2024 10:59:19 +0000 (+0300) Subject: [ERP-105] Добавлена формула расчёта Минимальный порог Чистой прибыли, руб., убран... X-Git-Tag: 1.4~20^2~1 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=87967eb73fc5a84393aa2824dc0a0bb1853651ee;p=erp24_rep%2Fyii-erp24%2F.git [ERP-105] Добавлена формула расчёта Минимальный порог Чистой прибыли, руб., убран Расчет премии --- diff --git a/erp24/actions/motivation/IndexAction.php b/erp24/actions/motivation/IndexAction.php index f46eb678..a74a1e67 100644 --- a/erp24/actions/motivation/IndexAction.php +++ b/erp24/actions/motivation/IndexAction.php @@ -161,7 +161,7 @@ class IndexAction extends Action } } - MotivationService::calculateFactFormula($motivationDataTableSort); + MotivationService::calculateFactFormula($motivationDataTableSort, $model->year, $model->month); // Формируем заголовок для 5-й недели if ($model->month == 2) { // Февраль diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index ee89be77..17886549 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -1009,7 +1009,10 @@ class MotivationService return $weeks; } - public static function calculateFactFormula(&$motivationDataTableSort) { + public static function calculateFactFormula(&$motivationDataTableSort, $year, $month) { + // Определяем последний день месяца + $lastDayOfMonth = date('t', strtotime("$year-$month-01")); + $indMap = []; foreach ($motivationDataTableSort as $ind => $row) { if (!key_exists('name', $row)) { @@ -1134,19 +1137,44 @@ class MotivationService $motivationDataTableSort[$indMap["Чистая прибыль"]][$column] / $c5; } - if ($ind > 0) { - $c62 = $motivationDataTableSort[$indMap["Чистая прибыль"]][$column]; - $b64 = $motivationDataTableSort[$indMap["Минимальный порог Чистой прибыли, руб."]][$ind == 6 ? "plan" : $column]; - - $j66 = 0; - if ($c62 >= $b64) { - $formula = $c62 - $c5 * $motivationDataTableSort[$indMap["Пороговый коэффициент"]]["plan"]; - if ($formula > 0) { - $j66 = $formula; - } + if ($ind == 0) { + $b62 = $motivationDataTableSort[$indMap["Чистая прибыль"]]["plan"]; + if ($b62 > 0) { + $b64 = $b62 * 0.9; + } else { + $b64 = $b62 * 1.1; } - $motivationDataTableSort[$indMap["Расчет премии"]][$column] = $j66 + 0; + $motivationDataTableSort[$indMap["Минимальный порог Чистой прибыли, руб."]]["plan"] = $b64; } + if ($ind >= 1 && $ind <= 4) { + $motivationDataTableSort[$indMap["Минимальный порог Чистой прибыли, руб."]][$column] = + $motivationDataTableSort[$indMap["Минимальный порог Чистой прибыли, руб."]]["plan"] / $lastDayOfMonth * 7; + } + if ($ind == 5) { + $motivationDataTableSort[$indMap["Минимальный порог Чистой прибыли, руб."]][$column] = + $motivationDataTableSort[$indMap["Минимальный порог Чистой прибыли, руб."]]["plan"] / $lastDayOfMonth * ($lastDayOfMonth - 4 * 7); + } + if ($ind == 7) { + $sum = 0; + foreach (range(1, 5) as $index) { + $sum += $motivationDataTableSort[$indMap["Минимальный порог Чистой прибыли, руб."]]['week' . $index]; + } + $motivationDataTableSort[$indMap["Минимальный порог Чистой прибыли, руб."]][$column] = $sum; + } + +// if ($ind > 0) { +// $c62 = $motivationDataTableSort[$indMap["Чистая прибыль"]][$column]; +// $b64 = $motivationDataTableSort[$indMap["Минимальный порог Чистой прибыли, руб."]][$ind == 6 ? "plan" : $column]; +// +// $j66 = 0; +// if ($c62 >= $b64) { +// $formula = $c62 - $c5 * $motivationDataTableSort[$indMap["Пороговый коэффициент"]]["plan"]; +// if ($formula > 0) { +// $j66 = $formula; +// } +// } +// $motivationDataTableSort[$indMap["Расчет премии"]][$column] = $j66 + 0; +// } } // Отклонение