From 240838b60b0d44fe63debf33237f8645fa5fe0c1 Mon Sep 17 00:00:00 2001 From: lilbit-prun <225798227+lilbit-prun@users.noreply.github.com> Date: Tue, 19 May 2026 04:31:47 +0000 Subject: [PATCH] Fix storage filling calculations If a base produces 100t and consumes 50t with 1500t of storage, then you can deliver 15 days worth of input mats and 15 days later the base will be full of output mats. So to me that means that filled should be 15 days, not 10 days. --- .../planning/components/tools/PlanVisitationFrequency.vue | 4 ++-- src/features/planning/usePlanCalculation.ts | 4 ++-- src/tests/features/planning/usePlanCalculation.test.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/features/planning/components/tools/PlanVisitationFrequency.vue b/src/features/planning/components/tools/PlanVisitationFrequency.vue index d9c21c07..644233aa 100644 --- a/src/features/planning/components/tools/PlanVisitationFrequency.vue +++ b/src/features/planning/components/tools/PlanVisitationFrequency.vue @@ -90,8 +90,8 @@ (sum, e) => sum + (e.delta > 0 ? e.totalVolume : 0), 0 ); - const dailyWeightTotal: number = dailyWeightImport + dailyWeightExport; - const dailyVolumeTotal: number = dailyVolumeImport + dailyVolumeExport; + const dailyWeightTotal: number = Math.max(dailyWeightImport, dailyWeightExport); + const dailyVolumeTotal: number = Math.max(dailyVolumeImport, dailyVolumeExport); return { storageFilled: Math.max( diff --git a/src/features/planning/usePlanCalculation.ts b/src/features/planning/usePlanCalculation.ts index 601dd0ad..f47117ce 100644 --- a/src/features/planning/usePlanCalculation.ts +++ b/src/features/planning/usePlanCalculation.ts @@ -919,8 +919,8 @@ export async function usePlanCalculation( (sum, e) => sum + (e.delta > 0 ? e.totalVolume : 0), 0 ); - const dailyWeightTotal: number = dailyWeightImport + dailyWeightExport; - const dailyVolumeTotal: number = dailyVolumeImport + dailyVolumeExport; + const dailyWeightTotal: number = Math.max(dailyWeightImport, dailyWeightExport); + const dailyVolumeTotal: number = Math.max(dailyVolumeImport, dailyVolumeExport); return { storageFilled: Math.max( diff --git a/src/tests/features/planning/usePlanCalculation.test.ts b/src/tests/features/planning/usePlanCalculation.test.ts index b44beac3..c07b6c94 100644 --- a/src/tests/features/planning/usePlanCalculation.test.ts +++ b/src/tests/features/planning/usePlanCalculation.test.ts @@ -141,7 +141,7 @@ describe("usePlanCalculation", async () => { const result = await calculate(); - expect(visitationData.value.storageFilled).toBe(22.342256698594255); + expect(visitationData.value.storageFilled).toBe(26.462529131522697); }); it("validate existing and saveable", async () => {