Implement integration-test based on YNAB-Export #46

Merged
jacob1123 merged 24 commits from integration-test into master 2022-04-06 21:26:47 +02:00
Showing only changes of commit cf39db52fb - Show all commits

View File

@ -81,15 +81,7 @@ func (h *Handler) prepareBudgeting(ctx context.Context, budget postgres.Budget,
categoriesWithBalance, moneyUsed := h.calculateBalances(
budget, firstOfNextMonth, firstOfMonth, categories, cumultativeBalances)
availableBalance := h.getAvailableBalance(budget, moneyUsed, cumultativeBalances, firstOfNextMonth)
for i := range categoriesWithBalance {
cat := &categoriesWithBalance[i]
if cat.ID != budget.IncomeCategoryID {
continue
}
cat.Available = availableBalance
}
availableBalance := h.getAvailableBalance(budget, moneyUsed, cumultativeBalances, categoriesWithBalance, firstOfNextMonth)
data := BudgetingForMonthResponse{categoriesWithBalance, availableBalance}
return data, nil
@ -102,7 +94,7 @@ type BudgetingForMonthResponse struct {
func (*Handler) getAvailableBalance(budget postgres.Budget,
moneyUsed numeric.Numeric, cumultativeBalances []postgres.GetCumultativeBalancesRow,
firstOfNextMonth time.Time,
categoriesWithBalance []CategoryWithBalance, firstOfNextMonth time.Time,
) numeric.Numeric {
availableBalance := moneyUsed
@ -118,6 +110,15 @@ func (*Handler) getAvailableBalance(budget postgres.Budget,
availableBalance.AddI(bal.Transactions)
availableBalance.AddI(bal.Assignments)
}
for i := range categoriesWithBalance {
cat := &categoriesWithBalance[i]
if cat.ID != budget.IncomeCategoryID {
continue
}
cat.Available = availableBalance
}
return availableBalance
}