How the Default Labour Product Fallback Works
Source: product.rb:198-230
- The system uses a three-step fallback to find the default labour product: (1) Check CompanySetting.default_labour_product_id. (2) If not found, search for products with item_code LAB, LABOR, or LABOUR that are labor type. (3) If still not found, auto-create a product with item_code "LAB", description "Labour", type labor.
- The auto-created "LAB" product may appear unexpectedly in the product list -- it was created by the system as a fallback
- This fallback runs whenever the system needs a default labour product (e.g., for booking appointments, labour line items)
- The search in step 2 checks three variations to handle regional spelling differences (LAB, LABOR, LABOUR)
- The auto-created product uses standard defaults: zero cost, zero stock, labor type
Support scenarios
- "Where did the 'LAB' product come from?" → The system auto-created it because no default labour product was configured and no existing product with code LAB/LABOR/LABOUR was found
- "How does the system pick the default labour product?" → It checks the company setting first, then searches by item code (LAB/LABOR/LABOUR), then auto-creates one if nothing matches
- "I deleted the LAB product and it came back" → The system re-creates it automatically when it needs a default labour product and cannot find one