How Serial Number Tracking Works
Source: product_serial_numbers_controller.rb:7-77, product_serial_number.rb:15
- Serial numbers link to products and can optionally link to vendor invoices and customer invoices
- Vendor_invoice and invoice links are only set on create if those params are present in the request
- Voided serial numbers are excluded from all list queries (voided is distinct from true)
- The "open only" filter excludes serial numbers already attached to invoice items (invoice_item_id is not null), so only unattached serials are shown when adding to an invoice
- Serial number list after create prioritizes vendor_invoice_item_id; if that returns no results, falls back to showing all serial numbers for the product
- The only model-level validation is that company_id must be present -- serial numbers have no format constraints
Support scenarios
- "Why doesn't my serial number have a vendor invoice link?" → The vendor_invoice_item_id was not included when the serial number was created
- "Why did my serial number disappear from the list?" → It was voided (soft-deleted), which hides it from all standard queries
- "Why don't I see all serial numbers when adding to an invoice?" → The "open only" filter hides serial numbers already attached to other invoice items
- "Why am I seeing all serial numbers for the product instead of just this vendor invoice?" → The vendor_invoice_item_id filter returned no results, so it fell back to showing all serials for the product