Skip to content

Commit

Permalink
refactor: Fix various bugs in YNAB API update
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Nov 8, 2023
1 parent 339465d commit a257132
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions automations/approve.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Automation } from "../automation"
import { Account, API, BudgetDetail, TransactionDetail, TransactionDetailClearedEnum } from "ynab"
import { Account, API, BudgetDetail, TransactionClearedStatus, TransactionDetail, TransactionFlagColor } from "ynab"


export class ApproverAutomation extends Automation {
Expand All @@ -25,7 +25,7 @@ export class ApproverAutomation extends Automation {

private shouldApproveTransaction(transaction: TransactionDetail, options: { [key: string]: string }): boolean {
return !transaction.approved &&
(options.cleared === "yes" ? transaction.cleared !== TransactionDetailClearedEnum.Uncleared : true) &&
(options.cleared === "yes" ? transaction.cleared !== TransactionClearedStatus.Uncleared : true) &&
(options.imported === "yes" ? transaction.import_id !== null : true)
}
}
6 changes: 3 additions & 3 deletions automations/replicate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Automation} from "../automation"
import {Account, API, BudgetDetail, TransactionDetail, TransactionDetailClearedEnum, TransactionDetailFlagColorEnum} from "ynab"
import {Account, API, BudgetDetail, TransactionClearedStatus, TransactionDetail, TransactionFlagColor } from "ynab"

export class ReplicateAutomation extends Automation {
public get kind() {
Expand Down Expand Up @@ -38,7 +38,7 @@ export class ReplicateAutomation extends Automation {
approved: true,
date: t.date,
import_id: t.import_id,
flag_color: (options["to_flag"] ? options["to_flag"] : t.flag_color) as TransactionDetailFlagColorEnum,
flag_color: (options["to_flag"] ? options["to_flag"] : t.flag_color) as TransactionFlagColor,
payee_name: t.payee_name,
memo: t.memo,
cleared: t.cleared,
Expand Down Expand Up @@ -87,7 +87,7 @@ export class ReplicateAutomation extends Automation {
return false
}

if (options["cleared"] === "yes" && transaction.cleared === TransactionDetailClearedEnum.Uncleared) {
if (options["cleared"] === "yes" && transaction.cleared === TransactionClearedStatus.Uncleared) {
return false
}

Expand Down
4 changes: 2 additions & 2 deletions automations/stocks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Automation } from "../automation"
import { getCurrencyData, getStockData } from "../utils/tiingo"

import { Account, API, BudgetDetail, SaveTransaction, SaveTransactionClearedEnum } from "ynab"
import { Account, API, BudgetDetail, SaveTransaction, TransactionClearedStatus } from "ynab"

export class StockAutomation extends Automation {
private stockChecker = new StockChecker()
Expand All @@ -27,7 +27,7 @@ export class StockAutomation extends Automation {
date: new Date().toISOString().split('T')[0],
amount: shift,
payee_name: options.payee_name || "Stock Market",
cleared: SaveTransactionClearedEnum.Cleared,
cleared: TransactionClearedStatus.Cleared,
approved: true,
memo: values.map(v => `${v.symbol}: ${v.nativeCurrency} ${v.nativeValue.toFixed(2)} @ ${v.nativeCurrency} ${v.nativePrice}`).join(', ')
}
Expand Down

0 comments on commit a257132

Please sign in to comment.