/victor-skills:smartbill-webfrom victor-skills
SmartBill invoice automation — issue, rewrite, download, record payments. Trigger: "SmartBill", "facturi".
Ships in victor-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
One CLI, npm run sb -- <cmd>, with two engines. Picking the wrong one is the
main way to waste time here, so start with the table below.
cd "${CLAUDE_PLUGIN_ROOT:-$HOME/workspace/victor-skills}/skills/smartbill-web"
| Engine | How | Cost | Needs |
|---|---|---|---|
| API | REST on ws.smartbill.ro | ~200 ms/call | token in ~/.claude/smartbill.env |
| Browser | Playwright on cloud.smartbill.ro | ~1.6 s/invoice + browser start | sb -- login once |
API issuing is OFF on this subscription since Sep 2026. Every REST call answers
Nu aveti acces la API-ul SmartBill, and/core/integrari/spells out why: "Abonamentul tau nu include emiteri prin API" - it is a Platinum feature. This is not a stale token; regenerating it changes nothing. Until the plan is upgraded everything goes through the browser: issue withissue+finalize.
Default to the API (when the plan allows it). Fall back to the browser only for the things the API genuinely cannot do:
| Need | Why the API can't | Use |
|---|---|---|
| Enumerate documents | SmartBill's public API has no listing endpoint. Only /series, /tax and /stocks return lists — there is no GET /invoices. | sb -- list (browser) — or sb -- recent, see below |
| Edit an issued invoice | No update endpoint exists. The API can only create, cancel, storno or delete. | sb -- edit (browser) |
| Copy an existing invoice | No "duplicate document" endpoint. create needs the full client + line payload spelled out. | sb -- copy (browser) |
| Change the customer on an issued invoice | No update endpoint, and the client endpoints are read-only. | sb -- reclient (browser) |
| Read expenses / bank statements | The whole Cheltuieli and Tranzactii bancare side lives only in the web app; ws.smartbill.ro knows nothing about it. | sb -- expenses, sb -- banktx, sb -- reconcile |
Everything else — reading a document, payment status, PDFs, issuing, payments, cancel/storno/delete, emailing — goes through the API.
API (once): create ~/.claude/smartbill.env, mode 600:
[email protected]
SMARTBILL_TOKEN=<token>
SMARTBILL_VAT_CODE=RO12345678
The token is in SmartBill Cloud → Contul meu → Integrari → API; the circular arrow next to it regenerates it (do that if it ever leaks — a screenshot of that page is enough to leak it). Env vars of the same names override the file. Never pass the token on the command line; it would land in shell history.
Browser (once, and again whenever the session expires):
npm install && npx playwright install chromium
npm run sb -- login # headless, with the Keychain password; cookies saved to storageState.json
npm run sb -- login --manual # by hand, in a window
login reads the credentials from the macOS Keychain, so an agent can log back
in on its own when the session dies. Store them once, by hand (-w with no
value prompts for the password, so it never lands in shell history or a chat):
security add-generic-password -s cloud.smartbill.ro -a <email> -w
The email is read back from the Keychain item; set SMARTBILL_ACCOUNT only if
several are stored. If the form does not let it through (captcha, 2FA), login
fails with the page text and --manual is the way in.
storageState.json is gitignored.
| Command | What it does |
|---|---|
sb -- series [--type factura|proforma|chitanta] | series + the next number each will issue |
sb -- taxes | VAT rates as name/percentage. Read these before issuing — names and rates differ per account and change over time |
sb -- stocks [--date] [--warehouse] [--product] | stock levels as of a date |
sb -- read --series S --number 324 [--full] | reads the document: date, due date, total, currency, counterparty, line items. --full dumps the raw text |
sb -- status --series S --number 324 | invoiceTotalAmount / paidAmount / unpaidAmount / paid |
sb -- get --series S --number 324 --out ./out [--name f.pdf] | download the PDF |
sb -- recent [--series S] [--count 10] [--json] | the closest thing to a listing without a browser — see below |
sb -- create --json invoice.json | issue an invoice from a full payload (invoice.example.json) |
sb -- pay --series S --number 324 [--date] [--value] [--type] [--vat] | record money received; amount, currency and client are read off the invoice |
sb -- pay --json payment.json | the same, spelled out in full (payment.example.json) |
sb -- storno --series S --number 324 | reverse an invoice in full, into the same series |
sb -- cancel / restore --series S --number 324 | void / un-void; the number is kept, so the series has no gap |
sb -- rm --series S --number 324 | irreversible, and only allowed for the LAST invoice in a series |
sb -- email --series S --number 324 [--to] [--subject] [--body] | SmartBill mails the document with the PDF attached |
pay needs no JSON file for the usual case. Given --series and --number it
reads the amount, currency and counterparty off the invoice itself, defaults
the value to whatever is still unpaid, and defaults the date to today:
npm run sb -- pay --series P --number 209 --date 2026-08-27 --vat NL001797931B01
It then re-reads the payment status and says settled: true/false, exiting
non-zero when the invoice is still open. A 200 from the POST is not evidence the
document is settled - only the status endpoint is. It also refuses to double-pay:
an invoice already marked paid comes back as alreadyPaid untouched.
Pick the value date from the payment advice, not from the day the email arrived - those differ, and the advice is what the client's books show.
While the API is off, use payweb — the same job through the web app's own
Incaseaza factura modal, keyed by the internal id (from find --json/list):
npm run sb -- payweb --id 10000001 --date 05/10/2026 --iban RO00BANKEURCRT0000000001 --dry-run
npm run sb -- payweb --id 10000001 --date 05/10/2026 --iban RO00BANKEURCRT0000000001
--date is the value date from the bank statement, and it is not cosmetic: on a
foreign-currency invoice the page re-fetches /core/exchange_rate_at_date/ when
the date changes, so the rate becomes that day's BNR rate — the same figure the
bank prints as the RON equivalent. Left at today, every EUR receipt is booked at
the wrong rate. --iban picks the bank account (the modal only offers accounts in
the invoice's currency); --type defaults to p (Ordin plata); --value
defaults to what is still unpaid and is refused if larger. The result is re-read
from /documente/suma_restanta/, the endpoint the modal itself uses, and the
command exits non-zero unless the remaining amount dropped by exactly the value.
SmartBill throttles the view page. After ~10 invoice views in a few minutes,
/raport/factura/<id>/ answers 403 Forbidden for every id while the session is
still alive (touch says alive: true, the report page still loads). It shows up
as waiting for locator('#incaseazaLnk') timing out. Space batches out instead of
retrying in a loop.
Issue date, client, line items and currency exist only inside the PDF — no
endpoint returns them. status deliberately does not say which currency its
numbers are in, so never quote a figure from status alone: reporting
"1250 RON" for a 1250 EUR invoice misstates it fivefold. Run read first.
read parses both SmartBill templates — the Romanian one for domestic clients
("Data emiterii" / "TOTAL PLATA") and the English one for foreign-currency
invoices ("Issue date" / "Total value"). A parser that only knows the first
returns blank fields for every EUR/USD invoice.
recent — listing without a browserThere is no list endpoint, so recent reads the next number from series and
walks backwards, fetching each document. Output is
doc / date / total / paid state / counterparty, one line item under each.
npm run sb -- recent --count 10 # all invoice series
npm run sb -- recent --series S --count 20 # one series
npm run sb -- recent --json # for scripting
It costs one PDF download + one status call per invoice (throttled to 3 req/s,
SmartBill's cap), so it is fine for tens of documents and wrong for thousands.
Use it for "what did I issue lately", "who hasn't paid". When you need internal
document ids — which edit and pdf --id take — use list instead; ids
appear nowhere in the API.
| Command | What it does |
|---|---|
sb -- login [--manual] | log in with the Keychain password (or by hand), saves cookies |
sb -- touch | hit an authenticated page and re-save the session; keeps login from ageing out |
sb -- list [--from dd/mm/yyyy --to dd/mm/yyyy] [--json] | number<TAB>id for every invoice in a period (bare: the current month). The only source of internal ids. |
sb -- find [--product X] [--client Y] [--from ..] [--to ..] [--details] [--json] | search the report; --product matches invoice lines, --details prints each line |
sb -- issue --template <id> --desc "..." --price 5000.00 [--qty 1] [--term "60 de zile"] [--vat "21 %"] [--mentions "..."] [--note "..."] [--dry-run] | issue a new invoice off an existing one, changing the line, the price and the VAT rate |
sb -- finalize --id <id> | turn the unnumbered draft issue leaves into an issued, numbered document |
sb -- reprice --id <id> --desc "..." --price 5000.00 [--term ..] [--dry-run] | change the line and price of an issued invoice in place, keeping its number (a fix caught before the document went anywhere); verified from the PDF |
sb -- copy --template <id> --csv rows.csv --out ./out | copies a template invoice once per CSV row, swaps the line description, issues it, downloads the PDF |
sb -- edit --csv edits.csv --out ./out | rewrites the line description of existing invoices and re-downloads their PDFs |
sb -- pdf --id <id> --out ./out [--name INV101.pdf] | re-download one PDF by internal id |
sb -- stornoweb --id <id> [--mentions "..."] [--dry-run] | reverse an issued invoice through Storneaza factura (/documente/storneaza-factura/<id>/), for while the API is off; saves a draft dated today, refuses a form whose total is not negative. Then finalize. Its "no confirmation" is the same false alarm as issue's: check find before retrying |
sb -- rmdraft --id <id> | delete an unnumbered draft through the row menu; refuses anything issued |
sb -- payweb --id <id> --date dd/mm/yyyy [--iban ..] [--value ..] [--type p] [--dry-run] | record a receipt through the Incaseaza modal, at the BNR rate of the value date — see Recording a payment |
sb -- inspect --id <id> [--page edit|view|report] [--js expr] | read-only dump, for when SmartBill moves a selector |
sb -- reclient --name X [--vat ..] [--regcom ..] [--address ..] [--city ..] [--brand ''] (--ids .. | --series S --from 1 --to 9) | rewrite the customer on invoices already issued; verifies name and VAT code in every PDF afterwards |
sb -- newclient --id <id> --name X --vat .. [--regcom ..] [--address ..] [--city ..] [--country ..] [--email ..] [--dry-run] | point a draft at a newly created customer, instead of editing the template's one |
Add --headed to watch it work. Progress is appended to smartbill.log.
copywas calledcreatebefore the API path existed.createnow means the API one, which builds an invoice from a JSON payload rather than from a template.
issue + finalizeTwo commands, because SmartBill's save is two steps:
npm run sb -- issue --template 10000000 --term "60 de zile" --price 5000.00 \
--desc "Onsite workshop, 1-2 Sep 2026, PO 4500000000" \
--dry-run # stage it, print the line and the totals
npm run sb -- issue --template 10000000 ... # without --dry-run: creates a DRAFT
npm run sb -- finalize --id 10000003 # -> S101, status Emisa
npm run sb -- pdf --id 10000003 --out ~/Downloads --name S101.pdf
issue copies a template invoice — inheriting client, series, currency, VAT rate
and UM — then rewrites the line description and the unit price, and sets the
payment term by its label ("60 de zile"), which is what moves the due date.
copy cannot do the price, and that is usually the whole point of a new invoice.
--vat "21 %" overrides the inherited VAT rate (#edit_product_vat_code; the
labels are 21 %, 11 %, 19 %, 9 %, 5 %, 0 % - Taxare inversa,
0 % - TVA Inclus, 0 % - SDD, 0 % - SFDD). Needed more often than it looks,
because templates carry a rate that belongs to their client, not to yours:
the whole EUR/P series is reverse-charged, so an EUR invoice to a private person
— who has no VAT code to reverse-charge to — has no template to inherit from. A
--dry-run prints {net, vat, total}, which is the one look that confirms the
rate landed before a fiscal document exists.
--price is in the LINE's currency, not the invoice's. A RON invoice whose
template line is priced in EUR (#edit_product_currency) takes --price 6000,
and SmartBill converts at the day's BNR rate (#edit_product_rate): the row and
the totals then show lei. Typing the lei amount converts it a second time.
Always --dry-run first. It stops before saving and prints the staged line
plus {net, vat, total, due} read off the form — one look confirms the VAT rate
and the due date before a fiscal document exists.
Details that each cost a failed run:
#edit_product_price
and clicking Modifica produs straight away applies the OLD total to the NEW
price. issue presses Tab first.Ciorna numbered
plain S, with no fiscal number — the state rmdraft was written for.#viewer_save_id ("Salveaza") on the document's own
view page, in the MAIN document. The old #view_save_disposition inside
iframe[src*=compact-view] is gone, and so is that iframe: the one on the view
page has the same src as the page, so hunting through frames finds nothing.
#viewer_pdf_id made the same journey — it is now a plain anchor to
/documente/pdf/factura/<id>/, which pdf fetches through the page's request
context instead of clicking (a programmatic click carries no user activation,
so Chrome refuses the download silently).issue and
finalize both re-read the row and print number, total and status.text=/salvat cu succes/i no longer appears — or no
longer within the timeout — so issue and newclient both report failure on
saves that landed perfectly. Never retry on that message: issue would
create a second draft of the same invoice. Do what the message says and check
list first; a draft shows up as a row whose number is the bare series letter.
The fix is a selector, not a retry — until it is found, treat that error as
"unknown, go and look".newclientissue inherits the template's client, which is wrong whenever the new invoice
is for somebody else. reclient is not the tool for that: it opens
edit_client(), which keeps the client id and therefore modifies the existing
customer in the nomenclator — renaming the template's client and overwriting its
VAT code, damage that happens off-invoice where nobody looks.
npm run sb -- newclient --id 10000004 --name "Foo Agency" --vat SE999999999901 \
--regcom "999999-9999" --address "551 82 Town" --city Town --country Suedia \
--email [email protected] --dry-run
add_new_client(e) branches on e.id: empty means add, anything else means
modify. The id lives in the modal's client-data, which clean_client_modal()
removes — so newclient cleans first and then refuses to save if the modal
still carries client-data. That guard is the whole safety of the command.
Two details that are not optional:
clean_client_modal() sets the country to Romania. A foreign customer
therefore needs --country spelled out, even though "leave it alone" feels
like the safe default. It is not — it silently domesticates the client.#client_brand survives an edit that ignores it, so the
previous customer's trading name rides along. newclient clears it; reclient
takes --brand '' for the same reason.client-data alone is no longer a sufficient guard (found 22 Sep 2026).
clean_client_modal() empties the modal — removeData('client-data') plus its
own inputs — but #client_id lives in the invoice header, outside the modal,
so the template's client id survives the clean. add_new_client(e) takes e.id
from there, and a non-empty id means modify: the POST went out as
{"id":"1234567","name":"New Customer",...}, which would have renamed the template's customer
in the nomenclator and overwritten its VAT code, off-invoice where nobody looks.
The old guard passed that payload happily. addInvoiceClient now clears
#client_id and #old_client_cif itself and refuses unless both the modal data
and #client_id are empty; a correct add reads "id":"". When re-deriving
this flow by hand, route **/core/add_client/** to abort — a probe that saves
is a probe that renames a real customer.
The modal will not save a client without CIF/CNP and address and city. Measured, with the POST intercepted so nothing landed:
| fields | result |
|---|---|
| name + country | blocked |
name + country + Platitor TVA | blocked |
| name + address + city + country | blocked |
| name + cif + country | blocked |
| name + cif + city | blocked |
| name + cif + address | blocked |
| name + cif + address + city | passes |
The refusal is completely silent — add_new_client is never reached, no
notification fires, no field is marked, and the DOM does not change by a single
class. The only symptom is newclient reporting "client modal stayed open".
So persoana_fizica is not a field you can set either: there is no control for
it, SmartBill infers it. An invoice to a private individual therefore cannot
be issued from their name alone — collect a fiscal code (CNP, or the foreign
equivalent), a street address and a city before creating the draft.
Verification is the PDF, and it checks the VAT code as well as the name: a
right name over the template's VAT code looks correct on screen and bills the
wrong legal entity. reclient now does the same, and both fetch the PDF through
the page (pdfBytes) rather than sb.invoicePdf — the API path cannot run at
all while API access is off, and a verification step that cannot run is worse
than none, because it throws after the write has landed.
find"Was this person ever invoiced?" is a report search, not 40 PDF downloads:
npm run sb -- find --product "Doe" --from 01/01/2025 --to 31/12/2026 # -> no documents match
npm run sb -- find --client "Example Bank" --from 01/08/2026 --to 31/08/2026 --details
--product searches the line text, which on per-participant invoices carries
the name and the order number (Workshop … for employee Alex Smith, order REF-000101). --client is the customer name. Zero rows is a real answer — the
command prints no documents match rather than waiting for one to appear.
Three things about that page cost an afternoon each, and are why this is a command rather than something to improvise:
?from=&to=. The
page holds it in input.period_filter (dd/mm/yyyy - dd/mm/yyyy) and pushes
it with window.save_interval(). Navigating to /raport/facturi/ afterwards
throws the change away and puts you back on the current month — so read the
rows from the page you set it on.networkidle never settles. Datadog and Survicate beacons keep firing, the
wait times out, and you read the table from before the filter — an unfiltered
listing that looks exactly like "the filter matched everything". find waits
for the report's own response, then for the row list to stop changing.Always add a positive control. --product Doe returning nothing means
"never invoiced" only if --product Smith returns his one invoice; without it
you cannot tell an empty result from a filter that silently did not apply.
Three reports the API cannot see at all. All three are Vue front-ends over plain JSON POST endpoints, so these commands do not click anything - they replay the page's own POST through the signed-in cookie jar. ~200 ms per report instead of ~6 s of page boot, and the rows arrive as data rather than as scraped cells.
| Command | What it does |
|---|---|
sb -- ibans | the bank accounts, with the id the next two commands take |
sb -- expenses --from dd/mm/yyyy --to dd/mm/yyyy [--unpaid] [--supplier X] [--json] | the Cheltuieli report: supplier, document, total, paid, remaining, status |
sb -- banktx --from .. --to .. [--iban <id>] [--out-only|--in-only] [--unprocessed] [--json] | the bank statement rows |
sb -- reconcile --from .. --to .. [--iban <id>] [--window 60] [--json] | proposes (payment -> expense) pairs, scored |
npm run sb -- ibans # 10001 LEI, 10002 EUR, 10003 USD, ...
npm run sb -- reconcile --iban 10001 --from 01/02/2026 --to 31/05/2026
Endpoints, since they are nowhere in any documentation:
| Report | POST |
|---|---|
| Cheltuieli | /achizitii/raport/documente_furnizori/v2/ajax/ — sSearch={from,to,documentType,page,resultsPerPage} |
| Tranzactii bancare | /raport/raport_extrase_v2/ajax/ — sSearch={from,to,iban,page,results_per_page,transaction_status[],synced} |
| Situatia platilor | /achizitii/raport/plati_la_furnizori/ajax/ — per-supplier balances |
They are Django views: the POST needs the csrftoken cookie echoed back in
X-CSRFToken, or the answer is a 403 HTML page that JSON.parse reports as
"Unexpected token <".
Amount is non-negotiable: a payment is only ever offered against an expense whose remaining amount it settles exactly (±0.005). Name similarity never compensates for a wrong amount - a wrong amount is a wrong payment record.
On top of that, 45 base + 35 if the supplier name appears in the statement text
PayU*<shop>.ro
while the expense carries the shop's legal SA/SRL name. Real matches, but a
human has to say so.ambiguous: n — n other expenses tie on the same score. Do not post those
unattended; the amount alone cannot separate two invoices of the same value.norm() folds diacritics and drops SRL/S.A./S.C. before comparing, because
the bank prints one form and SmartBill stores the other.
--statement <extras.pdf> face reconcile si banktx sa citeasca extrasul lunar
BT de pe disc in loc de feed-ul SmartBill. Asta e ce salveaza o luna intreaga cand
consimtamantul PSD2 a expirat:
npm run sb -- reconcile --from 01/07/2026 --to 31/07/2026 --exp-from 01/05/2026 \
--statement "<folder>/Statements_<IBAN>_2026-07_<COMPANY>.PDF"
--exp-from largeste doar fereastra de cheltuieli: o plata din iulie stinge des o
factura din iunie, si fara asta nu are ce gasi.
Extragerea trece prin pdftotext -layout (poppler), nu printr-o librarie JS,
pentru ca diferenta debit/credit e purtata exclusiv de pozitia coloanei. Fara
layout ai "529.10" si nimic care sa spuna daca banii au plecat sau au venit - iar
inversul inseamna o plata inregistrata ca incasare.
Trei lucruri care au costat cate o rulare gresita, toate in acelasi extras:
as 1129
si as 1183) sa arate identic si sa se cupleze pe factura gresita. Antetul e
zgomot de pagina, pozitiile coloanelor se citesc din textul brut.Parserul verifica singur rezultatul contra RULAJ TOTAL CONT din extras si
arunca daca debitul sau creditul nu ies la banut. Un rand pierdut sau dublat apare
acolo, nu trei pasi mai tarziu ca plata gresita.
Bancile retiparesc numarul de factura fara zerouri (AS001183 platit cu referinta
as 1183), deci potrivirea pe numar incearca si coada numerica fara padding.
glovo - cosuri de facturi pentru o plata de platformaO plata cu cardul catre o platforma de livrare nu e o factura, ci un cos:
factura de taxe a platformei plus factura restaurantului. De aici subset-sum, nu
potrivirea 1:1 din reconcile:
npm run sb -- glovo --from 01/07/2026 --to 31/07/2026 \
--exp-from 01/06/2026 --exp-to 15/09/2026 --before 5 --after 12 \
--statement "<folder>/Statements_<IBAN>_2026-07_<COMPANY>.PDF"
--platform schimba regexul (implicit glovo), --max-items marimea cosului
(3), --before/--after fereastra fata de data EPOS a comenzii, nu fata de
data decontarii.
Doua reguli care tin cautarea onesta:
--near 0). Cu ~120 de facturi
candidate, subseturile de 3 sunt sute de mii pe un interval de cateva mii de
lei: sa nimeresti la un leu de orice tinta e practic garantat. Un rezultat
„aproape" nu e o pista, e zgomot.Pe date reale, cu fereastra larga si cos de 3, nu inchide exact aproape nicio plata
Glovo. Nu e un prag de reglat: plata contine si parti pe care nu le factureaza
nimeni - vezi glovo-orders.
glovo-orders - singurul lucru care chiar inchide o plata GlovoNicio combinatie de facturi din SmartBill nu inchide o plata Glovo, pentru ca una dintre cele trei componente nu e facturata de nimeni. Istoricul de comenzi din contul Glovo e singura sursa care spune cum se sparge plata:
TOTAL = (PRODUCTS + DISCOUNT) -> factura restaurantului
+ (DELIVERY + SERVICE + WEATHER + MIN_BASKET) -> factura GLOVOAPPRO
+ COURIER_TIP -> nicio factura, niciodata
Verificat pe o comanda reala: produse minus discount = exact factura restaurantului din SPV, livrare + service = exact factura GLOVOAPPRO, iar suma lor plus bacsisul = exact plata cu cardul. Diferenta pe care niciun subset-sum n-o explica era factura de taxe plus bacsisul.
npm run sb -- glovo-orders --from 01/01/2026 --to 31/08/2026 \
--exp-from 01/01/2026 --exp-to 15/09/2026 --statement "<extrase.pdf,...>"
Comenzile se citesc din data/glovo-orders.psv (git-ignored - e istoricul tau de
comenzi, nu se comite), sau din SMARTBILL_GLOVO_ORDERS / --orders <fisier>.
Antetul PDF-ului ia firma si contul din SMARTBILL_COMPANY_LABEL si
SMARTBILL_IBAN_LABEL (env sau ~/.claude/smartbill.env), sau din --iban-label.
--pdf <fisier> scoate acelasi rezultat ca PDF pentru contabila. Layout-ul
coloreaza sursele, nu randurile: albastru = ce vine din extras (plata), verde
= ce vine din factura din SPV, ocru = partea fara factura. Fara separarea asta,
tabelul citeste „plata 219,38, factura 12,98" si arata ca o greseala, nu ca o
structura. Se ataseaza pe draft cu attach.mjs din skill-ul gmail-web -
conectorul Gmail vrea base64 inline, ceea ce nu are cum sa treaca prin conversatie.
Cum se recolteaza istoricul (glovoapp.com, in Chrome-ul in care esti logat):
api.glovoapp.com/v3/customer/orders-list?limit=12[&offset=<ultimul orderId>]
pentru lista, /v3/customer/orders/<id> pentru pricingBreakdown.fetch propriu: raspunde 401 fara antete CORS, deci
pica cu „Failed to fetch". Aplicatia foloseste XHR cu ~20 de antete Glovo-* plus
Authorization. Solutia: carligi XMLHttpRequest.prototype.setRequestHeader,
aduni antetele in pagina, apoi rulezi cererile tot din pagina. Tokenul nu
trebuie sa iasa niciodata in afara tabului.TOTAL e egal cu
suma platii cu cardul, si asta ancoreaza comanda in timp.paymentMethodsBreakdown spune cu ce card s-a platit (ultimele 4 cifre, aceleasi
ca in extras), deci separa comenzile firmei de cele personale.Platile cu cardul catre o platforma de livrare nu corespund 1:1 facturilor: factura
platformei acopera doar taxele ei, mancarea e facturata (sau nu) de restaurant, iar
bacsisul de nimeni. reconcile le lasa necuplate corect - nu e nimic de reglat
la scor sau la fereastra de zile. Se reconciliaza pe platforma, prin glovo-orders,
iar restul e o decizie de contabilitate. Notele lui Victor despre cazul lui (cifre,
analiza) sunt in repo-ul lui privat de skill-uri.
Both were true in September 2026 and each looks like "the matcher found nothing":
banktx returns [] for a period that plainly had payments. Check
/raport/raport_importuri_extrase/ for the last import, or read lastSync /
lastSyncDays off the ajax response. Re-connecting needs the bank's own auth
screen, so it is a human's job, not the CLI's.De verificat expenses cannot be paid. An e-invoice fetched from SPV lands
as De verificat with payable: false; it has to be registered
(Inregistrata) before any payment attaches to it. expenses --json reports
both fields - check payable before proposing anything.rows.csv — one new invoice per line:
# description,filename(optional)
"One-day onsite workshop for employee Alex Smith, order REF-000101",INV101_Alex-Smith.pdf
edits.csv — one existing invoice per line:
# id,description,filename(optional)
10000001,"One-day onsite workshop for employee Alex Smith, order REF-000101",INV101_Alex-Smith.pdf
Get the ids from list.
An invoice keeps its own snapshot of the client, frozen at issue time. Three things follow, and each one has cost an afternoon:
filter_form2_emitere) that is not submitted with the document. SmartBill
answers "Documentul a fost salvat cu succes!" and the PDF comes back byte-for-byte
the same.edit_client(). Its inputs must receive real input events;
values assigned to .value from injected JS are dropped on save, which looks
exactly like the silent no-op above.reclient does that flow, then re-reads each document from the PDF endpoint and
checks the customer name and every line of the address. The name can land
while the address quietly does not, so checking only the name passes a batch
that is still wrong. The run stops on the first document that did not change,
rather than working through the other twenty-four.
npm run sb -- reclient --series P --from 210 --to 234 \
--name 'New Name B.V.' --address 'T.a.v. Dept\nExample Street 1\n1234 AB' --city 'Amsterdam' \
--out ./out --csv names.csv # names.csv: number,filename
Add --dry-run to stage the modal without saving the document.
sessionid is a browser-session cookie - no expiry of its own - so login
writing it to storageState.json is what lets the CLI keep working after the
browser closes. Do not read the other cookies as a lifetime: srvid and dsc
carry 30-day expiries but have nothing to do with authentication. What ends the
session is the server, and observed behaviour is an idle timeout measured
in hours, not days.
npm run sb -- touch # {"alive":true,"sessionRefreshed":true}
bin/install-launchd.sh 900 # touch every 15 min, forever
bin/session-lab.sh status # age, touches, deaths
bin/install-launchd.sh --uninstall
touch exits non-zero when the session is gone, so it doubles as a health check
before a long batch. launchd rather than cron: a crontab on recent macOS needs
Full Disk Access or it dies silently.
Run bin/session-lab.sh reborn right after login so the age clock restarts.
Measuring, without a second account. Two different questions hide here, and one experimental design answers both:
bin/session-lab.sh pause 4h stops the
touches. Whether the next touch after the gap finds the session alive is the
measurement.ageMinutes at death is the cap.Do not try to build a control arm by copying storageState.json. Every copy
carries the same sessionid and therefore touches the same server-side session:
keeping one alive keeps them all alive, and the "control" measures nothing. An
independent control needs a second real login.
One more trap: do not take storageState.json's mtime as the session's birth.
touch rewrites that file every run, so the mtime is always "just now" and the
age at death - the single number that reveals an absolute cap - reads as zero
forever. session-lab.sh stamps the birth once, in its own file.
--cdp http://127.0.0.1:9222 attaches to a running Chrome instead of using the
saved login session. Use it when the account owner is not at the keyboard, or
when you want the automation to share a session a human keeps alive.
Chrome 136 and later refuse remote debugging on the default profile - that hole was being used to lift cookies - so this needs its own profile directory, signed into SmartBill once:
open -na "Google Chrome" --args \
--remote-debugging-port=9222 --user-data-dir="$HOME/.chrome-smartbill"
Do not try to reach the session by reading Chrome's cookie store instead: those files are encrypted against the login keychain, and copying them around is credential theft with extra steps.
__name helperThe CLI runs through tsx, whose esbuild pass rewrites arrow functions with a
__name helper. That helper does not exist inside the page, so a function
passed to page.evaluate / page.waitForFunction dies with
ReferenceError: __name is not defined. Pass a string expression instead,
interpolating any values with JSON.stringify. Everything in clients.ts does.
rm goes through the API and needs a series and a number; a draft has neither,
so the only way to clear one is the row menu in the invoice report - the same
clicks a human makes. rmdraft does exactly that, and three details make the
difference between working and silently doing nothing:
ul.dropDown.tools_<id> is display:none until
li.unelte_ico_<id> is clicked (it calls show_tools(<id>)). Clicking Delete
without it just retries against an invisible element until it times out.span.is_draft, and
the dialog itself warns that deleting a finalised document rolls the series
number back to the previous one. On a page full of issued invoices, a mistyped
id must not be able to do that.Playwright also dismisses native dialogs by default, so if a delete ever
hides behind window.confirm() it cancels itself. rmdraft accepts them.
create over copy for bulk issuingcopy no longer issues anything. SmartBill's copy flow now ends in an
UNNUMBERED draft that needs a confirmation step, and the control that used to
provide it - #view_save_disposition inside iframe[src*=compact-view] - is
gone, along with the EMISA badge and #viewer_pdf_id next to it. A run reports
failure while having created a document, so re-running silently issues the same
line twice. copy now stops and names the leftover instead, but the leftover
still has to be deleted by hand: rm needs a series and a number, and a draft
has neither.
Issue in bulk through the API instead. create numbers and issues the
document in one call, returns the number, and never opens a browser:
npm run sb -- create --json one-invoice.json # -> {"series":"P","number":"235"}
npm run sb -- get --series P --number 235 --out ./out --name whatever.pdf
Spelling out ~20 fields per invoice was the reason copy existed, but that is
what a loop is for: generate the payloads from your own data, POST each one,
then re-read each PDF and check the party, the total and the line before moving
on. A 22-invoice batch this way took under two minutes with every document
verified, after copy could not manage one.
When comparing a line against the PDF, squeeze whitespace on both sides. The
PDF wraps long lines and extraction turns the break into a space, so
REF-000123 reads back as REF- 000123 and a strict equality check fails on a
perfectly good invoice.
copy inherits client, currency, VAT rate, payment term and price from the
template and changes only the description — one CSV column instead of the ~20
fields create needs per invoice. For "one invoice per training participant"
that is both less typing and less to get wrong.
Do not drive SmartBill by screenshot-and-click. The UI shifts vertically between loads and coordinate clicks land on the wrong field — that is how a description once ended up in the BT-154 field. Everything below waits on selectors and verifies the line text before saving.
| Step | URL / selector |
|---|---|
| copy an invoice | /documente/copiaza/factura/<templateId>/ |
| edit an issued one | /documente/editare/factura/<id>/ |
| open the line editor | a.emitere_edit (pencil on line 1) |
| description field | [name="edit_product_name"] — not [name="edit_product_description"], that is BT-154 |
| apply | submit button of the Modificare produs modal |
| save | #saveInvoiceBtn |
| confirm (drafts only) | #view_save_disposition — inside the viewer iframe |
#viewer_pdf_id — inside the viewer iframe |
After #saveInvoiceBtn, SmartBill renders the document inside
iframe[name="show_document_iframe"] (/documente/compact-view/factura/<id>/).
The confirm button, the PDF icon and the EMISA badge all live in that frame.
Querying the main document for them returns nothing — which reads exactly like
"the save silently failed" when in fact it succeeded. Use page.frameLocator(...)
(helper viewer(page) in invoices.ts).
Two traps inside the trap:
name="show_document_iframe" — match on
src*="compact-view";#view_export_disposition exists in the main document too, but it is hidden and
clicking it dumps you on the dashboard. The real PDF button is #viewer_pdf_id
inside the frame.Injected JS can do the edit and the save (~1.6 s round-trip). It cannot do
the PDF export: a programmatic .click() carries no user activation, so Chrome
silently refuses the download — no file, no error. Playwright dispatches real
input events through CDP, so waitForEvent('download') works.
| Operation | Time |
|---|---|
| any API call | ~200 ms (throttled to 3/s) |
recent, per invoice | ~700 ms (PDF + status) |
browser copy/edit, per invoice | ~1.6 s (573 ms modal + 992 ms save) |
| the same by screenshot-and-click | ~45 s — almost all of it fixed sleeps |
create, copy, storno, cancel
or rm. Pass "isDraft": true while details are unsettled.rm is irreversible and only works on the last invoice in a series. Prefer
cancel (reversible) or storno (leaves an accounting trail).email sends real mail to a real client. Confirm the recipient first.[name="edit_product_description"]), not in the name.
For example,
Serviciu de instruire curs Java Avansat | Perioada: 7-8.09.2026 | Contract: AB123, Anexa 4 | 6.000,00 EUR x curs BNR 5,0000 lei/EUR
is 131 chars; Instruire Java Avansat 7-8.09.2026, contract AB123 anexa 4, 6000 EUR x 5,0000
is 77 and carries the same facts. This only bites domestic (S-series) invoices,
which are the ones that go to SPV.0159, not 159
on accounts that pad. An unpadded number comes back as "not found".taxes and series before issuing rather than reusing remembered values.waitForSelector is for.copy/edit. Multi-line invoices need
setLineDescription to take an index.--headed on one row before a bulk run.A Claude Skill is useless in Desktop: skills run in Anthropic's sandbox, which has no network access and no access to this machine — so the API calls, the credentials file and the local Chromium are all out of reach. An MCP server is spawned as a local process instead, so it can do all three.
src/mcp.ts exposes the same operations as tools, delegating to the same
api.ts / report.ts. It is already wired into
~/Library/Application Support/Claude/claude_desktop_config.json:
"smartbill": { "command": "/absolute/path/to/skills/smartbill/bin/smartbill-mcp.sh" }
Spelled out in full on purpose: Desktop expands neither ~ nor
$CLAUDE_PLUGIN_ROOT in this file, so it is the one place a hardcoded
absolute path is correct. Move the checkout and this line must be edited by hand.
Restart Desktop after changing that file — it is not re-read while running.
Two reasons it points at a shell script rather than at node directly:
node is not on PATH and "command": "npx" fails with spawn ENOENT;~/.nvm/versions/node/v22.21.1/bin/node) that breaks on the next patch
release. The launcher asks nvm for its default alias at startup instead.The token is not in the Desktop config — the server reads
~/.claude/smartbill.env like the CLI does, so the config file stays free of
secrets.
Tools: smartbill_series, _taxes, _stocks, _read_invoice,
_payment_status, _recent, _download_pdf, _list_documents,
_create_invoice, _record_payment, _reverse_invoice, _cancel_invoice,
_restore_invoice, _delete_invoice, _send_email.
copy and edit are deliberately not exposed as tools. They drive a browser
for ~1.6 s per invoice and are fed from CSV files; that belongs in a terminal.
Run them from the CLI.
| File | |
|---|---|
src/api.ts | REST client, credentials, typed calls |
src/pdf.ts | PDF text extraction + the two-template parser |
src/report.ts | recent — walking a series backwards; shared by the CLI and the MCP server |
src/invoices.ts | Playwright flows and selectors |
src/session.ts | browser session / login |
src/cli.ts | argument parsing; API commands dispatch before Playwright is imported |
src/mcp.ts | MCP server for Claude Desktop |
bin/smartbill-mcp.sh | launcher that resolves node for a minimal-env spawn |
invoice.example.json, payment.example.json | payloads for create / pay |
rows.example.csv, edits.example.csv | inputs for copy / edit |
The API layer is a flattened port of bogdanripa/smartbill-mcp — same endpoints and payload shapes, no MCP server to run.
bin/chrome-debug.sh (opens in a new tab)bin/install-launchd.sh (opens in a new tab)bin/session-lab.sh (opens in a new tab)bin/smartbill-mcp.sh (opens in a new tab)edits.example.csv (opens in a new tab)invoice.example.json (opens in a new tab)package.json (opens in a new tab)payment.example.json (opens in a new tab)references/OPEN-FINDINGS.md (opens in a new tab)rows.example.csv (opens in a new tab)src/acquisitions.ts (opens in a new tab)src/api.ts (opens in a new tab)src/btstatement.ts (opens in a new tab)src/cli.ts (opens in a new tab)src/clients.ts (opens in a new tab)src/glovo-pdf.ts (opens in a new tab)src/glovo.ts (opens in a new tab)src/invoices.ts (opens in a new tab)src/mcp.ts (opens in a new tab)src/pdf.ts (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub victorrentea/skills --plugin victor-skills9 skills in this plugin
/come-back-when-doneClears the terminal, then brings it back with a sound when the turn ends. Only on an explicit request to be summoned: "come back when done", "anunță-mă când e gata", "strigă-mă când termini"./dbBefore recommending or making any database change (index, column, constraint, migration, query rewrite). Triggers: indexing advice, schema changes, "add an index", "optimize this query"./jmeterCreates and runs JMeter load/performance tests. Trigger: JMeter, JMX, load/stress testing./scribd-to-pdfTurns a Scribd document into a local PDF. Trigger: Scribd URLs or mentions of Scribd./then-dieClose this terminal window after the work, if it all went fine./tooltipsAdd, restyle, or review a tooltip/hover hint — a native `title=` attribute, `el.title = ...`, or a CSS `::after` speech bubble. Triggers: "add a tooltip", "show a hint on hover", "what does this button do".