From cfd2388de03bd461bbd52845206fe2d9cf85c6ab Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Tue, 22 Feb 2022 16:50:59 +0000 Subject: [PATCH 1/8] Disable cache for apk calls and add yarn.lock --- docker/Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 From e5cf439231a75c5712732f03f51f1611c347e9af Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Tue, 22 Feb 2022 18:57:15 +0000 Subject: [PATCH 2/8] Update BudgetSettings to tailwindcss --- web/src/pages/Settings.vue | 99 +++++++++++++------------------------- 1 file changed, 34 insertions(+), 65 deletions(-) diff --git a/web/src/pages/Settings.vue b/web/src/pages/Settings.vue index 2acb8cd..d8467a0 100644 --- a/web/src/pages/Settings.vue +++ b/web/src/pages/Settings.vue @@ -4,6 +4,7 @@ import { useRouter } from "vue-router"; import { DELETE, POST } from "../api"; import { useBudgetsStore } from "../stores/budget"; import { useSessionStore } from "../stores/session"; +import Card from "../components/Card.vue"; const transactionsFile = ref(undefined); const assignmentsFile = ref(undefined); @@ -54,72 +55,40 @@ function ynabImport() { \ No newline at end of file From 1d81aa2fb360bb6eeab01ccbb359362858bca56a Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Tue, 22 Feb 2022 18:57:31 +0000 Subject: [PATCH 3/8] Do not try to set categories, if none are available --- web/src/stores/budget-account.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/src/stores/budget-account.ts b/web/src/stores/budget-account.ts index d0903fe..b5bf7df 100644 --- a/web/src/stores/budget-account.ts +++ b/web/src/stores/budget-account.ts @@ -102,6 +102,8 @@ export const useAccountStore = defineStore("budget/account", { async FetchMonthBudget(budgetid: string, year: number, month: number) { const result = await GET("/budget/" + budgetid + "/" + year + "/" + month); const response = await result.json(); + if(response.Categories == undefined || response.Categories.length <= 0) + return; this.addCategoriesForMonth(year, month, response.Categories); }, addCategoriesForMonth(year: number, month: number, categories: Category[]): void { From c3175b9be64aa41e5aac8774ca87279dcebaaebd Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Tue, 22 Feb 2022 19:14:17 +0000 Subject: [PATCH 4/8] Update NewBudget to use modal again --- web/src/dialogs/NewBudget.vue | 50 +++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/web/src/dialogs/NewBudget.vue b/web/src/dialogs/NewBudget.vue index c6eecb6..fca1ade 100644 --- a/web/src/dialogs/NewBudget.vue +++ b/web/src/dialogs/NewBudget.vue @@ -19,17 +19,45 @@ function newBudget() {

+

-
-
-
- New Budget -
-
- -
-
- - +
+
+
+
+ + + +
+

New Budget

+
+ + +
+
+ + +
From fffc91269edccf82edc2f8de5f5c43973cc28354 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Wed, 23 Feb 2022 13:34:25 +0000 Subject: [PATCH 5/8] Extract NewCategoryWithBalance --- server/budgeting.go | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/server/budgeting.go b/server/budgeting.go index 0645b2b..df43ca7 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,16 +163,10 @@ 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(), - } + hiddenCategory := NewCategoryWithBalance(&postgres.GetCategoriesRow{ + Name: "", + Group: "Hidden Categories", + }) moneyUsed := postgres.NewZeroNumeric() for i := range categories { @@ -194,13 +198,7 @@ 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(), - } + categoryWithBalance := NewCategoryWithBalance(cat) for _, bal := range cumultativeBalances { if bal.CategoryID != cat.ID { continue From 674bef667ba90ff1f4b4f87361cb981eff7e13a7 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Wed, 23 Feb 2022 13:34:34 +0000 Subject: [PATCH 6/8] Hide checkmark icon --- web/src/dialogs/NewBudget.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/src/dialogs/NewBudget.vue b/web/src/dialogs/NewBudget.vue index fca1ade..75e095e 100644 --- a/web/src/dialogs/NewBudget.vue +++ b/web/src/dialogs/NewBudget.vue @@ -22,7 +22,7 @@ function newBudget() {
-
+

New Budget

Date: Wed, 23 Feb 2022 13:42:33 +0000 Subject: [PATCH 7/8] Move logic for hidden categories to client --- server/budgeting.go | 18 ++---------------- web/src/pages/Budgeting.vue | 26 +++++++++++++++++++++++++- web/src/stores/budget-account.ts | 8 +++++++- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/server/budgeting.go b/server/budgeting.go index df43ca7..cccbbb5 100644 --- a/server/budgeting.go +++ b/server/budgeting.go @@ -163,24 +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 := NewCategoryWithBalance(&postgres.GetCategoriesRow{ - Name: "", - Group: "Hidden Categories", - }) 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 @@ -189,15 +178,12 @@ 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 { + moneyUsed *postgres.Numeric, firstOfMonth time.Time, budget postgres.Budget) CategoryWithBalance { categoryWithBalance := NewCategoryWithBalance(cat) for _, bal := range cumultativeBalances { if bal.CategoryID != cat.ID { diff --git a/web/src/pages/Budgeting.vue b/web/src/pages/Budgeting.vue index cd3d7cd..684d51b 100644 --- a/web/src/pages/Budgeting.vue +++ b/web/src/pages/Budgeting.vue @@ -14,10 +14,16 @@ const props = defineProps<{ const budgetsStore = useBudgetsStore(); const CurrentBudgetID = computed(() => budgetsStore.CurrentBudgetID); -const categoriesForMonth = useAccountStore().CategoriesForMonth; +const accountStore = useAccountStore(); +const categoriesForMonth = accountStore.CategoriesForMonth; const Categories = computed(() => { return [...categoriesForMonth(selected.value.Year, selected.value.Month)]; }); +const hiddenCategoriesForMonth = accountStore.HiddenCategoriesForMonth; +const HiddenCategories = computed(() => { + return [...hiddenCategoriesForMonth(selected.value.Year, selected.value.Month)]; +}); + const previous = computed(() => ({ Year: new Date(selected.value.Year, selected.value.Month - 1, 1).getFullYear(), @@ -88,5 +94,23 @@ onMounted(() => { + + {{ category.Group }} + {{ category.Name }} + + + + + + + + + + + + + + + diff --git a/web/src/stores/budget-account.ts b/web/src/stores/budget-account.ts index b5bf7df..a265cda 100644 --- a/web/src/stores/budget-account.ts +++ b/web/src/stores/budget-account.ts @@ -58,7 +58,13 @@ export const useAccountStore = defineStore("budget/account", { const yearMap = state.Months.get(year); const monthMap = yearMap?.get(month); console.log("MTH", monthMap) - return [...monthMap?.values() || []]; + return [...monthMap?.values() || []].filter(x => x.Group != "Hidden Categories"); + }, + HiddenCategoriesForMonth: (state) => (year: number, month: number) => { + const yearMap = state.Months.get(year); + const monthMap = yearMap?.get(month); + console.log("MTH", monthMap) + return [...monthMap?.values() || []].filter(x => x.Group == "Hidden Categories"); }, CurrentAccount(state): Account | undefined { if (state.CurrentAccountID == null) From 510c91205d05e4108a22ab6494bbd4203cf726e1 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Wed, 23 Feb 2022 14:10:54 +0000 Subject: [PATCH 8/8] Rewrite categories to be nested below groups --- web/src/pages/Budgeting.vue | 73 +++++++++++++------------------- web/src/stores/budget-account.ts | 28 ++++++++---- 2 files changed, 49 insertions(+), 52 deletions(-) diff --git a/web/src/pages/Budgeting.vue b/web/src/pages/Budgeting.vue index 684d51b..bf00f8c 100644 --- a/web/src/pages/Budgeting.vue +++ b/web/src/pages/Budgeting.vue @@ -15,13 +15,15 @@ const budgetsStore = useBudgetsStore(); const CurrentBudgetID = computed(() => budgetsStore.CurrentBudgetID); const accountStore = useAccountStore(); -const categoriesForMonth = accountStore.CategoriesForMonth; -const Categories = computed(() => { - return [...categoriesForMonth(selected.value.Year, selected.value.Month)]; -}); -const hiddenCategoriesForMonth = accountStore.HiddenCategoriesForMonth; -const HiddenCategories = computed(() => { - return [...hiddenCategoriesForMonth(selected.value.Year, selected.value.Month)]; +const categoriesForMonth = accountStore.CategoriesForMonthAndGroup; + +function GetCategories(group : string) { + return [...categoriesForMonth(selected.value.Year, selected.value.Month, group)]; +}; + +const groupsForMonth = accountStore.CategoryGroupsForMonth; +const GroupsForMonth = computed(() => { + return [...groupsForMonth(selected.value.Year, selected.value.Month)]; }); @@ -67,7 +69,6 @@ onMounted(() => {
- @@ -76,41 +77,25 @@ onMounted(() => { - - - - - - - - - - - - - - - - - - - - + +

{{ group }}

+ + + + + + + + + +
Group Category Activity Available
{{ category.Group }}{{ category.Name }} - - - - - - - -
{{ category.Group }}{{ category.Name }} - - - - - - - -
{{ category.Name }} + + + + + + + +
diff --git a/web/src/stores/budget-account.ts b/web/src/stores/budget-account.ts index a265cda..be57f7d 100644 --- a/web/src/stores/budget-account.ts +++ b/web/src/stores/budget-account.ts @@ -54,17 +54,29 @@ export const useAccountStore = defineStore("budget/account", { AccountsList(state) { return [...state.Accounts.values()]; }, - CategoriesForMonth: (state) => (year: number, month: number) => { + AllCategoriesForMonth: (state) => (year: number, month: number) => { const yearMap = state.Months.get(year); const monthMap = yearMap?.get(month); - console.log("MTH", monthMap) - return [...monthMap?.values() || []].filter(x => x.Group != "Hidden Categories"); + return [...monthMap?.values() || []]; }, - HiddenCategoriesForMonth: (state) => (year: number, month: number) => { - const yearMap = state.Months.get(year); - const monthMap = yearMap?.get(month); - console.log("MTH", monthMap) - return [...monthMap?.values() || []].filter(x => x.Group == "Hidden Categories"); + CategoryGroupsForMonth(state) { + return (year: number, month: number) => { + const categories = this.AllCategoriesForMonth(year, month); + const categoryGroups = []; + let prev = undefined; + for (const category of categories) { + if(category.Group != prev) + categoryGroups.push(category.Group); + prev = category.Group; + } + return categoryGroups; + } + }, + CategoriesForMonthAndGroup(state) { + return (year: number, month: number, group : string) => { + const categories = this.AllCategoriesForMonth(year, month); + return categories.filter(x => x.Group == group); + } }, CurrentAccount(state): Account | undefined { if (state.CurrentAccountID == null)