The Problem: The Omnichannel B2B Chaos
Dairy Farm Products was scaling its wholesale operations, but their digital and physical infrastructures were completely disconnected. Standard e-commerce platforms like Shopify are built for B2C retail; they fundamentally shatter when exposed to the complex realities of B2B field sales, custom pricing contracts, and legacy accounting systems.
The company was bleeding administrative hours trying to manage three distinct operational nightmares:
- The Field-to-Ledger Disconnect: Sales representatives were taking orders and collecting physical cash or past-due payments in the field. Reconciling those field operations with online customer orders and getting them into the accounting software required hours of manual, error-prone data entry.
- The "Webhook" Void: The company relied on Sage 50 Business Cloud for accounting. However, Sage does not provide native webhooks for real-time data updates. This forced the accounting team to manually double-enter invoices, leading to delayed payments and chaotic accounts receivable.
- The Custom Pricing Web: In wholesale, pricing is heavily negotiated. A single product might have 50 different prices depending on which client is logged in. Managing these overlapping contracts across physical and digital sales channels was leading to severe billing discrepancies.
The Targeted Metrics
To transform this operation, we established three non-negotiable system outcomes:
- Unified Omnichannel Sales: Merge field-sales operations and customer self-serve portals into a single, synchronized database.
- Achieve "Zero-Touch" Accounting: Eliminate manual invoice and payment entry by forcing the web platform and Sage 50 to synchronize automatically.
- 100% Pricing Accuracy: Ensure dynamic, contract-specific pricing resolves in milliseconds, whether an order is placed by a rep in a shop or a customer on their phone.
The System: The Enterprise Automation Hub
To solve this, I engineered a comprehensive "Modular Monolith" platform. This system eliminated the need for fragmented SaaS tools, serving as the absolute source of truth for field reps, customers, and administrative staff.
1. Tri-Level Operational Architecture
The system was architected around three distinct user roles, seamlessly interacting within the same data ecosystem:
- The Customer (Self-Serve): Customers can use a mobile-optimized web app to place orders based on their negotiated pricing. They can also securely pay outstanding balances via debit/credit card integrations (Stripe) without needing a sales rep present.
- The Sales Rep (Field Operations): Reps operating in the field have a dedicated portal. When visiting a shop, they can place orders on behalf of the customer, log physical cash collections for past invoices, and instantly push that data to the central system.
- The Admin (Command Center): Administrators approve pending orders, allocate incoming payments (both digital and field-collected cash) to specific invoices, and manage inventory.
2. Bi-Directional Sage 50 Synchronization
To bypass Sage 50's lack of webhooks, I built a custom background synchronization engine powered by Redis-backed job queues.
When an Admin approves a customer's self-serve order or a Rep's field order, the system instantly generates an invoice. The custom poller automatically pushes this invoice to Sage 50 and emails it to the customer. When a Sales Rep logs a cash payment in the field, or a customer pays via card, the Admin allocates the payment, and the poller instantly updates the ledger balance in Sage 50.
3. Dynamic Pricing Engine & Type-Safe Infrastructure
The backend resolves a complex hybrid pricing strategy (Base Price → Tiered Group Price → Customer Override Price) in milliseconds. To ensure enterprise-grade reliability, the entire platform was built using a strongly typed schema (TypeScript, Zod, tRPC). If a pricing rule changes in the database, it instantly propagates safely to both the Admin dashboard and the Customer mobile app.
Loading Diagram...
The Outcome: Scaling Without SaaS Bloat
By abandoning disjointed off-the-shelf tools and building a bespoke operational hub, Dairy Farm Products fundamentally transformed their business leverage.
The custom Sage 50 poller completely eliminated manual invoice reconciliation, bridging the gap between field sales and internal accounting. Sales representatives were empowered to operate faster in the field, while customers gained the autonomy to order and pay on their own terms. Finally, by containerizing and self-hosting the modular monolith on AWS, the company drastically reduced their monthly SaaS overhead while maintaining total ownership of their financial data and security compliance.
