تخطَّ إلى المحتوى

The invoice counter (seq)

هذا المحتوى غير متوفر بلغتك بعد.

Invoices, receipts (payments) and credit notes (returns) are also numbered by a gap-free counter per company and per stream, seq. It is given once, when the document is issued, and never changes. If all you need is “what has been issued since I last looked”, keep that one integer per stream instead of a version.

GET /invoices/cursor
→ {"data": {"last_seq": 41, "high_water": 9140}} start from "now"
GET /invoices?filter[seq_after]=41
→ {"data": [ …invoices 42, 43 in issue order… ],
"meta": {"last_seq": 43, "has_more": false}}

Store meta.last_seq and ask with it next time. Because the counter has no gaps, you can also check what you hold: if you have 41 and the next answer starts at 43, something is wrong on your side — ask for filter[id] or re-read from 41.

Stream Cursor seq is given when
Invoices GET /invoices/cursor the invoice is issued
Payments GET /payments/cursor the receipt is issued (a payment’s seq is its receipt’s)
Returns GET /returns/cursor the return is credited (credit_note_number is set)
Terminal window
curl -s "$SLFLO_BASE/invoices/cursor" -H "Authorization: Bearer $SLFLO_TOKEN"
curl -sg "$SLFLO_BASE/invoices?filter[seq_after]=0" -H "Authorization: Bearer $SLFLO_TOKEN" \
| jq '{seqs: [.data[].seq], meta}'
# on the sandbox: {"seqs": [1, 2], "meta": {"has_more": false, "last_seq": 2, "per_page": 100}}

The whole flow, with gap checks and acks, is Read invoices by seq.