Manufacture — business logic
The document for producing a finished item from components — the only
document type where receiving and expenditure happen at once, in a single
action: components are written off stock by recipe (bill of materials), the
finished item is received. A product is an item that itself consists of
other items (see Concept, "Products — recipes
(BOM)").
A component is picked from real stock
Just like on expenditure, a component is written off from a specific
warehouse lot — the pick fixes the item, quantity, and price at the moment
the line is added. Adding a product by its recipe unfolds the bill of
materials all at once: the product line (receiving) and all of its
component lines (expenditure) are added in one action. Adding the same
product again in the same document doesn't create duplicates — the old set
of components is removed and rebuilt from the current recipe.
A shortage doesn't block production
If there aren't enough components in stock, production is still allowed.
The system doesn't refuse to process — it simply records the fact of the
shortage; the decision to restock components is left to the user. This
follows the system's general principle — record reality rather than
enforce the "correct" order of actions (see Concept, "the main
principle"
on manufacturing from components that aren't in stock).
What happens on processing
- Product receiving. Every product line is received into stock. If the
product's price isn't set explicitly, it's calculated automatically from
the cost of the written-off components plus any extra costs — with a
warning to the user, but without blocking processing. - Component expenditure. Every component is written off from whichever
lot was picked when the line was added — the same mechanism as an
ordinary expenditure. - The product's supplier is inherited from its components. If all
components were written off from a single supplier's lots, the produced
item is attributed to that supplier; if components came from different
suppliers, the item is considered owned by the main company. The user
never specifies a "product's supplier" explicitly — it's a computed
consequence of where the components actually came from.
The price mode is fixed for the whole document
The first product added to a document determines the price mode for the
entire document, not for an individual line:
- Manual mode — the product's price is entered by the user and isn't
touched by the automatic calculation; every subsequent product on the
document must also have a manually entered price. - Auto mode — the price is calculated from components and extra costs,
either on demand or automatically on processing if it isn't set
explicitly.
The mode isn't reset even if every product on the document is deleted and
re-added — otherwise the manual-mode rule could be bypassed by recreating
the line with the same price through a different path.