Files
finanzen/convex/bank/types.ts

74 lines
1.6 KiB
TypeScript

import type { Id } from "../_generated/dataModel";
export type BankProviderName = "comdirect" | "fints";
export type NormalizedAccount = {
externalId: string;
name: string;
iban?: string;
balance: number;
currency: string;
};
export type NormalizedBalance = {
externalId: string;
balance: number;
currency: string;
};
export type NormalizedTransaction = {
externalRef?: string;
bookingDate?: string;
valueDate?: string;
description: string;
counterparty?: string;
amount: number;
vorgang?: string;
isPending: boolean;
rawText?: string;
categoryName?: string;
assignedMonth?: string;
effectiveMonth?: string;
};
export interface BankDataProvider {
readonly name: BankProviderName;
getAccounts(): Promise<NormalizedAccount[]>;
getBalance(accountExternalId: string): Promise<NormalizedBalance>;
getTransactions(
accountExternalId: string,
from: string,
to: string,
): Promise<NormalizedTransaction[]>;
}
export type SyncJobState = {
phase: "init" | "fetch_accounts" | "fetch_transactions" | "persist" | "done";
from: string;
to: string;
accountId?: Id<"accounts">;
provider: BankProviderName;
accounts: NormalizedAccount[];
accountIndex: number;
rows: Array<{
accountExternalId: string;
transactions: NormalizedTransaction[];
}>;
};
export type ImportRow = {
accountId?: Id<"accounts">;
categoryName: string;
bookingDate?: string;
valueDate?: string;
description: string;
counterparty?: string;
amount: number;
vorgang?: string;
isPending: boolean;
rawText?: string;
assignedMonth?: string;
effectiveMonth?: string;
externalRef?: string;
};