27 lines
831 B
TypeScript
Raw Normal View History

import type { Transaction } from "@/bank/sparebank1.ts"
import type { TransactionEntity } from "@actual-app/api/@types/loot-core/types/models"
import type { UUID } from "node:crypto"
// TODO more fields / correct fields?
export function bankTransactionIntoActualTransaction(
transaction: Transaction,
accountId: UUID,
): TransactionEntity {
return {
id: transaction.id,
// Transactions with the same id will be ignored
imported_id: transaction.id,
account: accountId,
// The value without decimals
amount: transaction.amount * 100,
date: transaction.date,
payee: transaction.description,
}
}
// TODO take the account from the bank and match it to the actual account
// Use ENV
export function bankAccountIntoActualAccount(account: string): string {
throw new Error("Not implemented")
}