@parv0888/scheme-engine 0.1.0
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/discount-application.d.ts.map +1 -0
- package/dist/calculators/discount-application.js +174 -0
- package/dist/calculators/discount-application.js.map +1 -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/esm/calculators/discount-application.js +170 -0
- package/dist/esm/calculators/discount-application.js.map +1 -0
- package/dist/esm/calculators/index.js +176 -0
- package/dist/esm/calculators/index.js.map +1 -0
- package/dist/esm/calculators/payout-types/article.js +70 -0
- package/dist/esm/calculators/payout-types/article.js.map +1 -0
- package/dist/esm/calculators/payout-types/basket.js +105 -0
- package/dist/esm/calculators/payout-types/basket.js.map +1 -0
- package/dist/esm/calculators/payout-types/coupon.js +71 -0
- package/dist/esm/calculators/payout-types/coupon.js.map +1 -0
- package/dist/esm/calculators/payout-types/discount.js +107 -0
- package/dist/esm/calculators/payout-types/discount.js.map +1 -0
- package/dist/esm/calculators/payout-types/fixed-discount.js +62 -0
- package/dist/esm/calculators/payout-types/fixed-discount.js.map +1 -0
- package/dist/esm/calculators/payout-types/foc.js +127 -0
- package/dist/esm/calculators/payout-types/foc.js.map +1 -0
- package/dist/esm/calculators/payout-types/mrp-percentage.js +74 -0
- package/dist/esm/calculators/payout-types/mrp-percentage.js.map +1 -0
- package/dist/esm/calculators/payout-types/nlp.js +56 -0
- package/dist/esm/calculators/payout-types/nlp.js.map +1 -0
- package/dist/esm/calculators/payout-types/per-unit.js +91 -0
- package/dist/esm/calculators/payout-types/per-unit.js.map +1 -0
- package/dist/esm/calculators/payout-types/product-new.js +82 -0
- package/dist/esm/calculators/payout-types/product-new.js.map +1 -0
- package/dist/esm/calculators/payout-types/product.js +70 -0
- package/dist/esm/calculators/payout-types/product.js.map +1 -0
- package/dist/esm/calculators/payout-types/topup.js +43 -0
- package/dist/esm/calculators/payout-types/topup.js.map +1 -0
- package/dist/esm/calculators/slab-matcher.js +64 -0
- package/dist/esm/calculators/slab-matcher.js.map +1 -0
- package/dist/esm/helpers/calc-type-checks.js +30 -0
- package/dist/esm/helpers/calc-type-checks.js.map +1 -0
- package/dist/esm/helpers/compare-value.js +109 -0
- package/dist/esm/helpers/compare-value.js.map +1 -0
- package/dist/esm/helpers/constraint-checks.js +67 -0
- package/dist/esm/helpers/constraint-checks.js.map +1 -0
- package/dist/esm/helpers/index.js +8 -0
- package/dist/esm/helpers/index.js.map +1 -0
- package/dist/esm/helpers/math.js +84 -0
- package/dist/esm/helpers/math.js.map +1 -0
- package/dist/esm/helpers/payout-type-checks.js +29 -0
- package/dist/esm/helpers/payout-type-checks.js.map +1 -0
- package/dist/esm/helpers/qualifier-checks.js +188 -0
- package/dist/esm/helpers/qualifier-checks.js.map +1 -0
- package/dist/esm/helpers/scheme-applicability.js +93 -0
- package/dist/esm/helpers/scheme-applicability.js.map +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types/applied-scheme.js +19 -0
- package/dist/esm/types/applied-scheme.js.map +1 -0
- package/dist/esm/types/enums.js +115 -0
- package/dist/esm/types/enums.js.map +1 -0
- package/dist/esm/types/index.js +5 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/item-props.js +2 -0
- package/dist/esm/types/item-props.js.map +1 -0
- package/dist/esm/types/scheme.js +2 -0
- package/dist/esm/types/scheme.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 +29 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixed-discount.js","sourceRoot":"","sources":["../../../../src/calculators/payout-types/fixed-discount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAA0B,MAAM,iBAAiB,CAAC;AAkB3E;;;;;;;;GAQG;AACH,MAAM,UAAU,4BAA4B,CAC1C,KAAmC;IAEnC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IACtF,MAAM,MAAM,GAAG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";
|
|
3
|
+
import { isPayoutCalcTypeStep, isPayoutCalcTypeContinuous, isPayoutCalcTypeStepMultiplier } from "../../helpers/calc-type-checks";
|
|
4
|
+
import { isValidConstraintType, isValidFocStepMultiplierSchemeLogic } from "../../helpers/constraint-checks";
|
|
5
|
+
import { calculateStepMultiplierDiscount, calculatePayoutForFocContinuousScheme } from "../../helpers/math";
|
|
6
|
+
import { findMatchingSlab } from "../slab-matcher";
|
|
7
|
+
/**
|
|
8
|
+
* Calculate payout for FOC and FOC_SLAB payout types.
|
|
9
|
+
* Supports: Step, Continuous, StepMultiplier.
|
|
10
|
+
*
|
|
11
|
+
* FOC: focPercent = itemDiscountPercent (the free qty percentage)
|
|
12
|
+
* FOC_SLAB continuous: focPercent = Math.floor(payout × compareValue)
|
|
13
|
+
* FOC continuous: focPercent = slab.payout (or interpolated)
|
|
14
|
+
* FOC StepMultiplier: focPercent = calculateStepMultiplierDiscount(compareValue, slab)
|
|
15
|
+
*/
|
|
16
|
+
export function calculateFocPayout(input) {
|
|
17
|
+
const { scheme, compareValue, applicableProducts, isMrpBilling, companyUsesStepfocSchemeInDms = false, applyContinuousSchemeLogic = false, applyStepMultiplierSchemeLogic = false, } = input;
|
|
18
|
+
const isFocSlab = scheme.payoutType === SchemePayoutType.FOC_SLAB;
|
|
19
|
+
const result = createEmptySlabResult(scheme.payoutType);
|
|
20
|
+
result.targetMethod = "setFocScheme";
|
|
21
|
+
if (!isValidConstraintType(scheme.constraintType)) {
|
|
22
|
+
result.warnings.push(`Constraint type not matching: ${scheme.constraintType}`);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
const slabs = [...scheme.slabs].sort((a, b) => (a.constraint < b.constraint ? 1 : -1));
|
|
26
|
+
if (slabs.length === 0) {
|
|
27
|
+
result.warnings.push("Slab list is empty");
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
const payoutCalcType = scheme.payoutCalculationType;
|
|
31
|
+
const matcherParams = {
|
|
32
|
+
slabs,
|
|
33
|
+
compareValue,
|
|
34
|
+
applicableProducts,
|
|
35
|
+
payoutType: scheme.payoutType,
|
|
36
|
+
discountOn: scheme.discountOn ?? null,
|
|
37
|
+
};
|
|
38
|
+
// ─── Step ──────────────────────────────────────────────────────
|
|
39
|
+
if (isPayoutCalcTypeStep(payoutCalcType)) {
|
|
40
|
+
const match = findMatchingSlab(matcherParams);
|
|
41
|
+
if (!match)
|
|
42
|
+
return result;
|
|
43
|
+
const { slab } = match;
|
|
44
|
+
const stepDiscountPercent = isMrpBilling ? slab.mrpPayout : slab.payout;
|
|
45
|
+
const discountAmountTotal = (stepDiscountPercent * slab.constraint) / 100;
|
|
46
|
+
let itemDiscountPercent;
|
|
47
|
+
if (companyUsesStepfocSchemeInDms) {
|
|
48
|
+
itemDiscountPercent = stepDiscountPercent;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const employeeWiseRemainingBudget = scheme.employeeWiseRemainingBudget;
|
|
52
|
+
if ((employeeWiseRemainingBudget || employeeWiseRemainingBudget === 0) &&
|
|
53
|
+
compareValue > employeeWiseRemainingBudget) {
|
|
54
|
+
itemDiscountPercent = ((employeeWiseRemainingBudget || 0) * 100) / (compareValue || 1);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
itemDiscountPercent = ((discountAmountTotal || 0) * 100) / (compareValue || 1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
result.matched = true;
|
|
61
|
+
result.matchedSlabId = slab.id;
|
|
62
|
+
result.focPercent = itemDiscountPercent;
|
|
63
|
+
result.discountPercent = itemDiscountPercent;
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
// ─── Continuous FOC_SLAB ───────────────────────────────────────
|
|
67
|
+
if (isPayoutCalcTypeContinuous(payoutCalcType) && isFocSlab) {
|
|
68
|
+
const match = findMatchingSlab(matcherParams);
|
|
69
|
+
if (!match)
|
|
70
|
+
return result;
|
|
71
|
+
const { slab } = match;
|
|
72
|
+
const stepDiscountPercent = isMrpBilling ? slab.mrpPayout : slab.payout;
|
|
73
|
+
const itemDiscountPercent = Math.floor(stepDiscountPercent * compareValue);
|
|
74
|
+
result.matched = true;
|
|
75
|
+
result.matchedSlabId = slab.id;
|
|
76
|
+
result.focPercent = itemDiscountPercent;
|
|
77
|
+
result.discountPercent = itemDiscountPercent;
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
// ─── Continuous FOC ────────────────────────────────────────────
|
|
81
|
+
if (isPayoutCalcTypeContinuous(payoutCalcType)) {
|
|
82
|
+
const match = findMatchingSlab(matcherParams);
|
|
83
|
+
if (!match)
|
|
84
|
+
return result;
|
|
85
|
+
const { slab } = match;
|
|
86
|
+
let itemDiscountPercent;
|
|
87
|
+
// Check if continuous FOC interpolation should be applied
|
|
88
|
+
const canInterpolate = applyContinuousSchemeLogic &&
|
|
89
|
+
isValidFocStepMultiplierSchemeLogic(scheme.category, scheme.constraintType, scheme.payoutIn) &&
|
|
90
|
+
compareValue !== slab.constraint;
|
|
91
|
+
if (canInterpolate) {
|
|
92
|
+
itemDiscountPercent = isMrpBilling
|
|
93
|
+
? slab.mrpPayout
|
|
94
|
+
: calculatePayoutForFocContinuousScheme(slab.constraint, slab.payout, compareValue);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
itemDiscountPercent = isMrpBilling ? slab.mrpPayout : slab.payout;
|
|
98
|
+
}
|
|
99
|
+
result.matched = true;
|
|
100
|
+
result.matchedSlabId = slab.id;
|
|
101
|
+
result.focPercent = itemDiscountPercent;
|
|
102
|
+
result.discountPercent = itemDiscountPercent;
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
// ─── Step Multiplier ───────────────────────────────────────────
|
|
106
|
+
if (isPayoutCalcTypeStepMultiplier(payoutCalcType)) {
|
|
107
|
+
if (!applyStepMultiplierSchemeLogic || !isValidFocStepMultiplierSchemeLogic(scheme.category, scheme.constraintType, scheme.payoutIn)) {
|
|
108
|
+
result.warnings.push("Step multiplier logic not applicable for this scheme configuration");
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
const match = findMatchingSlab(matcherParams);
|
|
112
|
+
if (!match)
|
|
113
|
+
return result;
|
|
114
|
+
const { slab } = match;
|
|
115
|
+
const itemDiscountPercent = isMrpBilling
|
|
116
|
+
? slab.mrpPayout
|
|
117
|
+
: calculateStepMultiplierDiscount(compareValue, slab);
|
|
118
|
+
result.matched = true;
|
|
119
|
+
result.matchedSlabId = slab.id;
|
|
120
|
+
result.focPercent = itemDiscountPercent;
|
|
121
|
+
result.discountPercent = itemDiscountPercent;
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
result.warnings.push(`No matching calculation type found: ${payoutCalcType}`);
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=foc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foc.js","sourceRoot":"","sources":["../../../../src/calculators/payout-types/foc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAClI,OAAO,EAAE,qBAAqB,EAAE,mCAAmC,EAAE,MAAM,iCAAiC,CAAC;AAC7G,OAAO,EAAE,+BAA+B,EAAE,qCAAqC,EAAE,MAAM,oBAAoB,CAAC;AAC5G,OAAO,EAAE,gBAAgB,EAA0B,MAAM,iBAAiB,CAAC;AAqB3E;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAyB;IAC1D,MAAM,EACJ,MAAM,EACN,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,6BAA6B,GAAG,KAAK,EACrC,0BAA0B,GAAG,KAAK,EAClC,8BAA8B,GAAG,KAAK,GACvC,GAAG,KAAK,CAA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AC;QAC/B,MAAM,CAAC,UAAU,GAAG,mBAAmB,CAAC;QACxC,MAAM,CAAC,eAAe,GAAG,mBAAmB,CAAC;QAC7C,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,kEAAkE;IAClE,IAAI,8BAA8B,CAAC,cAAc,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC,8BAA8B,IAAI,CAAC,mCAAmC,CACzE,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,cAAc,EACrB,MAAM,CAAC,QAAQ,CAChB,EAAE,CAAC;YACF,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,oEAAoE,CAAC,CAAC;YAC3F,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,KAAK,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK;YAAE,OAAO,MAAM,CAAC;QAE1B,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;QACvB,MAAM,mBAAmB,GAAG,YAAY;YACtC,CAAC,CAAC,IAAI,CAAC,SAAS;YAChB,CAAC,CAAC,+BAA+B,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAExD,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,EAAE,CAAC;QAC/B,MAAM,CAAC,UAAU,GAAG,mBAAmB,CAAC;QACxC,MAAM,CAAC,eAAe,GAAG,mBAAmB,CAAC;QAC7C,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,uCAAuC,cAAc,EAAE,CAAC,CAAC;IAC9E,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { SchemePayoutType, AdditionalCalculationLogic } from "../../types/enums";
|
|
2
|
+
import { createEmptySlabResult } from "../../types/applied-scheme";
|
|
3
|
+
import { isPayoutCalcTypeContinuous, isPayoutCalcTypeStep } from "../../helpers/calc-type-checks";
|
|
4
|
+
import { isValidConstraintType } from "../../helpers/constraint-checks";
|
|
5
|
+
import { findMatchingSlab } from "../slab-matcher";
|
|
6
|
+
/**
|
|
7
|
+
* Calculate discount payout for PercentageDiscountOnMRP payout type.
|
|
8
|
+
*
|
|
9
|
+
* Bug 1 fix: Accepts both continuous AND step (previously step was dead code).
|
|
10
|
+
*
|
|
11
|
+
* With ACL=DISCOUNT_VALUE_SUBTRACTED_FROM_PRICE:
|
|
12
|
+
* 1. discountOnMRP = MRP × payout / 100
|
|
13
|
+
* 2. discountedPrice = MRP − discountOnMRP
|
|
14
|
+
* 3. discountedPriceExcTax = discountedPrice / (1 + tax/100)
|
|
15
|
+
* 4. Continuous: finalDiscountValue = (PTR − discountedPriceExcTax) × compareValue
|
|
16
|
+
* 5. Step: finalDiscountValue = (PTR − discountedPriceExcTax) × slab.constraint
|
|
17
|
+
* 6. finalDiscountPercent = finalDiscountValue / (PTR × compareValue) × 100
|
|
18
|
+
*/
|
|
19
|
+
export function calculateMrpPercentageDiscountPayout(input) {
|
|
20
|
+
const { scheme, compareValue, applicableProducts, isMrpBilling, productMrp, productPtr, totalTaxPercentage } = input;
|
|
21
|
+
const result = createEmptySlabResult(SchemePayoutType.PERCENTAGE_DISCOUNT_ON_MRP);
|
|
22
|
+
if (!isValidConstraintType(scheme.constraintType)) {
|
|
23
|
+
result.warnings.push(`Invalid constraint type: ${scheme.constraintType}`);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
const slabs = [...scheme.slabs].sort((a, b) => (a.constraint < b.constraint ? 1 : -1));
|
|
27
|
+
if (slabs.length === 0) {
|
|
28
|
+
result.warnings.push("Slab list is empty");
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
const payoutCalcType = scheme.payoutCalculationType;
|
|
32
|
+
// Bug 1 fix: accept both continuous AND step
|
|
33
|
+
if (!isPayoutCalcTypeContinuous(payoutCalcType) && !isPayoutCalcTypeStep(payoutCalcType)) {
|
|
34
|
+
result.warnings.push(`No matching calculation type found: ${payoutCalcType}`);
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
const matcherParams = {
|
|
38
|
+
slabs,
|
|
39
|
+
compareValue,
|
|
40
|
+
applicableProducts,
|
|
41
|
+
payoutType: SchemePayoutType.PERCENTAGE_DISCOUNT_ON_MRP,
|
|
42
|
+
discountOn: scheme.discountOn ?? null,
|
|
43
|
+
};
|
|
44
|
+
const match = findMatchingSlab(matcherParams);
|
|
45
|
+
if (!match)
|
|
46
|
+
return result;
|
|
47
|
+
const { slab } = match;
|
|
48
|
+
const itemDiscountPercent = isMrpBilling ? slab.mrpPayout : slab.payout;
|
|
49
|
+
let finalDiscountPercent = itemDiscountPercent;
|
|
50
|
+
if (scheme.additionalCalculationLogic === AdditionalCalculationLogic.DISCOUNT_VALUE_SUBTRACTED_FROM_PRICE) {
|
|
51
|
+
const discountOnMRP = (productMrp * itemDiscountPercent) / 100;
|
|
52
|
+
const discountedPrice = productMrp - discountOnMRP;
|
|
53
|
+
const discountedPriceExcTax = Number((discountedPrice / (1 + (totalTaxPercentage ?? 0) / 100)).toFixed(2));
|
|
54
|
+
if (isPayoutCalcTypeContinuous(payoutCalcType)) {
|
|
55
|
+
const finalDiscountValue = (productPtr - discountedPriceExcTax) * compareValue;
|
|
56
|
+
const totalPtr = productPtr * compareValue;
|
|
57
|
+
finalDiscountPercent = totalPtr > 0 ? (finalDiscountValue / totalPtr) * 100 : 0;
|
|
58
|
+
}
|
|
59
|
+
else if (isPayoutCalcTypeStep(payoutCalcType)) {
|
|
60
|
+
const finalDiscountValue = (productPtr - discountedPriceExcTax) * slab.constraint;
|
|
61
|
+
const totalPtr = productPtr * compareValue;
|
|
62
|
+
finalDiscountPercent = totalPtr > 0 ? (finalDiscountValue / totalPtr) * 100 : 0;
|
|
63
|
+
if (finalDiscountPercent < 0) {
|
|
64
|
+
finalDiscountPercent = 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
result.matched = true;
|
|
69
|
+
result.matchedSlabId = slab.id;
|
|
70
|
+
result.discountPercent = finalDiscountPercent;
|
|
71
|
+
result.targetMethod = "setDiscountScheme";
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=mrp-percentage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mrp-percentage.js","sourceRoot":"","sources":["../../../../src/calculators/payout-types/mrp-percentage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAClG,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAA0B,MAAM,iBAAiB,CAAC;AAoB3E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oCAAoC,CAClD,KAAmC;IAEnC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,GAAG,KAAK,CAAC;IACrH,MAAM,MAAM,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,0BAA0B,CAAC,CAAC;IAElF,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;QAClD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,4BAA4B,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;QAC1E,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CA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{ isPayoutCalcTypeContinuous, isPayoutCalcTypeStep } from "../../helpers/calc-type-checks";
|
|
4
|
+
import { isValidConstraintType } from "../../helpers/constraint-checks";
|
|
5
|
+
import { findMatchingSlab } from "../slab-matcher";
|
|
6
|
+
export function calculateNlpPayout(input) {
|
|
7
|
+
if (!input) {
|
|
8
|
+
const result = createEmptySlabResult(SchemePayoutType.NLP);
|
|
9
|
+
result.warnings.push("NLP payout type is not yet implemented");
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
const { scheme, compareValue, totalAmount, applicableProducts, productPtr } = input;
|
|
13
|
+
const result = createEmptySlabResult(SchemePayoutType.NLP);
|
|
14
|
+
if (!isValidConstraintType(scheme.constraintType)) {
|
|
15
|
+
result.warnings.push(`Invalid constraint type: ${scheme.constraintType}`);
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
const slabs = [...scheme.slabs].sort((a, b) => b.constraint - a.constraint);
|
|
19
|
+
if (slabs.length === 0) {
|
|
20
|
+
result.warnings.push("Slab list is empty");
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
const matcherParams = {
|
|
24
|
+
slabs,
|
|
25
|
+
compareValue,
|
|
26
|
+
applicableProducts,
|
|
27
|
+
payoutType: SchemePayoutType.NLP,
|
|
28
|
+
discountOn: scheme.discountOn ?? null,
|
|
29
|
+
};
|
|
30
|
+
const payoutCalcType = scheme.payoutCalculationType;
|
|
31
|
+
const isContinuous = isPayoutCalcTypeContinuous(payoutCalcType);
|
|
32
|
+
const isStep = isPayoutCalcTypeStep(payoutCalcType);
|
|
33
|
+
if (isContinuous || isStep) {
|
|
34
|
+
// Fixtures only require continuous; keep step supported by using the same matched slab.
|
|
35
|
+
const match = findMatchingSlab(matcherParams);
|
|
36
|
+
if (!match)
|
|
37
|
+
return result;
|
|
38
|
+
const { slab } = match;
|
|
39
|
+
const nlpPrice = slab.payout;
|
|
40
|
+
const unitPrice = productPtr;
|
|
41
|
+
const perUnitDiscount = Math.max(0, unitPrice - nlpPrice);
|
|
42
|
+
const discountValue = perUnitDiscount * compareValue;
|
|
43
|
+
let effectivePercent = 0;
|
|
44
|
+
if (totalAmount > 0) {
|
|
45
|
+
effectivePercent = (discountValue / totalAmount) * 100;
|
|
46
|
+
}
|
|
47
|
+
result.matched = true;
|
|
48
|
+
result.matchedSlabId = slab.id;
|
|
49
|
+
result.discountPercent = effectivePercent;
|
|
50
|
+
result.targetMethod = "setDiscountScheme";
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
result.warnings.push(`No matching calculation type found: ${payoutCalcType}`);
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=nlp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nlp.js","sourceRoot":"","sources":["../../../../src/calculators/payout-types/nlp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAClG,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAA0B,MAAM,iBAAiB,CAAC;AAsB3E,MAAM,UAAU,kBAAkB,CAAC,KAA0B;IAC3D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,MAAM,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC3D,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;QAC/D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IACpF,MAAM,MAAM,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,GAAG,C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AG,QAAQ,CAAC,CAAC;QAE1D,MAAM,aAAa,GAAG,eAAe,GAAG,YAAY,CAAC;QACrD,IAAI,gBAAgB,GAAG,CAAC,CAAC;QACzB,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;YACpB,gBAAgB,GAAG,CAAC,aAAa,GAAG,WAAW,CAAC,GAAG,GAAG,CAAC;QACzD,CAAC;QAED,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,EAAE,CAAC;QAC/B,MAAM,CAAC,eAAe,GAAG,gBAAgB,CAAC;QAC1C,MAAM,CAAC,YAAY,GAAG,mBAAmB,CAAC;QAC1C,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,uCAAuC,cAAc,EAAE,CAAC,CAAC;IAC9E,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { SchemePayoutType, SchemeConstraintType, AdditionalCalculationLogic } from "../../types/enums";
|
|
2
|
+
import { createEmptySlabResult } from "../../types/applied-scheme";
|
|
3
|
+
import { isValidConstraintType } from "../../helpers/constraint-checks";
|
|
4
|
+
import { findMatchingSlab } from "../slab-matcher";
|
|
5
|
+
/**
|
|
6
|
+
* Calculate discount payout for PerUnitDiscount payout type.
|
|
7
|
+
*
|
|
8
|
+
* Picks finalNetPrice based on constraintType, then:
|
|
9
|
+
* - With ACL=DISCOUNT_VALUE_SUBTRACTED_FROM_PRICE:
|
|
10
|
+
* discountAmountPreTax = perUnit / (1 + tax/100)
|
|
11
|
+
* percent = (discountAmountPreTax × 100) / finalNetPrice
|
|
12
|
+
* - Without:
|
|
13
|
+
* percent = (perUnit / finalNetPrice) × 100
|
|
14
|
+
*
|
|
15
|
+
* Stores recalculateSchemeData for later recalculation during price updates.
|
|
16
|
+
*/
|
|
17
|
+
export function calculatePerUnitPayout(input) {
|
|
18
|
+
const { scheme, compareValue, applicableProducts, isMrpBilling, totalTaxPercentage, perUnitPrices } = input;
|
|
19
|
+
const result = createEmptySlabResult(SchemePayoutType.PERUNIT);
|
|
20
|
+
if (!isValidConstraintType(scheme.constraintType)) {
|
|
21
|
+
result.warnings.push(`Invalid constraint type: ${scheme.constraintType}`);
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
if (!scheme.payoutCalculationType) {
|
|
25
|
+
result.warnings.push(`No matching calculation type found: ${scheme.payoutCalculationType}`);
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
const slabs = [...scheme.slabs].sort((a, b) => (a.constraint < b.constraint ? 1 : -1));
|
|
29
|
+
if (slabs.length === 0) {
|
|
30
|
+
result.warnings.push("Slab list is empty");
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
const matcherParams = {
|
|
34
|
+
slabs,
|
|
35
|
+
compareValue,
|
|
36
|
+
applicableProducts,
|
|
37
|
+
payoutType: SchemePayoutType.PERUNIT,
|
|
38
|
+
discountOn: scheme.discountOn ?? null,
|
|
39
|
+
};
|
|
40
|
+
const match = findMatchingSlab(matcherParams);
|
|
41
|
+
if (!match)
|
|
42
|
+
return result;
|
|
43
|
+
const { slab } = match;
|
|
44
|
+
const discountAmountOfPerUnit = isMrpBilling ? slab.mrpPayout : slab.payout;
|
|
45
|
+
const usesStdUnit = scheme.constraintType === SchemeConstraintType.STD_UNIT;
|
|
46
|
+
const usesSuperUnit = scheme.constraintType === SchemeConstraintType.SUPER_UNIT;
|
|
47
|
+
const usesAdditionalUnit = scheme.constraintType === SchemeConstraintType.ADDITIONAL_UNIT;
|
|
48
|
+
// Select the correct net price based on unit type
|
|
49
|
+
const { netPrice, stdUnitNetPrice, superUnitNetPrice, additionalUnitNetPrice, standardUnitConversionFactor, superUnitConversionFactor, additionalUnitConversionFactor, } = perUnitPrices;
|
|
50
|
+
const stdUnitFinalPrice = stdUnitNetPrice * standardUnitConversionFactor;
|
|
51
|
+
const superUnitFinalPrice = superUnitNetPrice * superUnitConversionFactor;
|
|
52
|
+
const additionalUnitFinalPrice = additionalUnitNetPrice * additionalUnitConversionFactor;
|
|
53
|
+
let finalNetPrice;
|
|
54
|
+
if (usesStdUnit) {
|
|
55
|
+
finalNetPrice = stdUnitFinalPrice;
|
|
56
|
+
}
|
|
57
|
+
else if (usesSuperUnit) {
|
|
58
|
+
finalNetPrice = superUnitFinalPrice;
|
|
59
|
+
}
|
|
60
|
+
else if (usesAdditionalUnit) {
|
|
61
|
+
finalNetPrice = additionalUnitFinalPrice;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
finalNetPrice = netPrice;
|
|
65
|
+
}
|
|
66
|
+
const discountAmountPreTax = discountAmountOfPerUnit / (1 + totalTaxPercentage / 100);
|
|
67
|
+
let itemDiscountPercent;
|
|
68
|
+
if (scheme.additionalCalculationLogic === AdditionalCalculationLogic.DISCOUNT_VALUE_SUBTRACTED_FROM_PRICE) {
|
|
69
|
+
itemDiscountPercent = ((discountAmountPreTax || 0) * 100) / (finalNetPrice || 1);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
itemDiscountPercent = ((discountAmountOfPerUnit ?? 0) / (finalNetPrice || 1)) * 100;
|
|
73
|
+
}
|
|
74
|
+
result.matched = true;
|
|
75
|
+
result.matchedSlabId = slab.id;
|
|
76
|
+
result.discountPercent = itemDiscountPercent;
|
|
77
|
+
result.targetMethod = "setDiscountScheme";
|
|
78
|
+
// Store recalculation data for later price recalculation
|
|
79
|
+
result.recalculateSchemeData = {
|
|
80
|
+
discountAmountOfPerUnit,
|
|
81
|
+
totalTaxPercentage,
|
|
82
|
+
usesStdUnit,
|
|
83
|
+
usesSuperUnit,
|
|
84
|
+
usesAdditionalUnit,
|
|
85
|
+
compareValue,
|
|
86
|
+
calculationOnCompleteNumber: scheme.calculationOnCompleteNumber,
|
|
87
|
+
additionalCalculationLogic: scheme.additionalCalculationLogic,
|
|
88
|
+
};
|
|
89
|
+
return result;
|
|
90
|
+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} from "../../types/applied-scheme";
|
|
3
|
+
import { isPayoutCalcTypeContinuous } from "../../helpers/calc-type-checks";
|
|
4
|
+
import { isValidConstraintType } from "../../helpers/constraint-checks";
|
|
5
|
+
import { findMatchingSlab } from "../slab-matcher";
|
|
6
|
+
/**
|
|
7
|
+
* Calculate payout for PRODUCT_SCHEME_NEW payout type.
|
|
8
|
+
*
|
|
9
|
+
* Continuous: payoutQty = Math.floor(payout × compareValue)
|
|
10
|
+
* Factor-based: same as PRODUCT with factor = floor(compareValue / constraint)
|
|
11
|
+
*/
|
|
12
|
+
export function calculateProductSchemeNewPayout(input) {
|
|
13
|
+
const { scheme, compareValue, totalAmount, applicableProducts, isMrpBilling, focProductPrice = 0, companyUsesUnitaryProductScheme = false, } = input;
|
|
14
|
+
const result = createEmptySlabResult(SchemePayoutType.PRODUCT_SCHEME_NEW);
|
|
15
|
+
result.targetMethod = "addProduct";
|
|
16
|
+
if (!isValidConstraintType(scheme.constraintType)) {
|
|
17
|
+
result.warnings.push(`Invalid constraint type: ${scheme.constraintType}`);
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
const slabs = [...scheme.slabs].sort((a, b) => (a.constraint < b.constraint ? 1 : -1));
|
|
21
|
+
if (slabs.length === 0) {
|
|
22
|
+
result.warnings.push("Slab list is empty");
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
const payoutCalcType = scheme.payoutCalculationType;
|
|
26
|
+
const matcherParams = {
|
|
27
|
+
slabs,
|
|
28
|
+
compareValue,
|
|
29
|
+
applicableProducts,
|
|
30
|
+
payoutType: SchemePayoutType.PRODUCT_SCHEME_NEW,
|
|
31
|
+
discountOn: scheme.discountOn ?? null,
|
|
32
|
+
};
|
|
33
|
+
// ─── Continuous ────────────────────────────────────────────────
|
|
34
|
+
if (isPayoutCalcTypeContinuous(payoutCalcType)) {
|
|
35
|
+
const match = findMatchingSlab(matcherParams);
|
|
36
|
+
if (!match)
|
|
37
|
+
return result;
|
|
38
|
+
const { slab } = match;
|
|
39
|
+
const payoutProductId = slab.productId;
|
|
40
|
+
const payoutQty = Math.floor((isMrpBilling ? slab.mrpPayout : slab.payout) * compareValue);
|
|
41
|
+
result.matched = true;
|
|
42
|
+
result.matchedSlabId = slab.id;
|
|
43
|
+
result.freeQty = payoutQty;
|
|
44
|
+
result.productToAdd = { productId: payoutProductId, quantity: payoutQty };
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
// ─── Factor-based (any other truthy payoutCalculationType) ─────
|
|
48
|
+
if (payoutCalcType) {
|
|
49
|
+
const match = findMatchingSlab(matcherParams);
|
|
50
|
+
if (!match)
|
|
51
|
+
return result;
|
|
52
|
+
const { slab } = match;
|
|
53
|
+
const payoutProductId = slab.productId;
|
|
54
|
+
const payoutProductMasterBatchId = slab.masterBatchId?.[0] || null;
|
|
55
|
+
const employeeWiseRemainingBudget = scheme.employeeWiseRemainingBudget;
|
|
56
|
+
let factor;
|
|
57
|
+
if ((employeeWiseRemainingBudget || employeeWiseRemainingBudget === 0) &&
|
|
58
|
+
compareValue > employeeWiseRemainingBudget) {
|
|
59
|
+
factor = Math.floor(employeeWiseRemainingBudget / slab.constraint);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
factor = Math.floor(compareValue / slab.constraint);
|
|
63
|
+
}
|
|
64
|
+
const payoutQty = (isMrpBilling ? slab.mrpPayout : slab.payout) * factor;
|
|
65
|
+
result.matched = true;
|
|
66
|
+
result.matchedSlabId = slab.id;
|
|
67
|
+
result.freeQty = payoutQty;
|
|
68
|
+
result.productToAdd = { productId: payoutProductId, quantity: payoutQty, masterBatchId: payoutProductMasterBatchId };
|
|
69
|
+
// Unitary product scheme distribution
|
|
70
|
+
if (companyUsesUnitaryProductScheme && focProductPrice > 0) {
|
|
71
|
+
const discountAmountTotal = focProductPrice * payoutQty;
|
|
72
|
+
const itemDiscountPercent = ((discountAmountTotal || 0) * 100) / (totalAmount || 1);
|
|
73
|
+
result.discountPercent = itemDiscountPercent;
|
|
74
|
+
result.discountValue = discountAmountTotal;
|
|
75
|
+
result.targetMethod = "setDiscountAndValueScheme";
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
result.warnings.push(`No matching calculation type found: ${payoutCalcType}`);
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=product-new.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-new.js","sourceRoot":"","sources":["../../../../src/calculators/payout-types/product-new.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAA0B,MAAM,iBAAiB,CAAC;AAoB3E;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAC7C,KAAgC;IAEhC,MAAM,EACJ,MAAM,EACN,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,eAAe,GAAG,CAAC,EACnB,+BAA+B,GAAG,KAAK,GACxC,GAAG,KAAK,CAAC;IACV,MAAM,MAAM,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;IAC1E,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;IAEnC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;QAClD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,4BAA4B,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;QAC1E,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAA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AG,CAAC,CAAC,mBAAmB,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC;YACpF,MAAM,CAAC,eAAe,GAAG,mBAAmB,CAAC;YAC7C,MAAM,CAAC,aAAa,GAAG,mBAAmB,CAAC;YAC3C,MAAM,CAAC,YAAY,GAAG,2BAA2B,CAAC;QACpD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,uCAAuC,cAAc,EAAE,CAAC,CAAC;IAC9E,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { SchemePayoutType } from "../../types/enums";
|
|
2
|
+
import { createEmptySlabResult } from "../../types/applied-scheme";
|
|
3
|
+
import { isValidConstraintType } from "../../helpers/constraint-checks";
|
|
4
|
+
import { findMatchingSlab } from "../slab-matcher";
|
|
5
|
+
/**
|
|
6
|
+
* Calculate payout for PRODUCT payout type.
|
|
7
|
+
*
|
|
8
|
+
* factor = Math.floor(compareValue / slab.constraint)
|
|
9
|
+
* payoutQty = payout × factor
|
|
10
|
+
* Calls addProduct to add free product.
|
|
11
|
+
*
|
|
12
|
+
* If companyUsesUnitaryProductScheme, also distributes focProduct price
|
|
13
|
+
* as a discount across applicable products.
|
|
14
|
+
*/
|
|
15
|
+
export function calculateProductPayout(input) {
|
|
16
|
+
const { scheme, compareValue, totalAmount, applicableProducts, isMrpBilling, focProductPrice = 0, companyUsesUnitaryProductScheme = false, } = input;
|
|
17
|
+
const result = createEmptySlabResult(SchemePayoutType.PRODUCT);
|
|
18
|
+
result.targetMethod = "addProduct";
|
|
19
|
+
if (!isValidConstraintType(scheme.constraintType)) {
|
|
20
|
+
result.warnings.push(`Invalid constraint type: ${scheme.constraintType}`);
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
if (!scheme.payoutCalculationType) {
|
|
24
|
+
result.warnings.push(`No matching calculation type found: ${scheme.payoutCalculationType}`);
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
const slabs = [...scheme.slabs].sort((a, b) => (a.constraint < b.constraint ? 1 : -1));
|
|
28
|
+
if (slabs.length === 0) {
|
|
29
|
+
result.warnings.push("Slab list is empty");
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
const matcherParams = {
|
|
33
|
+
slabs,
|
|
34
|
+
compareValue,
|
|
35
|
+
applicableProducts,
|
|
36
|
+
payoutType: SchemePayoutType.PRODUCT,
|
|
37
|
+
discountOn: scheme.discountOn ?? null,
|
|
38
|
+
};
|
|
39
|
+
const match = findMatchingSlab(matcherParams);
|
|
40
|
+
if (!match)
|
|
41
|
+
return result;
|
|
42
|
+
const { slab } = match;
|
|
43
|
+
const payoutProductId = slab.productId;
|
|
44
|
+
const payoutProductMasterBatchId = slab.masterBatchId?.[0] || null;
|
|
45
|
+
// Budget-cap the factor
|
|
46
|
+
const employeeWiseRemainingBudget = scheme.employeeWiseRemainingBudget;
|
|
47
|
+
let factor;
|
|
48
|
+
if ((employeeWiseRemainingBudget || employeeWiseRemainingBudget === 0) &&
|
|
49
|
+
compareValue > employeeWiseRemainingBudget) {
|
|
50
|
+
factor = Math.floor(employeeWiseRemainingBudget / slab.constraint);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
factor = Math.floor(compareValue / slab.constraint);
|
|
54
|
+
}
|
|
55
|
+
const payoutQty = (isMrpBilling ? slab.mrpPayout : slab.payout) * factor;
|
|
56
|
+
result.matched = true;
|
|
57
|
+
result.matchedSlabId = slab.id;
|
|
58
|
+
result.freeQty = payoutQty;
|
|
59
|
+
result.productToAdd = { productId: payoutProductId, quantity: payoutQty, masterBatchId: payoutProductMasterBatchId };
|
|
60
|
+
// If unitary product scheme, also calculate distributed discount
|
|
61
|
+
if (companyUsesUnitaryProductScheme && focProductPrice > 0) {
|
|
62
|
+
const discountAmountTotal = focProductPrice * payoutQty;
|
|
63
|
+
const itemDiscountPercent = ((discountAmountTotal || 0) * 100) / (totalAmount || 1);
|
|
64
|
+
result.discountPercent = itemDiscountPercent;
|
|
65
|
+
result.discountValue = discountAmountTotal;
|
|
66
|
+
result.targetMethod = "setDiscountAndValueScheme";
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=product.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product.js","sourceRoot":"","sources":["../../../../src/calculators/payout-types/product.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAA0B,MAAM,iBAAiB,CAAC;AAoB3E;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAA6B;IAClE,MAAM,EACJ,MAAM,EACN,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,eAAe,GAAG,CAAC,EACnB,+BAA+B,GAAG,KAAK,GACxC,GAAG,KAAK,CAAC;IACV,MAAM,MAAM,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC/D,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;IAEnC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;QAClD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,4BAA4B,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;QAC1E,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC;QAClC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,uCAAuC,MAAM,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAC5F,OAAO,MAAM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U,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,SAAS,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAEzE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,EAAE,CAAC;IAC/B,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC;IAC3B,MAAM,CAAC,YAAY,GAAG,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,0BAA0B,EAAE,CAAC;IAErH,iEAAiE;IACjE,IAAI,+BAA+B,IAAI,eAAe,GAAG,CAAC,EAAE,CAAC;QAC3D,MAAM,mBAAmB,GAAG,eAAe,GAAG,SAAS,CAAC;QACxD,MAAM,mBAAmB,GAAG,CAAC,CAAC,mBAAmB,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC;QACpF,MAAM,CAAC,eAAe,GAAG,mBAAmB,CAAC;QAC7C,MAAM,CAAC,aAAa,GAAG,mBAAmB,CAAC;QAC3C,MAAM,CAAC,YAAY,GAAG,2BAA2B,CAAC;IACpD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SchemePayoutType } from "../../types/enums";
|
|
2
|
+
import { createEmptySlabResult } from "../../types/applied-scheme";
|
|
3
|
+
import { isValidConstraintType } from "../../helpers/constraint-checks";
|
|
4
|
+
import { findMatchingSlab } from "../slab-matcher";
|
|
5
|
+
/**
|
|
6
|
+
* Calculate payout for TOPUP (TopUpDiscount) payout type.
|
|
7
|
+
* Simple: itemDiscountPercent = slab.payout directly.
|
|
8
|
+
*/
|
|
9
|
+
export function calculateTopupPayout(input) {
|
|
10
|
+
const { scheme, compareValue, applicableProducts, isMrpBilling } = input;
|
|
11
|
+
const result = createEmptySlabResult(SchemePayoutType.TOPUP);
|
|
12
|
+
if (!isValidConstraintType(scheme.constraintType)) {
|
|
13
|
+
result.warnings.push(`Invalid constraint type: ${scheme.constraintType}`);
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
if (!scheme.payoutCalculationType) {
|
|
17
|
+
result.warnings.push(`No matching calculation type found: ${scheme.payoutCalculationType}`);
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
const slabs = [...scheme.slabs].sort((a, b) => (a.constraint < b.constraint ? 1 : -1));
|
|
21
|
+
if (slabs.length === 0) {
|
|
22
|
+
result.warnings.push("Slab list is empty");
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
const matcherParams = {
|
|
26
|
+
slabs,
|
|
27
|
+
compareValue,
|
|
28
|
+
applicableProducts,
|
|
29
|
+
payoutType: SchemePayoutType.TOPUP,
|
|
30
|
+
discountOn: scheme.discountOn ?? null,
|
|
31
|
+
};
|
|
32
|
+
const match = findMatchingSlab(matcherParams);
|
|
33
|
+
if (!match)
|
|
34
|
+
return result;
|
|
35
|
+
const { slab } = match;
|
|
36
|
+
const itemDiscountPercent = isMrpBilling ? slab.mrpPayout : slab.payout;
|
|
37
|
+
result.matched = true;
|
|
38
|
+
result.matchedSlabId = slab.id;
|
|
39
|
+
result.discountPercent = itemDiscountPercent;
|
|
40
|
+
result.targetMethod = "setDiscountScheme";
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=topup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topup.js","sourceRoot":"","sources":["../../../../src/calculators/payout-types/topup.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACx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