Remove income category from result
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
cef62574bb
commit
01c407d4f1
@ -25,6 +25,13 @@ func FromInt64WithExp(value int64, exp int32) Numeric {
|
||||
return Numeric{Numeric: pgtype.Numeric{Int: big.NewInt(value), Exp: exp, Status: pgtype.Present}}
|
||||
}
|
||||
|
||||
func (n *Numeric) SetZero() {
|
||||
n.Exp = 0
|
||||
n.Int = big.NewInt(0)
|
||||
n.Status = pgtype.Present
|
||||
n.NaN = false
|
||||
}
|
||||
|
||||
func (n Numeric) GetFloat64() float64 {
|
||||
if n.Status != pgtype.Present {
|
||||
return 0
|
||||
|
@ -79,7 +79,7 @@ func (h *Handler) prepareBudgeting(ctx context.Context, budget postgres.Budget,
|
||||
return BudgetingForMonthResponse{}, fmt.Errorf("error loading balances: %w", err)
|
||||
}
|
||||
|
||||
categoriesWithBalance, moneyUsed := h.calculateBalances(firstOfNextMonth, firstOfMonth, categories, cumultativeBalances)
|
||||
categoriesWithBalance, moneyUsed := h.calculateBalances(budget, firstOfNextMonth, firstOfMonth, categories, cumultativeBalances)
|
||||
availableBalance := h.getAvailableBalance(budget, moneyUsed, cumultativeBalances, categoriesWithBalance, firstOfNextMonth)
|
||||
|
||||
data := BudgetingForMonthResponse{categoriesWithBalance, availableBalance}
|
||||
@ -107,17 +107,9 @@ func (*Handler) getAvailableBalance(budget postgres.Budget,
|
||||
}
|
||||
|
||||
availableBalance.AddI(bal.Transactions)
|
||||
availableBalance.AddI(bal.Assignments)
|
||||
availableBalance.AddI(bal.Assignments) // should be zero, but who knows
|
||||
}
|
||||
|
||||
for i := range categoriesWithBalance {
|
||||
cat := &categoriesWithBalance[i]
|
||||
if cat.ID != budget.IncomeCategoryID {
|
||||
continue
|
||||
}
|
||||
|
||||
cat.Available = availableBalance
|
||||
}
|
||||
return availableBalance
|
||||
}
|
||||
|
||||
@ -155,7 +147,7 @@ func (h *Handler) getBudget(c *gin.Context, budgetUUID uuid.UUID) {
|
||||
c.JSON(http.StatusOK, data)
|
||||
}
|
||||
|
||||
func (h *Handler) calculateBalances(firstOfNextMonth time.Time, firstOfMonth time.Time,
|
||||
func (h *Handler) calculateBalances(budget postgres.Budget, firstOfNextMonth time.Time, firstOfMonth time.Time,
|
||||
categories []postgres.GetCategoriesRow, cumultativeBalances []postgres.GetCumultativeBalancesRow,
|
||||
) ([]CategoryWithBalance, numeric.Numeric) {
|
||||
categoriesWithBalance := []CategoryWithBalance{}
|
||||
@ -163,6 +155,10 @@ func (h *Handler) calculateBalances(firstOfNextMonth time.Time, firstOfMonth tim
|
||||
moneyUsed := numeric.Zero()
|
||||
for i := range categories {
|
||||
cat := &categories[i]
|
||||
if cat.ID == budget.IncomeCategoryID {
|
||||
continue
|
||||
}
|
||||
|
||||
categoryWithBalance := NewCategoryWithBalance(cat)
|
||||
for _, bal := range cumultativeBalances {
|
||||
if bal.CategoryID != cat.ID {
|
||||
|
@ -113,7 +113,7 @@ export const useAccountStore = defineStore("budget/account", {
|
||||
const categoryGroups = [];
|
||||
let prev = undefined;
|
||||
for (const category of categories) {
|
||||
if (category.ID == this.GetIncomeCategoryID) continue;
|
||||
//if (category.ID == this.GetIncomeCategoryID) continue;
|
||||
|
||||
if (prev == undefined || category.Group != prev.Name) {
|
||||
prev = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user