(Note · · 5 min read)
Two reports disagree about what the stock is worth
A hundred units bought at different prices over six months are now in one warehouse. Asked what they are worth, a system can give several different answers, all arithmetically correct. Which one it gives should be a decision somebody made, and usually it is a side effect of how a query was written.
By Md. Habibur Rahman Shohel, full-stack & AI product engineer in Dhaka
The cost of a unit is not a property of the unit
Identical items bought at different times cost different amounts. When one is sold, which purchase it came from is a question the physical world does not answer, so a rule has to be chosen: oldest first, weighted average of what is held, or the specific batch identified.
Each gives a different cost of sale, therefore a different profit figure and a different closing stock value. None is wrong. Applying different ones in different reports is.
Choose one, store it, apply it in one place
Make the method an explicit setting, and compute valuation through a single code path every report calls. The failure mode is two developers, six months apart, each writing a reasonable cost calculation — after which two screens disagree and nobody can say which to trust.
Where the rule may change, record which method produced each historical figure. Recomputing the past under a new rule silently restates reports that have already been acted on.
Record cost on the movement
With a movement ledger, store the unit cost on each incoming entry and the cost assigned on each outgoing one. Valuation then becomes reading entries rather than reconstructing prices from purchase history.
That also makes a weighted average honest: it is the average of what is actually held, which changes with each receipt, and storing the cost at the moment of each movement is the only way to reproduce the figure later.
Decide what counts as cost
The invoice price is rarely the whole cost. Freight, duty and handling belong in the value of the goods; whether your system includes them changes every margin figure it produces.
Decide, write it down, and apply it consistently — including when those charges arrive on a separate invoice weeks later, which is the case that gets handled by whoever happens to be entering it.
Returns go back at the cost they left
A returned item re-enters stock, and valuing it at today's price rather than the cost assigned when it was sold creates profit or loss out of nothing. Reference the original movement so the reversal carries the original cost.
The same applies to a cancelled purchase and a transfer between locations: a transfer is not a sale and must not change total value, only where it sits.
Round once, and make it reconcile
Valuation multiplies quantities by unit costs and sums them, which is where fractions of a currency unit accumulate. Hold costs with enough precision to be accurate, round when presenting, and make sure the total shown equals the sum of the lines shown.
A report whose lines do not add to its own total is the fastest way to lose a finance team's confidence in a system — and the fastest way to be asked to prove every other number in it.
Common questions
Why do two reports give different stock values?
Because identical items bought at different prices can be costed by different rules — oldest first, weighted average, or specific batch — and each gives a different cost of sale and closing value. All are defensible; applying different ones in different reports is not.
How should a valuation method be managed in code?
As an explicit stored setting with a single code path that every report calls, and a record of which method produced each historical figure. Two reasonable calculations written months apart is how two screens come to disagree with no way to tell which is right.
Should freight and duty be part of inventory cost?
That is a decision to make and write down, because it changes every margin figure. Whatever you choose, apply it consistently — including when those charges arrive on a separate invoice weeks after the goods.
At what cost does a returned item re-enter stock?
At the cost assigned when it was sold, referenced from the original movement. Valuing it at today's price creates profit or loss out of nothing. A warehouse transfer likewise must change location without changing total value.