Record a purchase in the savings record
record_purchasesAdd a receipt to the user's savings record: one row per line (generic item, quantity, unit, paidMinor in cents, optional offerId from search_offers). Each line is stored with its price range around the store that day (cheapest, typical, priciest) and returns savings vs each plus the percentile; negative savings (paid above typical) are kept. Lines on a thin range are shown but not totalled. Each line has basis (what it was compared with) or notCounted (why not) and a plain summary; the receipt has a summary, method and methodUrl (how savings are counted, an estimate compared with typical prices nearby) to pass on to the user. Append-only and idempotent: reuse operationId to retry safely; to fix a purchase, record a new one with supersedesPurchaseId.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"operationId": "<operationId>",
"purchasedOn": "<purchasedOn>",
"near": "<near>",
"basis": "<basis>",
"lines": "<lines>"
},
"name": "record_purchases"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| near | Yes | The store's postal code, or the shopper's; sets which stores the range is drawn from. | |
| basis | Yes | receipt: read from a receipt; user_report: the user said so. | |
| lines | Yes | ||
| banner | No | Where it was bought, e.g. "no-frills". | |
| storeId | No | The store's id from stores_near, when known. | |
| radiusKm | No | Search radius in km around `near` (default 5). | |
| operationId | Yes | A stable id for this write (e.g. a UUID you generate once per receipt). Replaying it returns the same receipt. | |
| purchasedOn | Yes | Purchase date, YYYY-MM-DD. | |
| correctionReason | No | ||
| supersedesPurchaseId | No | A purchase this one corrects; the old one stays stored but leaves the totals. |