From d4a6bf5d7eabbb89576f113cf3bdd43100ef835f Mon Sep 17 00:00:00 2001 From: Alex Phillips Date: Tue, 28 Dec 2021 16:10:40 -0500 Subject: [PATCH] cleanup --- backend/src/controllers/AccountsController.ts | 1 - backend/src/entities/CategoryMonth.ts | 8 +++----- backend/src/repositories/BudgetMonths.ts | 5 +---- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/backend/src/controllers/AccountsController.ts b/backend/src/controllers/AccountsController.ts index 0b8529b..f5a8bd2 100644 --- a/backend/src/controllers/AccountsController.ts +++ b/backend/src/controllers/AccountsController.ts @@ -166,7 +166,6 @@ export class AccountsController extends Controller { } const clearedTransactions = await getRepository(Transaction).find({ accountId: account.id, status: TransactionStatus.Cleared }) - console.log(clearedTransactions) for (const transaction of clearedTransactions) { transaction.status = TransactionStatus.Reconciled await getRepository(Transaction).update(transaction.id, transaction.getUpdatePayload()) diff --git a/backend/src/entities/CategoryMonth.ts b/backend/src/entities/CategoryMonth.ts index 4f1754c..7e2abf1 100644 --- a/backend/src/entities/CategoryMonth.ts +++ b/backend/src/entities/CategoryMonth.ts @@ -24,8 +24,6 @@ export type CategoryMonthOriginalValues = { export class CategoryMonthCache { static cache: { [key: string]: CategoryMonthOriginalValues } = {} - static transfers: string[] = [] - public static get(id: string): CategoryMonthOriginalValues | null { if (CategoryMonthCache.cache[id]) { return CategoryMonthCache.cache[id] @@ -114,9 +112,9 @@ export class CategoryMonth { categoryId: this.categoryId, budgetMonthId: this.budgetMonthId, month: this.month, - budgeted: this.budgeted, - activity: this.activity, - balance: this.balance, + budgeted: {...this.budgeted}, + activity: {...this.activity}, + balance: {...this.balance}, } } diff --git a/backend/src/repositories/BudgetMonths.ts b/backend/src/repositories/BudgetMonths.ts index 5dfdbff..90eef96 100644 --- a/backend/src/repositories/BudgetMonths.ts +++ b/backend/src/repositories/BudgetMonths.ts @@ -12,7 +12,6 @@ export class BudgetMonths extends Repository { const months = await budget.getMonths() let newBudgetMonth - let counter = 1 let direction = 1 let monthFrom = new Date() monthFrom.setDate(1) @@ -20,20 +19,18 @@ export class BudgetMonths extends Repository { if (month < months[0]) { monthFrom = new Date(`${months[0]}T12:00:00`) direction = -1 - counter = -1 } else if (month > months[months.length - 1]) { monthFrom = new Date(`${months[months.length - 1]}T12:00:00`) } // iterate over all months until we hit the first budget month do { - monthFrom.setMonth(monthFrom.getMonth() + counter) + monthFrom.setMonth(monthFrom.getMonth() + direction) newBudgetMonth = this.create({ budgetId, month: formatMonthFromDateString(monthFrom), }) await this.insert(newBudgetMonth) - newBudgetMonth.budget = Promise.resolve(budget) } while (newBudgetMonth.month !== month) return newBudgetMonth