Difference between revisions of "VbzCart/tables/stk places"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
(corrections to match actual table)
(one more column: isActivated)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==About==
 
==About==
* '''Purpose''': places where containers may be found, organized hierarchically
+
* '''Purpose''': places where {{vbzcart|table|stk_bins|bins}} may be found, organized hierarchically
 
* '''History''':
 
* '''History''':
 
** '''2010-11-30''' added '''isActive''' field, so we can hide all the old GA places
 
** '''2010-11-30''' added '''isActive''' field, so we can hide all the old GA places
 
** '''2012-02-06''' added '''isEnabled''' field so cat_items stock can be calculated properly by query
 
** '''2012-02-06''' added '''isEnabled''' field so cat_items stock can be calculated properly by query
 
*** Also corrected type for isActive to match actual table
 
*** Also corrected type for isActive to match actual table
 +
** '''2017-04-22'''
 +
*** Finally worked out better terminology. A Place is "active" if it is "enabled" AND is not contained by a Place that has been disabled (un-"enabled") -- but that's kind of the opposite of how we were using the terms. Rather than reverse them, I came up with something more specific and unambiguous.
 +
**** Renamed "isEnabled" to "isActiveSpace".
 +
**** Renamed "isActive" to "isSelfActive".
 +
**** Created "isActivated".
 +
*** At first, I thought maybe the caching of "is this Place within a Place that has not been disabled?" was unnecessary, but it turns out the customer-facing calculations of what is currently in stock use queries which depend on the isEnabled field. So now this needs to happen:
 +
**** Whenever a Place record is saved and '''isSelfActive''' has changed, the code should update '''isActiveSpace''' for all contained Places.
 +
*** Also changing from MYISAM to InnoDB, because there's really no reason to use MYISAM. (apparently this was done to the actual db earlier)
 
* '''Fields''':
 
* '''Fields''':
** '''isActive''': if FALSE, then normal operations should ignore this place ''and all places inside it''.
+
** '''isSelfActive''': if FALSE, then normal operations should ignore this place ''and all places inside it''.
** '''isEnabled''': (calculated by code) if TRUE, all parents between here and root are Active
+
** '''isActiveSpace''': (calculated) if TRUE, all parent-container Places are active (isSelfActive = TRUE)
 +
** '''isActivated''': (calculated): isSelfActive && isActiveSpace -- this is the flag which stock calculations should look at
 
==SQL==
 
==SQL==
<section begin=sql /><mysql>CREATE TABLE `stk_places` (
+
<mysql>CREATE TABLE `stk_places` (
 
   `ID` INT NOT NULL AUTO_INCREMENT,
 
   `ID` INT NOT NULL AUTO_INCREMENT,
 
   `ID_Parent`    INT                      COMMENT "self.ID of place in which this place is found; may be NULL",
 
   `ID_Parent`    INT                      COMMENT "self.ID of place in which this place is found; may be NULL",
   `isActive`     TINYINT(1)       NOT NULL COMMENT "FALSE = don't normally show this place in lists or count its stock in totals",
+
   `isSelfActive` TINYINT(1)     NOT NULL COMMENT "FALSE = don't normally show this place in lists or count its stock in totals",
   `isEnabled`   TINYINT(1)       NOT NULL COMMENT "(calculated field) TRUE = all parents between here and root are Active",
+
   `isActiveSpace` TINYINT(1)     NOT NULL COMMENT "(calculated) TRUE = all ancestors are isSelfActive=TRUE",
 +
  `isActivated`  TINYINT(1)      NOT NULL COMMENT "(calculated) TRUE = this Place is active",
 
   `Name`        VARCHAR(63)      NOT NULL COMMENT "brief descriptive name for listings and tree-paths",
 
   `Name`        VARCHAR(63)      NOT NULL COMMENT "brief descriptive name for listings and tree-paths",
 
   `Descr`        VARCHAR(127) DEFAULT NULL COMMENT "(optional) description of this place, so it can be located",
 
   `Descr`        VARCHAR(127) DEFAULT NULL COMMENT "(optional) description of this place, so it can be located",
 
   PRIMARY KEY(`ID`)
 
   PRIMARY KEY(`ID`)
  ) ENGINE = MYISAM;</mysql>
+
  ) ENGINE = InnoDB;</mysql>
<section end=sql />
 
 
==Archive==
 
==Archive==
 
These notes do not currently apply. They may be things we will want to use at some point, but are not currently in use on this table.
 
These notes do not currently apply. They may be things we will want to use at some point, but are not currently in use on this table.

Latest revision as of 11:56, 22 April 2017

About

  • Purpose: places where bins may be found, organized hierarchically
  • History:
    • 2010-11-30 added isActive field, so we can hide all the old GA places
    • 2012-02-06 added isEnabled field so cat_items stock can be calculated properly by query
      • Also corrected type for isActive to match actual table
    • 2017-04-22
      • Finally worked out better terminology. A Place is "active" if it is "enabled" AND is not contained by a Place that has been disabled (un-"enabled") -- but that's kind of the opposite of how we were using the terms. Rather than reverse them, I came up with something more specific and unambiguous.
        • Renamed "isEnabled" to "isActiveSpace".
        • Renamed "isActive" to "isSelfActive".
        • Created "isActivated".
      • At first, I thought maybe the caching of "is this Place within a Place that has not been disabled?" was unnecessary, but it turns out the customer-facing calculations of what is currently in stock use queries which depend on the isEnabled field. So now this needs to happen:
        • Whenever a Place record is saved and isSelfActive has changed, the code should update isActiveSpace for all contained Places.
      • Also changing from MYISAM to InnoDB, because there's really no reason to use MYISAM. (apparently this was done to the actual db earlier)
  • Fields:
    • isSelfActive: if FALSE, then normal operations should ignore this place and all places inside it.
    • isActiveSpace: (calculated) if TRUE, all parent-container Places are active (isSelfActive = TRUE)
    • isActivated: (calculated): isSelfActive && isActiveSpace -- this is the flag which stock calculations should look at

SQL

<mysql>CREATE TABLE `stk_places` (

  `ID` INT NOT NULL AUTO_INCREMENT,
  `ID_Parent`    INT                       COMMENT "self.ID of place in which this place is found; may be NULL",
  `isSelfActive`  TINYINT(1)      NOT NULL COMMENT "FALSE = don't normally show this place in lists or count its stock in totals",
  `isActiveSpace` TINYINT(1)      NOT NULL COMMENT "(calculated) TRUE = all ancestors are isSelfActive=TRUE",
  `isActivated`   TINYINT(1)      NOT NULL COMMENT "(calculated) TRUE = this Place is active",
  `Name`         VARCHAR(63)      NOT NULL COMMENT "brief descriptive name for listings and tree-paths",
  `Descr`        VARCHAR(127) DEFAULT NULL COMMENT "(optional) description of this place, so it can be located",
  PRIMARY KEY(`ID`)
) ENGINE = InnoDB;</mysql>

Archive

These notes do not currently apply. They may be things we will want to use at some point, but are not currently in use on this table.

  • Rules: Both stock Bins and order Packages can be in Places. Later, Places may have attributes to tell us whether we can ship items directly from there (or at all) and whether or not they are effectively "local" to us, but for now they don't.
  • Fields:
    • isLocal: FALSE = items aren't where we are, so they must either be shipped here first or shipped to customer in separate pkg
    • isWhse: TRUE = items have to be fetched for shipping; some delay involved, and may want to print out lists of stuff to fetch
    • ID_Supp: NOT NULL = this location is a supplier's stock, and items must be ordered from it in order to be shippable