IMS. ← All docs

Receiving — business logic

The main way goods enter the system at all (aside from manufacture and a
direct stock correction). Receiving has one direction only — goods are
always added to stock, there's no reverse meaning for the document. A
customer return is the same document with a different operation, not a
separate type (see overview of types).

What happens on processing

For each receiving line:

  1. If the item doesn't yet have a "this item's price from this supplier"
    card, it's created.
  2. A new lot is created in stock: warehouse, supplier, quantity, price,
    arrival date, expiry date, order link (if any). It's the lot that goes
    on to live its own life afterward — expenditure, discounting,
    manufacture all reference the lot, not the source document's line.
  3. The item's summary card is updated — accumulated quantity and the last
    receiving price.
  4. The "last purchase price from this supplier" card is updated — but only
    if this receiving is newer than the already-stored price. An older
    receiving entered after the fact can't retroactively overwrite the
    current active price.

Receiving doesn't check availability "in reverse" — any quantity can be
accepted, there's no limit (unlike expenditure, which can't write off more
than is in stock).

Debt or payment

Why not the other way around (always recording debt): because real
practice varies — sometimes goods are paid for on the spot, sometimes taken
on credit. Explicitly specifying an account in the header is the user's own
decision about which of the two scenarios actually happened.

Two prices: Cost and Price

Every receiving line has a Cost (the cost basis at which the item
enters stock) and a Price (the supplier's invoice price). They usually
match, but diverge when there are extra costs — shipping, customs,
insurance, broker fees.

Extra costs are distributed across lines proportionally to each line's
value:

coefficient = total_extra_costs / total_goods_value
new_price   = original_price + original_price × coefficient

Any rounding remainder (cents that don't divide evenly) goes to the most
expensive line on the document — so the recalculated line sum exactly
matches (goods + extra costs), with no "lost" cents.

Example. Item A: 100 units × $10 = $1000. Item B: 50 units × $20 =
$1000. Total goods — $2000, shipping — $200. Coefficient 200/2000 = 0.1 →
item A's price becomes $11, item B's becomes $22 — the extra cost was
distributed in proportion to each item's share of the total.

Extra costs can be added to both prices at once, or to Cost only, leaving
Price as-is — the second option is needed when reconciling with a supplier
against the original invoice price, while stock needs the full landed cost.

Re-running the calculation (say, extra costs changed after the first pass)
always starts from the supplier's original price, not from the
already-adjusted one from the previous step — so re-running doesn't
"double up" the markup.