@the-apparel-lab/pricing-engine 1.0.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.
Files changed (58) hide show
  1. package/config/pricing-config.json +23 -0
  2. package/dist/audit/actuals-comparison.d.ts +10 -0
  3. package/dist/audit/actuals-comparison.d.ts.map +1 -0
  4. package/dist/audit/actuals-comparison.js +96 -0
  5. package/dist/audit/actuals-comparison.js.map +1 -0
  6. package/dist/audit/margin.d.ts +20 -0
  7. package/dist/audit/margin.d.ts.map +1 -0
  8. package/dist/audit/margin.js +34 -0
  9. package/dist/audit/margin.js.map +1 -0
  10. package/dist/audit-runner.d.ts +11 -0
  11. package/dist/audit-runner.d.ts.map +1 -0
  12. package/dist/audit-runner.js +277 -0
  13. package/dist/audit-runner.js.map +1 -0
  14. package/dist/calculators/blanks.d.ts +18 -0
  15. package/dist/calculators/blanks.d.ts.map +1 -0
  16. package/dist/calculators/blanks.js +26 -0
  17. package/dist/calculators/blanks.js.map +1 -0
  18. package/dist/calculators/decoration.d.ts +32 -0
  19. package/dist/calculators/decoration.d.ts.map +1 -0
  20. package/dist/calculators/decoration.js +63 -0
  21. package/dist/calculators/decoration.js.map +1 -0
  22. package/dist/calculators/setup-fees.d.ts +27 -0
  23. package/dist/calculators/setup-fees.d.ts.map +1 -0
  24. package/dist/calculators/setup-fees.js +60 -0
  25. package/dist/calculators/setup-fees.js.map +1 -0
  26. package/dist/calculators/shipping.d.ts +14 -0
  27. package/dist/calculators/shipping.d.ts.map +1 -0
  28. package/dist/calculators/shipping.js +17 -0
  29. package/dist/calculators/shipping.js.map +1 -0
  30. package/dist/cli.d.ts +3 -0
  31. package/dist/cli.d.ts.map +1 -0
  32. package/dist/cli.js +192 -0
  33. package/dist/cli.js.map +1 -0
  34. package/dist/config.d.ts +224 -0
  35. package/dist/config.d.ts.map +1 -0
  36. package/dist/config.js +368 -0
  37. package/dist/config.js.map +1 -0
  38. package/dist/index.d.ts +20 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +295 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/types.d.ts +230 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/dist/types.js +4 -0
  45. package/dist/types.js.map +1 -0
  46. package/dist/utils/blanks-lookup.d.ts +42 -0
  47. package/dist/utils/blanks-lookup.d.ts.map +1 -0
  48. package/dist/utils/blanks-lookup.js +99 -0
  49. package/dist/utils/blanks-lookup.js.map +1 -0
  50. package/dist/utils/money.d.ts +21 -0
  51. package/dist/utils/money.d.ts.map +1 -0
  52. package/dist/utils/money.js +38 -0
  53. package/dist/utils/money.js.map +1 -0
  54. package/dist/utils/vendor-lookup.d.ts +49 -0
  55. package/dist/utils/vendor-lookup.d.ts.map +1 -0
  56. package/dist/utils/vendor-lookup.js +308 -0
  57. package/dist/utils/vendor-lookup.js.map +1 -0
  58. package/package.json +28 -0
