fix calculate schedule day

This commit is contained in:
giovanni
2026-06-04 14:11:55 +07:00
parent b4f7c15d03
commit 675c0ade61
@@ -1487,17 +1487,22 @@ func (s *hppV2Service) buildManualCutoverDepreciationPart(
return nil, nil
}
reportScheduleDay := DepreciationScheduleDay(*originDate, periodDate, contextRow.HouseType)
if reportScheduleDay <= 0 {
return nil, nil
}
// Hitung schedule day relatif terhadap cutover_date, bukan dari chick_in_date.
// Ini menangani kasus cut-over flock yang belum 175 hari pada period date,
// karena bisnis sudah menetapkan cutover_date sebagai awal depresiasi.
// Rumus setara secara matematis dengan DepreciationScheduleDay ketika flock >= 175 hari.
cutoverScheduleDay := DepreciationScheduleDay(*originDate, manualInput.CutoverDate, contextRow.HouseType)
startDay := 1
if cutoverScheduleDay > 0 {
startDay = cutoverScheduleDay
}
daysSinceCutover := int(dateOnly(periodDate).Sub(dateOnly(manualInput.CutoverDate)).Hours() / 24)
reportScheduleDay := startDay + daysSinceCutover
if reportScheduleDay <= 0 {
return nil, nil
}
houseType := NormalizeDepreciationHouseType(contextRow.HouseType)
multiplicationByHouseType, effectiveDates, err := s.hppRepo.GetMultiplicationPercentages(context.Background(), []string{houseType}, reportScheduleDay, contextRow.ProjectFlockID)
if err != nil {