Case 920

The oldest cost was charged first and the profit was inflation

the_oldest_cost_was_charged_first_and_the_profit_was_inflation.eml - A shop buys a hundred units in January at 10 and a hundred in June at 15, sells a hundred in July at 20, and charges the January cost against the sale as its oldest-first method requires. What the profit contains when the units sold are replaced at today's price is computed below.

ok: true — round-trip fixpoint reached (python1 == python2)updated 2026-09-19

EML

eml
# Self-authored for the EML case corpus (no external origin). A shop buys a
# hundred units in January at 10 and a hundred in June at 15, sells a hundred
# in July at 20, and charges the January cost against the sale as its
# oldest-first method requires. What the profit contains when the units sold
# are replaced at today's price is computed below.
#
# The books are careful. Both purchases are real and at real prices; the sale
# is real; the oldest-first rule is applied exactly; and the intent is exactly
# 'how much did the shop make on the sale'.
#
# The units sold must be replaced at 15, not 10, so half the reported profit is
# the rise in the price of stock the shop still has to hold - a gain on paper
# that is taxed as if it were money made.

100 => units_bought_in_january
10 => january_cost_per_unit
100 => units_bought_in_june
15 => june_cost_per_unit
100 => units_sold_in_july
20 => selling_price_per_unit

units_sold_in_july * selling_price_per_unit => sale_proceeds
units_sold_in_july * january_cost_per_unit => cost_charged_oldest_first
sale_proceeds - cost_charged_oldest_first => reported_profit
units_sold_in_july * june_cost_per_unit => cost_to_replace_the_units_sold
sale_proceeds - cost_to_replace_the_units_sold => profit_after_replacement
reported_profit - profit_after_replacement => holding_gain_inside_the_profit
int(holding_gain_inside_the_profit * 10000 / reported_profit) => share_of_profit_that_is_price_rise_per_myriad

"bought in January               : " + str(units_bought_in_january) + " at " + str(january_cost_per_unit) ^0
"bought in June                  : " + str(units_bought_in_june) + " at " + str(june_cost_per_unit) ^0
"sold in July                    : " + str(units_sold_in_july) + " at " + str(selling_price_per_unit) + ", proceeds " + str(sale_proceeds) ^0
"" ^0
"cost charged, oldest first      : " + str(cost_charged_oldest_first) ^0
"reported profit                 : " + str(reported_profit) ^0
"cost to replace what was sold   : " + str(cost_to_replace_the_units_sold) ^0
"profit after replacement        : " + str(profit_after_replacement) ^0
"holding gain inside the profit  : " + str(holding_gain_inside_the_profit) + ", " + str(share_of_profit_that_is_price_rise_per_myriad) + " per ten thousand of the profit" ^0
"" ^0

# ---- what the books verified ----

"the oldest-first books" ^0
"  purchases : real, at real prices" ^0
"  sale : real" ^0
"  rule : oldest cost charged first, exactly" ^0
"  intent : how much did the shop make on the sale" ^0
"  units misattributed : 0" ^0
"  verdict : PROFIT 1000 ON THE JULY SALE" ^0
"" ^0
"  applying the oldest-first rule exactly to real purchases" ^0
"  is the part done right here, and it is why " + str(reported_profit) + " is" ^0
"  precisely the rule's answer" ^0
"" ^0

# ---- what the profit contains ----

"two kinds of gain" ^0
"  the trading gain : sell at " + str(selling_price_per_unit) + " what costs " + str(june_cost_per_unit) + " to put back, " + str(profit_after_replacement) ^0
"  the holding gain : stock bought at " + str(january_cost_per_unit) + " now worth " + str(june_cost_per_unit) + ", " + str(holding_gain_inside_the_profit) ^0
"  what oldest-first reports : both, as one number" ^0
"  what the shop can spend : the trading gain; the holding" ^0
"    gain is already committed to restocking" ^0
"  what is taxed : the whole " + str(reported_profit) ^0
"" ^0

# ---- what the shop got ----

"after the sale" ^0
"  reported : " + str(reported_profit) ^0
"  left after replacing the units : " + str(profit_after_replacement) ^0
"  is the rule misapplied : no" ^0
"  is " + str(reported_profit) + " what the shop made : half of it is the price of" ^0
"    stock rising while it sat on the shelf" ^0
"" ^0

# ---- null control ----

