gemcap-be-common 1.4.231 → 1.4.233

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.
@@ -14,15 +14,24 @@ const extractReferenceValue = (reference, key) => {
14
14
  let value = match[1].trim();
15
15
  // Remove trailing account markers like /AC- or /BC-
16
16
  value = value.split('/')[0].trim();
17
+ // Remove NOTPROVIDED if present
18
+ value = value.replace(/NOTPROVIDED/gi, '').trim();
19
+ // Collapse multiple spaces (incl. tabs) into a single space
20
+ value = value.replace(/\s{2,}/g, ' ');
17
21
  return value;
18
22
  };
19
23
  const convertBankReferenceToTransactionReference = (rawReference) => {
20
- if (!rawReference) {
21
- return ' : : ';
24
+ // If reference is empty/null → return empty string
25
+ if (!rawReference || !rawReference.trim()) {
26
+ return '';
22
27
  }
23
28
  const org = extractReferenceValue(rawReference, 'ORG');
24
29
  const bnf = extractReferenceValue(rawReference, 'BNF');
25
30
  const obi = extractReferenceValue(rawReference, 'OBI');
31
+ // If none of the required keys were found → return original reference as-is
32
+ if (!org && !bnf && !obi) {
33
+ return rawReference;
34
+ }
26
35
  return `${org || ''} : ${bnf || ''} : ${obi || ''}`;
27
36
  };
28
37
  exports.convertBankReferenceToTransactionReference = convertBankReferenceToTransactionReference;
@@ -17,17 +17,29 @@ const extractReferenceValue = (reference: string, key: string): string => {
17
17
  // Remove trailing account markers like /AC- or /BC-
18
18
  value = value.split('/')[0].trim();
19
19
 
20
+ // Remove NOTPROVIDED if present
21
+ value = value.replace(/NOTPROVIDED/gi, '').trim();
22
+
23
+ // Collapse multiple spaces (incl. tabs) into a single space
24
+ value = value.replace(/\s{2,}/g, ' ');
25
+
20
26
  return value;
21
27
  };
22
28
 
23
29
  export const convertBankReferenceToTransactionReference = (rawReference: string) => {
24
- if (!rawReference) {
25
- return ' : : ';
30
+ // If reference is empty/null → return empty string
31
+ if (!rawReference || !rawReference.trim()) {
32
+ return '';
26
33
  }
27
34
 
28
35
  const org = extractReferenceValue(rawReference, 'ORG');
29
36
  const bnf = extractReferenceValue(rawReference, 'BNF');
30
37
  const obi = extractReferenceValue(rawReference, 'OBI');
31
38
 
39
+ // If none of the required keys were found → return original reference as-is
40
+ if (!org && !bnf && !obi) {
41
+ return rawReference;
42
+ }
43
+
32
44
  return `${org || ''} : ${bnf || ''} : ${obi || ''}`;
33
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.4.231",
3
+ "version": "1.4.233",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -322,7 +322,6 @@ class BankUploadedTransactionsService {
322
322
  });
323
323
  const loanTransactionsService = this.getLoanTransactionsService();
324
324
  const normalizedTransaction = await loanTransactionsService.normalizeLoanTransaction(getLoanTransaction(), userId);
325
- console.log({ normalizedTransaction });
326
325
  const createdLoanTransaction = await loanTransactionsService.createLoanTransaction(normalizedTransaction);
327
326
  loanTransactionsMap[String(transaction._id)] = [...loanTransactionsMap[String(transaction._id)], new mongoose_1.default.Types.ObjectId(String(createdLoanTransaction._id))];
328
327
  productIds.add(String(foundCashAllocationProduct.productId));
@@ -360,7 +360,6 @@ export class BankUploadedTransactionsService {
360
360
  });
361
361
  const loanTransactionsService = this.getLoanTransactionsService();
362
362
  const normalizedTransaction = await loanTransactionsService.normalizeLoanTransaction(getLoanTransaction() as ILoanTransactionDoc, userId);
363
- console.log({ normalizedTransaction });
364
363
  const createdLoanTransaction = await loanTransactionsService.createLoanTransaction(normalizedTransaction as Partial<ILoanTransactionWithId>);
365
364
  loanTransactionsMap[String(transaction._id)] = [...loanTransactionsMap[String(transaction._id)], new mongoose.Types.ObjectId(String(createdLoanTransaction._id))];
366
365
  productIds.add(String(foundCashAllocationProduct.productId));