diff --git a/internal/common/service/common.hppv2.service.go b/internal/common/service/common.hppv2.service.go index b171109b..d132cb14 100644 --- a/internal/common/service/common.hppv2.service.go +++ b/internal/common/service/common.hppv2.service.go @@ -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 {