mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 07:45:44 +00:00
feat: manual pullet cost
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user