You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Excel公式或VBA实现基于FIFO逻辑的出库总成本计算

FIFO Inventory Cost Calculation for Outbound Orders

Got it, let's work through implementing FIFO (First-In-First-Out) inventory costing for your outbound shipments. The goal is to calculate the total cost for each outbound line item by using the oldest available inventory first from your inbound list.

Input Data

Inbound (IN) Inventory List

PNQtyPrice
A1005
B1506
C1507
D50-9
E1005
F59
G206
I57
J157
J3010
K10010
K5010
A208

Outbound (OUT) Shipment List

PNQty
A120
B10
C110
D60
E100
J20
J10

FIFO Cost Calculation Logic

FIFO means we consume the oldest inventory batches first before moving to newer ones. For each outbound line item:

  1. Match the PN to all inbound batches of the same PN, ordered by their arrival (the sequence they appear in the IN list).
  2. Deduct the outbound quantity from the earliest available batches until the outbound qty is fully covered.
  3. Calculate the weighted average price for the outbound line if multiple batches are used, or use the single batch price if only one is needed.
  4. Total cost = Outbound Qty × Calculated Price.

Let’s break down key examples to clarify:

  • PN="A": Outbound qty is 120. We first take all 100 units from the first batch (price $5), then the remaining 20 units from the second batch (price $8). The weighted price is ((100*5)+(20*8))/120 = 5.5, total cost is 120×5.5=660.
  • PN="J" first outbound line (20 units): Take all 15 units from the first J batch (price $7), then 5 units from the second J batch (price $10). Weighted price is ((15*7)+(5*10))/20 = 7.75, total cost 20×7.75=155.
  • PN="J" second outbound line (10 units): Now 25 units remain in the second J batch. We take 10 units at $10, so total cost is 10×10=100.

Final Calculated Result

PNQtyPriceTotal
A1205.5660
B10660
C1107770
D60-9-540
E1005500
J207.75155
J1010100

Content of this question originates from Stack Exchange, asked by author baimzz.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:57:11