fifo

fifo, function

def process fifo(onHand: number, purchDate: date, purchQty: number): number

Returns the remaining units per purchase order assuming FIFO consumption, based on onHand and the purchase stream described by purchDate and purchQty.

Examples

table Items[id] = with
  [| as id, as OnHand |]
  [| "cap", 5 |]

table POs = with
  [| as Pid, as PurchDate, as PurchQty |]
  [| "cap", date(2020, 1, 1), 2 |]
  [| "cap", date(2020, 1, 5), 3 |]

POs.Remain = fifo(Items.OnHand[POs.Pid], POs.PurchDate, POs.PurchQty)

show table "FIFO" with
  POs.PurchDate
  POs.PurchQty
  POs.Remain

This produces the following table:

PurchDate PurchQty Remain
2020-01-01 2 2
2020-01-05 3 3

See also

User Contributed Notes
0 notes + add a note