fix hitung ayam dan karung data yang ditampilkan melebihi estimasi panen
CI / lint-and-test (push) Canceled after 0s

This commit is contained in:
Alberto-Audrix committed 2026-07-29 10:48:03 +07:00
1 parent 32a36cceff
commit b6117ae7d5
8 files changed
+105 -49

No files matched your search

+4 -2
View File
@@ -95,8 +95,10 @@ class Cycle {
const diffMs = today - startDate;
const daysDiff = Math.floor(diffMs / (1000 * 60 * 60 * 24));
// Use calculated day, but don't exceed totalDays
calculatedCurrentDay = Math.min(daysDiff, cycle.total_days);
// 0-based day index: day 0 = startDate, last day = startDate + (totalDays - 1)
// Cap at totalDays - 1 so currentDay never maps past Estimasi Panen / end_date
const lastDayIndex = Math.max(0, cycle.total_days - 1);
calculatedCurrentDay = Math.min(daysDiff, lastDayIndex);
}
return {