Fix test without available property
This commit is contained in:
@@ -13,17 +13,17 @@ import (
|
||||
|
||||
type CategoryWithBalance struct {
|
||||
*postgres.GetCategoriesRow
|
||||
Available numeric.Numeric
|
||||
Activity numeric.Numeric
|
||||
Assigned numeric.Numeric
|
||||
AvailableLastMonth numeric.Numeric
|
||||
Activity numeric.Numeric
|
||||
Assigned numeric.Numeric
|
||||
}
|
||||
|
||||
func NewCategoryWithBalance(category *postgres.GetCategoriesRow) CategoryWithBalance {
|
||||
return CategoryWithBalance{
|
||||
GetCategoriesRow: category,
|
||||
Available: numeric.Zero(),
|
||||
Activity: numeric.Zero(),
|
||||
Assigned: numeric.Zero(),
|
||||
GetCategoriesRow: category,
|
||||
AvailableLastMonth: numeric.Zero(),
|
||||
Activity: numeric.Zero(),
|
||||
Assigned: numeric.Zero(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,16 +157,17 @@ func (h *Handler) calculateBalances(budget postgres.Budget, month Month,
|
||||
}
|
||||
|
||||
moneyUsed.SubI(bal.Assignments)
|
||||
categoryWithBalance.Available.AddI(bal.Assignments)
|
||||
categoryWithBalance.Available.AddI(bal.Transactions)
|
||||
if !categoryWithBalance.Available.IsPositive() && month.InPast(bal.Date) {
|
||||
moneyUsed.AddI(categoryWithBalance.Available)
|
||||
categoryWithBalance.Available = numeric.Zero()
|
||||
}
|
||||
|
||||
if month.InPresent(bal.Date) {
|
||||
categoryWithBalance.Activity = bal.Transactions
|
||||
categoryWithBalance.Assigned = bal.Assignments
|
||||
continue
|
||||
}
|
||||
|
||||
categoryWithBalance.AvailableLastMonth.AddI(bal.Assignments)
|
||||
categoryWithBalance.AvailableLastMonth.AddI(bal.Transactions)
|
||||
if !categoryWithBalance.AvailableLastMonth.IsPositive() {
|
||||
moneyUsed.AddI(categoryWithBalance.AvailableLastMonth)
|
||||
categoryWithBalance.AvailableLastMonth = numeric.Zero()
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user