Caltru

Feature

Historical costs

A cost is a fact about a moment. Caltru writes it against the order line when the sale happens, and nothing afterwards can move it — including a refund issued months later.

The core

The recorded cost is never rewritten

A ledger row is written the moment an order line is created, from any path, and nothing that happens afterwards can move it.

  • A ledger row is written the moment an order line is created — checkout, admin Add item, REST, WP-CLI, an import. One set of hooks covers every path, because they all pass through WooCommerce's CRUD layer.
  • Editing the product, recalculating totals, or another plugin calling calculate_totals() all leave the recorded cost alone.
  • WooCommerce is handed the historical figure back, through its own per-item cost filter — so core's order screens, and anything else reading that value, show what the order actually cost rather than what the product costs today.
  • Lines recorded without a cost get a second chance: entering the cost later fills them in, marked as an estimate, never overwriting a real figure.
  • VAT-inclusive costs are normalised using each product's own tax class, not one flat rate.
  • Costs live in WooCommerce's own Cost of Goods Sold field, not a private copy — so they stay with the products whatever the shop does next.

There is a test that sets a cost, places an order, changes the cost to something else, recalculates the order, refunds part of it, and asserts every historical figure is untouched.

That test is the product. Everything on this page is a consequence of it.

Dating

A refund is dated by the refund

Its own negative ledger row, on the day it happened — so a closed month never changes underneath anyone.

  • A refund is its own negative ledger row, dated by the refund and not by the original order.
  • Cost is returned only for the quantity actually returned, matching what WooCommerce itself does.
  • A partial refund reduces profit on the refund date by exactly that share.
  • An amount-only goodwill refund — no product behind it — is reported as its own line, not spread proportionally across unrelated products.

Most cost plugins either ignore refunds or prorate them, which silently moves profit between products and between months.

Prorating is invented attribution. This refuses to invent it: a goodwill refund with no product behind it is reported as exactly that, and the products that had nothing to do with it keep their margins.

Stop finding out when a customer does.

What to order, how many, and the arithmetic behind it — inside the WooCommerce admin you already use.

Not an ERP and not a purchasing suite. Caltru works out what to order; placing the order stays with you. What's deliberately not included