Вывод плана по суткам
This commit is contained in:
@@ -32,11 +32,8 @@ class PlanCalculator extends BaseMetricService implements MetricCalculatorInterf
|
|||||||
$startCurrentMonth = $endDate->copy()->startOfMonth()->setHours(9);
|
$startCurrentMonth = $endDate->copy()->startOfMonth()->setHours(9);
|
||||||
$currentMonth = $endDate->month;
|
$currentMonth = $endDate->month;
|
||||||
|
|
||||||
// Кол-во календарных месяцев, затронутых выбранным диапазоном (для нормы за период)
|
// Кол-во дней в выбранном диапазоне (для нормы за период — пропорционально дням, а не месяцам)
|
||||||
$monthsInRange = max(
|
$daysInRange = max(1, $startDate->diffInDays($endDate));
|
||||||
1,
|
|
||||||
($endDate->year * 12 + $endDate->month) - ($startDate->year * 12 + $startDate->month) + 1
|
|
||||||
);
|
|
||||||
|
|
||||||
// Получаем фактические выписки с начала года по прошлый месяц
|
// Получаем фактические выписки с начала года по прошлый месяц
|
||||||
$previousOutcomeMonth = DB::table('report_duties as r')
|
$previousOutcomeMonth = DB::table('report_duties as r')
|
||||||
@@ -74,6 +71,9 @@ class PlanCalculator extends BaseMetricService implements MetricCalculatorInterf
|
|||||||
// План на 1 месяц (равномерно)
|
// План на 1 месяц (равномерно)
|
||||||
$oneMonthPlan = $annualPlan > 0 ? ceil($annualPlan / 12) : 0;
|
$oneMonthPlan = $annualPlan > 0 ? ceil($annualPlan / 12) : 0;
|
||||||
|
|
||||||
|
// План на 1 день (равномерно, от годового плана)
|
||||||
|
$dailyPlan = $annualPlan > 0 ? $annualPlan / 365 : 0;
|
||||||
|
|
||||||
// ===== БЕЗОПАСНОЕ ПОЛУЧЕНИЕ ЗНАЧЕНИЙ =====
|
// ===== БЕЗОПАСНОЕ ПОЛУЧЕНИЕ ЗНАЧЕНИЙ =====
|
||||||
// Факт за прошлые месяцы (без текущего)
|
// Факт за прошлые месяцы (без текущего)
|
||||||
$actualToLastMonth = (int) ($previousOutcomeMonth[$departmentId]->total ?? 0);
|
$actualToLastMonth = (int) ($previousOutcomeMonth[$departmentId]->total ?? 0);
|
||||||
@@ -105,7 +105,7 @@ class PlanCalculator extends BaseMetricService implements MetricCalculatorInterf
|
|||||||
$results[$departmentId] = [
|
$results[$departmentId] = [
|
||||||
'year_plan' => $annualPlan,
|
'year_plan' => $annualPlan,
|
||||||
'month_plan' => $oneMonthPlan,
|
'month_plan' => $oneMonthPlan,
|
||||||
'period_plan' => $oneMonthPlan * $monthsInRange, // норма за выбранный период (мес. × кол-во месяцев)
|
'period_plan' => (int) round($dailyPlan * $daysInRange), // норма за выбранный период (дневной план × кол-во дней)
|
||||||
'total_debt' => $totalDebt,
|
'total_debt' => $totalDebt,
|
||||||
'current_mouth_dept' => $currentMonthPlanOnly,
|
'current_mouth_dept' => $currentMonthPlanOnly,
|
||||||
'cumulative_plan' => $cumulativePlan,
|
'cumulative_plan' => $cumulativePlan,
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
import {NFlex, NSpace, NTag, NTooltip} from 'naive-ui'
|
import {NFlex, NSpace, NTag, NTooltip} from 'naive-ui'
|
||||||
import {percentType} from "../../../Utils/numbers.js";
|
import {percentType} from "../../../Utils/numbers.js";
|
||||||
import {computed} from "vue";
|
import {computed} from "vue";
|
||||||
import {format, toDate} from "date-fns";
|
|
||||||
import {ru} from "date-fns/locale";
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
isTotalRow: {
|
isTotalRow: {
|
||||||
@@ -26,18 +24,9 @@ const props = defineProps({
|
|||||||
total_debt: 0,
|
total_debt: 0,
|
||||||
year_plan: 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(() => {
|
const typePlan = computed(() => {
|
||||||
if (props.plan.debt_from_year > 20) return 'error'
|
if (props.plan.debt_from_year > 20) return 'error'
|
||||||
if (props.plan.debt_from_year > 10) return 'warning'
|
if (props.plan.debt_from_year > 10) return 'warning'
|
||||||
@@ -89,7 +78,7 @@ const periodPercent = computed(() => {
|
|||||||
</template>
|
</template>
|
||||||
<NSpace vertical>
|
<NSpace vertical>
|
||||||
<NFlex align="center" justify="start" :wrap="false" size="small">
|
<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>
|
</NFlex>
|
||||||
<NTag :type="typePlan">Долг с начала года: {{ plan.debt_from_year }}</NTag>
|
<NTag :type="typePlan">Долг с начала года: {{ plan.debt_from_year }}</NTag>
|
||||||
<!-- Долг с начала года: {{ plan.debt_from_year }}-->
|
<!-- Долг с начала года: {{ plan.debt_from_year }}-->
|
||||||
|
|||||||
@@ -183,8 +183,7 @@ const columns = ref([
|
|||||||
{
|
{
|
||||||
isTotalRow: row.isTotalRow,
|
isTotalRow: row.isTotalRow,
|
||||||
value: row.outcome,
|
value: row.outcome,
|
||||||
plan: row.plan,
|
plan: row.plan
|
||||||
endDate: props.date[1]
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user