@ashray.mehta/statement-converter 1.5.1 → 1.5.3
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.
package/adapters/ICICIAdapter.js
CHANGED
|
@@ -54,19 +54,42 @@ const moment_1 = __importDefault(require("moment"));
|
|
|
54
54
|
class ICICIAdapter extends TransactionAdapter_1.TransactionAdapter {
|
|
55
55
|
convert(xlsxData) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var _a;
|
|
57
58
|
const workBook = XLSX.read(xlsxData, { raw: true, type: 'array' });
|
|
58
59
|
const sheet = workBook.Sheets[workBook.SheetNames[0]];
|
|
59
60
|
const addressForTransactionDate = XLSXUtil_1.XLSXUtil.findText(sheet, "Transaction Date");
|
|
60
|
-
const addressForDetails = XLSXUtil_1.XLSXUtil.findText(sheet, "Transaction Remark");
|
|
61
|
+
const addressForDetails = (_a = XLSXUtil_1.XLSXUtil.findText(sheet, "Transaction Remark")) !== null && _a !== void 0 ? _a : XLSXUtil_1.XLSXUtil.findText(sheet, "Transaction Remarks");
|
|
61
62
|
const addressForAmount = XLSXUtil_1.XLSXUtil.findText(sheet, "Amount (INR)");
|
|
62
63
|
const addressForCreditOrDebit = XLSXUtil_1.XLSXUtil.findText(sheet, "CR/DR");
|
|
64
|
+
const addressForWithdrawal = XLSXUtil_1.XLSXUtil.findText(sheet, "Withdrawal Amount (INR )");
|
|
65
|
+
const addressForDeposit = XLSXUtil_1.XLSXUtil.findText(sheet, "Deposit Amount (INR )");
|
|
63
66
|
const addressForLegend = XLSXUtil_1.XLSXUtil.findText(sheet, "Legends Used in Account Statement");
|
|
64
67
|
const startingRow = addressForTransactionDate.r + 1;
|
|
65
|
-
const
|
|
68
|
+
const range = XLSX.utils.decode_range(sheet['!ref']);
|
|
69
|
+
let lastRow;
|
|
70
|
+
if (addressForLegend) {
|
|
71
|
+
lastRow = addressForLegend.r - 1;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
lastRow = range.e.r;
|
|
75
|
+
}
|
|
66
76
|
const rows = [...Array(1 + lastRow - startingRow).keys()].map(v => startingRow + v);
|
|
67
77
|
return rows.map(row => {
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
let isOutflow, amount;
|
|
79
|
+
if (addressForAmount) {
|
|
80
|
+
isOutflow = this.isOutflow(sheet, row, addressForCreditOrDebit.c);
|
|
81
|
+
amount = XLSXUtil_1.XLSXUtil.getNumberInCell(sheet, row, addressForAmount.c);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const withdrawal = XLSXUtil_1.XLSXUtil.getNumberInCell(sheet, row, addressForWithdrawal.c);
|
|
85
|
+
isOutflow = true;
|
|
86
|
+
amount = withdrawal;
|
|
87
|
+
if (withdrawal === 0) {
|
|
88
|
+
const deposit = XLSXUtil_1.XLSXUtil.getNumberInCell(sheet, row, addressForDeposit.c);
|
|
89
|
+
isOutflow = false;
|
|
90
|
+
amount = deposit;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
70
93
|
const date = (0, moment_1.default)(XLSXUtil_1.XLSXUtil.getCellValue(sheet, row, addressForTransactionDate.c), 'DD/MM/YYYY').toDate();
|
|
71
94
|
const payee = XLSXUtil_1.XLSXUtil.getCellValue(sheet, row, addressForDetails.c);
|
|
72
95
|
return {
|
|
@@ -81,16 +81,17 @@ class ICICICreditCardAdapter extends TransactionAdapter_1.TransactionAdapter {
|
|
|
81
81
|
})
|
|
82
82
|
.map(row => {
|
|
83
83
|
let isOutflow, amount;
|
|
84
|
-
if (addressForCreditOrDebit
|
|
84
|
+
if (addressForCreditOrDebit) {
|
|
85
|
+
const creditOrDebit = XLSXUtil_1.XLSXUtil.getCellValue(sheet, row, addressForCreditOrDebit.c);
|
|
86
|
+
isOutflow = creditOrDebit !== "CR";
|
|
87
|
+
const amountCellValue = XLSXUtil_1.XLSXUtil.getCellValue(sheet, row, addressForAmount.c);
|
|
88
|
+
amount = parseFloat(amountCellValue.replace(/,/g, ''));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
85
91
|
const result = this.determineDebitOrCredit(sheet, row, addressForAmount.c);
|
|
86
92
|
isOutflow = result.isOutflow;
|
|
87
93
|
amount = result.amount;
|
|
88
94
|
}
|
|
89
|
-
else {
|
|
90
|
-
isOutflow = XLSXUtil_1.XLSXUtil.getCellValue(sheet, row, addressForCreditOrDebit.c) == "";
|
|
91
|
-
const amountCellValue = XLSXUtil_1.XLSXUtil.getCellValue(sheet, row, addressForAmount.c);
|
|
92
|
-
amount = parseFloat(amountCellValue.replace(/,/g, ''));
|
|
93
|
-
}
|
|
94
95
|
const date = (0, moment_1.default)(XLSXUtil_1.XLSXUtil.getCellValue(sheet, row, addressForTransactionDate.c), 'DD/MM/YYYY').toDate();
|
|
95
96
|
return {
|
|
96
97
|
Payee: XLSXUtil_1.XLSXUtil.getCellValue(sheet, row, addressForDetails.c),
|