{"id":"inventory-fifo-period-close","version":"1.0.0","description":"Close a periodic FIFO inventory period with exact valuation and a balanced caller-mapped closing entry.","supported_operations":["close periodic FIFO inventory","prepare FIFO closing entry","post periodic inventory adjustment","balance FIFO inventory close","period-end FIFO journal","inventory close exact arithmetic"],"unsupported_operations":["perpetual FIFO transaction processing","tax or legal advice"],"semantics":["Periodic FIFO assigns the earliest available units to cost of goods sold and retains the latest units in ending inventory; it does not model intra-period sales.","Layers sort by acquired_on ascending, then beginning before purchase, then zero-based input_index, then layer_id; input_index makes equal-date ties explicit and deterministic.","Quantities and unit costs are canonical nonnegative decimal strings. All products and sums use integer/rational arithmetic; binary floating point is never used.","output_scale is explicit (0 through 12). Valuation totals and layer extensions are rounded once at final presentation, never per unit or cumulatively. The journal uses a documented balancing-residual policy: round goods available, beginning inventory, and ending inventory once; post COGS as rounded goods available minus rounded ending inventory and Purchases as rounded goods available minus rounded beginning inventory. Thus actual lines balance even when independently rounded components would not. Supported modes are half-up, half-even, half-down, up, down, ceiling and floor.","Inputs are immutable. Output contains reference_version IAS-2-2024-25-27+periodic-FIFO-v1.","Disclaimer: arithmetic calculation only; not financial, tax, legal, or investment advice."],"limits":{"max_input_bytes":131072,"max_layers_per_source":500,"max_layers":1000,"max_string_bytes":64,"max_output_bytes":8192},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["beginning_layers","purchases","physical_ending_quantity","output_scale","rounding_mode","accounts"],"properties":{"beginning_layers":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["layer_id","acquired_on","quantity","unit_cost"],"properties":{"layer_id":{"type":"string","minLength":1,"maxLength":64},"acquired_on":{"type":"string","pattern":"^[0-9]{4}-[0-9]{2}-[0-9]{2}$"},"quantity":{"type":"string","pattern":"^(0|[1-9][0-9]{0,17})(\\.[0-9]{1,12})?$","maxLength":32},"unit_cost":{"type":"string","pattern":"^(0|[1-9][0-9]{0,17})(\\.[0-9]{1,12})?$","maxLength":32}}},"maxItems":500},"purchases":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["layer_id","acquired_on","quantity","unit_cost"],"properties":{"layer_id":{"type":"string","minLength":1,"maxLength":64},"acquired_on":{"type":"string","pattern":"^[0-9]{4}-[0-9]{2}-[0-9]{2}$"},"quantity":{"type":"string","pattern":"^(0|[1-9][0-9]{0,17})(\\.[0-9]{1,12})?$","maxLength":32},"unit_cost":{"type":"string","pattern":"^(0|[1-9][0-9]{0,17})(\\.[0-9]{1,12})?$","maxLength":32}}},"maxItems":500},"physical_ending_quantity":{"type":"string","pattern":"^(0|[1-9][0-9]{0,17})(\\.[0-9]{1,12})?$","maxLength":32},"output_scale":{"type":"integer","minimum":0,"maximum":12},"rounding_mode":{"type":"string","enum":["half-up","half-even","half-down","up","down","ceiling","floor"]},"accounts":{"type":"object","additionalProperties":false,"required":["inventory","cogs","purchases"],"properties":{"inventory":{"type":"string","minLength":1,"maxLength":64},"cogs":{"type":"string","minLength":1,"maxLength":64},"purchases":{"type":"string","minLength":1,"maxLength":64}}}}},"output_schema":{"type":"object","additionalProperties":false,"required":["reference_version","valuation","postings","debits","credits"],"properties":{"reference_version":{"type":"string","const":"IAS-2-2024-25-27+periodic-FIFO-v1"},"valuation":{"type":"object","additionalProperties":false,"required":["reference_version","available_quantity","ending_quantity","sold_quantity","goods_available_cost","ending_inventory","cogs","ending_layers"],"properties":{"reference_version":{"type":"string","const":"IAS-2-2024-25-27+periodic-FIFO-v1"},"available_quantity":{"type":"string"},"ending_quantity":{"type":"string"},"sold_quantity":{"type":"string"},"goods_available_cost":{"type":"string"},"ending_inventory":{"type":"string"},"cogs":{"type":"string"},"ending_layers":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["layer_id","source","input_index","acquired_on","quantity","unit_cost","extended_cost"],"properties":{"layer_id":{"type":"string"},"source":{"type":"string","enum":["beginning","purchase"]},"input_index":{"type":"integer","minimum":0,"maximum":499},"acquired_on":{"type":"string"},"quantity":{"type":"string"},"unit_cost":{"type":"string"},"extended_cost":{"type":"string"}}},"maxItems":1000}}},"postings":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["line","account","debit","credit"],"properties":{"line":{"type":"integer","minimum":1,"maximum":4},"account":{"type":"string"},"debit":{"type":"string"},"credit":{"type":"string"}}},"minItems":4,"maxItems":4},"debits":{"type":"string"},"credits":{"type":"string"}}},"examples":[{"input":{"beginning_layers":[{"layer_id":"B1","acquired_on":"2026-01-01","quantity":"10","unit_cost":"2.00"}],"purchases":[{"layer_id":"P1","acquired_on":"2026-01-10","quantity":"5","unit_cost":"3.00"}],"physical_ending_quantity":"6","output_scale":2,"rounding_mode":"half-up","accounts":{"inventory":"Inventory","cogs":"COGS","purchases":"Purchases"}},"output":{"reference_version":"IAS-2-2024-25-27+periodic-FIFO-v1","valuation":{"reference_version":"IAS-2-2024-25-27+periodic-FIFO-v1","available_quantity":"15","ending_quantity":"6","sold_quantity":"9","goods_available_cost":"35.00","ending_inventory":"17.00","cogs":"18.00","ending_layers":[{"layer_id":"B1","source":"beginning","input_index":0,"acquired_on":"2026-01-01","quantity":"1","unit_cost":"2","extended_cost":"2.00"},{"layer_id":"P1","source":"purchase","input_index":0,"acquired_on":"2026-01-10","quantity":"5","unit_cost":"3","extended_cost":"15.00"}]},"postings":[{"line":1,"account":"Inventory","debit":"17.00","credit":"0.00"},{"line":2,"account":"COGS","debit":"18.00","credit":"0.00"},{"line":3,"account":"Purchases","debit":"0.00","credit":"15.00"},{"line":4,"account":"Inventory","debit":"0.00","credit":"20.00"}],"debits":"35.00","credits":"35.00"}},{"input":{"beginning_layers":[{"layer_id":"B1","acquired_on":"2026-01-01","quantity":"3","unit_cost":"1.25"}],"purchases":[{"layer_id":"P1","acquired_on":"2026-01-02","quantity":"4","unit_cost":"2.50"},{"layer_id":"P2","acquired_on":"2026-01-03","quantity":"2","unit_cost":"4.00"}],"physical_ending_quantity":"5","output_scale":2,"rounding_mode":"half-even","accounts":{"inventory":"Inventory","cogs":"COGS","purchases":"Purchases"}},"output":{"reference_version":"IAS-2-2024-25-27+periodic-FIFO-v1","valuation":{"reference_version":"IAS-2-2024-25-27+periodic-FIFO-v1","available_quantity":"9","ending_quantity":"5","sold_quantity":"4","goods_available_cost":"21.75","ending_inventory":"15.50","cogs":"6.25","ending_layers":[{"layer_id":"P1","source":"purchase","input_index":0,"acquired_on":"2026-01-02","quantity":"3","unit_cost":"2.5","extended_cost":"7.50"},{"layer_id":"P2","source":"purchase","input_index":1,"acquired_on":"2026-01-03","quantity":"2","unit_cost":"4","extended_cost":"8.00"}]},"postings":[{"line":1,"account":"Inventory","debit":"15.50","credit":"0.00"},{"line":2,"account":"COGS","debit":"6.25","credit":"0.00"},{"line":3,"account":"Purchases","debit":"0.00","credit":"18.00"},{"line":4,"account":"Inventory","debit":"0.00","credit":"3.75"}],"debits":"21.75","credits":"21.75"}}],"execute_url":"/v1/tools/inventory-fifo-period-close/versions/1.0.0/execute"}