56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
import * as plugins from '../csvparser.plugins.js';
|
|
|
|
import { ExtendedDate } from '@push.rocks/smarttime';
|
|
|
|
import * as interfaces from './interfaces/index.js';
|
|
|
|
export class CsvFidor extends plugins.portablefinance.AcCsvParser<plugins.portablefinance.IMonetaryTransaction> {
|
|
|
|
// INSTANCE
|
|
public paymentProviderName: string = 'Fidor Bank AG';
|
|
public description: string = 'a csv parser optimized for csv files from Fidor.';
|
|
public csvDescriptorArray: plugins.portablefinance.ICsvDescriptor[] = [];
|
|
|
|
constructor() {
|
|
super();
|
|
}
|
|
|
|
addCsvDecriptor (csvDescriptorArg: plugins.portablefinance.ICsvDescriptor): void {
|
|
this.csvDescriptorArray.push(csvDescriptorArg);
|
|
}
|
|
|
|
/**
|
|
* returns the transactions
|
|
*/
|
|
public async getTransactions(): Promise<plugins.portablefinance.IMonetaryTransaction[]> {
|
|
const payments: plugins.portablefinance.IMonetaryTransaction[] = [];
|
|
|
|
for (const csvDescriptor of this.csvDescriptorArray) {
|
|
const csvInstance = new plugins.smartcsv.Csv(csvDescriptor.contentString, {
|
|
headers: true
|
|
});
|
|
|
|
const fidorTransactionArray: interfaces.IFidorOriginalTransaction[] = await csvInstance.exportAsObject();
|
|
for (const transaction of fidorTransactionArray) {
|
|
payments.push({
|
|
id: await plugins.smarthash.sha265FromObject(transaction),
|
|
data: {
|
|
additionalIds: [],
|
|
amount: parseFloat(transaction.Wert.replace('.', '').replace(',', '.')),
|
|
date: plugins.smarttime.ExtendedDate.fromEuropeanDate(transaction.Datum).getTime(),
|
|
name: transaction.Beschreibung,
|
|
description: transaction.Beschreibung2,
|
|
originAccountId: null,
|
|
originTransactionId: null,
|
|
paymentAccountId: null,
|
|
justForLooks: null,
|
|
voucherData: null,
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
return payments;
|
|
}
|
|
}
|