@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,103 @@
|
|
|
1
|
+
export interface ItemCalculationProps {
|
|
2
|
+
/** FE/engine product identifier (SKU). */
|
|
3
|
+
productId: number;
|
|
4
|
+
/** DB identifier for the product (if different from productId). */
|
|
5
|
+
productDbId: number;
|
|
6
|
+
/** PTR/ex-tax unit selling price for this line. */
|
|
7
|
+
price: number;
|
|
8
|
+
/** MRP (Maximum Retail Price) for the SKU. */
|
|
9
|
+
mrp: number;
|
|
10
|
+
/** Unit price used when billing is on MRP (MRP billing flows). */
|
|
11
|
+
mrpBillingPrice: number;
|
|
12
|
+
/** Billed quantity (excluding free qty). */
|
|
13
|
+
quantity: number;
|
|
14
|
+
/** Free quantity granted (FOC/Product schemes). */
|
|
15
|
+
freeQty: number;
|
|
16
|
+
/** Primary category id for scheme applicability/qualification. */
|
|
17
|
+
primaryCategoryId: number;
|
|
18
|
+
/** Secondary category id for scheme applicability/qualification. */
|
|
19
|
+
secondaryCategoryId: number;
|
|
20
|
+
/** Alternate category/group label used by some schemes. */
|
|
21
|
+
category1: string | null;
|
|
22
|
+
/** Attribute text 1 used for filtering and qualifier rules. */
|
|
23
|
+
productAttributeText1: string | null;
|
|
24
|
+
/** Attribute text 2 used for filtering and qualifier rules. */
|
|
25
|
+
productAttributeText2: string | null;
|
|
26
|
+
/** Pricing master batch id (used when SKU is split by pricing batch). */
|
|
27
|
+
masterBatchId?: string;
|
|
28
|
+
/** Manufacturing batch number (used by filter constraints). */
|
|
29
|
+
batchNo?: string;
|
|
30
|
+
/** MRP batch identifier used in qualifier matching (if present). */
|
|
31
|
+
mrpBatch?: string;
|
|
32
|
+
/** Conversion factor from base unit to standard unit. */
|
|
33
|
+
standardUnitConversionFactor: number;
|
|
34
|
+
/** Conversion factor for “actual standard unit” (some companies use a different standard unit basis). */
|
|
35
|
+
actualStandardUnitConversionFactor: number;
|
|
36
|
+
/** Conversion factor for super unit. */
|
|
37
|
+
superUnitConversionFactor: number;
|
|
38
|
+
/** Conversion factor for additional unit. */
|
|
39
|
+
additionalUnitConversionFactor: number;
|
|
40
|
+
/** IGST % rate. */
|
|
41
|
+
igst: number;
|
|
42
|
+
/** CGST % rate. */
|
|
43
|
+
cgst: number;
|
|
44
|
+
/** SGST % rate. */
|
|
45
|
+
sgst: number;
|
|
46
|
+
/** Cess % rate. */
|
|
47
|
+
cessPercent: number;
|
|
48
|
+
/** VAT % rate (legacy). */
|
|
49
|
+
vatPercent: number;
|
|
50
|
+
/** Total GST % rate (when stored as combined). */
|
|
51
|
+
gstPercent: number;
|
|
52
|
+
/** Gross line value before scheme discounts (caller-computed). */
|
|
53
|
+
grossValue: number;
|
|
54
|
+
/** Net line value after non-scheme adjustments as per caller model (caller-computed). */
|
|
55
|
+
netValue: number;
|
|
56
|
+
/** Cash discount value already applied (caller-computed; schemes may be computed on top of this depending on flow). */
|
|
57
|
+
cashDiscountValue: number;
|
|
58
|
+
/** Whether the item is saleable / must-sell eligible (affects qualifier logic). */
|
|
59
|
+
isSaleable: boolean;
|
|
60
|
+
/** True if this line itself is a free product line (not a billed line). */
|
|
61
|
+
isFreeProduct?: boolean;
|
|
62
|
+
/** True if the outlet is focused (some outlet constraints rely on this). */
|
|
63
|
+
isFocused?: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface AggregateCalculationProps {
|
|
66
|
+
/** Total billed quantity across the aggregated set (excluding free qty). */
|
|
67
|
+
totalQuantity: number;
|
|
68
|
+
/** Total value/amount across the aggregated set (caller-defined: usually sum of price×qty). */
|
|
69
|
+
totalAmount: number;
|
|
70
|
+
/** Total standard units across the aggregated set. */
|
|
71
|
+
totalStdUnits: number;
|
|
72
|
+
/** Total “actual standard units” across the aggregated set. */
|
|
73
|
+
actualTotalStdUnits: number;
|
|
74
|
+
/** Total super units across the aggregated set. */
|
|
75
|
+
totalSuperUnits: number;
|
|
76
|
+
/** Total additional units across the aggregated set. */
|
|
77
|
+
totalAdditionalUnits: number;
|
|
78
|
+
/** Compare value used for slab matching (qty/amount/units depending on constraintType). */
|
|
79
|
+
compareValue: number;
|
|
80
|
+
/** Aggregated tax % used for tax-sensitive calculators (PerUnit/MRP %). */
|
|
81
|
+
totalTaxPercentage: number;
|
|
82
|
+
/** MRP value used for MRP % discount calculations (often per-SKU). */
|
|
83
|
+
productMrp: number;
|
|
84
|
+
/** PTR/ex-tax unit price used for MRP % discount calculations (often per-SKU). */
|
|
85
|
+
productPtr: number;
|
|
86
|
+
}
|
|
87
|
+
export interface PerUnitPriceProps {
|
|
88
|
+
/** Net unit price for base unit (used when constraintType is quantity). */
|
|
89
|
+
netPrice: number;
|
|
90
|
+
/** Net unit price at standard unit level. */
|
|
91
|
+
stdUnitNetPrice: number;
|
|
92
|
+
/** Net unit price at super unit level. */
|
|
93
|
+
superUnitNetPrice: number;
|
|
94
|
+
/** Net unit price at additional unit level. */
|
|
95
|
+
additionalUnitNetPrice: number;
|
|
96
|
+
/** Conversion factor to translate standard unit net price into base-unit comparable price. */
|
|
97
|
+
standardUnitConversionFactor: number;
|
|
98
|
+
/** Conversion factor to translate super unit net price into base-unit comparable price. */
|
|
99
|
+
superUnitConversionFactor: number;
|
|
100
|
+
/** Conversion factor to translate additional unit net price into base-unit comparable price. */
|
|
101
|
+
additionalUnitConversionFactor: number;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=item-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item-props.d.ts","sourceRoot":"","sources":["../../src/types/item-props.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,GAAG,EAAE,MAAM,CAAC;IACZ,kEAAkE;IAClE,eAAe,EAAE,MAAM,CAAC;IACxB,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAGhB,kEAAkE;IAClE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oEAAoE;IACpE,mBAAmB,EAAE,MAAM,CAAC;IAC5B,2DAA2D;IAC3D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,+DAA+D;IAC/D,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,+DAA+D;IAC/D,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,yEAAyE;IACzE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,yDAAyD;IACzD,4BAA4B,EAAE,MAAM,CAAC;IACrC,yGAAyG;IACzG,kCAAkC,EAAE,MAAM,CAAC;IAC3C,wCAAwC;I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,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+CAA+C;IAC/C,sBAAsB,EAAE,MAAM,CAAC;IAC/B,8FAA8F;IAC9F,4BAA4B,EAAE,MAAM,CAAC;IACrC,2FAA2F;IAC3F,yBAAyB,EAAE,MAAM,CAAC;IAClC,gGAAgG;IAChG,8BAA8B,EAAE,MAAM,CAAC;CACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item-props.js","sourceRoot":"","sources":["../../src/types/item-props.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { SchemeCategory, SchemePayoutType, SchemeBudgetType, AdditionalCalculationLogic, ThirdQualifierType, type SchemeConstraintTypeValue, type SchemeSchemeOnValue, type SchemePayoutInValue } from "./enums";
|
|
2
|
+
export interface OutletConstraints {
|
|
3
|
+
/** Allowed/required shop types for this scheme (outlet eligibility). */
|
|
4
|
+
requiredShopTypes?: any;
|
|
5
|
+
/** Allowed/required outlet segmentations for this scheme (outlet eligibility). */
|
|
6
|
+
requiredSegmentations?: any;
|
|
7
|
+
/** Whether scheme requires the outlet to be marked as focused. */
|
|
8
|
+
requiredIsFocused?: any;
|
|
9
|
+
/** Allowed/required channels for this scheme (GT/MT/etc.). */
|
|
10
|
+
requiredChannels?: any;
|
|
11
|
+
}
|
|
12
|
+
export interface FilterConstraints {
|
|
13
|
+
/** If provided, scheme applies only for items with MRP exactly in this list. */
|
|
14
|
+
mrp?: number[];
|
|
15
|
+
/** If provided, scheme applies only for items whose attribute text 1 matches one of these. */
|
|
16
|
+
attribute1?: string[];
|
|
17
|
+
/** If provided, scheme applies only for items whose attribute text 2 matches one of these. */
|
|
18
|
+
attribute2?: string[];
|
|
19
|
+
/** If provided, scheme applies only for items whose alternate category matches one of these. */
|
|
20
|
+
altCategory?: string[];
|
|
21
|
+
/** If provided, scheme applies only for manufacturing batch numbers in this list. */
|
|
22
|
+
manufacturingBatchNumbers?: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface FirstQualifier {
|
|
25
|
+
/** The type of entity to qualify on (product/category/attribute). */
|
|
26
|
+
entityType: number;
|
|
27
|
+
/** The entity identifier/value (e.g. productId, categoryId, attributeText). */
|
|
28
|
+
entity: number | string;
|
|
29
|
+
/** Optional batch identifier constraint (MRP batch) for qualifier matching. */
|
|
30
|
+
batch: number | string | null;
|
|
31
|
+
/** Minimum required quantity for this qualifier to be satisfied. */
|
|
32
|
+
quantity: number;
|
|
33
|
+
/** Whether the matching items must be saleable/must-sell for qualifier to pass. */
|
|
34
|
+
isMustSell: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface BasketSlab {
|
|
37
|
+
/** Basket-slab identifier (row id). */
|
|
38
|
+
id: number;
|
|
39
|
+
/** Product id tied to this basket requirement (optional in some DB shapes). */
|
|
40
|
+
productId: number | null;
|
|
41
|
+
/** Required quantity/value threshold for this basket component. */
|
|
42
|
+
quantity: number;
|
|
43
|
+
/** Basket identifier this component belongs to. */
|
|
44
|
+
basketId: number;
|
|
45
|
+
/** Whether this basket component is mandatory to qualify for the slab. */
|
|
46
|
+
isBasketMandatory: boolean;
|
|
47
|
+
/** The parent scheme slab id this basket component is attached to. */
|
|
48
|
+
schemeSlabId: number;
|
|
49
|
+
}
|
|
50
|
+
export interface Basket {
|
|
51
|
+
/** Basket identifier. */
|
|
52
|
+
id: number;
|
|
53
|
+
/** Product IDs that constitute the basket group. */
|
|
54
|
+
productIds: number[];
|
|
55
|
+
}
|
|
56
|
+
export interface Slab {
|
|
57
|
+
/** Slab identifier. */
|
|
58
|
+
id: number;
|
|
59
|
+
/** Minimum threshold to qualify for this slab (qty/amount/units depending on scheme.constraintType). */
|
|
60
|
+
constraint: number;
|
|
61
|
+
/** Optional maximum threshold for the slab (used for range-based slabs). */
|
|
62
|
+
maxConstraint?: number;
|
|
63
|
+
/** Payout configured for PTR/ex-tax flows (percent/value depending on payout type). */
|
|
64
|
+
payout: number;
|
|
65
|
+
/** Payout configured for MRP billing flows (used when scheme is evaluated on MRP billing price). */
|
|
66
|
+
mrpPayout: number;
|
|
67
|
+
/** Priority/order among slabs (when multiple could match). */
|
|
68
|
+
priority: number;
|
|
69
|
+
/** Human-readable slab description (used for UI/printing). */
|
|
70
|
+
payoutDescription: string;
|
|
71
|
+
/** Product id to add/grant for PRODUCT/COUPON style payouts (DB can store any type). */
|
|
72
|
+
productId?: any;
|
|
73
|
+
/** Secondary qualifier value used for category/qualifier gating (legacy scheme model). */
|
|
74
|
+
secondQualifier: number;
|
|
75
|
+
/** Master batch id for payout product or scheme batch scoping (pricing batch). */
|
|
76
|
+
masterBatchId: string;
|
|
77
|
+
/** Basket invoice payout percent (used by basket schemes as discount percent). */
|
|
78
|
+
basketInvoicePayout: number;
|
|
79
|
+
/** Basket constraint type (qty vs amount) used in basket qualification. */
|
|
80
|
+
basketConstraintType: number;
|
|
81
|
+
/** Secondary qualifier type (e.g. LPC) describing how secondQualifier should be interpreted. */
|
|
82
|
+
secondQualifierType: number | null;
|
|
83
|
+
/** First-qualifier rules that must be satisfied for this slab to apply. */
|
|
84
|
+
firstQualifier: FirstQualifier[];
|
|
85
|
+
/** Basket qualifiers attached to this slab (mandatory/optional baskets). */
|
|
86
|
+
qualifierSchemeSlabs: BasketSlab[];
|
|
87
|
+
/** For step-multiplier schemes: the increment size above the base constraint. */
|
|
88
|
+
multiplierStepSize?: number | null;
|
|
89
|
+
/** Third qualifier values (often used for amount/quantity gating beyond second qualifier). */
|
|
90
|
+
thirdQualifier: number[] | null;
|
|
91
|
+
/** Type for the third qualifier (value vs quantity). */
|
|
92
|
+
thirdQualifierType: ThirdQualifierType | null;
|
|
93
|
+
}
|
|
94
|
+
export interface Scheme {
|
|
95
|
+
/** Scheme identifier. */
|
|
96
|
+
id: number;
|
|
97
|
+
/** Scheme name/code shown to users. */
|
|
98
|
+
name: string;
|
|
99
|
+
/** Scheme category: Primary vs Secondary (discount bucket). */
|
|
100
|
+
category: SchemeCategory | string;
|
|
101
|
+
/** The metric used to qualify slabs (Amount, Quantity, StdUnit, etc.). */
|
|
102
|
+
constraintType: SchemeConstraintTypeValue | string;
|
|
103
|
+
/** Business payout mechanic (Discount, FOC, Product, MRP%, etc.). */
|
|
104
|
+
payoutType: SchemePayoutType | string;
|
|
105
|
+
/** Calculation type for slabs (step/continuous/stepmultiplier/prorata). */
|
|
106
|
+
payoutCalculationType: string;
|
|
107
|
+
/** Field that indicates what discount is “on” (DB legacy; often used by client/UI). */
|
|
108
|
+
payoutOn: string;
|
|
109
|
+
/** Payout unit (quantity/standard unit) used for some payout types. */
|
|
110
|
+
payoutIn: SchemePayoutInValue | string;
|
|
111
|
+
/** True when payout should be interpreted as a range rather than discrete slabs. */
|
|
112
|
+
payoutAsRange?: boolean;
|
|
113
|
+
/** What entity the scheme is configured on (product/category/group/all/master batch). */
|
|
114
|
+
schemeOn: SchemeSchemeOnValue | string;
|
|
115
|
+
/** Scheme subtype used for extendable/non-extendable behaviors (and GST claim identification). */
|
|
116
|
+
schemeSubType: string;
|
|
117
|
+
/** Secondary subtype (e.g. claimable/non-claimable) for special flows like GST claim. */
|
|
118
|
+
schemeSubType2?: string;
|
|
119
|
+
/** Step size/step metadata from DB (used in some UIs and some step logic). */
|
|
120
|
+
schemeStep: number;
|
|
121
|
+
/** DB-provided block ids; meaning depends on schemeOn (legacy structure). */
|
|
122
|
+
schemeBlockArray: number[];
|
|
123
|
+
/** Selected product ids this scheme targets (product-level schemes). */
|
|
124
|
+
selectedProductBlockArray: number[];
|
|
125
|
+
/** Slab definitions (thresholds and payouts) for this scheme. */
|
|
126
|
+
slabs: Slab[];
|
|
127
|
+
/** Outlet-level constraints (who can avail the scheme). */
|
|
128
|
+
outletConstraints: OutletConstraints;
|
|
129
|
+
/** Item-level filter constraints (MRP, attributes, manufacturing batch numbers, etc.). */
|
|
130
|
+
filterConstraints?: FilterConstraints;
|
|
131
|
+
/** Long textual description for display/audit. */
|
|
132
|
+
stringDescription: string;
|
|
133
|
+
/** Whether the scheme is applied individually per line vs pooled across lines. */
|
|
134
|
+
isIndividual: boolean;
|
|
135
|
+
/** Whether the company is using MRP billing for this scheme evaluation. */
|
|
136
|
+
ismrpBilling?: boolean;
|
|
137
|
+
/** Whether this scheme is a markup-type scheme. */
|
|
138
|
+
isMarkup?: boolean;
|
|
139
|
+
/** Whether the scheme is marked preferred (used in conflict resolution). */
|
|
140
|
+
isPreferred?: boolean | null;
|
|
141
|
+
/** Budget amount for this scheme (if budgeted). */
|
|
142
|
+
schemeBudget: number | null;
|
|
143
|
+
/** Budget type (value vs quantity). */
|
|
144
|
+
schemeBudgetType: SchemeBudgetType | null;
|
|
145
|
+
/** Remaining budget specific to employee/user context (used for budget capping). */
|
|
146
|
+
employeeWiseRemainingBudget?: number;
|
|
147
|
+
/** Optional attribute text associated with scheme (used for tagging/reporting). */
|
|
148
|
+
attributeText: string | null;
|
|
149
|
+
/** Additional calculation logic modifier (e.g. discount value subtracted from price). */
|
|
150
|
+
additionalCalculationLogic?: AdditionalCalculationLogic | null;
|
|
151
|
+
/** When true, caller expects rounding/complete-number behavior for calculations. */
|
|
152
|
+
calculationOnCompleteNumber?: boolean;
|
|
153
|
+
/** UI hint: whether qty details should be shown for this scheme. */
|
|
154
|
+
showQtyDetails?: boolean;
|
|
155
|
+
/** Optional application sequence when multiple schemes exist. */
|
|
156
|
+
schemeSequence?: number | null;
|
|
157
|
+
/** If true, prevent other schemes from being applied once this scheme is applied. */
|
|
158
|
+
restrictProductsWithSchemeApplied?: boolean | null;
|
|
159
|
+
/** Additional applicability scope marker (legacy DB field). */
|
|
160
|
+
applicableOn?: number | null;
|
|
161
|
+
/** Alternate scheme link used for master-batch schemes and fallbacks. */
|
|
162
|
+
alternateSchemeId?: number | null;
|
|
163
|
+
/** Variant label/type (e.g. MasterBatch variant). */
|
|
164
|
+
schemeVariant?: string;
|
|
165
|
+
/** Discount-on type (e.g. group scheme) affecting qualifier checks. */
|
|
166
|
+
discountOn?: number | null;
|
|
167
|
+
/** ERP identifier for scheme, if synced from ERP. */
|
|
168
|
+
erpId?: any;
|
|
169
|
+
/** Distributor scoping for scheme (who is eligible to see/apply). */
|
|
170
|
+
distributors?: any;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=scheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheme.d.ts","sourceRoot":"","sources":["../../src/types/scheme.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,0BAA0B,EAC1B,kBAAkB,EAClB,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACzB,MAAM,SAAS,CAAC;AAGjB,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,GAAG,CAAC;IACxB,kFAAkF;IAClF,qBAAqB,CAAC,EAAE,GAAG,CAAC;IAC5B,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,GAAG,CAAC;IACxB,8DAA8D;IAC9D,gBAAgB,CAAC,EAAE,GAAG,CAAC;CACxB;AAGD,MAAM,WAAW,iBAAiB;IAChC,gFAAgF;IAChF,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,8FAA8F;IAC9F,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,8FAA8F;IAC9F,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,gGAAgG;IAChG,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,qFAAqF;IACrF,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;CACtC;AAGD,MAAM,WAAW,cAAc;IAC7B,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,+EAA+E;IAC/E,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC9B,oEAA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ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@parv0888/scheme-engine",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Pure-function scheme calculation engine for FieldAssist DMS",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc && tsc -p tsconfig.esm.json",
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"prepublishOnly": "npm run build && npm test",
|
|
15
|
+
"db:download:secondary-discount-diffs": "node scripts/download_secondary_discount_diffs.js",
|
|
16
|
+
"db:test:secondary-discount-diffs": "cross-env RUN_DB_DIFF_TESTS=1 jest __tests__/db_secondary_discount_diffs.test.ts --runInBand",
|
|
17
|
+
"lint": "eslint src/"
|
|
18
|
+
},
|
|
19
|
+
"license": "UNLICENSED",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/jest": "^30.0.0",
|
|
22
|
+
"@types/pg": "^8.15.5",
|
|
23
|
+
"cross-env": "^7.0.3",
|
|
24
|
+
"jest": "^30.2.0",
|
|
25
|
+
"pg": "^8.16.3",
|
|
26
|
+
"ts-jest": "^29.4.6",
|
|
27
|
+
"typescript": "^5.9.3"
|
|
28
|
+
}
|
|
29
|
+
}
|