Refactor transactions store

This commit is contained in:
2022-02-28 13:03:53 +00:00
parent 27372199f7
commit 024c5e0a1c
2 changed files with 23 additions and 16 deletions

View File

@ -53,12 +53,15 @@ export const useBudgetsStore = defineStore('budget', {
const response = await result.json();
this.MergeBudgetingData(response);
},
MergeBudgetingData(response : any) {
MergeBudgetingData(response: any) {
const accounts = useAccountStore();
for (const account of response.Accounts || []) {
useAccountStore().Accounts.set(account.ID, account);
const existingAccount = accounts.Accounts.get(account.ID);
account.Transactions = existingAccount?.Transactions ?? [];
accounts.Accounts.set(account.ID, account);
}
for (const category of response.Categories || []) {
useAccountStore().Categories.set(category.ID, category);
accounts.Categories.set(category.ID, category);
}
},
}