Skip to content

Add smartbill-style adapter (Romanian invoicing, v1) - #50

Merged
deblasis merged 3 commits into
mainfrom
add-smartbill-style
Aug 16, 2026
Merged

Add smartbill-style adapter (Romanian invoicing, v1)#50
deblasis merged 3 commits into
mainfrom
add-smartbill-style

Conversation

@deblasis

Copy link
Copy Markdown
Contributor

Follow-up to #47 (merged), from the same integration work: the Romanian
arm of the bookkeeping rails.

What

smartbill-style — a SmartBill-style Romanian invoicing/bookkeeping
API v1 simulator, useful for testing anything that issues invoices and
proforma, records payments, tracks stock, or reads PURCHASE invoices
("what does this company spend, and on what?").

  • Surface (16 endpoints): invoices (create/get/list/cancel),
    invoice payments (add/delete), proforma estimates
    (create/list/cancel), purchase invoices as the spend surface,
    stocks and stock movements, messages, company lookup.
  • Conventions modelled:
    • Basic auth (username:token, base64) with genuine 401s for missing
      or malformed headers.
    • Bare-JSON envelopes, unlike wrapper APIs: lists are keyed arrays
      with plain page/pageSize pagination metadata (totalPages must
      be followed); creates return an empty body, like the real API.
    • cif scoping where a foreign or unknown cif is an indistinguishable
      404.
    • Money and quantities as decimal strings; dates YYYY-MM-DD with
      inclusive startDate/endDate list filters.
  • Purchase invoice product lines carry an explicit category — the
    classification in the customer's books, and the natural unit of spend
    (one invoice can mix groceries and utilities).
  • Includes a pure-Starlark base64 decoder, for runtimes without the
    crypto builtin.

Verification

  • stunt adapter lint clean.
  • Conformance test (internal/engine/smartbill_style_test.go, following
    the existing pattern): 401/404 paths, pagination envelope, line-level
    classification with date filtering, the empty-body create contract,
    decimal-string round-trip, and invoice cancellation.
  • go test ./... green.

🤖 Generated with Claude Code

Dev and others added 3 commits August 15, 2026 21:48
A SmartBill-style invoicing/bookkeeping API simulator: invoices
(create/get/list/cancel), proforma estimates, invoice payments, purchase
invoices as the spend surface (product lines carry the book
classification), stocks and stock movements, messages.

Models the v1 conventions: Basic auth with genuine 401s, bare-JSON
envelopes (empty body on create, like the real API), plain page/pageSize
pagination with totalPages, cif scoping where a foreign cif is an
indistinguishable 404, and decimal-string money and quantities. Includes
a pure-Starlark base64 decoder for runtimes without the crypto builtin.

Conformance test covers the 401/404 paths, pagination, line-level
classification with date filtering, the empty-body create contract, and
invoice cancellation.
…plier objects, numeric amounts, paymentstatus

Reviewer findings on PR #50 (2 criticals + 4 majors + minors):
- CRITICAL route scheme: the real API has no version segment — all routes
  re-schemed to the real version-free paths (/invoice, /invoice/cancel,
  /invoice/restore, /invoice/paymentstatus, /estimate(+cancel), /purchase,
  /payment, /payment/v2, /stocks, /document/send, /tax, /series);
  invented /invoice/list /estimate/list /purchase/list /company
  /message/email dropped (documents read by cif+seriesname+number)
- CRITICAL shapes: seriesName (not series), client/supplier objects (not
  scalar buyer fields), the {payment:{companyVatCode,value,type,isCash,
  invoicesList}} envelope, {list:[...]} for stocks/tax/series grouped by
  warehouse, errorText errors, JSON-NUMERIC money (the README's
  decimal-string claim was factually wrong), per-line VAT totals
  (totalNet/totalVAT/invoiceTotalAmount), GET paymentstatus with
  paid/unpaid amounts; purchase 'category' dropped (a FIC concept)
- json.loads -> json_safe_decode with raw_body authoritative (malformed
  JSON -> 400 errorText, was a 500; empty-body no longer silently
  creates)
- hand-rolled base64 decoder (crashed 500 on non-ASCII) -> alphabet
  pre-check + crypto.base64_decode
- payment delete driveable: create discloses paymentId; float-round-trip
  number comparisons via _num_key
- internal keys stripped (store auto-id, _batch, sim_account);
  simulator affordances namespaced under /sim/*
- tests rewritten: auth negatives incl. malformed base64, real field
  assertions, totals math, paymentstatus paid/unpaid transitions,
  cancel/restore, estimate/purchase flows, stocks grouping + filters,
  document/send, error-body assertions
@deblasis
deblasis merged commit 269b5a3 into main Aug 16, 2026
1 check passed
@deblasis
deblasis deleted the add-smartbill-style branch August 16, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant