VbzCart/docs/tables/stk history

From Woozle Writes Code
< VbzCart‎ | docs‎ | tables
Revision as of 18:52, 27 December 2008 by imported>Woozle (created; old table renamed stk_history_old)
Jump to navigation Jump to search

About

  • Purpose: log of all stock movement
  • Refers to: Template:Vbzcart/query, Template:Vbzcart/table
  • History:
    • 2008-12-26 Changed field names, added new fields:
      • QtyFound → QtyBefore – quantity in this stock line before moving
      • QtyDone → QtyAdded – quantity added to this stock line
      • QtyLeft → QtyAfter – quantity in this stock line after moving
      • + QtyTotBefore – total of item in this bin before move)
      • + QtyTotAfter – total of item in this bin after move)
  • Rules:
    • Stock items must always be moved to or from a stock line. (The source/destination can be either another stock line or a line from a package or received restock.)
    • The sign of QtyAdded indicates whether the movement was to or from.
  • Notes:
    • The IDS_Line* fields are somewhat redundant, but I decided that redundancy was a goal: one of the purposes of history data (including stk_history) is to help reconstruct what happened when something goes wrong. Maintenance of the _stk_containers table is also somewhat redundant, but should make displaying meaningful history reports quicker (i.e. it's basically a sort of cache, as are all the _* tables).
    • Commented-out bits can be included if you have no incomplete legacy data to deal with.

SQL

<section begin=sql /><mysql>DROP TABLE IF EXISTS `stk_history`;

CREATE TABLE `stk_history` (

 `ID`           INT   NOT NULL   AUTO_INCREMENT,
 `ID_Stock`     INT   NOT NULL   COMMENT "stk_items.ID of item being moved",
 `ID_Bin`       INT   NOT NULL   COMMENT "stock item is being moved to or from this bin",
 `ID_Item`      INT /*NOT NULL*/ COMMENT "cat_items.ID of item being moved",
 `QtyBefore`    INT /*NOT NULL*/ COMMENT "quantity found in this stock line before the move",
 `QtyAdded`     INT   NOT NULL   COMMENT "quantity moved (Qty fields at targ/dest may change value later)",
 `QtyAfter`     INT   NOT NULL   COMMENT "quantity remaining in this stock line after the move",
 `QtyBinBefore` INT /*NOT NULL*/ COMMENT "quantity of this ID_Item in the current bin before the move",
 `QtyBinAfter`  INT /*NOT NULL*/ COMMENT "quantity of this ID_Item in the current bin after the move",
 `When`         DATETIME      NOT NULL    COMMENT "when the move happened",
 `IDS_Cont`     VARCHAR(31) /*NOT NULL*/  COMMENT "container.IDS of where the item was moved to/from",
 `ID_Line`      VARCHAR(31) /*NOT NULL*/  COMMENT "appropriate table's ID of where item was moved to/from",
 `What`         VARCHAR(63)  DEFAULT NULL COMMENT "brief automatic description of operation",
 `Notes`        VARCHAR(255) DEFAULT NULL COMMENT "optional human-added explanatory notes",
 PRIMARY KEY(`ID`)

) ENGINE = MYISAM;</mysql> <section end=sql />