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.
- package/helpers/bank-reference.helper.ts +33 -0
- package/models/BankIntegrationAccount.model.d.ts +1 -0
- package/models/BankIntegrationAccount.model.js +3 -0
- package/models/BankIntegrationAccount.model.ts +4 -0
- package/package.json +1 -1
- package/services/bank-uploaded-transactions.service.ts +2 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -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
|
+
};
|
|
@@ -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
|
@@ -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,
|