# The same sale costed at replacement (or newest-first), so the profit is the
# trading gain and the holding gain is shown separately.
1000 => nc_profit_shown_oldest_first
500 => nc_profit_shown_at_replacement_cost
500 => nc_holding_gain_shown_separately

"null control - cost the sale at replacement" ^0
"  profit shown, oldest first : " + str(nc_profit_shown_oldest_first) ^0
"  profit shown, replacement cost : " + str(nc_profit_shown_at_replacement_cost) ^0
"  holding gain shown separately : " + str(nc_holding_gain_shown_separately) ^0
"  no purchase and no sale changed; the price rise stopped" ^0
"  being reported as trade" ^0
"" ^0

# ---- the rule ----

"what an exact oldest-first costing guarantees" ^0
"  the sale is matched to the oldest units' cost : exactly," ^0
"    real purchases, the rule to the letter" ^0
"  the profit is what the shop made : not addressed; the" ^0
"    units sold cost " + str(cost_to_replace_the_units_sold) + " to replace, so " + str(holding_gain_inside_the_profit) + " of the " + str(reported_profit) + " is the" ^0
"    stock's price rising, " + str(share_of_profit_that_is_price_rise_per_myriad) + " per ten thousand of the profit" ^0
"" ^0

"a cost from January set against a sale in July measures the months between" ^0
"as profit; when prices rise, the oldest cost is the cheapest, and the gap it" ^0
"opens is inflation wearing the shape of trade" ^0
"" ^0

"The oldest-first rule is applied exactly to real purchases - " + str(reported_profit) + " is its answer." ^0
"But the units sold cost " + str(cost_to_replace_the_units_sold) + " to put back, so " + str(holding_gain_inside_the_profit) + " of that profit is the" ^0
"January stock's price rising on the shelf, " + str(share_of_profit_that_is_price_rise_per_myriad) + " per ten thousand of the" ^0
"reported figure, until the sale is costed at replacement." ^0

Python (deterministic transpilation)

python
units_bought_in_january = 100
january_cost_per_unit = 10
units_bought_in_june = 100
june_cost_per_unit = 15
units_sold_in_july = 100
selling_price_per_unit = 20
sale_proceeds = units_sold_in_july * selling_price_per_unit
cost_charged_oldest_first = units_sold_in_july * january_cost_per_unit
reported_profit = sale_proceeds - cost_charged_oldest_first
cost_to_replace_the_units_sold = units_sold_in_july * june_cost_per_unit
profit_after_replacement = sale_proceeds - cost_to_replace_the_units_sold
holding_gain_inside_the_profit = reported_profit - profit_after_replacement
share_of_profit_that_is_price_rise_per_myriad = int(holding_gain_inside_the_profit * 10000 / reported_profit)
print("bought in January               : " + str(units_bought_in_january) + " at " + str(january_cost_per_unit))
print("bought in June                  : " + str(units_bought_in_june) + " at " + str(june_cost_per_unit))
print("sold in July                    : " + str(units_sold_in_july) + " at " + str(selling_price_per_unit) + ", proceeds " + str(sale_proceeds))
print("")
print("cost charged, oldest first      : " + str(cost_charged_oldest_first))
print("reported profit                 : " + str(reported_profit))
print("cost to replace what was sold   : " + str(cost_to_replace_the_units_sold))
print("profit after replacement        : " + str(profit_after_replacement))
print("holding gain inside the profit  : " + str(holding_gain_inside_the_profit) + ", " + str(share_of_profit_that_is_price_rise_per_myriad) + " per ten thousand of the profit")
print("")
print("the oldest-first books")
print("  purchases : real, at real prices")
print("  sale : real")
print("  rule : oldest cost charged first, exactly")
print("  intent : how much did the shop make on the sale")
print("  units misattributed : 0")
print("  verdict : PROFIT 1000 ON THE JULY SALE")
print("")
print("  applying the oldest-first rule exactly to real purchases")
print("  is the part done right here, and it is why " + str(reported_profit) + " is")
print("  precisely the rule's answer")
print("")
print("two kinds of gain")
print("  the trading gain : sell at " + str(selling_price_per_unit) + " what costs " + str(june_cost_per_unit) + " to put back, " + str(profit_after_replacement))
print("  the holding gain : stock bought at " + str(january_cost_per_unit) + " now worth " + str(june_cost_per_unit) + ", " + str(holding_gain_inside_the_profit))
print("  what oldest-first reports : both, as one number")
print("  what the shop can spend : the trading gain; the holding")
print("    gain is already committed to restocking")
print("  what is taxed : the whole " + str(reported_profit))
print("")
print("after the sale")
print("  reported : " + str(reported_profit))
print("  left after replacing the units : " + str(profit_after_replacement))
print("  is the rule misapplied : no")
print("  is " + str(reported_profit) + " what the shop made : half of it is the price of")
print("    stock rising while it sat on the shelf")
print("")
nc_profit_shown_oldest_first = 1000
nc_profit_shown_at_replacement_cost = 500
nc_holding_gain_shown_separately = 500
print("null control - cost the sale at replacement")
print("  profit shown, oldest first : " + str(nc_profit_shown_oldest_first))
print("  profit shown, replacement cost : " + str(nc_profit_shown_at_replacement_cost))
print("  holding gain shown separately : " + str(nc_holding_gain_shown_separately))
print("  no purchase and no sale changed; the price rise stopped")
print("  being reported as trade")
print("")
print("what an exact oldest-first costing guarantees")
print("  the sale is matched to the oldest units' cost : exactly,")
print("    real purchases, the rule to the letter")
print("  the profit is what the shop made : not addressed; the")
print("    units sold cost " + str(cost_to_replace_the_units_sold) + " to replace, so " + str(holding_gain_inside_the_profit) + " of the " + str(reported_profit) + " is the")
print("    stock's price rising, " + str(share_of_profit_that_is_price_rise_per_myriad) + " per ten thousand of the profit")
print("")
print("a cost from January set against a sale in July measures the months between")
print("as profit; when prices rise, the oldest cost is the cheapest, and the gap it")
print("opens is inflation wearing the shape of trade")
print("")
print("The oldest-first rule is applied exactly to real purchases - " + str(reported_profit) + " is its answer.")
print("But the units sold cost " + str(cost_to_replace_the_units_sold) + " to put back, so " + str(holding_gain_inside_the_profit) + " of that profit is the")
print("January stock's price rising on the shelf, " + str(share_of_profit_that_is_price_rise_per_myriad) + " per ten thousand of the")
print("reported figure, until the sale is costed at replacement.")

