gemcap-be-common 1.5.134 → 1.5.135
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/db/brokers.db.js +3 -1
- package/db/brokers.db.ts +5 -4
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/db/brokers.db.js
CHANGED
|
@@ -13,7 +13,9 @@ const LoanBroker_model_1 = require("../models/LoanBroker.model");
|
|
|
13
13
|
const main_helper_1 = require("../helpers/main.helper");
|
|
14
14
|
const handleBrokerInterestFee = (statementAmount, charges, interestShare, baseInterestTotal, primeRate) => {
|
|
15
15
|
const interestCharge = charges.find((charge) => reports_db_1.EChargeType[charge.chargeType] === reports_db_1.EChargeType.INTEREST_FEE && charge.active && !charge.deletedAt);
|
|
16
|
-
const interestBase =
|
|
16
|
+
const interestBase = baseInterestTotal
|
|
17
|
+
? new decimal_js_1.default(primeRate).add(interestCharge?.percent || 0).div(baseInterestTotal).toDP(2).toNumber()
|
|
18
|
+
: 0;
|
|
17
19
|
const minBase = Math.min(1, interestBase);
|
|
18
20
|
return new decimal_js_1.default(statementAmount).mul(interestShare).mul(minBase).toDP(2).toNumber();
|
|
19
21
|
};
|
package/db/brokers.db.ts
CHANGED
|
@@ -11,10 +11,12 @@ import { ILoanChargeDoc, ILoanChargeView } from '../models/LoanCharges.model';
|
|
|
11
11
|
|
|
12
12
|
export const handleBrokerInterestFee = (statementAmount: number, charges: ILoanChargeView[], interestShare: number, baseInterestTotal: number, primeRate: number) => {
|
|
13
13
|
const interestCharge = charges.find((charge) => EChargeType[charge.chargeType] === EChargeType.INTEREST_FEE && charge.active && !charge.deletedAt);
|
|
14
|
-
const interestBase =
|
|
14
|
+
const interestBase = baseInterestTotal
|
|
15
|
+
? new Decimal(primeRate).add(interestCharge?.percent || 0).div(baseInterestTotal).toDP(2).toNumber()
|
|
16
|
+
: 0;
|
|
15
17
|
const minBase = Math.min(1, interestBase);
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
+
return new Decimal(statementAmount).mul(interestShare).mul(minBase).toDP(2).toNumber();
|
|
19
|
+
};
|
|
18
20
|
|
|
19
21
|
export const getProductBrokers = async (productId: string) => {
|
|
20
22
|
return ProductBroker.aggregate<IProductBrokerDocWithLoanBroker>([
|
|
@@ -51,7 +53,6 @@ export const enrichWithBrokers = async (transactions: ILedgerDataRow[], product:
|
|
|
51
53
|
let statementAmount: number;
|
|
52
54
|
|
|
53
55
|
|
|
54
|
-
|
|
55
56
|
if (shareName === 'interestShare') {
|
|
56
57
|
statementAmount = handleBrokerInterestFee(-t.statementAmount, charges, broker.interestShare, broker.baseInterestTotal, primeRate);
|
|
57
58
|
} else {
|