changes according to the test
This commit is contained in:
@@ -180,3 +180,31 @@ func legacyOrderQty(quantity float64) int {
|
||||
}
|
||||
return q
|
||||
}
|
||||
|
||||
// assertOutletNamed refuses an order that does not say which shop it is for.
|
||||
//
|
||||
// Stock is held per outlet — availableStock filters `locationid = ?` — so a
|
||||
// line with no outlet matches no ledger row and reads as zero available. Every
|
||||
// such order was then refused as "insufficient stock ... available 0", naming
|
||||
// the shelf as the problem when the shelf was full and the request was what was
|
||||
// incomplete. A merchant reading that goes and checks their stock, finds it,
|
||||
// and has nowhere else to look.
|
||||
//
|
||||
// Per line rather than per order: a line may carry its own outlet, and only
|
||||
// falls back to the header's when it does not.
|
||||
func assertOutletNamed(lines []stockLine) error {
|
||||
for _, line := range lines {
|
||||
if line.Locationid != 0 {
|
||||
continue
|
||||
}
|
||||
name := line.Productname
|
||||
if name == "" {
|
||||
name = fmt.Sprintf("ID %d", line.Productid)
|
||||
}
|
||||
return fmt.Errorf(
|
||||
"this order names no outlet, so there is no shelf to sell '%s' from: "+
|
||||
"send locationid on the order, or on each item", name,
|
||||
)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user