Receiving quantities
Base quantities for receipt confirmations and ASN lines, and received totals that come from receiving evidence rather than current plate contents.
Request with "decision": "receive" and one of these operations: post_confirmation, import_asn_line, set_received_qty.
Clauses applied
receive.history: ReceiptLines.ReceivedQty sums receiving evidence, never the current contents of its plates.receive.unresolved: Unresolved units, lots or serial requirements block posting.receive.factor: UOM factor is frozen once; serial captures use factor 1 and base quantity 1.
Evidence questions
asn_unit@1
A supplier's advance ship notice states this line's quantity and unit in its own words. Which of the item's units does that quantity count? The decision adds options per request, such as the item's own units.
| Answer | Meaning |
|---|---|
unclear | None of them for certain: the unit is missing or unknown, or its pack size conflicts with every unit of the item. |
Examples
Supplier ASN in cartons of twelve
{
"decision": "receive",
"proposal": {
"operation": "import_asn_line",
"base_qty": "144"
},
"item": {
"sku": "BEV-COLD-BREW-12",
"description": "Cold brew coffee 12 fl oz can",
"base_uom": "EA",
"units": {
"CS": "12",
"PL": "1440"
}
},
"line": {
"id": "RL-20488-3",
"asn": {
"qty": "12",
"unit_text": "CTN 12/1 12OZ",
"description": "COLD BREW ORIG 12/12OZ CAN"
}
}
}Response from the rules with no model loaded, so every question abstains.
{
"verdict": "review",
"next": {
"action": "resolve_unit",
"text": "The ASN line's unit \"CTN 12/1 12OZ\" cannot be mapped to the item's units: the unit could not be settled with certainty. Resolve it before the line is imported.",
"role": "Receiving Lead"
},
"questions": [
{
"ask": "line/asn",
"question": "asn_unit@1",
"status": "model_unavailable",
"evidence": [
"/line/asn/unit_text"
]
}
]
}Run this example in the consoleDownload the request
Received total read from current plates
{
"decision": "receive",
"proposal": {
"operation": "set_received_qty",
"received_qty": "108"
},
"item": {
"sku": "BEV-COLD-BREW-12",
"base_uom": "EA",
"units": {
"CS": "12"
}
},
"line": {
"id": "RL-20488-3",
"frozen_uom": "CS",
"frozen_factor": "12"
},
"confirmations": [
{
"id": "RC-77120",
"base_qty": "144",
"status": "Posted"
}
],
"plates": [
{
"lpn": "LPN00045121",
"qty": "108"
}
]
}Response from the rules with no model loaded, so every question abstains.
{
"verdict": "reject",
"next": {
"action": "use_receiving_evidence",
"text": "Line RL-20488-3 received 144 base units by its posted confirmations, not 108. The proposal matches what the plates hold now, which later picks and shipments have changed."
},
"questions": []
}Run this example in the consoleDownload the request
Call it from your code
Each snippet sends the first example above to the hosted API with the key in RACKSORT_API_KEY and prints the verdict and the next step. Create an account, then create a key. The quickstart walks through the first request.
curl
export RACKSORT_API_KEY="paste-your-key-here"
curl https://racksort.com/api/v1/decide \
-H "Authorization: Bearer $RACKSORT_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'EOF'
{
"decision": "receive",
"proposal": {
"operation": "import_asn_line",
"base_qty": "144"
},
"item": {
"sku": "BEV-COLD-BREW-12",
"description": "Cold brew coffee 12 fl oz can",
"base_uom": "EA",
"units": {
"CS": "12",
"PL": "1440"
}
},
"line": {
"id": "RL-20488-3",
"asn": {
"qty": "12",
"unit_text": "CTN 12/1 12OZ",
"description": "COLD BREW ORIG 12/12OZ CAN"
}
}
}
EOFPython
Python 3.8 or newer, standard library only. Keep the User-Agent header: requests with Python's default one are refused. With requests or httpx it is not needed.
import json
import os
import urllib.error
import urllib.request
request = {
"decision": "receive",
"proposal": {
"operation": "import_asn_line",
"base_qty": "144",
},
"item": {
"sku": "BEV-COLD-BREW-12",
"description": "Cold brew coffee 12 fl oz can",
"base_uom": "EA",
"units": {
"CS": "12",
"PL": "1440",
},
},
"line": {
"id": "RL-20488-3",
"asn": {
"qty": "12",
"unit_text": "CTN 12/1 12OZ",
"description": "COLD BREW ORIG 12/12OZ CAN",
},
},
}
call = urllib.request.Request(
"https://racksort.com/api/v1/decide",
data=json.dumps(request).encode(),
headers={
"Authorization": f"Bearer {os.environ['RACKSORT_API_KEY']}",
"Content-Type": "application/json",
# Cloudflare refuses Python's default User-Agent, so name the client.
"User-Agent": "racksort-example/1.0",
},
)
try:
with urllib.request.urlopen(call, timeout=30) as response:
result = json.load(response)
except urllib.error.HTTPError as error:
raise SystemExit(json.load(error)["error"]["message"])
print(result["verdict"], "-", result["next"]["text"])TypeScript
Node.js 18 or newer. Save it as decide.mts and run npx tsx decide.mts.
type Verdict = "allow" | "replay" | "reject" | "review" | "reconcile";
interface Decision {
verdict: Verdict;
state?: string;
next: { action: string; text: string; role?: string };
}
const request = {
"decision": "receive",
"proposal": {
"operation": "import_asn_line",
"base_qty": "144"
},
"item": {
"sku": "BEV-COLD-BREW-12",
"description": "Cold brew coffee 12 fl oz can",
"base_uom": "EA",
"units": {
"CS": "12",
"PL": "1440"
}
},
"line": {
"id": "RL-20488-3",
"asn": {
"qty": "12",
"unit_text": "CTN 12/1 12OZ",
"description": "COLD BREW ORIG 12/12OZ CAN"
}
}
};
const response = await fetch("https://racksort.com/api/v1/decide", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RACKSORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(request),
});
const body = await response.json();
if (!response.ok) throw new Error(body.error.message);
const result = body as Decision;
console.log(result.verdict, "-", result.next.text);
Request schema
{
"type": "object",
"required": [
"decision",
"proposal",
"item",
"line"
],
"additionalProperties": false,
"properties": {
"decision": {
"const": "receive"
},
"proposal": {
"type": "object",
"required": [
"operation"
],
"additionalProperties": false,
"properties": {
"operation": {
"type": "string",
"enum": [
"post_confirmation",
"import_asn_line",
"set_received_qty"
]
},
"entered_qty": {
"type": "string",
"format": "decimal"
},
"entered_uom": {
"type": "string",
"pattern": "^[A-Za-z0-9_-]{1,20}$"
},
"base_qty": {
"type": "string",
"format": "decimal"
},
"received_qty": {
"type": "string",
"format": "decimal"
}
}
},
"item": {
"type": "object",
"required": [
"sku",
"base_uom"
],
"additionalProperties": false,
"properties": {
"sku": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"description": {
"type": "string",
"minLength": 1,
"maxLength": 4000
},
"base_uom": {
"type": "string",
"pattern": "^[A-Za-z0-9_-]{1,20}$"
},
"units": {
"type": "object",
"additionalProperties": {
"type": "string",
"format": "decimal"
}
}
}
},
"line": {
"type": "object",
"required": [
"id"
],
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"frozen_uom": {
"type": "string",
"pattern": "^[A-Za-z0-9_-]{1,20}$"
},
"frozen_factor": {
"type": "string",
"format": "decimal"
},
"asn": {
"type": "object",
"required": [
"qty",
"unit_text"
],
"additionalProperties": false,
"properties": {
"qty": {
"type": "string",
"format": "decimal"
},
"unit_text": {
"type": "string",
"minLength": 1,
"maxLength": 4000
},
"description": {
"type": "string",
"minLength": 1,
"maxLength": 4000
}
}
}
}
},
"confirmations": {
"type": "array",
"items": {
"type": "object",
"required": [
"id",
"base_qty",
"status"
],
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"base_qty": {
"type": "string",
"format": "signed-decimal"
},
"status": {
"type": "string",
"enum": [
"Draft",
"Posted"
]
}
}
},
"maxItems": 1000
},
"plates": {
"type": "array",
"items": {
"type": "object",
"required": [
"lpn",
"qty"
],
"additionalProperties": false,
"properties": {
"lpn": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"qty": {
"type": "string",
"format": "decimal"
}
}
},
"maxItems": 1000
}
}
}