@ashray.mehta/statement-converter 1.5.2 → 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.
@@ -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 lastRow = addressForLegend.r - 1;
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
- const isOutflow = this.isOutflow(sheet, row, addressForCreditOrDebit.c);
69
- const amount = XLSXUtil_1.XLSXUtil.getNumberInCell(sheet, row, addressForAmount.c);
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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ashray.mehta/statement-converter",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "Library to convert statements from frequently used banks to QIF.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",