Add smartbill-style adapter (Romanian invoicing, v1) - #50
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/bookkeepingAPI 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?").
invoice payments (add/delete), proforma estimates
(create/list/cancel), purchase invoices as the spend surface,
stocks and stock movements, messages, company lookup.
username:token, base64) with genuine 401s for missingor malformed headers.
with plain
page/pageSizepagination metadata (totalPagesmustbe followed); creates return an empty body, like the real API.
cifscoping where a foreign or unknown cif is an indistinguishable404.
YYYY-MM-DDwithinclusive
startDate/endDatelist filters.category— theclassification in the customer's books, and the natural unit of spend
(one invoice can mix groceries and utilities).
cryptobuiltin.Verification
stunt adapter lintclean.internal/engine/smartbill_style_test.go, followingthe 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