Skip to main content

Average cost (WAC): test plan

For: testers checking average cost on the QA server before release v2.7.0. Every check below starts from a known quantity and average, does one thing, and compares the new average with a hand calculation. The rules are in Average cost (WAC): the rules.

Set up once

You need Why
The v2.7.0 scripts run on the QA shop, including the backfill Without them nothing is costed
Branch A, and a user holding it with View Purchase Price To see costs
A role without View Purchase Price To check cost is hidden
A fresh product W at A, 0 on hand, never purchased A clean start for each run
A spreadsheet to work out the expected average Compare to 6 decimals

Where to read the cost. Product › Stock history: each row shows unit cost, total cost and method WAC. The average on the stock row is in the Stock report (or ask a developer for product.stock.average_cost).

Use the receiving mode the shop has (PUR › stockEvent): with ON_GRN the GRN moves stock, with ON_BILL the purchase bill does. Test both if the QA server has a shop of each.

Goods coming in

# Check Steps Pass when
1 First purchase Purchase 10 W at ₹100 (without tax) 10 on hand, average ₹100
2 Second purchase blends Purchase 10 W at ₹130 20 on hand, average ₹115
3 Tax is not cost Purchase 10 W at ₹100 + 18% GST The cost used is ₹100, not ₹118
4 From zero or below Sell W down to 0 (or below, if allowed) › purchase 5 at ₹90 Average ₹90, the old average ignored
5 GRN In an ON_GRN shop, GRN 10 at ₹120 Same blend as #2, on the GRN
6 Production output Run production that makes W W's quantity rises, its average is unchanged (output is not costed yet)
7 Transfer in Receive a transfer of W (Stock transfers: test plan #22) Blended at the dispatch cost

Goods going out

# Check Steps Pass when
8 Sale From 20 at ₹115, sell 5 15 on hand, average still ₹115. Stock history: unit cost 115, total 575
9 Sale line keeps its cost Purchase 10 more at ₹200 (average moves) › edit the sale from #8 down to 3 2 come back at ₹115, not at the new average
10 Sale line grows Edit the same sale up to 8 Old 3 keep ₹115, the extra 5 leave at today's average. Line cost is the blend
11 Delete a sale Delete the sale All units come back at the cost the line stored
12 BOM consumption Production that uses W as a material W leaves at its average. Average unchanged

Returns and undo

# Check Steps Pass when
13 Sale return Return 2 of a sale that left at ₹115 2 come back at ₹115. Average blends ₹115 in
14 Sale return of an old sale Return a sale saved before v2.7.0 (no stored cost) Comes back at today's average. Average unchanged
15 Purchase return From 20 at ₹115, return 10 bought at ₹130 10 left, average ₹100 ((2300 − 1300) ÷ 10)
16 Purchase return of everything Return all units 0 on hand, average 0
17 Residual From 5 at ₹100, return 5 bought at ₹130 0 on hand, average 0. Stock history remarks show "[Residual cost -150.000000]"
18 GRN void Void the GRN from #5 Units leave at ₹120, the GRN's own cost
19 Purchase bill line removed Edit a purchase (ON_BILL) and remove a line Units leave at the line's cost
20 Return more than bought Purchase 10 › return 6 › return 5 more Second return refused: more than bought less returned
21 Return more than sold Sell 4 › return 3 › return 2 more Second return refused

Opening stock and adjustments

# Check Steps Pass when
22 Opening stock on an empty row New product with purchase price (without tax) ₹50 and opening stock 10 Average ₹50
23 Opening stock with cost 0 As the role without View Purchase Price, new product with opening stock 10 Average stays blank. Not ₹0
24 Opening stock on a row with stock Product with 10 on hand, opening stock again Average unchanged
25 Adjustment Adjust stock up or down Quantity changes, average unchanged

Stock below zero

# Check Steps Pass when
26 Setting off (default) Sell more W than on hand Works as before (unless the Sales screen's own block out-of-stock is on)
27 Setting on Ask a developer to set PRD › rejectNegativeStockOnWac = true › sell more than on hand "Not enough stock: … on hand, … requested for …". Nothing saved
28 BOM with setting on Production that uses more W than on hand Refused the same way
29 Purchase return with setting on Return more than on hand (but not more than bought) Not refused by this setting

Who sees the cost

# Check Steps Pass when
30 Cost hidden As the role without View Purchase Price: Stock report, Stock history, product, transfer Average, unit cost and total cost are blank, never 0

Exact quantities

# Check Steps Pass when
31 Decimals Purchase 0.1 › purchase 0.2 › sell 0.3 0 on hand exactly. Not 0.00000000000000004

Before release: go-live checks (with a developer)

# Check Pass when
32 stock_wac_columns.sql on a copy of each shop Runs. If it refuses, the duplicate rows are listed and merged first
33 stock_quantity_numeric.sql Time measured on a copy. Stock totals before and after match
34 stock_average_cost_backfill.sql Its check returns 0 rows
35 Stock report value Total stock value before and after go-live is explained

Also run Check on every screen from the Tester handbook on screens that show cost.