askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
danq9
signup: the person chooses the password and name on the confirm page
83c7aa6
2 weeks, 5 days ago
History
stock_moves.json · 4.8 KB · 135 lines
| 1 | { |
| 2 | "name": "stock_moves", |
| 3 | "title": "Stock Moves", |
| 4 | "version": 3, |
| 5 | "storage": "append", |
| 6 | "hooks": { |
| 7 | "before_write": "hook_stock_moves" |
| 8 | }, |
| 9 | "description": "Immutable ledger of inventory movement: product_id moves quantity from from_location_id to to_location_id. Never updated once written -- stock LEVELS are derived by folding this log (see object_stock.py), never stored on this collection or anywhere else. Reconciled against a private predecessor-system catalog audit, not part of this repo (its StockMove model: 'immutable, levels DERIVED not stored'). This is the textbook append-mode collection per docs/append-only-storage-design.md: write-heavy, never updated, an inspectable audit trail by design -- see docs/storage-modes.md's 'Append (opt-in per collection)' section for what that changes about how this collection is physically written and read. TAX POSTURE: some jurisdictions assess business personal property tax on inventory VALUE as of a specific date, per location -- this log supports that by construction (fold moves up to any date, per location, at stamped unit_cost_cents); nothing may ever collapse the location dimension or overwrite stamped costs.", |
| 10 | "fields": [ |
| 11 | { |
| 12 | "name": "id" |
| 13 | }, |
| 14 | { |
| 15 | "name": "product_id", |
| 16 | "type": "relation", |
| 17 | "required": true, |
| 18 | "relation": { |
| 19 | "collection": "products", |
| 20 | "display_field": "name" |
| 21 | }, |
| 22 | "label": "Product" |
| 23 | }, |
| 24 | { |
| 25 | "name": "from_location_id", |
| 26 | "label": "From Location", |
| 27 | "relation": { |
| 28 | "collection": "locations", |
| 29 | "display_field": "name" |
| 30 | }, |
| 31 | "help": "Optional -- blank means an external origin (e.g. a purchase, where stock enters from outside any tracked location)." |
| 32 | }, |
| 33 | { |
| 34 | "name": "to_location_id", |
| 35 | "label": "To Location", |
| 36 | "relation": { |
| 37 | "collection": "locations", |
| 38 | "display_field": "name" |
| 39 | }, |
| 40 | "help": "Optional -- blank means an external destination (e.g. a sale, where stock leaves to outside any tracked location)." |
| 41 | }, |
| 42 | { |
| 43 | "name": "quantity", |
| 44 | "type": "number", |
| 45 | "required": true, |
| 46 | "label": "Quantity", |
| 47 | "help": "A count/measure, not money -- may be fractional. The one deliberate float-shaped exception in this package, same as app-orders' order_lines.quantity: Decimal arithmetic everywhere this is read (object_stock.py), never a bare float." |
| 48 | }, |
| 49 | { |
| 50 | "name": "unit_cost_cents", |
| 51 | "type": "integer", |
| 52 | "label": "Unit Cost (cents)", |
| 53 | "help": "Optional. Integer cents, never a float or currency type, per 00-doctrine-and-contract.md." |
| 54 | }, |
| 55 | { |
| 56 | "name": "reason", |
| 57 | "type": "enum", |
| 58 | "label": "Reason", |
| 59 | "default": "transfer", |
| 60 | "enum": [ |
| 61 | "purchase", |
| 62 | "sale", |
| 63 | "transfer", |
| 64 | "adjustment", |
| 65 | "return", |
| 66 | "count", |
| 67 | "waste", |
| 68 | "breakage", |
| 69 | "theft", |
| 70 | "expiry", |
| 71 | "damage", |
| 72 | "disaster" |
| 73 | ], |
| 74 | "help": "The first six match the predecessor system's stock move reasons (reconciled against a private source audit, not part of this repo). v3 adds the LOSS taxonomy (plan/inventory-adjustments-spec.md): waste/breakage/theft/expiry/damage/disaster name what actually happened instead of hiding it under 'adjustment' -- a loss move leaves from_location_id with NO to_location_id (goods left the system; hook-enforced) and composes a shrinkage journal (system_stock_books). 'adjustment' remains for count variances only (action_apply_count writes them)." |
| 75 | }, |
| 76 | { |
| 77 | "name": "reference", |
| 78 | "type": "text", |
| 79 | "label": "Reference", |
| 80 | "help": "Free-text provenance pointer, e.g. an order id. No enforced relation -- this package has no hard dependency on app-orders." |
| 81 | }, |
| 82 | { |
| 83 | "name": "occurred_at", |
| 84 | "type": "datetime", |
| 85 | "label": "Occurred" |
| 86 | }, |
| 87 | { |
| 88 | "name": "owner_id", |
| 89 | "type": "text", |
| 90 | "label": "Owner" |
| 91 | }, |
| 92 | { |
| 93 | "name": "entity_id", |
| 94 | "type": "text", |
| 95 | "label": "Entity", |
| 96 | "relation": { |
| 97 | "collection": "entities", |
| 98 | "display_field": "name" |
| 99 | }, |
| 100 | "help": "The set of books this belongs to (65 multi-entity). Optional during rollout; backfilled to the owner's default entity, set by the entity switcher on new writes." |
| 101 | }, |
| 102 | { |
| 103 | "name": "created_at", |
| 104 | "type": "datetime", |
| 105 | "label": "Created", |
| 106 | "read_only": true |
| 107 | } |
| 108 | ], |
| 109 | "forms": { |
| 110 | "default": { |
| 111 | "fields": [ |
| 112 | "product_id", |
| 113 | "from_location_id", |
| 114 | "to_location_id", |
| 115 | "quantity", |
| 116 | "unit_cost_cents", |
| 117 | "reason", |
| 118 | "reference", |
| 119 | "occurred_at" |
| 120 | ] |
| 121 | } |
| 122 | }, |
| 123 | "views": { |
| 124 | "list_mode": "table", |
| 125 | "list_fields": [ |
| 126 | "product_id", |
| 127 | "reason", |
| 128 | "quantity", |
| 129 | "occurred_at" |
| 130 | ], |
| 131 | "filter_fields": [ |
| 132 | "reason" |
| 133 | ] |
| 134 | } |
| 135 | } |