@ashray.mehta/statement-converter 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,6 +3,7 @@ import { Transaction } from '../models/Transaction';
|
|
|
3
3
|
import { TransactionAdapter } from './TransactionAdapter';
|
|
4
4
|
export declare class ICICICreditCardAdapter extends TransactionAdapter {
|
|
5
5
|
convert(xlsxData: ArrayBuffer): Promise<Transaction[]>;
|
|
6
|
+
private parseMoment;
|
|
6
7
|
private findFirstRow;
|
|
7
8
|
private findLastRow;
|
|
8
9
|
private determineDebitOrCredit;
|
|
@@ -64,7 +64,6 @@ class ICICICreditCardAdapter extends TransactionAdapter_1.TransactionAdapter {
|
|
|
64
64
|
const addressForReferenceNumber = (_e = XLSXUtil_1.XLSXUtil.findTextIgnoringWhitespace(sheet, "Reference Number")) !== null && _e !== void 0 ? _e : XLSXUtil_1.XLSXUtil.findTextIgnoringWhitespace(sheet, 'Sr.No.');
|
|
65
65
|
const addressForCreditOrDebit = XLSXUtil_1.XLSXUtil.findTextIgnoringWhitespace(sheet, "BillingAmountSign");
|
|
66
66
|
const range = XLSX.utils.decode_range(sheet['!ref']);
|
|
67
|
-
const rangeEnd = range.e;
|
|
68
67
|
const lastRow = this.findLastRow(sheet, range, addressForTransactionDate);
|
|
69
68
|
const startingRow = this.findFirstRow(sheet, range, addressForTransactionDate);
|
|
70
69
|
const rows = [...Array(1 + lastRow - startingRow).keys()].map(v => startingRow + v);
|
|
@@ -72,7 +71,8 @@ class ICICICreditCardAdapter extends TransactionAdapter_1.TransactionAdapter {
|
|
|
72
71
|
.filter(row => {
|
|
73
72
|
// ICICI sometimes has account numbers in the Date field which serve as a separator between inflows and outflows.
|
|
74
73
|
// This filters those rows out.
|
|
75
|
-
|
|
74
|
+
const parsedDate = this.parseMoment(XLSXUtil_1.XLSXUtil.getCellValue(sheet, row, addressForTransactionDate.c));
|
|
75
|
+
return parsedDate.isValid();
|
|
76
76
|
})
|
|
77
77
|
.map(row => {
|
|
78
78
|
let isOutflow, amount;
|
|
@@ -87,7 +87,7 @@ class ICICICreditCardAdapter extends TransactionAdapter_1.TransactionAdapter {
|
|
|
87
87
|
isOutflow = result.isOutflow;
|
|
88
88
|
amount = result.amount;
|
|
89
89
|
}
|
|
90
|
-
const date =
|
|
90
|
+
const date = this.parseMoment(XLSXUtil_1.XLSXUtil.getCellValue(sheet, row, addressForTransactionDate.c)).toDate();
|
|
91
91
|
return {
|
|
92
92
|
Payee: XLSXUtil_1.XLSXUtil.getCellValue(sheet, row, addressForDetails.c),
|
|
93
93
|
Outflow: isOutflow ? amount : 0,
|
|
@@ -99,6 +99,9 @@ class ICICICreditCardAdapter extends TransactionAdapter_1.TransactionAdapter {
|
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
+
parseMoment(text) {
|
|
103
|
+
return (0, moment_1.default)(text, ['DD/MM/YYYY', 'DD-MMM-YY']);
|
|
104
|
+
}
|
|
102
105
|
findFirstRow(sheet, range, addressForTransactionDate) {
|
|
103
106
|
var current = addressForTransactionDate.r; // Right after this is where the data should start, but sometimes there are blank rows after the header.
|
|
104
107
|
for (var current = addressForTransactionDate.r + 1; current <= range.e.r; current++) {
|