Вывод плана по суткам

This commit is contained in:
Brusnitsyn
2026-07-06 14:23:15 +00:00
parent 040c83c4d1
commit d1e087e4a8
3 changed files with 8 additions and 20 deletions

View File

@@ -32,11 +32,8 @@ class PlanCalculator extends BaseMetricService implements MetricCalculatorInterf
$startCurrentMonth = $endDate->copy()->startOfMonth()->setHours(9);
$currentMonth = $endDate->month;
// Кол-во календарных месяцев, затронутых выбранным диапазоном (для нормы за период)
$monthsInRange = max(
1,
($endDate->year * 12 + $endDate->month) - ($startDate->year * 12 + $startDate->month) + 1
);
// Кол-во дней в выбранном диапазоне (для нормы за период — пропорционально дням, а не месяцам)
$daysInRange = max(1, $startDate->diffInDays($endDate));
// Получаем фактические выписки с начала года по прошлый месяц
$previousOutcomeMonth = DB::table('report_duties as r')
@@ -74,6 +71,9 @@ class PlanCalculator extends BaseMetricService implements MetricCalculatorInterf
// План на 1 месяц (равномерно)
$oneMonthPlan = $annualPlan > 0 ? ceil($annualPlan / 12) : 0;
// План на 1 день (равномерно, от годового плана)
$dailyPlan = $annualPlan > 0 ? $annualPlan / 365 : 0;
// ===== БЕЗОПАСНОЕ ПОЛУЧЕНИЕ ЗНАЧЕНИЙ =====
// Факт за прошлые месяцы (без текущего)
$actualToLastMonth = (int) ($previousOutcomeMonth[$departmentId]->total ?? 0);
@@ -105,7 +105,7 @@ class PlanCalculator extends BaseMetricService implements MetricCalculatorInterf
$results[$departmentId] = [
'year_plan' => $annualPlan,
'month_plan' => $oneMonthPlan,
'period_plan' => $oneMonthPlan * $monthsInRange, // норма за выбранный период (мес. × кол-во месяцев)
'period_plan' => (int) round($dailyPlan * $daysInRange), // норма за выбранный период (дневной план × кол-во дней)
'total_debt' => $totalDebt,
'current_mouth_dept' => $currentMonthPlanOnly,
'cumulative_plan' => $cumulativePlan,

View File

@@ -2,8 +2,6 @@
import {NFlex, NSpace, NTag, NTooltip} from 'naive-ui'
import {percentType} from "../../../Utils/numbers.js";
import {computed} from "vue";
import {format, toDate} from "date-fns";
import {ru} from "date-fns/locale";
const props = defineProps({
isTotalRow: {
@@ -26,18 +24,9 @@ const props = defineProps({
total_debt: 0,
year_plan: 0,
})
},
endDate: {
type: [Number, String],
default: null
}
})
const formatedMonth = computed(() => {
const date = toDate(props.endDate)
return date.toLocaleString('ru', { month: 'long' })
})
const typePlan = computed(() => {
if (props.plan.debt_from_year > 20) return 'error'
if (props.plan.debt_from_year > 10) return 'warning'
@@ -89,7 +78,7 @@ const periodPercent = computed(() => {
</template>
<NSpace vertical>
<NFlex align="center" justify="start" :wrap="false" size="small">
<NTag type="info">План на {{formatedMonth}}: {{ plan.month_plan }} / {{ plan.current_mouth_dept }}</NTag>
<NTag type="info">План / Выбывшие: {{ plan.period_plan }} / {{ value }}</NTag>
</NFlex>
<NTag :type="typePlan">Долг с начала года: {{ plan.debt_from_year }}</NTag>
<!-- Долг с начала года: {{ plan.debt_from_year }}-->

View File

@@ -183,8 +183,7 @@ const columns = ref([
{
isTotalRow: row.isTotalRow,
value: row.outcome,
plan: row.plan,
endDate: props.date[1]
plan: row.plan
}
)
}