How Branch Product Copy and Find Works
Source: products_controller.rb:47-54, products_controller.rb:61-64, products_controller.rb:95-113
- Copying a product from another branch prevents duplicates: if a product with the same item_code and branch_link already exists, the system returns the existing product without creating a new one
- Copy validates branch membership: the source product's company must belong to the same franchise/branch as the requesting company, otherwise "Invalid product ID" is raised
- Copied branch products always start with zero stock (quantity_on_hand = 0) regardless of the source product's stock level
- The reserved stock field (qty_reserved) is only included in the copy if the company has the reserved_stock feature enabled
- When a non-owner branch finds a product from the dealer, quantity_on_hand and qty_reserved are reset to zero, ID is cleared, and if the product has a vendor, the system tries to find the matching vendor in the local company; if not found, vendor_id is cleared
Support scenarios
- "Why did copying a branch product not create a new product?" → A product with the same item_code and branch_link already exists at your branch
- "Why am I getting 'Invalid product ID' when copying?" → The source product belongs to a different franchise/branch than your company
- "Why does the copied product show zero stock?" → Copied products always start at zero stock, even if the source had stock
- "Why does the product from head office show no vendor?" → The vendor at head office does not exist at your branch, so the link was cleared