Document inventory management in the data model docs.

This commit is contained in:
Michael Stenta 2021-03-01 11:56:47 -05:00
parent 235b98afff
commit 99eae4de12
5 changed files with 68 additions and 0 deletions

View File

@ -27,6 +27,7 @@ keeping data types are **Assets** and **Logs**. Other types include
- [Location](/model/logic/location)
- [Group membership](/model/logic/group)
- [Inventory](/model/logic/inventory)
## Conventions

View File

@ -0,0 +1,20 @@
# Inventory
farmOS can track the inventory of Assets over time.
Inventory is tracked via [Logs](/model/type/log) with *inventory adjustment*
[Quantities](/model/type/quantity). The Inventory module adds two fields to
Quantity records: "inventory asset" and "inventory adjustment". Each Quantity
can reference a single Asset, and either "reset", "increment", or "decrement"
that Asset's inventory. The Quantity's "measure", "value", and "units" fields
are used in the inventory calculations.
Asset inventory is determined by querying all Quantities that reference the
Asset and define an adjustment type of "reset", "increment", or "decrement".
Inventory is calculated by adding all "increment" adjustments and subtracting
all "decrement" adjustments, starting from the most recent "reset" adjustment
(or zero if no "reset" adjustment exists).
A separate inventory is tracked for each measure+unit pair, so Assets can have
a single simple inventory (without a specified measure or unit), or they can
have multiple inventories of different measures and units.

View File

@ -140,6 +140,23 @@ created or managed by software outside of farmOS, it can be identified easily.
It can also be used to store additional structured metadata that does not fit
into the standard Asset attributes.
### Additional attributes
Assets *may* contain additional attributes:
- Inventory
#### Inventory
The inventory attribute summarizes current Asset inventory levels. This field
is not editable itself, but is rather computed based on "inventory adjustment"
logs. Each inventory can have a "measure", "value", and "units".
For more information, see [farmOS Inventory Logic](/model/logic/inventory).
This field is added to all Asset types by default only if the Inventory module
is enabled.
## Relationships
Assets can be related to other records in farmOS These relationships are

View File

@ -74,6 +74,19 @@ integers (numerator and denominator).
A Quantity may have a label assigned to it. This helps to distinguish multiple
Quantities of the same measure within a Log.
### Additional attributes
Quantities *may* contain additional attributes:
- Inventory adjustment
#### Inventory adjustment
A Quantity can be designated as an "inventory adjustment" to reset, increment,
or decrement the inventory of Assets referenced (see "Inventory asset" below).
For more information, see [farmOS Inventory Logic](/model/logic/inventory).
## Relationships
All Quantities have the same standard set of relationships. Modules can add
@ -90,6 +103,22 @@ Relationships that are common to all Quantity types include:
The Unit of measurement is stored as a [Term](/model/type/term) in the Units
vocabulary.
### Additional relationships
Quantities *may* contain additional relationships:
- Inventory asset
#### Inventory asset
Quantities can reference Assets, along with the "Inventory adjustment"
attribute (above) to record adjustments to the Asset's inventory.
This field is added to all Quantity types by default only if the Inventory
module is enabled.
For more information, see [farmOS Inventory Logic](/model/logic/inventory).
## Type-specific fields
In addition to the fields that are common to all Quantity types described

View File

@ -12,6 +12,7 @@ nav:
- Logic:
- Location: model/logic/location.md
- Group membership: model/logic/group.md
- Inventory: model/logic/inventory.md
- Conventions: model/convention/index.md
- Development:
- API: