Skip to main content
POST
Create a cost line

Authorizations

X-Session-Token
string
header
required

Session token for authentication.

Body

application/vnd.api+json

The cost line to create. The line amount, the charge and the profit are always worked out by the server from the rate, the quantity and the margin — none of them can be sent by the client.

There are three valid shapes, and the one rule behind them is that a line may supply its own rate:

  1. A rate code, priced from the register. Send cost_item and no rate. The server resolves the rate from the register version in force on work_date, records that version as cost_item_version, and copies the rate code into cost_item_snapshot. If no version covers work_date the request is refused with CH.004.208.
  2. A rate code, priced on this job. Send cost_item and rate. The register is not consulted for a version at all, so cost_item_version comes back null and a rate code carrying no versions is perfectly usable — the code, name and category are still governed by the register, and the price is this job's. cost_item_snapshot must not be sent; the server copies it.
  3. Ad hoc. Send rate and cost_item_snapshot, and no cost_item. A cost with no rate code behind it: the client supplies both the price and the description that gives it meaning. Both are required, and so is cost_item_snapshot.category within it — a line nothing can attribute would break the roll-up's category split.

Anything else is refused with CH.004.215.

Whichever shape it is, the price is frozen the moment the line is written. Revising the register afterwards changes what future work costs and leaves recorded work exactly as recorded.

margin_override works the same way in all three: it pins what this particular line sells at, and the charge it produces is still worked out by the server.

data
object
required

Response

An individual cost line.

JSON API response object

data
object
required

A cost line — one costed entry on a cost sheet: a quantity of a rate code, priced at the rate that was in force on the day the work was done.

The pricing is a snapshot, on both sides. rate and amount are resolved once, on write, from the register version in force on work_date, and that version is referenced by the cost_item_version relationship. margin and charge — what the line sells for — are frozen at the same moment. None of them are ever recomputed: revising a rate or a margin in the register changes what future lines cost and sell for, and leaves every existing line exactly as it was recorded.

This resource carries monetary values and is permissioned separately from the cost sheet it belongs to.

jsonapi
object
required
included
object[]

Related resources that can be included when a cost line is returned.

cost-items and cost-item-versions are both optional on a line, so asking for either simply yields nothing for the lines that have none — an ad-hoc line has no rate code, and a line priced on the job has no register version behind its rate. Neither is an error, and a request for both across a mixed collection comes back with whatever exists.

An organisation