Fix calls to isAfter and so on

This commit is contained in:
Jan Bader 2022-04-06 21:44:43 +00:00
parent 54e591bc5e
commit 35690681cf

View File

@ -88,7 +88,7 @@ func (*Handler) getAvailableBalance(budget postgres.Budget, month Month,
continue
}
if !month.nextMonth().isAfter(bal.Date) {
if !month.InPast(bal.Date) {
continue
}
@ -152,19 +152,19 @@ func (h *Handler) calculateBalances(budget postgres.Budget, month Month,
}
// skip everything in the future
if month.nextMonth().isAfter(bal.Date) {
if month.InFuture(bal.Date) {
continue
}
moneyUsed.SubI(bal.Assignments)
categoryWithBalance.Available.AddI(bal.Assignments)
categoryWithBalance.Available.AddI(bal.Transactions)
if !categoryWithBalance.Available.IsPositive() && month.isAfter(bal.Date) {
if !categoryWithBalance.Available.IsPositive() && month.InPast(bal.Date) {
moneyUsed.AddI(categoryWithBalance.Available)
categoryWithBalance.Available = numeric.Zero()
}
if month.contains(bal.Date) {
if month.InPresent(bal.Date) {
categoryWithBalance.Activity = bal.Transactions
categoryWithBalance.Assigned = bal.Assignments
}