Skip to content

ERP Order Verification System

The ERP Order Verification system provides immediate feedback on whether an order submitted to the ERP system was correctly processed with all items intact. This addresses a critical issue where the Prophet 21 ERP sometimes silently drops certain line items during order creation without returning an explicit error.

  1. Silent Item Dropping: The Prophet 21 ERP may silently drop or modify items during order creation without returning an explicit error
  2. Verification Challenges: Previous attempts to verify order contents using the transaction-based API failed with “400 Bad Request” errors
  3. User Uncertainty: Without verification, users had no clear way to know if their orders were correctly processed by the ERP

The Order Verification system uses a multi-step approach:

  1. Order Creation/Update: The standard order creation/update flow creates or updates an order in the ERP
  2. Post-Creation Verification: After successful order creation/update, a separate verification process uses the P21 Data Services API (not the transaction API) to fetch the actual items in the ERP order
  3. Comparison & Analysis: The system compares what was sent to what actually exists in the ERP system
  4. Status Persistence: The verification status and any discrepancies are stored in the database and returned to the frontend
  5. User Interface Updates: The UI clearly displays verification status and highlights problematic items that need attention
sequenceDiagram
participant Frontend
participant Backend
participant TransactionAPI as P21 Transaction API
participant DataServicesAPI as P21 Data Services API
participant Database
Frontend->>Backend: Send order creation/update request
Backend->>TransactionAPI: Create/update order
TransactionAPI-->>Backend: Return order number
Backend->>DataServicesAPI: Fetch actual items in order
DataServicesAPI-->>Backend: Return actual items
Backend->>Backend: Compare sent vs. actual items
Backend->>Database: Store verification status
Backend-->>Frontend: Return status, verification details
Frontend->>Frontend: Update UI with verification information

The verification system defines several states:

  1. verified: All items submitted to the ERP exist in the order with correct quantities
  2. mismatch: One or more items are missing or have quantity discrepancies compared to what was sent
  3. verification_failed: The verification process itself encountered an error
  4. pending: Initial state, verification not yet attempted

The verification status and details are stored in the orders table:

  • erpVerificationStatus: Text enum (‘verified’, ‘mismatch’, ‘verification_failed’, ‘pending’, null)
  • erpUnverifiedItemIds: JSONB array of objects containing details of problematic items

In prophet21-service.ts, two key methods handle verification:

  • fetchVerifiedOrderItems: Makes a call to the P21 Data Services API to get the actual order items
  • executeOrderVerification: Compares sent items with items returned from the API
  • The createOrder and updateOrder methods in Prophet21Service call the verification process
  • The API endpoints (generate-quote.ts and update-quote.ts) handle the verification results and update the database
  • pdfOrderStore.ts manages verification state and handles API responses
  • OrderEditor.tsx displays verification status, highlighting problematic items
  1. User submits an order creation/update request
  2. After the ERP processes the order, our system calls the Data Services API to verify what’s actually in the order
  3. Any discrepancies are identified and tracked
  4. The UI displays clear feedback about verification status
  5. For mismatches, problematic items are highlighted and users are guided on what to do next
  1. Immediate Feedback: Users know immediately if their orders were processed correctly
  2. Problem Identification: Specific items that weren’t processed correctly are clearly identified
  3. Actionable Guidance: Clear instructions on how to resolve issues
  4. Error Traceability: Verification status persists across page refreshes and system restarts