How Purchase Order Voiding, Copying, and Supplier Integrations Work
Source: purchase_orders_controller.rb:202-601, purchase_orders_controller.rb:452-486
- Voiding a PO requires it to be in a processed state (not suggested) -- suggested POs should be deleted instead, and the error message explicitly says so
- Voiding is blocked if the PO has any non-voided vendor invoices linked to it -- void or delete the vendor invoices first
- Copying a PO creates a new PO in "suggested" status with all line items copied but no order number assigned yet (order number is generated on processing)
- Repco/Ashdown/Prolink punchout returns destroy ALL existing PO items and rebuild from supplier data; any manual edits to PO items before the return are lost; punchout is only processed if PO status is "Submitted"
- Repco punchout creates new products by SKU if not found locally; existing product descriptions are not overwritten (only updated if blank)
- HSY order returns handle four scenarios: (1) same part, same qty = no change; (2) same part, different qty = update; (3) new part = create product if needed and add to PO; (4) part removed = soft-delete the PO item
- PartsTech integration sets PO status to "ordered" and saves the partstech_invoice_url on confirmation
- All punchout orders are auto-processed after save; invoice and job card links are preserved during the rebuild by matching on product_id
Support scenarios
- "Why can't I void this order? It says to delete it instead." → The PO is still in "suggested" status; delete it rather than voiding
- "Why can't I void this purchase order? There's a supplier invoice." → There are non-voided vendor invoices linked to the PO; void those first
- "I edited my PO items and they disappeared after the Repco return" → Punchout returns destroy all existing items and rebuild from supplier data; manual edits are always overwritten
- "Why does my copied purchase order have no order number?" → Order numbers are only assigned when the PO is processed, and copies start in "suggested" status