🐛 Do not upload transactions that are not booked
All checks were successful
Deploy application / deploy (push) Successful in 8s
All checks were successful
Deploy application / deploy (push) Successful in 8s
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import * as Transactions from "@sb1/transactions.ts"
|
||||
import * as Oauth from "@sb1/oauth.ts"
|
||||
import {
|
||||
BANK_INITIAL_REFRESH_TOKEN,
|
||||
BANK_OAUTH_CLIENT_ID,
|
||||
@ -5,22 +7,21 @@ import {
|
||||
DB_DIRECTORY,
|
||||
DB_FILENAME,
|
||||
} from "@/config.ts"
|
||||
import logger from "@common/logger.ts"
|
||||
import dayjs from "dayjs"
|
||||
import type { Database } from "better-sqlite3"
|
||||
import {
|
||||
clearTokens,
|
||||
createDb,
|
||||
fetchToken,
|
||||
insertTokens,
|
||||
} from "@sb1impl/db/queries.ts"
|
||||
import * as Oauth from "@sb1/oauth.ts"
|
||||
import * as Transactions from "@sb1/transactions.ts"
|
||||
import { bankTransactionIntoActualTransaction } from "./mappings.ts"
|
||||
import type { OAuthTokenResponse } from "@sb1/types.ts"
|
||||
import { createDirIfMissing } from "@/fs.ts"
|
||||
import logger from "@common/logger.ts"
|
||||
import dayjs from "dayjs"
|
||||
|
||||
import type { ActualTransaction, Bank, Interval } from "@common/types.ts"
|
||||
import type { TokenResponse } from "@sb1impl/db/types.ts"
|
||||
import { createDirIfMissing } from "@/fs.ts"
|
||||
import type { OAuthTokenResponse } from "@sb1/types.ts"
|
||||
import type { Database } from "better-sqlite3"
|
||||
|
||||
export class Sparebank1Impl implements Bank {
|
||||
private readonly db: Database
|
||||
@ -31,6 +32,7 @@ export class Sparebank1Impl implements Bank {
|
||||
this.db = createDb(databaseFilePath)
|
||||
}
|
||||
|
||||
// TODO if not cleared rerun later
|
||||
async fetchTransactions(
|
||||
interval: Interval,
|
||||
...accountKeys: ReadonlyArray<string>
|
||||
@ -40,8 +42,15 @@ export class Sparebank1Impl implements Bank {
|
||||
accountKeys,
|
||||
interval,
|
||||
)
|
||||
const sparebankTransactions = response.transactions
|
||||
return sparebankTransactions.map(bankTransactionIntoActualTransaction)
|
||||
|
||||
return response.transactions
|
||||
.map((transaction) => {
|
||||
const actualTransaction =
|
||||
bankTransactionIntoActualTransaction(transaction)
|
||||
|
||||
return actualTransaction.cleared === true ? actualTransaction : null
|
||||
})
|
||||
.filter((transaction) => transaction !== null)
|
||||
}
|
||||
|
||||
shutdown(): void {
|
||||
|
Reference in New Issue
Block a user