2024-12-23 16:47:07 +01:00
|
|
|
import type { Transaction } from "@/bank/sparebank1.ts"
|
2024-11-17 22:27:29 +01:00
|
|
|
import type { TransactionEntity } from "@actual-app/api/@types/loot-core/types/models"
|
2024-12-01 19:35:45 +01:00
|
|
|
import type { UUID } from "node:crypto"
|
2024-11-17 22:27:29 +01:00
|
|
|
|
|
|
|
// TODO more fields / correct fields?
|
2024-12-01 20:48:42 +01:00
|
|
|
export function bankTransactionIntoActualTransaction(
|
2024-11-17 22:27:29 +01:00
|
|
|
transaction: Transaction,
|
2024-12-01 19:35:45 +01:00
|
|
|
accountId: UUID,
|
2024-11-17 22:27:29 +01:00
|
|
|
): TransactionEntity {
|
|
|
|
return {
|
|
|
|
id: transaction.id,
|
2024-12-01 20:48:42 +01:00
|
|
|
// Transactions with the same id will be ignored
|
|
|
|
imported_id: transaction.id,
|
2024-12-01 19:35:45 +01:00
|
|
|
account: accountId,
|
2024-12-01 20:48:42 +01:00
|
|
|
// The value without decimals
|
|
|
|
amount: transaction.amount * 100,
|
2024-11-17 22:27:29 +01:00
|
|
|
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")
|
|
|
|
}
|