Migrated from GitLab wiki
@@ -0,0 +1,11 @@
|
||||
# Purpose
|
||||
|
||||
Infinite inventory was implemented to provide a mode of operation for users who don't have stock-level data. All SKUs are considered to have an infinite amount of inventory available, by way of a single initial bucket with an infinite quantity.. Users can later "back in" to inventory tracking by setting concrete values for stock-level (by creating a new bucket), and apply a blended/estimated cost-price for any previously removed stock that was counted against the infinite bucket.
|
||||
|
||||
# Implementation
|
||||
|
||||
The quantity 'infinity' is represented in the PHP context as a float value of 'INF'. This is a little ugly, since every other stock-level value is an integer, but it works.
|
||||
|
||||
Stock-Levels in the database (MariaDB) are stored as integers, and the database has no concept of infinity. Therefore, we represent infinite quantities as NULL in the relevant integer columns. This allows most arithmetic to work since `5 + NULL = NULL`, `NULL - 5 = NULL`. Though `5/NULL = NULL` (while division by infinity should probably approximate to zero).
|
||||
|
||||
Thus, in the database initial infinite buckets are created with `InventoryBucket.qty = NULL`. There is also currently an isInfinite flag on buckets, and I currently don't remember why it exists or where it's used.
|
||||
Reference in New Issue
Block a user