Flow · 8 steps
Keeping the chart of accounts
Add an account, point a SKU at it, and see why an account in use cannot be removed.
Every SKU posts to three accounts: the asset its stock is valued in, the income a sale credits, and the cost of sales. Every organization starts with the three defaults (1400, 4000 and 5000). An account any SKU names, or a role's default, can be neither removed nor renumbered until nothing depends on it.
Services involved
A filled dot is a read; a ring is a call that changes something.
- Inventory Manager:
https://inventory.getmanifold.io
Every call carries Authorization: Bearer $MANIFOLD_TOKEN unless its step says otherwise
(getting a token). Run a flow in your sandbox, not your live
organization: see Before you start.
1 See the chart you were born with
Three accounts, code-ascending, each marked defaultFor its role and carrying skus, the number of SKUs posting to it. Anyone may read the chart — every account picker does.
GET /accounts Inventory Manager
What the answer holds: the operation's example.
From your answer, later steps send [1].id as {accountId}.
2 Try to remove the default sales account
A role's default is protected outright — 409 DefaultAccountProtected — because a SKU that never chose is posting to it. It can still be renamed. Editing the chart needs the admin job.
DELETE /accounts/{accountId} Inventory Manager
{
"_tag": "DefaultAccountProtected",
"accountId": "{accountId}",
"code": 4000,
"roles": [
"revenue"
]
}3 Add a wholesale sales account
Codes are whole numbers, unique within the organization: a second account on 4000 would be a 409 AccountCodeConflict.
POST /accounts Inventory Manager
{
"code": 4150,
"name": "Wholesale sales"
}Answers 201. What the answer holds: the operation's example.
From your answer, later steps send id as {accountId}.
Records inventory.account-saved.
4 Say what it is for
Anything omitted stays as it was, and the event carries the whole account, so a replay lands on the same row whatever order edits arrived in.
PUT /accounts/{accountId} Inventory Manager
{
"description": "Trade customers, ex-GST."
}What the answer holds: the operation's example.
Records inventory.account-saved.
5 Point a SKU at it
A SKU stores the codes, not the ids: accounts names 4150 for revenue and leaves the other two on their defaults. A code the chart lacks is refused with 409 UnknownAccountCode.
POST /items Inventory Manager
{
"sku": "WIDGET-BLUE",
"name": "Blue widget, 40mm",
"quantity": 0,
"accounts": {
"inventory": 1400,
"revenue": 4150,
"expense": 5000
}
}Answers 201. What the answer holds: the operation's example.
Records inventory.item-created.
6 Try to remove it
Refused: one SKU posts to it, and the 409 AccountInUse says how many. Renumbering is refused the same way — from a SKU's point of view a new code is a removal.
DELETE /accounts/{accountId} Inventory Manager
{
"_tag": "AccountInUse",
"accountId": "{accountId}",
"code": 4150,
"skus": 1
}7 Move the SKU back to the defaults
The configuration screen's account pickers offer Default for each role; choosing it stores the default code. The event carries only what changed.
PATCH /items/WIDGET-BLUE Inventory Manager
{
"accounts": {
"inventory": 1400,
"revenue": 4000,
"expense": 5000
}
}What the answer holds: the operation's example.
Records inventory.item-updated.
8 Now it goes
Nothing posts to it any more, so the delete answers with the account as it was and appends inventory.account-deleted.
DELETE /accounts/{accountId} Inventory Manager
What the answer holds: the operation's example.
Records inventory.account-deleted.
What a recorded fact is: Facts and the journal. Why a repeated step changes nothing: Idempotency and retries.