Refactor transactions store
This commit is contained in:
@ -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);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user