Skip to main content

What they bought, paid, and still owe

GET 

/api/contacts/:contact/ledger

The oldest question in a CRM.

Every figure is a list of {currency, amount}, never a single number. A person can pay half in lira and half in euro; adding those together needs an exchange rate nobody here is entitled to choose, and the rate on the day of the sale, the day of the payment and the day of the report are three different numbers.

Cancelled sales are excluded, voided payments are excluded, and refunds subtract — three separate rules, each of them a way for a total to lie. refunded is reported alongside collected rather than only netted into it: "we took 10.000 and gave 3.000 back" and "we took 7.000" are different facts about a business.

Or the CRM's, when the CRM owns the sales​

A workspace can say its sales live in a connected CRM (doc 43 §7). This endpoint then stops answering with our totals and answers with their open balance, read live, in the record drawer's own four-state vocabulary — source is what tells the two apart.

sold and collected are deliberately absent from that answer: totalling somebody else's orders would mean us doing arithmetic on a ledger whose discount and refund rules we cannot see. What an agent on the phone needs is what is still owed, and that is one read and their own number.

A claim the provider cannot honour is IGNORED — handing a data class to a CRM that publishes no such records moves the truth nowhere, so the answer falls back to ours. A connection we merely cannot reach keeps the claim and answers unavailable, because "we could not ask" and "they owe nothing" are different sentences.

Request​

Responses​

The ledger — ours, or theirs. Discriminated by source.