Refactor ING importer
This commit is contained in:
@@ -36,27 +36,21 @@ const headers = [
|
|||||||
'unknown4',
|
'unknown4',
|
||||||
];
|
];
|
||||||
|
|
||||||
const readIngTransaction = (data: string[]): IngTransaction|undefined => {
|
|
||||||
if (data.length !== headers.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const transaction: IngTransaction = {};
|
|
||||||
headers.forEach((key, index) => {
|
|
||||||
transaction[key] = data[index].trim();
|
|
||||||
});
|
|
||||||
|
|
||||||
return transaction;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default class extends BaseTransactionParser<ParserConfig> {
|
export default class extends BaseTransactionParser<ParserConfig> {
|
||||||
protected requiredFields = [];
|
protected requiredFields = [];
|
||||||
#transactions: ValidatedIngTransaction[] = [];
|
#transactions: ValidatedIngTransaction[] = [];
|
||||||
|
|
||||||
async pushTransaction(data: string[]): Promise<boolean> {
|
async pushTransaction(data: string[]): Promise<boolean> {
|
||||||
const ing = readIngTransaction(data);
|
if (data.length !== headers.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const transaction: IngTransaction = {};
|
||||||
|
headers.forEach((key, index) => {
|
||||||
|
transaction[key] = data[index].trim();
|
||||||
|
});
|
||||||
|
|
||||||
if (!ing) {
|
if (!transaction) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,18 +59,19 @@ export default class extends BaseTransactionParser<ParserConfig> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const transactionAmount = parseAmount(ing.transactionAmount);
|
const transactionAmount = parseAmount(transaction.transactionAmount);
|
||||||
const lockAmount = parseAmount(ing.lockAmount);
|
const lockAmount = parseAmount(transaction.lockAmount);
|
||||||
|
|
||||||
if(transactionAmount === undefined && lockAmount === undefined) {
|
if(transactionAmount === undefined && lockAmount === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#transactions.push({
|
this.#transactions.push({
|
||||||
...ing,
|
...transaction,
|
||||||
transactionAmount,
|
transactionAmount,
|
||||||
lockAmount,
|
lockAmount,
|
||||||
} as ValidatedIngTransaction);
|
} as ValidatedIngTransaction);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user