Back to case studies
ERP & INTEGRATION
BACKEND

ThaiOfficePro

A back-office ERP platform solving inventory mismatch issues through a redesigned inventory model with enforced invariants, automated marketplace integrations, and ISO-compliant audit trails. Built to support forecasting and future system extensions.

KotlinSpring BootPostgreSQLShopee APILazada APISCD-2
ThaiOfficePro back-office ERP workspace
2
Marketplace Integrations
Shopee & Lazada APIs
100%
Data Accuracy
With SCD-2 history
Real-time
Order Processing
Automated workflows

The Challenge

The original workflow relied on three paper-based columns—available, reserved, and broken—all manually counted. Staff manually deducted stock from available when shipping, leading to frequent negative counts and mismatched inventory. This error-prone process caused operational inefficiencies and made accurate forecasting impossible.

The Solution

Redesigned the inventory model with five columns (available, in_progress, reserved, broken, in_warehouse) and enforced a core invariant that prevents data corruption. Integrated Shopee APIs for automated order processing, implemented barcode scanning workflows, and built a complete financial reconciliation module. The schema is ISO-compliant, fully auditable, and designed to support forecasting and future extensions.

Core Capabilities

Dual Marketplace Integration
Seamless connection to both Shopee and Lazada APIs for order sync, inventory updates, and shipping events
Two-Step Stock Management
Inventory transitions through states (available → in_progress → out) with validation at each step
Historical Tracking
SCD-2 implementation preserves all changes with valid_from/valid_to timestamps for audit trails
Fault Tolerance
Resilient integration layer with retry policies and clear error states for external API calls
Transaction Safety
Critical flows wrapped in transactional boundaries to maintain database consistency
Analytics Ready
Clean, time-series friendly data models support demand forecasting and budget optimization
ISO-Compliant Audit
Inventory schema designed for ISO compliance with full audit trails and point-in-time state reconstruction
Barcode Workflows
Scanner-based workflows designed for workers of all skill levels, eliminating manual typing errors
Financial Reconciliation
Complete bill creation, tracking, credit management, and payment status modules
Access Control
Page-level access control configurable from admin console, preventing unnecessary data exposure

Inventory Model Redesign

Core Invariant

available + in_progress + reserved + broken = in_warehouse
This invariant is enforced at the database level, preventing any operation that would violate data integrity.

OLD MODEL (3 Columns)

available
reserved
broken
Manual counting, error-prone deductions, frequent mismatches

NEW MODEL (5 Columns)

available
in_progress(new)
reserved
broken
in_warehouse(new)
Enforced invariant, automated workflows, ISO-compliant audit trails

Order Processing Workflow

Order Created
Shopee/Lazada/Manual
available → in_progress
Barcode Scan
Staff confirmation
in_progress → out
Warehouse Update
Automatic
in_warehouse -= qty

When an order is created, stock automatically moves from available to in_progress. Before shipping, staff must scan the barcode to confirm removal, which deducts stock from both in_progress and in_warehouse. This eliminates manual errors and ensures the invariant is always maintained.

Need an ERP Solution?

Let's discuss how we can build a robust, auditable backend system for your inventory management and marketplace integration needs.