gemcap-be-common 1.4.227 → 1.4.230

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.
@@ -0,0 +1,33 @@
1
+
2
+ const extractReferenceValue = (reference: string, key: string): string => {
3
+ if (!reference) {
4
+ return '';
5
+ }
6
+
7
+ // Capture everything after KEY= until the next XXX= block or end of string
8
+ const regex = new RegExp(`${key}=([\\s\\S]*?)(?=\\s+[A-Z]{2,}=|$)`);
9
+ const match = reference.match(regex);
10
+
11
+ if (!match) {
12
+ return '';
13
+ }
14
+
15
+ let value = match[1].trim();
16
+
17
+ // Remove trailing account markers like /AC- or /BC-
18
+ value = value.split('/')[0].trim();
19
+
20
+ return value;
21
+ };
22
+
23
+ export const convertBankReferenceToTransactionReference = (rawReference: string) => {
24
+ if (!rawReference) {
25
+ return ' : : ';
26
+ }
27
+
28
+ const org = extractReferenceValue(rawReference, 'ORG');
29
+ const bnf = extractReferenceValue(rawReference, 'BNF');
30
+ const obi = extractReferenceValue(rawReference, 'OBI');
31
+
32
+ return `${org || ''} : ${bnf || ''} : ${obi || ''}`;
33
+ };
@@ -27,6 +27,7 @@ export interface IBankIntegrationAccount {
27
27
  integrationId: mongoose.Types.ObjectId;
28
28
  externalAccountId: string;
29
29
  name: string;
30
+ accountNumber: string;
30
31
  accountType: string;
31
32
  currency: string;
32
33
  rawPayload: string;
@@ -17,6 +17,9 @@ exports.BankIntegrationAccountSchema = new mongoose_1.default.Schema({
17
17
  name: {
18
18
  type: String,
19
19
  },
20
+ accountNumber: {
21
+ type: String,
22
+ },
20
23
  accountType: {
21
24
  type: String,
22
25
  },
@@ -6,6 +6,7 @@ export interface IBankIntegrationAccount {
6
6
  integrationId: mongoose.Types.ObjectId;
7
7
  externalAccountId: string;
8
8
  name: string;
9
+ accountNumber: string;
9
10
  accountType: string;
10
11
  currency: string;
11
12
  rawPayload: string;
@@ -49,6 +50,9 @@ export const BankIntegrationAccountSchema = new mongoose.Schema<IBankIntegration
49
50
  name: {
50
51
  type: String,
51
52
  },
53
+ accountNumber: {
54
+ type: String,
55
+ },
52
56
  accountType: {
53
57
  type: String,
54
58
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.4.227",
3
+ "version": "1.4.230",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -31,6 +31,7 @@ import { MAIN_DATE_FORMAT } from '../constants/date-formats.constants';
31
31
  import { LoanTransactionsService } from './loan-transactions.service';
32
32
  import { CashAllocationService } from './cash-allocation.service';
33
33
  import { LoanStatementStatusService } from './loan-statement-status.service';
34
+ import { convertBankReferenceToTransactionReference } from '../helpers/bank-reference.helper';
34
35
 
35
36
  const useExternalUploader = false; // TODO keep only external upload
36
37
 
@@ -352,7 +353,7 @@ export class BankUploadedTransactionsService {
352
353
  description: '',
353
354
  effectiveDate: null,
354
355
  productId: foundCashAllocationProduct.productId,
355
- reference: splitTransaction ? splitTransaction.memo : transactionToConvert.reference,
356
+ reference: splitTransaction ? splitTransaction.memo : convertBankReferenceToTransactionReference(transactionToConvert.reference),
356
357
  transactionType: transaction.amount > 0 ? ELoanTransactionTypes.COLLECTION : ELoanTransactionTypes.DISBURSEMENT,
357
358
  balance: 0,
358
359
  floatedBalance: 0,