@parv0888/scheme-engine 0.1.1 → 0.1.2
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/dist/calculators/discount-application.d.ts +44 -0
- package/dist/calculators/index.d.ts +65 -0
- package/dist/calculators/index.d.ts.map +1 -0
- package/dist/calculators/index.js +196 -0
- package/dist/calculators/index.js.map +1 -0
- package/dist/calculators/payout-types/article.d.ts +23 -0
- package/dist/calculators/payout-types/article.d.ts.map +1 -0
- package/dist/calculators/payout-types/article.js +73 -0
- package/dist/calculators/payout-types/article.js.map +1 -0
- package/dist/calculators/payout-types/basket.d.ts +49 -0
- package/dist/calculators/payout-types/basket.d.ts.map +1 -0
- package/dist/calculators/payout-types/basket.js +108 -0
- package/dist/calculators/payout-types/basket.js.map +1 -0
- package/dist/calculators/payout-types/coupon.d.ts +23 -0
- package/dist/calculators/payout-types/coupon.d.ts.map +1 -0
- package/dist/calculators/payout-types/coupon.js +74 -0
- package/dist/calculators/payout-types/coupon.js.map +1 -0
- package/dist/calculators/payout-types/discount.d.ts +21 -0
- package/dist/calculators/payout-types/discount.d.ts.map +1 -0
- package/dist/calculators/payout-types/discount.js +110 -0
- package/dist/calculators/payout-types/discount.js.map +1 -0
- package/dist/calculators/payout-types/fixed-discount.d.ts +31 -0
- package/dist/calculators/payout-types/fixed-discount.d.ts.map +1 -0
- package/dist/calculators/payout-types/fixed-discount.js +65 -0
- package/dist/calculators/payout-types/fixed-discount.js.map +1 -0
- package/dist/calculators/payout-types/foc.d.ts +30 -0
- package/dist/calculators/payout-types/foc.d.ts.map +1 -0
- package/dist/calculators/payout-types/foc.js +130 -0
- package/dist/calculators/payout-types/foc.js.map +1 -0
- package/dist/calculators/payout-types/mrp-percentage.d.ts +34 -0
- package/dist/calculators/payout-types/mrp-percentage.d.ts.map +1 -0
- package/dist/calculators/payout-types/mrp-percentage.js +77 -0
- package/dist/calculators/payout-types/mrp-percentage.js.map +1 -0
- package/dist/calculators/payout-types/nlp.d.ts +22 -0
- package/dist/calculators/payout-types/nlp.d.ts.map +1 -0
- package/dist/calculators/payout-types/nlp.js +59 -0
- package/dist/calculators/payout-types/nlp.js.map +1 -0
- package/dist/calculators/payout-types/per-unit.d.ts +32 -0
- package/dist/calculators/payout-types/per-unit.d.ts.map +1 -0
- package/dist/calculators/payout-types/per-unit.js +94 -0
- package/dist/calculators/payout-types/per-unit.js.map +1 -0
- package/dist/calculators/payout-types/product-new.d.ts +27 -0
- package/dist/calculators/payout-types/product-new.d.ts.map +1 -0
- package/dist/calculators/payout-types/product-new.js +85 -0
- package/dist/calculators/payout-types/product-new.js.map +1 -0
- package/dist/calculators/payout-types/product.d.ts +31 -0
- package/dist/calculators/payout-types/product.d.ts.map +1 -0
- package/dist/calculators/payout-types/product.js +73 -0
- package/dist/calculators/payout-types/product.js.map +1 -0
- package/dist/calculators/payout-types/topup.d.ts +19 -0
- package/dist/calculators/payout-types/topup.d.ts.map +1 -0
- package/dist/calculators/payout-types/topup.js +46 -0
- package/dist/calculators/payout-types/topup.js.map +1 -0
- package/dist/calculators/slab-matcher.d.ts +41 -0
- package/dist/calculators/slab-matcher.d.ts.map +1 -0
- package/dist/calculators/slab-matcher.js +68 -0
- package/dist/calculators/slab-matcher.js.map +1 -0
- package/dist/helpers/calc-type-checks.d.ts +21 -0
- package/dist/helpers/calc-type-checks.d.ts.map +1 -0
- package/dist/helpers/calc-type-checks.js +36 -0
- package/dist/helpers/calc-type-checks.js.map +1 -0
- package/dist/helpers/compare-value.d.ts +40 -0
- package/dist/helpers/compare-value.d.ts.map +1 -0
- package/dist/helpers/compare-value.js +120 -0
- package/dist/helpers/compare-value.js.map +1 -0
- package/dist/helpers/constraint-checks.d.ts +30 -0
- package/dist/helpers/constraint-checks.d.ts.map +1 -0
- package/dist/helpers/constraint-checks.js +73 -0
- package/dist/helpers/constraint-checks.js.map +1 -0
- package/dist/helpers/index.d.ts +8 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +24 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/math.d.ts +50 -0
- package/dist/helpers/math.d.ts.map +1 -0
- package/dist/helpers/math.js +96 -0
- package/dist/helpers/math.js.map +1 -0
- package/dist/helpers/payout-type-checks.d.ts +17 -0
- package/dist/helpers/payout-type-checks.d.ts.map +1 -0
- package/dist/helpers/payout-type-checks.js +34 -0
- package/dist/helpers/payout-type-checks.js.map +1 -0
- package/dist/helpers/qualifier-checks.d.ts +62 -0
- package/dist/helpers/qualifier-checks.d.ts.map +1 -0
- package/dist/helpers/qualifier-checks.js +194 -0
- package/dist/helpers/qualifier-checks.js.map +1 -0
- package/dist/helpers/scheme-applicability.d.ts +40 -0
- package/dist/helpers/scheme-applicability.d.ts.map +1 -0
- package/dist/helpers/scheme-applicability.js +99 -0
- package/dist/helpers/scheme-applicability.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/types/applied-scheme.d.ts +157 -0
- package/dist/types/applied-scheme.d.ts.map +1 -0
- package/dist/types/applied-scheme.js +22 -0
- package/dist/types/applied-scheme.js.map +1 -0
- package/dist/types/enums.d.ts +91 -0
- package/dist/types/enums.d.ts.map +1 -0
- package/dist/types/enums.js +118 -0
- package/dist/types/enums.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/item-props.d.ts +103 -0
- package/dist/types/item-props.d.ts.map +1 -0
- package/dist/types/item-props.js +3 -0
- package/dist/types/item-props.js.map +1 -0
- package/dist/types/scheme.d.ts +172 -0
- package/dist/types/scheme.d.ts.map +1 -0
- package/dist/types/scheme.js +3 -0
- package/dist/types/scheme.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findMatchingSlab = findMatchingSlab;
|
|
4
|
+
exports.findInterpolationSlabs = findInterpolationSlabs;
|
|
5
|
+
const constraint_checks_1 = require("../helpers/constraint-checks");
|
|
6
|
+
const qualifier_checks_1 = require("../helpers/qualifier-checks");
|
|
7
|
+
/**
|
|
8
|
+
* Finds the first matching slab from a list sorted desc by constraint.
|
|
9
|
+
* Applies:
|
|
10
|
+
* 1. Secondary category / qualifier filter
|
|
11
|
+
* 2. Payout-type-aware constraint check (with maxConstraint handling)
|
|
12
|
+
*
|
|
13
|
+
* Returns the matched slab or null if none matched.
|
|
14
|
+
*/
|
|
15
|
+
function findMatchingSlab(params) {
|
|
16
|
+
const { slabs, compareValue, applicableProducts, payoutType, discountOn } = params;
|
|
17
|
+
for (let i = 0; i < slabs.length; i++) {
|
|
18
|
+
const slab = slabs[i];
|
|
19
|
+
// Check secondary category / first qualifier / third qualifier
|
|
20
|
+
const qualifierParams = {
|
|
21
|
+
secondQualifier: slab.secondQualifier,
|
|
22
|
+
secondQualifierType: slab.secondQualifierType,
|
|
23
|
+
discountOn,
|
|
24
|
+
firstQualifier: slab.firstQualifier,
|
|
25
|
+
thirdQualifier: slab.thirdQualifier,
|
|
26
|
+
thirdQualifierType: slab.thirdQualifierType,
|
|
27
|
+
schemePayoutType: payoutType,
|
|
28
|
+
slabConstraint: slab.constraint,
|
|
29
|
+
};
|
|
30
|
+
if (!(0, qualifier_checks_1.checkIfSecondaryCategoryFilterPassed)(qualifierParams, applicableProducts)) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if ((0, constraint_checks_1.checkSlabConstraint)(compareValue, slab, payoutType)) {
|
|
34
|
+
return { slab, index: i };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Finds two adjacent slabs for step/continuous interpolation.
|
|
41
|
+
* Returns the lower and upper slab. If compare value exceeds the highest slab,
|
|
42
|
+
* uses that slab for both lower and upper.
|
|
43
|
+
*/
|
|
44
|
+
function findInterpolationSlabs(params) {
|
|
45
|
+
const { slabs, compareValue, applicableProducts, payoutType, discountOn } = params;
|
|
46
|
+
for (let i = 0; i < slabs.length; i++) {
|
|
47
|
+
const lowerSlab = slabs[i];
|
|
48
|
+
const qualifierParams = {
|
|
49
|
+
secondQualifier: lowerSlab.secondQualifier,
|
|
50
|
+
secondQualifierType: lowerSlab.secondQualifierType,
|
|
51
|
+
discountOn,
|
|
52
|
+
firstQualifier: lowerSlab.firstQualifier,
|
|
53
|
+
thirdQualifier: lowerSlab.thirdQualifier,
|
|
54
|
+
thirdQualifierType: lowerSlab.thirdQualifierType,
|
|
55
|
+
schemePayoutType: payoutType,
|
|
56
|
+
slabConstraint: lowerSlab.constraint,
|
|
57
|
+
};
|
|
58
|
+
if (!(0, qualifier_checks_1.checkIfSecondaryCategoryFilterPassed)(qualifierParams, applicableProducts)) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if ((0, constraint_checks_1.checkSlabConstraint)(compareValue, lowerSlab, payoutType)) {
|
|
62
|
+
const upperSlab = i === slabs.length - 1 ? lowerSlab : slabs[i + 1];
|
|
63
|
+
return { lower: lowerSlab, upper: upperSlab, lowerIndex: i };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=slab-matcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slab-matcher.js","sourceRoot":"","sources":["../../src/calculators/slab-matcher.ts"],"names":[],"mappings":";;AAkCA,4CA4BC;AAOD,wDA8BC;AAhGD,oEAAmE;AACnE,kEAA8G;AAsB9G;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAAC,MAAyB;IACxD,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAEnF,KAAK,IA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,EAAE,SAAS,CAAC,cAAc;YACxC,kBAAkB,EAAE,SAAS,CAAC,kBAAkB;YAChD,gBAAgB,EAAE,UAAU;YAC5B,cAAc,EAAE,SAAS,CAAC,UAAU;SACrC,CAAC;QAEF,IAAI,CAAC,IAAA,uDAAoC,EAAC,eAAe,EAAE,kBAAkB,CAAC,EAAE,CAAC;YAC/E,SAAS;QACX,CAAC;QAED,IAAI,IAAA,uCAAmB,EAAC,YAAY,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,CAAC;YAC7D,MAAM,SAAS,GAAG,CAAC,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACpE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;QAC/D,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if payout calculation type is 'step'.
|
|
3
|
+
* Normalizes to lowercase for comparison.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isPayoutCalcTypeStep(payoutCalcType: string | null): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Checks if payout calculation type is 'continuous'.
|
|
8
|
+
* Normalizes to lowercase for comparison.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isPayoutCalcTypeContinuous(payoutCalcType: string | null): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Checks if payout calculation type is 'stepmultiplier'.
|
|
13
|
+
* Normalizes to lowercase for comparison.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isPayoutCalcTypeStepMultiplier(payoutCalcType: string | null): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Checks if payout calculation type is 'prorata'.
|
|
18
|
+
* NEW: Not yet in either codebase — implements Bug 9 fix.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isPayoutCalcTypeProrata(payoutCalcType: string | null): boolean;
|
|
21
|
+
//# sourceMappingURL=calc-type-checks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calc-type-checks.d.ts","sourceRoot":"","sources":["../../src/helpers/calc-type-checks.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAE3E;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAEjF;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAErF;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAE9E"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPayoutCalcTypeStep = isPayoutCalcTypeStep;
|
|
4
|
+
exports.isPayoutCalcTypeContinuous = isPayoutCalcTypeContinuous;
|
|
5
|
+
exports.isPayoutCalcTypeStepMultiplier = isPayoutCalcTypeStepMultiplier;
|
|
6
|
+
exports.isPayoutCalcTypeProrata = isPayoutCalcTypeProrata;
|
|
7
|
+
const enums_1 = require("../types/enums");
|
|
8
|
+
/**
|
|
9
|
+
* Checks if payout calculation type is 'step'.
|
|
10
|
+
* Normalizes to lowercase for comparison.
|
|
11
|
+
*/
|
|
12
|
+
function isPayoutCalcTypeStep(payoutCalcType) {
|
|
13
|
+
return payoutCalcType?.toLowerCase()?.trim() === enums_1.SchemePayoutCalculationType.STEP;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Checks if payout calculation type is 'continuous'.
|
|
17
|
+
* Normalizes to lowercase for comparison.
|
|
18
|
+
*/
|
|
19
|
+
function isPayoutCalcTypeContinuous(payoutCalcType) {
|
|
20
|
+
return payoutCalcType?.toLowerCase()?.trim() === enums_1.SchemePayoutCalculationType.CONTINUOUS;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Checks if payout calculation type is 'stepmultiplier'.
|
|
24
|
+
* Normalizes to lowercase for comparison.
|
|
25
|
+
*/
|
|
26
|
+
function isPayoutCalcTypeStepMultiplier(payoutCalcType) {
|
|
27
|
+
return payoutCalcType?.toLowerCase()?.trim() === enums_1.SchemePayoutCalculationType.STEP_MULTIPLIER;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Checks if payout calculation type is 'prorata'.
|
|
31
|
+
* NEW: Not yet in either codebase — implements Bug 9 fix.
|
|
32
|
+
*/
|
|
33
|
+
function isPayoutCalcTypeProrata(payoutCalcType) {
|
|
34
|
+
return payoutCalcType?.toLowerCase()?.trim() === enums_1.SchemePayoutCalculationType.PRORATA;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=calc-type-checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calc-type-checks.js","sourceRoot":"","sources":["../../src/helpers/calc-type-checks.ts"],"names":[],"mappings":";;AAMA,oDAEC;AAMD,gEAEC;AAMD,wEAEC;AAMD,0DAEC;AAhCD,0CAA6D;AAE7D;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,cAA6B;IAChE,OAAO,cAAc,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,mCAA2B,CAAC,IAAI,CAAC;AACpF,CAAC;AAED;;;GAGG;AACH,SAAgB,0BAA0B,CAAC,cAA6B;IACtE,OAAO,cAAc,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,mCAA2B,CAAC,UAAU,CAAC;AAC1F,CAAC;AAED;;;GAGG;AACH,SAAgB,8BAA8B,CAAC,cAA6B;IAC1E,OAAO,cAAc,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,mCAA2B,CAAC,eAAe,CAAC;AAC/F,CAAC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CAAC,cAA6B;IACnE,OAAO,cAAc,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,mCAA2B,CAAC,OAAO,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ItemCalculationProps } from "../types/item-props";
|
|
2
|
+
/**
|
|
3
|
+
* Get the base value of an item for scheme constraint comparison.
|
|
4
|
+
* Uses netValue + cashDiscountValue if available, else quantity * price.
|
|
5
|
+
*/
|
|
6
|
+
export declare function itemBaseValueForConstraint(item: ItemCalculationProps, isMrpBilling?: boolean): number;
|
|
7
|
+
/**
|
|
8
|
+
* Calculate MRP billing price (MRP / (1 + tax/100)).
|
|
9
|
+
*/
|
|
10
|
+
export declare function calculateMrpBillingPrice(item: ItemCalculationProps, includeAllTaxes?: boolean): number;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the aggregate quantity across all items.
|
|
13
|
+
*/
|
|
14
|
+
export declare function calculateTotalQuantity(items: ItemCalculationProps[]): number;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the aggregate amount (base value for constraint) across all items.
|
|
17
|
+
*/
|
|
18
|
+
export declare function calculateTotalAmount(items: ItemCalculationProps[], isMrpBilling?: boolean): number;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the total quantity in standard units (cases).
|
|
21
|
+
*/
|
|
22
|
+
export declare function calculateTotalStdUnits(items: ItemCalculationProps[]): number;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the total quantity in actual standard units.
|
|
25
|
+
*/
|
|
26
|
+
export declare function calculateActualTotalStdUnits(items: ItemCalculationProps[]): number;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the total quantity in super units.
|
|
29
|
+
*/
|
|
30
|
+
export declare function calculateTotalSuperUnits(items: ItemCalculationProps[]): number;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the total quantity in additional units.
|
|
33
|
+
*/
|
|
34
|
+
export declare function calculateTotalAdditionalUnits(items: ItemCalculationProps[]): number;
|
|
35
|
+
/**
|
|
36
|
+
* Get the compare value for a scheme based on its constraint type.
|
|
37
|
+
* Uses FE superset with 6 constraint types.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getCategorySchemeCompareValue(constraintType: string, totalQuantity: number, totalAmount: number, totalStdUnits: number, actualStdUnits: number, totalSuperUnits: number, totalAdditionalUnits: number): number;
|
|
40
|
+
//# sourceMappingURL=compare-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare-value.d.ts","sourceRoot":"","sources":["../../src/helpers/compare-value.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,oBAAoB,EAC1B,YAAY,UAAQ,GACnB,MAAM,CAUR;AAMD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,oBAAoB,EAC1B,eAAe,UAAQ,GACtB,MAAM,CAkBR;AAID;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAE5E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,EAAE,EAAE,YAAY,UAAQ,GAAG,MAAM,CAEhG;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAU5E;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAKlF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAK9E;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAKnF;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EACvB,oBAAoB,EAAE,MAAM,GAC3B,MAAM,CAiBR"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.itemBaseValueForConstraint = itemBaseValueForConstraint;
|
|
4
|
+
exports.calculateMrpBillingPrice = calculateMrpBillingPrice;
|
|
5
|
+
exports.calculateTotalQuantity = calculateTotalQuantity;
|
|
6
|
+
exports.calculateTotalAmount = calculateTotalAmount;
|
|
7
|
+
exports.calculateTotalStdUnits = calculateTotalStdUnits;
|
|
8
|
+
exports.calculateActualTotalStdUnits = calculateActualTotalStdUnits;
|
|
9
|
+
exports.calculateTotalSuperUnits = calculateTotalSuperUnits;
|
|
10
|
+
exports.calculateTotalAdditionalUnits = calculateTotalAdditionalUnits;
|
|
11
|
+
exports.getCategorySchemeCompareValue = getCategorySchemeCompareValue;
|
|
12
|
+
const enums_1 = require("../types/enums");
|
|
13
|
+
/**
|
|
14
|
+
* Get the base value of an item for scheme constraint comparison.
|
|
15
|
+
* Uses netValue + cashDiscountValue if available, else quantity * price.
|
|
16
|
+
*/
|
|
17
|
+
function itemBaseValueForConstraint(item, isMrpBilling = false) {
|
|
18
|
+
const price = isMrpBilling ? calculateMrpBillingPrice(item) : (item.price || 0);
|
|
19
|
+
const totalValueForSchemeApplication = getTotalValueForSchemeApplication(item);
|
|
20
|
+
if (totalValueForSchemeApplication) {
|
|
21
|
+
return totalValueForSchemeApplication;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return (item.quantity || 0) * price;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function getTotalValueForSchemeApplication(item) {
|
|
28
|
+
return (item.netValue || 0) + (item.cashDiscountValue || 0);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Calculate MRP billing price (MRP / (1 + tax/100)).
|
|
32
|
+
*/
|
|
33
|
+
function calculateMrpBillingPrice(item, includeAllTaxes = false) {
|
|
34
|
+
let totalTaxPercent = 0;
|
|
35
|
+
const cessPercent = Number(item.cessPercent ?? 0);
|
|
36
|
+
const igstPercent = Number(item.igst ?? 0);
|
|
37
|
+
const vatPercent = Number(item.vatPercent ?? 0);
|
|
38
|
+
if (includeAllTaxes) {
|
|
39
|
+
if (igstPercent > 0) {
|
|
40
|
+
totalTaxPercent = igstPercent + cessPercent;
|
|
41
|
+
}
|
|
42
|
+
else if (vatPercent > 0) {
|
|
43
|
+
totalTaxPercent = vatPercent + cessPercent;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
totalTaxPercent = igstPercent;
|
|
48
|
+
}
|
|
49
|
+
const calculatedPrice = Number(item.mrp ?? 0) / (1 + totalTaxPercent / 100);
|
|
50
|
+
return Number(calculatedPrice.toFixed(2));
|
|
51
|
+
}
|
|
52
|
+
// ─── Aggregate Calculators ──────────────────────────────────────
|
|
53
|
+
/**
|
|
54
|
+
* Returns the aggregate quantity across all items.
|
|
55
|
+
*/
|
|
56
|
+
function calculateTotalQuantity(items) {
|
|
57
|
+
return items.reduce((prev, curr) => prev + (curr.quantity || 0), 0);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns the aggregate amount (base value for constraint) across all items.
|
|
61
|
+
*/
|
|
62
|
+
function calculateTotalAmount(items, isMrpBilling = false) {
|
|
63
|
+
return items.reduce((prev, curr) => prev + itemBaseValueForConstraint(curr, isMrpBilling), 0);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns the total quantity in standard units (cases).
|
|
67
|
+
*/
|
|
68
|
+
function calculateTotalStdUnits(items) {
|
|
69
|
+
const total = items.reduce((prev, curr) => prev + curr.quantity / (curr.standardUnitConversionFactor || 1), 0);
|
|
70
|
+
const roundedTotal = Math.round((total + Number.EPSILON) * 100) / 100;
|
|
71
|
+
if (Math.abs(total - roundedTotal) < Number.EPSILON) {
|
|
72
|
+
return roundedTotal;
|
|
73
|
+
}
|
|
74
|
+
return total;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns the total quantity in actual standard units.
|
|
78
|
+
*/
|
|
79
|
+
function calculateActualTotalStdUnits(items) {
|
|
80
|
+
return items.reduce((prev, curr) => prev + curr.quantity / (curr.actualStandardUnitConversionFactor || 1), 0);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns the total quantity in super units.
|
|
84
|
+
*/
|
|
85
|
+
function calculateTotalSuperUnits(items) {
|
|
86
|
+
return items.reduce((prev, curr) => prev + curr.quantity / (curr.superUnitConversionFactor || 1), 0);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Returns the total quantity in additional units.
|
|
90
|
+
*/
|
|
91
|
+
function calculateTotalAdditionalUnits(items) {
|
|
92
|
+
return items.reduce((prev, curr) => {
|
|
93
|
+
if (!curr.additionalUnitConversionFactor)
|
|
94
|
+
return prev;
|
|
95
|
+
return prev + curr.quantity / curr.additionalUnitConversionFactor;
|
|
96
|
+
}, 0);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get the compare value for a scheme based on its constraint type.
|
|
100
|
+
* Uses FE superset with 6 constraint types.
|
|
101
|
+
*/
|
|
102
|
+
function getCategorySchemeCompareValue(constraintType, totalQuantity, totalAmount, totalStdUnits, actualStdUnits, totalSuperUnits, totalAdditionalUnits) {
|
|
103
|
+
switch (constraintType) {
|
|
104
|
+
case enums_1.SchemeConstraintType.QUANTITY:
|
|
105
|
+
return totalQuantity;
|
|
106
|
+
case enums_1.SchemeConstraintType.AMOUNT:
|
|
107
|
+
return totalAmount;
|
|
108
|
+
case enums_1.SchemeConstraintType.STD_UNIT:
|
|
109
|
+
return totalStdUnits;
|
|
110
|
+
case enums_1.SchemeConstraintType.ACTUAL_STD_UNIT:
|
|
111
|
+
return actualStdUnits;
|
|
112
|
+
case enums_1.SchemeConstraintType.SUPER_UNIT:
|
|
113
|
+
return totalSuperUnits;
|
|
114
|
+
case enums_1.SchemeConstraintType.ADDITIONAL_UNIT:
|
|
115
|
+
return totalAdditionalUnits;
|
|
116
|
+
default:
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=compare-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare-value.js","sourceRoot":"","sources":["../../src/helpers/compare-value.ts"],"names":[],"mappings":";;AAOA,gEAaC;AASD,4DAqBC;AAOD,wDAEC;AAKD,oDAEC;AAKD,wDAUC;AAKD,oEAKC;AAKD,4DAKC;AAKD,sEAKC;AAMD,sEAyBC;AA9ID,0CAAsD;AAGtD;;;GAGG;AACH,SAAgB,0BAA0B,CACxC,IAA0B,EAC1B,YAAY,GAAG,KAAK;IAEpB,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IAEhF,MAAM,8BAA8B,GAAG,iCAAiC,CAAC,IAAI,CAAC,CAAC;IAE/E,IAAI,8BAA8B,EAAE,CAAC;QACnC,OAAO,8BAA8B,CAAC;IACxC,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC;IACtC,CAAC;AACH,CAAC;AAED,SAAS,iCAAiC,CAAC,IAA0B;IACnE,OAAO,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,SAAgB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AE,OAAO,IAAI,CAAC;QACtD,OAAO,IAAI,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,8BAA8B,CAAC;IACpE,CAAC,EAAE,CAAC,CAAC,CAAC;AACR,CAAC;AAED;;;GAGG;AACH,SAAgB,6BAA6B,CAC3C,cAAsB,EACtB,aAAqB,EACrB,WAAmB,EACnB,aAAqB,EACrB,cAAsB,EACtB,eAAuB,EACvB,oBAA4B;IAE5B,QAAQ,cAAc,EAAE,CAAC;QACvB,KAAK,4BAAoB,CAAC,QAAQ;YAChC,OAAO,aAAa,CAAC;QACvB,KAAK,4BAAoB,CAAC,MAAM;YAC9B,OAAO,WAAW,CAAC;QACrB,KAAK,4BAAoB,CAAC,QAAQ;YAChC,OAAO,aAAa,CAAC;QACvB,KAAK,4BAAoB,CAAC,eAAe;YACvC,OAAO,cAAc,CAAC;QACxB,KAAK,4BAAoB,CAAC,UAAU;YAClC,OAAO,eAAe,CAAC;QACzB,KAAK,4BAAoB,CAAC,eAAe;YACvC,OAAO,oBAAoB,CAAC;QAC9B;YACE,OAAO,CAAC,CAAC;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SchemePayoutType } from "../types/enums";
|
|
2
|
+
import type { Slab } from "../types/scheme";
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a constraint type is valid (one of the 6 known types).
|
|
5
|
+
* Uses FE superset: includes SUPER_UNIT and ADDITIONAL_UNIT.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isValidConstraintType(constraintType: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Checks if a compare value satisfies a slab's constraint.
|
|
10
|
+
*
|
|
11
|
+
* Bug 10 fix: maxConstraint enforcement is payout-type-aware.
|
|
12
|
+
* - For DISCOUNT, PERUNIT, MRP%, FIXED_DISCOUNT, BASKET, COUPON: ignore maxConstraint
|
|
13
|
+
* - For FOC, FOC_SLAB, PRODUCT, PRODUCT_SCHEME_NEW, TOPUP: enforce maxConstraint
|
|
14
|
+
*
|
|
15
|
+
* @param compareValue - The aggregated value to compare against the slab
|
|
16
|
+
* @param slab - The slab with constraint and optional maxConstraint
|
|
17
|
+
* @param payoutType - The scheme payout type (determines maxConstraint enforcement)
|
|
18
|
+
*/
|
|
19
|
+
export declare function checkSlabConstraint(compareValue: number, slab: Slab, payoutType?: SchemePayoutType | string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Validates that a FOC step multiplier scheme has valid configuration.
|
|
22
|
+
* Used as a guard before applying StepMultiplier calculation.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isValidFocStepMultiplierSchemeLogic(category: string, constraintType: string, payoutIn: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Validates that a continuous FOC scheme has valid configuration.
|
|
27
|
+
* Used as a guard before applying continuous FOC interpolation.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isValidContinuousSchemeLogic(category: string, constraintType: string, payoutIn: string): boolean;
|
|
30
|
+
//# sourceMappingURL=constraint-checks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraint-checks.d.ts","sourceRoot":"","sources":["../../src/helpers/constraint-checks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CASrE;AAWD;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,IAAI,EACV,UAAU,CAAC,EAAE,gBAAgB,GAAG,MAAM,GACrC,OAAO,CAWT;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CACjD,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,GACf,OAAO,CAeT;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,GACf,OAAO,CAET"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidConstraintType = isValidConstraintType;
|
|
4
|
+
exports.checkSlabConstraint = checkSlabConstraint;
|
|
5
|
+
exports.isValidFocStepMultiplierSchemeLogic = isValidFocStepMultiplierSchemeLogic;
|
|
6
|
+
exports.isValidContinuousSchemeLogic = isValidContinuousSchemeLogic;
|
|
7
|
+
const enums_1 = require("../types/enums");
|
|
8
|
+
/**
|
|
9
|
+
* Checks if a constraint type is valid (one of the 6 known types).
|
|
10
|
+
* Uses FE superset: includes SUPER_UNIT and ADDITIONAL_UNIT.
|
|
11
|
+
*/
|
|
12
|
+
function isValidConstraintType(constraintType) {
|
|
13
|
+
return (constraintType === enums_1.SchemeConstraintType.QUANTITY ||
|
|
14
|
+
constraintType === enums_1.SchemeConstraintType.AMOUNT ||
|
|
15
|
+
constraintType === enums_1.SchemeConstraintType.STD_UNIT ||
|
|
16
|
+
constraintType === enums_1.SchemeConstraintType.ACTUAL_STD_UNIT ||
|
|
17
|
+
constraintType === enums_1.SchemeConstraintType.SUPER_UNIT ||
|
|
18
|
+
constraintType === enums_1.SchemeConstraintType.ADDITIONAL_UNIT);
|
|
19
|
+
}
|
|
20
|
+
// Payout types that enforce maxConstraint on slab matching (Appendix C)
|
|
21
|
+
const MAX_CONSTRAINT_ENFORCED_TYPES = new Set([
|
|
22
|
+
enums_1.SchemePayoutType.FOC,
|
|
23
|
+
enums_1.SchemePayoutType.FOC_SLAB,
|
|
24
|
+
enums_1.SchemePayoutType.PRODUCT,
|
|
25
|
+
enums_1.SchemePayoutType.PRODUCT_SCHEME_NEW,
|
|
26
|
+
enums_1.SchemePayoutType.TOPUP,
|
|
27
|
+
]);
|
|
28
|
+
/**
|
|
29
|
+
* Checks if a compare value satisfies a slab's constraint.
|
|
30
|
+
*
|
|
31
|
+
* Bug 10 fix: maxConstraint enforcement is payout-type-aware.
|
|
32
|
+
* - For DISCOUNT, PERUNIT, MRP%, FIXED_DISCOUNT, BASKET, COUPON: ignore maxConstraint
|
|
33
|
+
* - For FOC, FOC_SLAB, PRODUCT, PRODUCT_SCHEME_NEW, TOPUP: enforce maxConstraint
|
|
34
|
+
*
|
|
35
|
+
* @param compareValue - The aggregated value to compare against the slab
|
|
36
|
+
* @param slab - The slab with constraint and optional maxConstraint
|
|
37
|
+
* @param payoutType - The scheme payout type (determines maxConstraint enforcement)
|
|
38
|
+
*/
|
|
39
|
+
function checkSlabConstraint(compareValue, slab, payoutType) {
|
|
40
|
+
if (compareValue < slab.constraint) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
// Only enforce maxConstraint for specific payout types
|
|
44
|
+
if (payoutType && MAX_CONSTRAINT_ENFORCED_TYPES.has(payoutType) && slab.maxConstraint) {
|
|
45
|
+
return compareValue <= slab.maxConstraint;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Validates that a FOC step multiplier scheme has valid configuration.
|
|
51
|
+
* Used as a guard before applying StepMultiplier calculation.
|
|
52
|
+
*/
|
|
53
|
+
function isValidFocStepMultiplierSchemeLogic(category, constraintType, payoutIn) {
|
|
54
|
+
const validCategories = ["Primary", "Secondary"];
|
|
55
|
+
const validConstraints = [
|
|
56
|
+
enums_1.SchemeConstraintType.AMOUNT,
|
|
57
|
+
enums_1.SchemeConstraintType.QUANTITY,
|
|
58
|
+
enums_1.SchemeConstraintType.STD_UNIT,
|
|
59
|
+
enums_1.SchemeConstraintType.SUPER_UNIT,
|
|
60
|
+
];
|
|
61
|
+
const validPayoutIns = ["Quantity", "Standard_Unit"];
|
|
62
|
+
return (validCategories.includes(category) &&
|
|
63
|
+
validConstraints.includes(constraintType) &&
|
|
64
|
+
validPayoutIns.includes(payoutIn));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Validates that a continuous FOC scheme has valid configuration.
|
|
68
|
+
* Used as a guard before applying continuous FOC interpolation.
|
|
69
|
+
*/
|
|
70
|
+
function isValidContinuousSchemeLogic(category, constraintType, payoutIn) {
|
|
71
|
+
return isValidFocStepMultiplierSchemeLogic(category, constraintType, payoutIn);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=constraint-checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraint-checks.js","sourceRoot":"","sources":["../../src/helpers/constraint-checks.ts"],"names":[],"mappings":";;AAOA,sDASC;AAsBD,kDAeC;AAMD,kFAmBC;AAMD,oEAMC;AA1FD,0CAAwE;AAGxE;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,cAAsB;IAC1D,OAAO,CACL,cAAc,KAAK,4BAAoB,CAAC,QAAQ;QAChD,cAAc,KAAK,4BAAoB,CAAC,MAAM;QAC9C,cAAc,KAAK,4BAAoB,CAAC,QAAQ;QAChD,cAAc,KAAK,4BAAoB,CAAC,eAAe;QACvD,cAAc,KAAK,4BAAoB,CAAC,UAAU;QAClD,cAAc,KAAK,4BAAoB,CAAC,eAAe,CACxD,CAAC;AACJ,CAAC;AAED,wEAAwE;AACxE,MAAM,6BAA6B,GAAwB,IAAI,GAAG,CAAC;IACjE,wBAAgB,CAAC,GAAG;IACpB,wBAAgB,CAAC,QAAQ;IACzB,wBAAgB,CAAC,OAAO;IACxB,wBAAgB,CAAC,kBAAkB;IACnC,wBAAgB,CAAC,KAAK;CACvB,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,SAAgB,mBAAmB,CACjC,YAAoB,EACpB,IAAU,EACV,UAAsC;IAEtC,IAAI,YAAY,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,uDAAuD;IACvD,IAAI,UAAU,IAAI,6BAA6B,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QACtF,OAAO,YAAY,IAAI,IAAI,CAAC,aAAa,CAAC;IAC5C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,SAAgB,mCAAmC,CACjD,QAAgB,EAChB,cAAsB,EACtB,QAAgB;IAEhB,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IACjD,MAAM,gBAAgB,GAAG;QACvB,4BAAoB,CAAC,MAAM;QAC3B,4BAAoB,CAAC,QAAQ;QAC7B,4BAAoB,CAAC,QAAQ;QAC7B,4BAAoB,CAAC,UAAU;KAChC,CAAC;IACF,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAErD,OAAO,CACL,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACjC,gBAA6B,CAAC,QAAQ,CAAC,cAAc,CAAC;QACvD,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAClC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,4BAA4B,CAC1C,QAAgB,EAChB,cAAsB,EACtB,QAAgB;IAEhB,OAAO,mCAAmC,CAAC,QAAQ,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./calc-type-checks";
|
|
2
|
+
export * from "./payout-type-checks";
|
|
3
|
+
export * from "./constraint-checks";
|
|
4
|
+
export * from "./qualifier-checks";
|
|
5
|
+
export * from "./scheme-applicability";
|
|
6
|
+
export * from "./math";
|
|
7
|
+
export * from "./compare-value";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./calc-type-checks"), exports);
|
|
18
|
+
__exportStar(require("./payout-type-checks"), exports);
|
|
19
|
+
__exportStar(require("./constraint-checks"), exports);
|
|
20
|
+
__exportStar(require("./qualifier-checks"), exports);
|
|
21
|
+
__exportStar(require("./scheme-applicability"), exports);
|
|
22
|
+
__exportStar(require("./math"), exports);
|
|
23
|
+
__exportStar(require("./compare-value"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,uDAAqC;AACrC,sDAAoC;AACpC,qDAAmC;AACnC,yDAAuC;AACvC,yCAAuB;AACvB,kDAAgC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Slab } from "../types/scheme";
|
|
2
|
+
/**
|
|
3
|
+
* Calculate discount value from a base value and percent.
|
|
4
|
+
* Pure equivalent of BaseOrderItem.calculateDiscount().
|
|
5
|
+
*/
|
|
6
|
+
export declare function calculateDiscount(baseValue: number, discountPercent: number | null): number;
|
|
7
|
+
/**
|
|
8
|
+
* Calculate FOC discount value — same formula but without toFixed rounding.
|
|
9
|
+
* Pure equivalent of BaseOrderItem.calculateFocDiscount().
|
|
10
|
+
*/
|
|
11
|
+
export declare function calculateFocDiscount(baseValue: number, discountPercent: number | null): number;
|
|
12
|
+
/**
|
|
13
|
+
* Calculate discount percent from base value and discount value.
|
|
14
|
+
* Pure equivalent of BaseOrderItem.calculateDiscountPercent().
|
|
15
|
+
*/
|
|
16
|
+
export declare function calculateDiscountPercent(baseValue: number, discountValue: number | null): number;
|
|
17
|
+
/**
|
|
18
|
+
* Calculate after-markup discount value.
|
|
19
|
+
* Pure equivalent of BaseOrderItem.calculateAfterMarkupDiscountValue().
|
|
20
|
+
*/
|
|
21
|
+
export declare function calculateAfterMarkupDiscountValue(baseValue: number, discountPercent: number | null): number;
|
|
22
|
+
/**
|
|
23
|
+
* Calculate markup discount.
|
|
24
|
+
* Pure equivalent of BaseOrderItem.calculateMarkupDiscount().
|
|
25
|
+
*/
|
|
26
|
+
export declare function calculateMarkupDiscount(baseValue: number, discountPercent: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Calculate step multiplier discount for FOC schemes.
|
|
29
|
+
* Handles both multiplierStepSize and fallback ratio-based calculation.
|
|
30
|
+
*/
|
|
31
|
+
export declare function calculateStepMultiplierDiscount(purchasedQty: number, slab: Slab): number;
|
|
32
|
+
/**
|
|
33
|
+
* Calculate continuous FOC payout using linear interpolation.
|
|
34
|
+
* Formula: payout + floor((payout / constraint) * (compareValue - constraint))
|
|
35
|
+
*/
|
|
36
|
+
export declare function calculatePayoutForFocContinuousScheme(constraint: number, payout: number, compareValue: number): number;
|
|
37
|
+
/**
|
|
38
|
+
* Format a price to 2 decimal places.
|
|
39
|
+
*/
|
|
40
|
+
export declare function formatPrice(value: number): string;
|
|
41
|
+
/**
|
|
42
|
+
* Fixed decimal precision.
|
|
43
|
+
*/
|
|
44
|
+
export declare function fixedDecimal(value: number, decimals: number): number;
|
|
45
|
+
/**
|
|
46
|
+
* Clamp a value to be at least 0.
|
|
47
|
+
* Bug 7 fix: prevents negative discount values.
|
|
48
|
+
*/
|
|
49
|
+
export declare function clampNonNegative(value: number): number;
|
|
50
|
+
//# sourceMappingURL=math.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../src/helpers/math.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAE3F;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAE9F;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAEhG;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAE3G;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAI1F;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAgBxF;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,CACnD,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,GACnB,MAAM,CAGR;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEtD"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateDiscount = calculateDiscount;
|
|
4
|
+
exports.calculateFocDiscount = calculateFocDiscount;
|
|
5
|
+
exports.calculateDiscountPercent = calculateDiscountPercent;
|
|
6
|
+
exports.calculateAfterMarkupDiscountValue = calculateAfterMarkupDiscountValue;
|
|
7
|
+
exports.calculateMarkupDiscount = calculateMarkupDiscount;
|
|
8
|
+
exports.calculateStepMultiplierDiscount = calculateStepMultiplierDiscount;
|
|
9
|
+
exports.calculatePayoutForFocContinuousScheme = calculatePayoutForFocContinuousScheme;
|
|
10
|
+
exports.formatPrice = formatPrice;
|
|
11
|
+
exports.fixedDecimal = fixedDecimal;
|
|
12
|
+
exports.clampNonNegative = clampNonNegative;
|
|
13
|
+
/**
|
|
14
|
+
* Calculate discount value from a base value and percent.
|
|
15
|
+
* Pure equivalent of BaseOrderItem.calculateDiscount().
|
|
16
|
+
*/
|
|
17
|
+
function calculateDiscount(baseValue, discountPercent) {
|
|
18
|
+
return Number((((baseValue || 0) * (discountPercent || 0)) / 100).toFixed(2));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Calculate FOC discount value — same formula but without toFixed rounding.
|
|
22
|
+
* Pure equivalent of BaseOrderItem.calculateFocDiscount().
|
|
23
|
+
*/
|
|
24
|
+
function calculateFocDiscount(baseValue, discountPercent) {
|
|
25
|
+
return Number(((baseValue || 0) * (discountPercent ?? 0)) / 100);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Calculate discount percent from base value and discount value.
|
|
29
|
+
* Pure equivalent of BaseOrderItem.calculateDiscountPercent().
|
|
30
|
+
*/
|
|
31
|
+
function calculateDiscountPercent(baseValue, discountValue) {
|
|
32
|
+
return Number((((discountValue || 0) / (baseValue || 0)) * 100).toFixed(2));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Calculate after-markup discount value.
|
|
36
|
+
* Pure equivalent of BaseOrderItem.calculateAfterMarkupDiscountValue().
|
|
37
|
+
*/
|
|
38
|
+
function calculateAfterMarkupDiscountValue(baseValue, discountPercent) {
|
|
39
|
+
return Number(((baseValue || 0) / (1 + (discountPercent || 0) / 100)).toFixed(2));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Calculate markup discount.
|
|
43
|
+
* Pure equivalent of BaseOrderItem.calculateMarkupDiscount().
|
|
44
|
+
*/
|
|
45
|
+
function calculateMarkupDiscount(baseValue, discountPercent) {
|
|
46
|
+
const discountValue = discountPercent / 100;
|
|
47
|
+
const markUpValue = baseValue / (1 + discountValue);
|
|
48
|
+
return baseValue - markUpValue;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Calculate step multiplier discount for FOC schemes.
|
|
52
|
+
* Handles both multiplierStepSize and fallback ratio-based calculation.
|
|
53
|
+
*/
|
|
54
|
+
function calculateStepMultiplierDiscount(purchasedQty, slab) {
|
|
55
|
+
if (slab.multiplierStepSize && slab.multiplierStepSize > 0) {
|
|
56
|
+
const payoutPerAdditionalStep = (slab.payout * slab.multiplierStepSize) / slab.constraint;
|
|
57
|
+
const stepAboveBase = Math.floor((purchasedQty - slab.constraint) / slab.multiplierStepSize);
|
|
58
|
+
const payoutAboveBase = stepAboveBase * payoutPerAdditionalStep;
|
|
59
|
+
const totalPayout = slab.payout + payoutAboveBase;
|
|
60
|
+
return Math.floor(totalPayout);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const ratio = slab.payout / slab.constraint;
|
|
64
|
+
const multiples = Math.floor(purchasedQty / slab.constraint);
|
|
65
|
+
const eligibleQty = multiples * slab.constraint;
|
|
66
|
+
return Math.floor(eligibleQty * ratio);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Calculate continuous FOC payout using linear interpolation.
|
|
71
|
+
* Formula: payout + floor((payout / constraint) * (compareValue - constraint))
|
|
72
|
+
*/
|
|
73
|
+
function calculatePayoutForFocContinuousScheme(constraint, payout, compareValue) {
|
|
74
|
+
const payoutValue = (payout / constraint) * (compareValue - constraint);
|
|
75
|
+
return payout + Math.floor(Number(payoutValue));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Format a price to 2 decimal places.
|
|
79
|
+
*/
|
|
80
|
+
function formatPrice(value) {
|
|
81
|
+
return value.toFixed(2);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Fixed decimal precision.
|
|
85
|
+
*/
|
|
86
|
+
function fixedDecimal(value, decimals) {
|
|
87
|
+
return Number(value.toFixed(decimals));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Clamp a value to be at least 0.
|
|
91
|
+
* Bug 7 fix: prevents negative discount values.
|
|
92
|
+
*/
|
|
93
|
+
function clampNonNegative(value) {
|
|
94
|
+
return Math.max(0, value);
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=math.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../src/helpers/math.ts"],"names":[],"mappings":";;AAMA,8CAEC;AAMD,oDAEC;AAMD,4DAEC;AAMD,8EAEC;AAMD,0DAIC;AAMD,0EAgBC;AAMD,sFAOC;AAKD,kCAEC;AA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EG;AACH,SAAgB,YAAY,CAAC,KAAa,EAAE,QAAgB;IAC1D,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AACzC,CAAC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,KAAa;IAC5C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SchemePayoutType } from "../types/enums";
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether a scheme payout type involves free-of-cost product.
|
|
4
|
+
* Matches: FOC, FOCSlab, Product, CouponScheme, ProductSchemeNew
|
|
5
|
+
* Accepts string to be interoperable with both backend and frontend enum types.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isFocTypePayoutScheme(payoutType: SchemePayoutType | string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Checks if scheme payout type is PercentageDiscountOnMRP.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isPercentDiscountOnMRPTypePayoutScheme(payoutType: SchemePayoutType | string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Checks if scheme payout type is a product-based type
|
|
14
|
+
* (PRODUCT, PRODUCT_SCHEME_NEW, COUPON).
|
|
15
|
+
*/
|
|
16
|
+
export declare function isProductSchemePayoutType(payoutType: SchemePayoutType | string): boolean;
|
|
17
|
+
//# sourceMappingURL=payout-type-checks.d.ts.map
|