diff --git a/docker/Dockerfile b/docker/Dockerfile index 4c930c3..86408a2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,17 +1,16 @@ FROM alpine as godeps -RUN apk add go +RUN apk --no-cache add go RUN go install github.com/kyleconroy/sqlc/cmd/sqlc@latest RUN go install github.com/go-task/task/v3/cmd/task@latest RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest FROM alpine -RUN apk add go -RUN apk add nodejs yarn bash curl git git-perl tmux +RUN apk --no-cache add go nodejs yarn bash curl git git-perl tmux ADD docker/build.sh / RUN yarn global add @vue/cli ENV PATH="/root/.yarn/bin/:${PATH}" WORKDIR /src -ADD web/package.json /src/web/ +ADD web/package.json web/yarn.lock /src/web/ RUN yarn COPY --from=godeps /root/go/bin/task /root/go/bin/sqlc /root/go/bin/golangci-lint /usr/local/bin/ CMD /build.sh diff --git a/server/budgeting.go b/server/budgeting.go index 0645b2b..cccbbb5 100644 --- a/server/budgeting.go +++ b/server/budgeting.go @@ -30,6 +30,16 @@ type CategoryWithBalance struct { Assigned postgres.Numeric } +func NewCategoryWithBalance(category *postgres.GetCategoriesRow) CategoryWithBalance { + return CategoryWithBalance{ + GetCategoriesRow: category, + Available: postgres.NewZeroNumeric(), + AvailableLastMonth: postgres.NewZeroNumeric(), + Activity: postgres.NewZeroNumeric(), + Assigned: postgres.NewZeroNumeric(), + } +} + func getDate(c *gin.Context) (time.Time, error) { var year, month int yearString := c.Param("year") @@ -153,30 +163,13 @@ func (h *Handler) calculateBalances(budget postgres.Budget, firstOfNextMonth time.Time, firstOfMonth time.Time, categories []postgres.GetCategoriesRow, cumultativeBalances []postgres.GetCumultativeBalancesRow) ([]CategoryWithBalance, postgres.Numeric) { categoriesWithBalance := []CategoryWithBalance{} - hiddenCategory := CategoryWithBalance{ - GetCategoriesRow: &postgres.GetCategoriesRow{ - Name: "", - Group: "Hidden Categories", - }, - Available: postgres.NewZeroNumeric(), - AvailableLastMonth: postgres.NewZeroNumeric(), - Activity: postgres.NewZeroNumeric(), - Assigned: postgres.NewZeroNumeric(), - } moneyUsed := postgres.NewZeroNumeric() for i := range categories { cat := &categories[i] // do not show hidden categories categoryWithBalance := h.CalculateCategoryBalances(cat, cumultativeBalances, - firstOfNextMonth, &moneyUsed, firstOfMonth, hiddenCategory, budget) - if cat.Group == "Hidden Categories" { - hiddenCategory.Available = hiddenCategory.Available.Add(categoryWithBalance.Available) - hiddenCategory.AvailableLastMonth = hiddenCategory.AvailableLastMonth.Add(categoryWithBalance.AvailableLastMonth) - hiddenCategory.Activity = hiddenCategory.Activity.Add(categoryWithBalance.Activity) - hiddenCategory.Assigned = hiddenCategory.Assigned.Add(categoryWithBalance.Assigned) - continue - } + firstOfNextMonth, &moneyUsed, firstOfMonth, budget) if cat.ID == budget.IncomeCategoryID { continue @@ -185,22 +178,13 @@ func (h *Handler) calculateBalances(budget postgres.Budget, categoriesWithBalance = append(categoriesWithBalance, categoryWithBalance) } - categoriesWithBalance = append(categoriesWithBalance, hiddenCategory) - return categoriesWithBalance, moneyUsed } func (*Handler) CalculateCategoryBalances(cat *postgres.GetCategoriesRow, cumultativeBalances []postgres.GetCumultativeBalancesRow, firstOfNextMonth time.Time, - moneyUsed *postgres.Numeric, firstOfMonth time.Time, hiddenCategory CategoryWithBalance, - budget postgres.Budget) CategoryWithBalance { - categoryWithBalance := CategoryWithBalance{ - GetCategoriesRow: cat, - Available: postgres.NewZeroNumeric(), - AvailableLastMonth: postgres.NewZeroNumeric(), - Activity: postgres.NewZeroNumeric(), - Assigned: postgres.NewZeroNumeric(), - } + moneyUsed *postgres.Numeric, firstOfMonth time.Time, budget postgres.Budget) CategoryWithBalance { + categoryWithBalance := NewCategoryWithBalance(cat) for _, bal := range cumultativeBalances { if bal.CategoryID != cat.ID { continue diff --git a/web/src/dialogs/NewBudget.vue b/web/src/dialogs/NewBudget.vue index c6eecb6..75e095e 100644 --- a/web/src/dialogs/NewBudget.vue +++ b/web/src/dialogs/NewBudget.vue @@ -19,17 +19,45 @@ function newBudget() {
+
-Group | Category | @@ -70,23 +77,25 @@ onMounted(() => { | Activity | Available | |||
---|---|---|---|---|---|---|---|
{{ category.Group }} | -{{ category.Name }} | -- | - |
- |
-
- |
-
- |
-
- |
-
{{ category.Name }} | ++ | + |
+ |
+
+ |
+
+ |
+
+ |
+
This removes transactions and assignments to start from scratch. Accounts and categories are kept. Not undoable!
- -This deletes the whole bugdet including all transactions, assignments, accounts and categories. Not undoable!
+ +This restores YNABs functionality, that would substract any overspent categories' balances from next months inflows.
+ +