feat: manual pullet cost

This commit is contained in:
Adnan Zahir
2026-04-19 15:10:53 +07:00
parent a2ae139fae
commit 69d6fc165a
13 changed files with 857 additions and 33 deletions
@@ -49,7 +49,23 @@ func CalculateDepreciationAtDayN(
houseType string,
percentByHouseType map[string]map[int]float64,
) (float64, float64, float64) {
if initialPulletCost <= 0 || dayN <= 0 {
return CalculateDepreciationFromDayRange(initialPulletCost, 1, dayN, houseType, percentByHouseType)
}
func CalculateDepreciationFromDayRange(
initialPulletCost float64,
startDay int,
endDay int,
houseType string,
percentByHouseType map[string]map[int]float64,
) (float64, float64, float64) {
if initialPulletCost <= 0 || endDay <= 0 {
return 0, 0, 0
}
if startDay <= 0 {
startDay = 1
}
if endDay < startDay {
return 0, 0, 0
}
@@ -63,10 +79,10 @@ func CalculateDepreciationAtDayN(
pulletCostDayN := 0.0
depreciationValue := 0.0
depreciationPercent := 0.0
for day := 1; day <= dayN; day++ {
for day := startDay; day <= endDay; day++ {
pct := housePercent[day]
dep := current * (pct / 100)
if day == dayN {
if day == endDay {
pulletCostDayN = current
depreciationValue = dep
depreciationPercent = pct