Skip to content
English
  • There are no suggestions because the search field is empty.

How Stock Take Processing Works

Source: stock_takes_controller.rb:108-191

  • Stock take update creates a new record if the ID is empty, otherwise finds and updates the existing record -- all wrapped in a database transaction
  • Processing requires a valid CompanyIntegration record; missing it raises "Integration record not found"
  • When reserved_stock is enabled and count_excludes_reserved is true, the new quantity_on_hand = draft_quantity + qty_reserved (the counted amount plus the reserved amount)
  • When count_excludes_reserved is false, quantity_on_hand = draft_quantity directly (the counted amount replaces everything including reserved)
  • A StockTakeLog is created for each processed item recording old_quantity, new_quantity, post_date (today), and reserved stock info
  • If the company has Neto integration and the product has a neto_product_sku, the system syncs the new quantity to Neto; Neto sync errors are logged but do not block processing
  • Stock take entries are deleted from the draft table after successful processing; the log entries persist as the historical record
  • Errors on individual items are logged but processing continues for remaining items -- partial success is possible; all errors are compiled into EventLog after the loop

Support scenarios

  • "Why is my quantity on hand higher than what I counted?" → The count_excludes_reserved flag is true, so reserved stock was added on top of your counted amount
  • "Why am I getting 'Integration record not found' when processing stocktake?" → The CompanyIntegration record is missing or invalid for this company
  • "Why did my stocktake entries disappear after processing?" → Draft entries are deleted after successful processing; check StockTakeLogs for the history
  • "Why did some stocktake items not process?" → Individual items can fail without blocking the rest; the error messages are logged to the EventLog