Great discussion here. To address the questions comprehensively:
Tiered Pricing Logic: We use a straightforward threshold evaluation with SQL-style range queries. The directive queries the UD_PricingTiers table with WHERE conditions that match product category, customer segment, and quantity ranges. For threshold boundaries, we use “greater than or equal to” logic, so an order quantity of exactly 100 units qualifies for the 100+ tier. This eliminates ambiguity.
Here’s the core logic pattern:
// Pseudocode - Pricing calculation steps:
1. Retrieve customer segment from UD_CustomerSegment table
2. Get product category from Part.ProdCode field
3. Query UD_PricingTiers WHERE Category=X, Segment=Y, Qty<=OrderQty
4. Sort results by QtyThreshold DESC, select top 1 (highest applicable tier)
5. Calculate: BasePrice * (1 - DiscountPct/100)
// See: Pricing Configuration Guide Section 3.4
Customer Segment Lookup: This happens first in the directive flow. We join Customer and UD_CustomerSegment tables using CustNum as the key. If no segment record exists, we default to “Standard” pricing (no tier discounts). The lookup is cached per order header to avoid repeated queries for multi-line orders.
Order Quantity Thresholds: Our threshold structure is simple - we define breakpoints at 10, 50, 100, 250, 500 units with progressively higher discounts. The directive evaluates OrderDtl.OrderQty against these ranges. We also implemented a “cumulative quantity” option that sums quantities across all lines of the same product category, which some customers requested for consolidated pricing.
Pre-Processing Directive: Critical choice here. We used pre-processing (before save) rather than post-processing because we need to modify the unit price before Epicor’s pricing engine calculates extended amounts and taxes. The directive updates OrderDtl.DocUnitPrice directly, and Epicor’s standard logic handles the rest. This keeps our customization minimal and maintainable.
Regarding Advanced Pricing module - we evaluated it but found it too rigid for our segment-based tiering model. The native module excels at contract pricing and promotional discounts but doesn’t elegantly handle dynamic segment classification with quantity thresholds. Custom directive gave us exactly the flexibility we needed.
One lesson learned: thoroughly test with your actual order entry workflows. We initially had issues with quote conversions where the directive wasn’t firing properly. Had to add quote-to-order conversion as a separate trigger point. Also, document your UD table structure extensively - future maintenance depends on clear understanding of the pricing matrix design.
The 4-6% margin improvement came from consistent application of our intended pricing strategy. Previously, manual pricing was inconsistent - some CSRs were too generous with discounts, others too conservative. Automation eliminated that variability and ensured every order got exactly the pricing it deserved based on segment and volume.