Skip to content

Inventory and Stock

Current authority

Google Sheets is still the practical inventory authority.

Core tabs:

  • Imports: batch-level receipt, landed cost, status, and Quantity Remaining.
  • Inventory: formula-driven SKU aggregation.
  • ProductName / Variation: canonicalization and dropdown support.
  • Marketplace tabs (Shopee, Lazada) and Orders: order-line projections used by allocation.

How allocation works today

New allocatable rows carry Status = For Allocation. Apps Script then:

  1. Finds an arrived import row for the same SKU with enough quantity.
  2. Subtracts from Imports.Quantity Remaining.
  3. Writes allocation/import status back to the order line.
  4. Supports reversal/cancellation paths that attempt to restore quantity.

Important fragility

This is a business-critical inventory transaction implemented as several Google Sheet writes. It is not a database transaction and has no durable idempotency key or row-level lock.

Failure modes:

  • Row insertion/sorting can move records while scripts infer position.
  • Reversal can depend on mutable current SKU/quantity fields.
  • Missing allocation quantity can prevent exact reversal.
  • Concurrent edits/triggers can race.

Marketplace stock sync

exzen-core currently pushes stock back to marketplaces as part of its scheduled loop.

tcg-platform also has marketplace stock sync code, but its sync toggles are off. Do not enable tcg-platform marketplace stock sync while exzen-core stock sync is still active, or there will be competing inventory writers.