stdout (executed)

text
bought in January               : 100 at 10
bought in June                  : 100 at 15
sold in July                    : 100 at 20, proceeds 2000

cost charged, oldest first      : 1000
reported profit                 : 1000
cost to replace what was sold   : 1500
profit after replacement        : 500
holding gain inside the profit  : 500, 5000 per ten thousand of the profit

the oldest-first books
  purchases : real, at real prices
  sale : real
  rule : oldest cost charged first, exactly
  intent : how much did the shop make on the sale
  units misattributed : 0
  verdict : PROFIT 1000 ON THE JULY SALE

  applying the oldest-first rule exactly to real purchases
  is the part done right here, and it is why 1000 is
  precisely the rule's answer

two kinds of gain
  the trading gain : sell at 20 what costs 15 to put back, 500
  the holding gain : stock bought at 10 now worth 15, 500
  what oldest-first reports : both, as one number
  what the shop can spend : the trading gain; the holding
    gain is already committed to restocking
  what is taxed : the whole 1000

after the sale
  reported : 1000
  left after replacing the units : 500
  is the rule misapplied : no
  is 1000 what the shop made : half of it is the price of
    stock rising while it sat on the shelf

null control - cost the sale at replacement
  profit shown, oldest first : 1000
  profit shown, replacement cost : 500
  holding gain shown separately : 500
  no purchase and no sale changed; the price rise stopped
  being reported as trade

what an exact oldest-first costing guarantees
  the sale is matched to the oldest units' cost : exactly,
    real purchases, the rule to the letter
  the profit is what the shop made : not addressed; the
    units sold cost 1500 to replace, so 500 of the 1000 is the
    stock's price rising, 5000 per ten thousand of the profit

a cost from January set against a sale in July measures the months between
as profit; when prices rise, the oldest cost is the cheapest, and the gap it
opens is inflation wearing the shape of trade

The oldest-first rule is applied exactly to real purchases - 1000 is its answer.
But the units sold cost 1500 to put back, so 500 of that profit is the
January stock's price rising on the shelf, 5000 per ten thousand of the
reported figure, until the sale is costed at replacement.

Trace event types

eml:run:starteml:assigneml:outputeml:run:done