package/dist/index.js ADDED
@@ -0,0 +1,295 @@
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
+ exports.validateOrderInput = exports.loadBlanksPricing = exports.loadVendorPricing = exports.loadPricingConfig = exports.compareEstimateToActuals = void 0;
18
+ exports.calculatePrice = calculatePrice;
19
+ const config_1 = require("./config");
20
+ const blanks_lookup_1 = require("./utils/blanks-lookup");
21
+ const blanks_1 = require("./calculators/blanks");
22
+ const decoration_1 = require("./calculators/decoration");
23
+ const setup_fees_1 = require("./calculators/setup-fees");
24
+ const shipping_1 = require("./calculators/shipping");
25
+ const margin_1 = require("./audit/margin");
26
+ const money_1 = require("./utils/money");
27
+ // Re-export for consumers
28
+ var actuals_comparison_1 = require("./audit/actuals-comparison");
29
+ Object.defineProperty(exports, "compareEstimateToActuals", { enumerable: true, get: function () { return actuals_comparison_1.compareEstimateToActuals; } });
30
+ var config_2 = require("./config");
31
+ Object.defineProperty(exports, "loadPricingConfig", { enumerable: true, get: function () { return config_2.loadPricingConfig; } });
32
+ Object.defineProperty(exports, "loadVendorPricing", { enumerable: true, get: function () { return config_2.loadVendorPricing; } });
33
+ Object.defineProperty(exports, "loadBlanksPricing", { enumerable: true, get: function () { return config_2.loadBlanksPricing; } });
34
+ Object.defineProperty(exports, "validateOrderInput", { enumerable: true, get: function () { return config_2.validateOrderInput; } });
35
+ __exportStar(require("./types"), exports);
36
+ function calculatePrice(order, options) {
37
+ // Validate input upfront — catches bad data before it causes cryptic errors
38
+ const validatedOrder = (0, config_1.validateOrderInput)(order);
39
+ const config = options?.pricingConfig ?? (0, config_1.loadPricingConfig)(options?.pricingConfigPath);
40
+ const vendorData = options?.vendorData ?? (0, config_1.loadVendorPricing)(options?.vendorPricingPath);
41
+ const multipliers = config.multipliers;
42
+ // Blanks pricing is optional — only loaded when auto-lookup is needed.
43
+ // Pass blanksData: null to explicitly disable (prevents file fallback).
44
+ let blanksData;
45
+ if (options?.blanksData) {
46
+ blanksData = options.blanksData;
47
+ }
48
+ else if (options?.blanksData === null) {
49
+ // Explicitly disabled — do not attempt file-based fallback
50
+ }
51
+ else if (options?.blanksPricingPath) {
52
+ blanksData = (0, config_1.loadBlanksPricing)(options.blanksPricingPath);
53
+ }
54
+ else {
55
+ try {
56
+ blanksData = (0, config_1.loadBlanksPricing)();
57
+ }
58
+ catch {
59
+ // No blanks pricing file available — auto-lookup won't be used
60
+ }
61
+ }
62
+ const lineItemBreakdowns = [];
63
+ const allWarnings = [];
64
+ let orderDigitizing;
65
+ for (const item of validatedOrder.line_items) {
66
+ const totalQuantity = item.quantity + (item.has_oversized ? (item.oversized_quantity ?? 0) : 0);
67
+ // 1. Blanks — resolve garment cost (manual or auto-lookup)
68
+ let blanksSource = 'manual';
69
+ let blanksSupplier;
70
+ let unitCostDollars = item.garment_unit_cost;
71
+ let oversizedUnitCostDollars = item.oversized_garment_unit_cost;
72
+ if (unitCostDollars == null && blanksData) {
73
+ const lookup = (0, blanks_lookup_1.lookupBlankPricing)(blanksData, {
74
+ brandSku: item.brand_sku,
75
+ color: item.color,
76
+ });
77
+ if (lookup.unitPriceCents != null) {
78
+ unitCostDollars = (0, money_1.toDollars)(lookup.unitPriceCents);
79
+ blanksSource = 'auto_lookup';
80
+ blanksSupplier = lookup.supplier;
81
+ }
82
+ if (item.has_oversized && oversizedUnitCostDollars == null && lookup.oversizedUnitPriceCents != null) {
83
+ oversizedUnitCostDollars = (0, money_1.toDollars)(lookup.oversizedUnitPriceCents);
84
+ }
85
+ }
86
+ if (unitCostDollars == null) {
87
+ throw new Error(`No garment cost for "${item.brand_sku}" in color "${item.color}". ` +
88
+ `Provide garment_unit_cost manually or ensure the style exists in the blanks pricing database.`);
89
+ }
90
+ if (item.has_oversized && oversizedUnitCostDollars == null) {
91
+ throw new Error(`No oversized garment cost for "${item.brand_sku}" in color "${item.color}". ` +
92
+ `Provide oversized_garment_unit_cost manually or ensure oversized sizes exist in the blanks pricing database.`);
93
+ }
94
+ const blanksResult = (0, blanks_1.calculateBlanks)({
95
+ quantity: item.quantity,
96
+ unitCostCents: (0, money_1.toCents)(unitCostDollars),
97
+ blanksMultiplier: multipliers.blanks,
98
+ hasOversized: item.has_oversized,
99
+ oversizedQuantity: item.oversized_quantity,
100
+ oversizedUnitCostCents: oversizedUnitCostDollars != null
101
+ ? (0, money_1.toCents)(oversizedUnitCostDollars)
102
+ : undefined,
103
+ });
104
+ // 2. Decoration
105
+ const decorationResult = (0, decoration_1.calculateDecoration)({
106
+ designs: item.designs,
107
+ totalQuantity,
108
+ decorationMethod: item.decoration_method,
109
+ decorationMultiplier: multipliers.decoration[item.decoration_method],
110
+ vendorData,
111
+ manualCostPerUnitCents: item.manual_decoration_cost_per_unit != null
112
+ ? (0, money_1.toCents)(item.manual_decoration_cost_per_unit)
113
+ : undefined,
114
+ sublimationProductKey: item.sublimation_product_key,
115
+ });
116
+ // Collect decoration warnings (prefix with line item context when ambiguous)
117
+ if (decorationResult.warnings.length > 0) {
118
+ const prefix = (validatedOrder.line_items.length > 1 || item.designs.length > 1)
119
+ ? `[${item.garment_type} ${item.brand_sku}] `
120
+ : '';
121
+ allWarnings.push(...decorationResult.warnings.map(w => `${prefix}${w}`));
122
+ }
123
+ // 3. Setup fees
124
+ const setupResult = (0, setup_fees_1.calculateSetupFees)({
125
+ decorationMethod: item.decoration_method,
126
+ designs: item.designs,
127
+ vendorData,
128
+ digitizingMultiplier: multipliers.setup_fees.digitizing,
129
+ screenSetupMultiplier: multipliers.setup_fees.screen_setup,
130
+ });
131
+ // Aggregate digitizing across line items as a single separate charge
132
+ if (setupResult.digitizing) {
133
+ if (!orderDigitizing) {
134
+ orderDigitizing = {
135
+ estimated_cost: 0,
136
+ multiplier: multipliers.setup_fees.digitizing,
137
+ customer_price: 0,
138
+ };
139
+ }
140
+ orderDigitizing.estimated_cost += setupResult.digitizing.totalCostCents;
141
+ orderDigitizing.customer_price += setupResult.digitizing.totalMarkedUpCents;
142
+ }
143
+ // Build cost breakdown (all in cents)
144
+ const costBreakdown = {
145
+ blanks: {
146
+ estimated_cost: blanksResult.totalCostCents,
147
+ multiplier: multipliers.blanks,
148
+ marked_up: blanksResult.totalMarkedUpCents,
149
+ },
150
+ decoration: {
151
+ estimated_cost: decorationResult.totalCostCents,
152
+ multiplier: multipliers.decoration[item.decoration_method],
153
+ marked_up: decorationResult.totalMarkedUpCents,
154
+ },
155
+ screen_setup: setupResult.screenSetup
156
+ ? {
157
+ estimated_cost: setupResult.screenSetup.totalCostCents,
158
+ multiplier: multipliers.setup_fees.screen_setup,
159
+ marked_up: setupResult.screenSetup.totalMarkedUpCents,
160
+ }
161
+ : undefined,
162
+ };
163
+ // Costs that roll into per-unit price (blanks markup + decoration markup + screen setup markup)
164
+ const screenSetupMarkedUp = setupResult.screenSetup?.totalMarkedUpCents ?? 0;
165
+ // Build customer-facing output
166
+ const customerFacing = buildCustomerFacing(item, blanksResult.standardMarkedUpCents, blanksResult.oversizedMarkedUpCents, decorationResult.totalMarkedUpCents, screenSetupMarkedUp, totalQuantity);
167
+ // Line total costs — derived from customer-facing rounded values so the
168
+ // itemized rows always agree with the order total the customer sees.
169
+ const lineEstimatedCost = blanksResult.totalCostCents
170
+ + decorationResult.totalCostCents
171
+ + (setupResult.screenSetup?.totalCostCents ?? 0);
172
+ const lineCustomerPrice = (0, money_1.toCents)(customerFacing.standard_sizes.line_total)
173
+ + (customerFacing.oversized ? (0, money_1.toCents)(customerFacing.oversized.line_total) : 0);
174
+ // Decoration vendor attribution
175
+ const decorationSource = decorationResult.vendorIds.length > 0 ? 'vendor_lookup' : 'manual';
176
+ const decorationVendors = decorationResult.vendorIds.length > 0
177
+ ? decorationResult.vendorIds
178
+ : undefined;
179
+ // Build placements for the breakdown
180
+ const placements = item.designs.map((d, i) => ({
181
+ location: d.location,
182
+ color_count: 'color_count' in d ? d.color_count : undefined,
183
+ stitch_count: 'stitch_count' in d ? d.stitch_count : undefined,
184
+ vendor_id: decorationResult.perDesignCosts[i]?.vendorId,
185
+ }));
186
+ // Build human-readable breakdown string
187
+ const blanksMarkedDollars = (0, money_1.toDollars)(costBreakdown.blanks.marked_up);
188
+ const decoMarkedDollars = (0, money_1.toDollars)(costBreakdown.decoration.marked_up);
189
+ const setupMarkedDollars = costBreakdown.screen_setup
190
+ ? (0, money_1.toDollars)(costBreakdown.screen_setup.marked_up)
191
+ : 0;
192
+ const breakdownParts = [
193
+ `$${blanksMarkedDollars.toFixed(2)} blanks`,
194
+ `$${decoMarkedDollars.toFixed(2)} decoration`,
195
+ ];
196
+ if (setupMarkedDollars > 0) {
197
+ breakdownParts.push(`$${setupMarkedDollars.toFixed(2)} setup`);
198
+ }
199
+ const _breakdown = `(${breakdownParts.join(' + ')}) / ${totalQuantity} units = $${customerFacing.standard_sizes.unit_price.toFixed(2)}/unit`;
200
+ lineItemBreakdowns.push({
201
+ garment_type: item.garment_type,
202
+ brand_sku: item.brand_sku,
203
+ color: item.color,
204
+ decoration_method: item.decoration_method,
205
+ quantity: item.quantity,
206
+ oversized_quantity: item.has_oversized ? item.oversized_quantity : undefined,
207
+ placements,
208
+ cost_breakdown: costBreakdown,
209
+ customer_facing: customerFacing,
210
+ line_total_estimated_cost: lineEstimatedCost,
211
+ line_total_customer_price: lineCustomerPrice,
212
+ blanks_source: blanksSource,
213
+ blanks_supplier: blanksSupplier,
214
+ decoration_source: decorationSource,
215
+ decoration_vendors: decorationVendors,
216
+ _breakdown,
217
+ });
218
+ }
219
+ // 4. Shipping
220
+ const shippingResult = (0, shipping_1.calculateShipping)({
221
+ shippingCostCents: (0, money_1.toCents)(validatedOrder.shipping_cost),
222
+ shippingMultiplier: multipliers.shipping,
223
+ });
224
+ const shippingCharge = {
225
+ estimated_cost: shippingResult.costCents,
226
+ multiplier: multipliers.shipping,
227
+ customer_price: shippingResult.markedUpCents,
228
+ };
229
+ // Total customer price = line item prices + digitizing + shipping
230
+ const lineItemsTotalCustomerPrice = (0, money_1.sumCents)(lineItemBreakdowns.map(li => li.line_total_customer_price));
231
+ const digitizingCustomerPrice = orderDigitizing?.customer_price ?? 0;
232
+ const totalCustomerPriceCents = lineItemsTotalCustomerPrice + digitizingCustomerPrice + shippingResult.markedUpCents;
233
+ // Total estimated cost = line item costs + digitizing cost + shipping cost
234
+ const lineItemsTotalEstimatedCost = (0, money_1.sumCents)(lineItemBreakdowns.map(li => li.line_total_estimated_cost));
235
+ const digitizingEstimatedCost = orderDigitizing?.estimated_cost ?? 0;
236
+ const totalEstimatedCostCents = lineItemsTotalEstimatedCost + digitizingEstimatedCost + shippingResult.costCents;
237
+ // 5. Margin calculations
238
+ const marginResult = (0, margin_1.calculateMargin)({
239
+ totalCustomerPriceCents,
240
+ totalEstimatedCostCents,
241
+ paymentProcessingRate: config.payment_processing_rate,
242
+ });
243
+ return {
244
+ order_summary: {
245
+ total_customer_price: totalCustomerPriceCents,
246
+ total_estimated_cost: totalEstimatedCostCents,
247
+ estimated_processing_fee: marginResult.estimatedProcessingFeeCents,
248
+ true_net_revenue: marginResult.trueNetRevenueCents,
249
+ gross_margin_percent: marginResult.grossMarginPercent,
250
+ net_margin_percent: marginResult.netMarginPercent,
251
+ },
252
+ line_items: lineItemBreakdowns,
253
+ separate_charges: {
254
+ digitizing: orderDigitizing,
255
+ shipping: shippingCharge,
256
+ },
257
+ multipliers_used: multipliers,
258
+ warnings: allWarnings,
259
+ };
260
+ }
261
+ /**
262
+ * Build the customer-facing line item with standard/oversized split.
263
+ *
264
+ * Decoration and setup costs per unit are the same regardless of garment size,
265
+ * so they're allocated proportionally by unit count. Only blank costs differ.
266
+ */
267
+ function buildCustomerFacing(item, standardBlanksMarkedUpCents, oversizedBlanksMarkedUpCents, decorationMarkedUpCents, screenSetupMarkedUpCents, totalQuantity) {
268
+ const sharedPerUnitCents = (decorationMarkedUpCents + screenSetupMarkedUpCents) / totalQuantity;
269
+ // Standard sizes
270
+ const stdUnitPriceCents = (standardBlanksMarkedUpCents / item.quantity) + sharedPerUnitCents;
271
+ const stdUnitPrice = (0, money_1.roundMoney)((0, money_1.toDollars)(Math.round(stdUnitPriceCents)));
272
+ const stdLineTotal = (0, money_1.roundMoney)(stdUnitPrice * item.quantity);
273
+ const customerFacing = {
274
+ standard_sizes: {
275
+ label: 'Sizes: S - XL',
276
+ quantity: item.quantity,
277
+ unit_price: stdUnitPrice,
278
+ line_total: stdLineTotal,
279
+ },
280
+ };
281
+ // Oversized split
282
+ if (item.has_oversized && item.oversized_quantity && item.oversized_quantity > 0) {
283
+ const osUnitPriceCents = (oversizedBlanksMarkedUpCents / item.oversized_quantity) + sharedPerUnitCents;
284
+ const osUnitPrice = (0, money_1.roundMoney)((0, money_1.toDollars)(Math.round(osUnitPriceCents)));
285
+ const osLineTotal = (0, money_1.roundMoney)(osUnitPrice * item.oversized_quantity);
286
+ customerFacing.oversized = {
287
+ label: 'Sizes: 2XL+',
288
+ quantity: item.oversized_quantity,
289
+ unit_price: osUnitPrice,
290
+ line_total: osLineTotal,
291
+ };
292
+ }
293
+ return customerFacing;
294
+ }
295
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAyCA,wCAuQC;AApSD,qCAAuG;AAEvG,yDAA2D;AAC3D,iDAAuD;AACvD,yDAA+D;AAC/D,yDAA8D;AAC9D,qDAA2D;AAC3D,2CAAiD;AACjD,yCAAyE;AAEzE,0BAA0B;AAC1B,iEAAsE;AAA7D,8HAAA,wBAAwB,OAAA;AACjC,mCAAuG;AAA9F,2GAAA,iBAAiB,OAAA;AAAE,2GAAA,iBAAiB,OAAA;AAAE,2GAAA,iBAAiB,OAAA;AAAE,4GAAA,kBAAkB,OAAA;AAEpF,0CAAwB;AAexB,SAAgB,cAAc,CAC5B,KAAiB,EACjB,OAA+B;IAE/B,4EAA4E;IAC5E,MAAM,cAAc,GAAG,IAAA,2BAAkB,EAAC,KAAK,CAAC,CAAC;IAEjD,MAAM,MAAM,GAAG,OAAO,EAAE,aAAa,IAAI,IAAA,0BAAiB,EAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IACvF,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,IAAA,0BAAiB,EAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IACxF,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IAEvC,uEAAuE;IACvE,wEAAwE;IACxE,IAAI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AW,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAEtE,cAAc,CAAC,SAAS,GAAG;YACzB,KAAK,EAAE,aAAa;YACpB,QAAQ,EAAE,IAAI,CAAC,kBAAkB;YACjC,UAAU,EAAE,WAAW;YACvB,UAAU,EAAE,WAAW;SACxB,CAAC;IACJ,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC"}
@@ -0,0 +1,230 @@
1
+ export type DecorationMethod = 'screen_printing' | 'screen_print_transfers' | 'embroidery' | 'dtf' | 'dtg' | 'sublimation';
2
+ interface DesignPlacementBase {
3
+ location: string;
4
+ }
5
+ export interface ScreenPrintingDesign extends DesignPlacementBase {
6
+ method: 'screen_printing';
7
+ height: number;
8
+ width: number;
9
+ color_count: number;
10
+ }
11
+ export interface ScreenPrintTransfersDesign extends DesignPlacementBase {
12
+ method: 'screen_print_transfers';
13
+ height: number;
14
+ width: number;
15
+ color_count: number;
16
+ }
17
+ export interface EmbroideryDesign extends DesignPlacementBase {
18
+ method: 'embroidery';
19
+ height: number;
20
+ width: number;
21
+ stitch_count: number;
22
+ }
23
+ export interface DtfDesign extends DesignPlacementBase {
24
+ method: 'dtf';
25
+ height: number;
26
+ width: number;
27
+ }
28
+ export interface DtgDesign extends DesignPlacementBase {
29
+ method: 'dtg';
30
+ height: number;
31
+ width: number;
32
+ }
33
+ export interface SublimationDesign extends DesignPlacementBase {
34
+ method: 'sublimation';
35
+ height: number;
36
+ width: number;
37
+ }
38
+ export type DesignPlacement = ScreenPrintingDesign | ScreenPrintTransfersDesign | EmbroideryDesign | DtfDesign | DtgDesign | SublimationDesign;
39
+ export interface OrderLineItem {
40
+ garment_type: string;
41
+ brand_sku: string;
42
+ color: string;
43
+ /** Cost per garment in dollars. Optional if blanks pricing database is loaded for auto-lookup. */
44
+ garment_unit_cost?: number;
45
+ quantity: number;
46
+ decoration_method: DecorationMethod;
47
+ /** Informational only — engine uses designs.length. */
48
+ design_count?: number;
49
+ designs: DesignPlacement[];
50
+ has_oversized: boolean;
51
+ oversized_garment_unit_cost?: number;
52
+ oversized_quantity?: number;
53
+ manual_decoration_cost_per_unit?: number;
54
+ sublimation_product_key?: string;
55
+ }
56
+ export interface OrderInput {
57
+ line_items: OrderLineItem[];
58
+ shipping_cost: number;
59
+ }
60
+ /** All fields in integer cents. */
61
+ export interface CostComponent {
62
+ estimated_cost: number;
63
+ multiplier: number;
64
+ marked_up: number;
65
+ }
66
+ export interface LineItemCostBreakdown {
67
+ blanks: CostComponent;
68
+ decoration: CostComponent;
69
+ screen_setup?: CostComponent;
70
+ }
71
+ /** Customer-visible output. unit_price and line_total are in DOLLARS (not cents). */
72
+ export interface CustomerFacingLineItem {
73
+ standard_sizes: {
74
+ label: string;
75
+ quantity: number;
76
+ /** Dollars per unit (e.g. 16.05). */
77
+ unit_price: number;
78
+ /** Dollars total (e.g. 385.20). */
79
+ line_total: number;
80
+ };
81
+ oversized?: {
82
+ label: string;
83
+ quantity: number;
84
+ /** Dollars per unit. */
85
+ unit_price: number;
86
+ /** Dollars total. */
87
+ line_total: number;
88
+ };
89
+ }
90
+ export interface LineItemBreakdown {
91
+ garment_type: string;
92
+ brand_sku: string;
93
+ color: string;
94
+ decoration_method: DecorationMethod;
95
+ quantity: number;
96
+ oversized_quantity?: number;
97
+ placements: Array<{
98
+ location: string;
99
+ color_count?: number;
100
+ stitch_count?: number;
101
+ /** Which vendor was selected as cheapest for this placement. */
102
+ vendor_id?: string;
103
+ }>;
104
+ cost_breakdown: LineItemCostBreakdown;
105
+ customer_facing: CustomerFacingLineItem;
106
+ line_total_estimated_cost: number;
107
+ line_total_customer_price: number;
108
+ /** How the blank garment cost was determined. */
109
+ blanks_source?: 'manual' | 'auto_lookup';
110
+ /** Supplier that provided the blank price (when auto-looked-up). */
111
+ blanks_supplier?: string;
112
+ /** How the decoration cost was determined. */
113
+ decoration_source?: 'vendor_lookup' | 'manual';
114
+ /** Vendor(s) selected for decoration pricing. */
115
+ decoration_vendors?: string[];
116
+ /** Human-readable breakdown of how the unit price was derived. */
117
+ _breakdown: string;
118
+ }
119
+ /** All fields in integer cents. */
120
+ export interface SeparateCharge {
121
+ estimated_cost: number;
122
+ multiplier: number;
123
+ customer_price: number;
124
+ }
125
+ /** All order_summary and cost_breakdown fields are in integer cents. customer_facing fields are in dollars. */
126
+ export interface PriceBreakdown {
127
+ order_summary: {
128
+ /** Integer cents. */
129
+ total_customer_price: number;
130
+ /** Integer cents. */
131
+ total_estimated_cost: number;
132
+ /** Integer cents. */
133
+ estimated_processing_fee: number;
134
+ /** Integer cents. */
135
+ true_net_revenue: number;
136
+ /** Percentage (e.g. 45.2). */
137
+ gross_margin_percent: number;
138
+ /** Percentage (e.g. 42.1). */
139
+ net_margin_percent: number;
140
+ };
141
+ line_items: LineItemBreakdown[];
142
+ separate_charges: {
143
+ digitizing?: SeparateCharge;
144
+ shipping: SeparateCharge;
145
+ };
146
+ multipliers_used: PricingMultipliers;
147
+ /** Warnings generated during pricing (e.g. vendor fallbacks, manual overrides). */
148
+ warnings: string[];
149
+ }
150
+ export interface ActualLineItemCosts {
151
+ garment_type: string;
152
+ brand_sku: string;
153
+ quantity: number;
154
+ cost_breakdown: {
155
+ blanks: {
156
+ actual_cost: number;
157
+ source: string;
158
+ };
159
+ decoration: {
160
+ actual_cost: number;
161
+ source: string;
162
+ };
163
+ setup_fees: {
164
+ actual_cost: number;
165
+ source: string;
166
+ };
167
+ shipping: {
168
+ actual_cost: number;
169
+ source: string;
170
+ };
171
+ };
172
+ }
173
+ export interface ActualCosts {
174
+ order_id: string;
175
+ estimate_id: string;
176
+ actuals: {
177
+ line_items: ActualLineItemCosts[];
178
+ actual_processing_fee: number;
179
+ total_actual_cost: number;
180
+ };
181
+ }
182
+ export interface ComponentVariance {
183
+ estimated: number;
184
+ actual: number;
185
+ delta: number;
186
+ }
187
+ export interface EstimateVsActual {
188
+ order_id: string;
189
+ customer_paid: number;
190
+ estimated_total_cost: number;
191
+ actual_total_cost: number;
192
+ cost_variance: number;
193
+ cost_variance_percent: number;
194
+ estimated_net_margin_percent: number;
195
+ actual_net_margin_percent: number;
196
+ component_variances: {
197
+ blanks: ComponentVariance;
198
+ decoration: ComponentVariance;
199
+ setup_fees: ComponentVariance;
200
+ shipping: ComponentVariance;
201
+ };
202
+ }
203
+ export interface DecorationMultipliers {
204
+ screen_printing: number;
205
+ screen_print_transfers: number;
206
+ embroidery: number;
207
+ dtf: number;
208
+ dtg: number;
209
+ sublimation: number;
210
+ }
211
+ export interface SetupFeeMultipliers {
212
+ digitizing: number;
213
+ screen_setup: number;
214
+ }
215
+ export interface PricingMultipliers {
216
+ blanks: number;
217
+ decoration: DecorationMultipliers;
218
+ setup_fees: SetupFeeMultipliers;
219
+ shipping: number;
220
+ }
221
+ export interface PaymentProcessingRate {
222
+ percentage: number;
223
+ flat_fee: number;
224
+ }
225
+ export interface PricingConfig {
226
+ multipliers: PricingMultipliers;
227
+ payment_processing_rate: PaymentProcessingRate;
228
+ }
229
+ export {};
230
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,wBAAwB,GACxB,YAAY,GACZ,KAAK,GACL,KAAK,GACL,aAAa,CAAC;AAIlB,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,0BAA2B,SAAQ,mBAAmB;IACrE,MAAM,EAAE,wBAAwB,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WA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E,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,qBAAqB,CAAC;IAClC,UAAU,EAAE,mBAAmB,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,kBAAkB,CAAC;IAChC,uBAAuB,EAAE,qBAAqB,CAAC;CAChD"}
package/dist/types.js ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // ─── Decoration Method Enum ───
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,iCAAiC"}
@@ -0,0 +1,42 @@
1
+ import type { BlanksPricingData } from '../config';
2
+ export interface BlanksLookupResult {
3
+ /** Cheapest standard-size price per unit in cents, or null if not found. */
4
+ unitPriceCents: number | null;
5
+ /** Cheapest oversized-size price per unit in cents, or null if not found/applicable. */
6
+ oversizedUnitPriceCents: number | null;
7
+ /** Which supplier provided the pricing. */
8
+ supplier?: string;
9
+ /** Warning message if lookup partially or fully failed. */
10
+ warning?: string;
11
+ }
12
+ export interface BlanksLookupParams {
13
+ /** Brand and style, e.g. "Gildan 5000" or "Bella+Canvas 3001" */
14
+ brandSku: string;
15
+ /** Garment color, e.g. "White", "Black", "Dark Heather" */
16
+ color: string;
17
+ }
18
+ /**
19
+ * Normalize a brand_sku like "Gildan 5000" to a lookup key like "gildan_5000".
20
+ *
21
+ * Handles common variations:
22
+ * "Bella+Canvas 3001" → "bella_canvas_3001"
23
+ * "Port & Company PC61" → "port_company_pc61"
24
+ * "Independent Trading Co. SS4500" → "independent_trading_co_ss4500"
25
+ * "Next Level 3600" → "next_level_3600"
26
+ */
27
+ export declare function normalizeBrandSku(brandSku: string): string;
28
+ /**
29
+ * Normalize a color name for lookup.
30
+ * "Dark Heather" → "dark_heather"
31
+ * "Sport Grey" → "sport_grey"
32
+ */
33
+ export declare function normalizeColor(color: string): string;
34
+ /**
35
+ * Look up blank garment pricing from the blanks feed.
36
+ *
37
+ * Returns the cheapest standard-size price and cheapest oversized price
38
+ * for the given style and color. Uses the `standard_sizes` and `oversized_sizes`
39
+ * arrays from the feed to classify sizes.
40
+ */
41
+ export declare function lookupBlankPricing(blanksData: BlanksPricingData, params: BlanksLookupParams): BlanksLookupResult;
42
+ //# sourceMappingURL=blanks-lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blanks-lookup.d.ts","sourceRoot":"","sources":["../../src/utils/blanks-lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,4EAA4E;IAC5E,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,wFAAwF;IACxF,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAS1D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMpD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,iBAAiB,EAC7B,MAAM,EAAE,kBAAkB,GACzB,kBAAkB,CA6DpB"}