fv-cli

module
v0.1.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: MIT

README

fv

Command-line tool for issuing Polish VAT invoices (FA(3)) and sending them to KSeF 2.0.

fv builds an invoice from one amount and a buyer alias (fv issue --to acme --net "18500,43"), keeps it as a local draft, and sends it to KSeF only when you say so (fv send). Seller and buyer are configured by tax number; their name, address and VAT status come from the MF White List and EU VIES. It logs in to KSeF with your KSeF certificate (XAdES), encrypts the invoice for the session, and keeps the KSeF number and the UPO in a local archive. It is one static binary for Windows, macOS and Linux, written for people who invoice from a terminal and want a small, auditable tool instead of a web form.

Features

  • One command from amount to draft: seller, buyer, dates, VAT rate, bank account and numbering come from a small config.toml.
  • Buyers are looked up by NIP (MF White List) or EU VAT ID (VIES) and cached; the VAT status is checked and shown on every invoice.
  • Exact money arithmetic in grosze (no floating point); Polish and English decimal input, with documented shell quoting.
  • Foreign currency invoices with the NBP exchange rate.
  • FA(3) XML generated and validated against the official schema.
  • KSeF login with a certificate (XAdES), session encryption, one-shot send with a 120 s verdict poll, UPO stored with the invoice.
  • Safe by default: nothing is sent without confirmation; PROD needs a typed PRODUCTION; an unknown outcome blocks a resend until fv status resolves it.
  • Local archive with sequential numbering under an OS lock, immutable sent XML with a stored SHA-256.
  • Secrets in the OS keyring (Windows Credential Manager, macOS Keychain, Secret Service), redacted from logs and output.
  • Documented exit codes for scripting; every command has --help with examples.

Status

Verified live against the KSeF DEMO environment on 2026-10-31: certificate (XAdES) login, and PLN and EUR invoices accepted with a UPO. The TEST and PROD environments have not been exercised yet.

This project is not affiliated with the Polish Ministry of Finance (Ministerstwo Finansów) or the KSeF programme. It is not tax or accounting advice. Check every invoice before you send it, and use fv at your own risk.

Install

Download the archive for your platform from the Releases page (Windows .zip, Linux and macOS .tar.gz), verify it against checksums.txt, and put fv on your PATH. Or, with Go 1.26.10 or newer:

go install github.com/lwasak/fv-cli/cmd/fv@latest

The binaries are not code-signed:

  • macOS. A file downloaded in a browser is quarantined and Gatekeeper refuses to run it. Fetch the archive with curl -L -O <asset URL>, or remove the attribute after checking the checksum: xattr -d com.apple.quarantine fv.
  • Windows. Running fv from a terminal does not trigger SmartScreen. If an archive downloaded in a browser is blocked, run Unblock-File .\fv.exe once.

Details, checksums and per-OS notes: docs/install.md.

Quick start

fv init                                   # config, and import of your KSeF certificate
fv party add acme --nip 5252248481        # a buyer, looked up in the White List
fv issue --to acme --net "18500,43"       # a local draft; nothing is sent
fv show FV/2026/10/001                    # check it
fv send FV/2026/10/001                    # to KSeF, after a confirmation
fv status FV/2026/10/001                  # only when the answer was lost
$ fv issue --to acme --net "18500,43"
ENVIRONMENT: DEMO

Invoice:   FV/2026/10/001   [draft]
...
Total:     22 755,53 PLN

Nothing was sent to KSeF. To send: fv send FV/2026/10/001

$ fv send FV/2026/10/001
Send invoice FV/2026/10/001 to KSeF DEMO? [y/N] y
Sent FV/2026/10/001 to KSeF DEMO.
KSeF number: 5260250274-20261031-0100001AF62C-27
UPO:         stored (upo.xml)

Quote amounts ("18500,43"): PowerShell and other shells can mangle an unquoted comma. See docs/amounts.md and fv help amounts.

Security

  • The KSeF private key is stored encrypted as you imported it; it is decrypted in memory for one signature and not kept. The passphrase is never a flag or a config value: OS keyring, environment variable or a no-echo prompt.
  • Passphrases, tokens and PESEL are redacted from logs and output. All files are user-only (0600/0700, protected ACL on Windows) and written atomically.
  • TLS 1.2+ with the system trust store, no option to skip verification, fixed service addresses, no redirects. A send is posted once and never retried.
  • The local archive is not encrypted and holds buyer names and addresses: use full-disk encryption and protect backups.

Read docs/security.md for what fv protects and what you must protect.

Documentation

The user guide is in docs/: install, setup, parties, workflow, amounts, numbering and archive, exit codes, troubleshooting, security, the config reference and the design decisions. Every command also has --help.

Development

CI runs through Dagger (engine v0.21.11, Go SDK; module in ci/), so the same pipeline runs locally and on GitHub Actions. It needs a container engine.

dagger call check                         # gofmt, vet, tests (incl. XSD golden), cross-builds, govulncheck, gosec
dagger call build export --path=dist      # snapshot release archives in ./dist

Or with plain Go (1.26.10+; xmllint from libxml2 enables the XSD golden test):

gofmt -l .                                # must print nothing
go vet ./...
go test ./...
go build ./cmd/fv

scripts/Test-Live.ps1 (PowerShell 7) runs a manual live check against KSeF TEST or DEMO in an isolated temporary config; it needs your own certificate and refuses PROD.

Releasing

Releases are built by GoReleaser inside the Dagger pipeline when a version tag is pushed:

git tag v0.1.0 && git push origin v0.1.0

The release workflow publishes the archives, checksums.txt and a GitHub-generated changelog.

License

MIT © 2026 Łukasz Wasak.

Directories

Path Synopsis
cmd
fv command
Command fv issues Polish VAT invoices and sends them to KSeF.
Command fv issues Polish VAT invoices and sends them to KSeF.
internal
cli
Package cli holds the Cobra command tree of fv.
Package cli holds the Cobra command tree of fv.
config
Package config locates, loads and resolves fv's configuration.
Package config locates, loads and resolves fv's configuration.
credentials
Package credentials imports, stores, inspects and uses the KSeF login certificate.
Package credentials imports, stores, inspects and uses the KSeF login certificate.
credentials/credtest
Package credtest generates throwaway certificates and keys for tests.
Package credtest generates throwaway certificates and keys for tests.
exitcode
Package exitcode maps sentinel errors to fv process exit codes, so packages can tag their errors without importing the cli package.
Package exitcode maps sentinel errors to fv process exit codes, so packages can tag their errors without importing the cli package.
fa3
Package fa3 builds FA(3) invoice XML (KSeF schema 1-0E) deterministically from already computed amounts, and ships the vendored XSD used to validate it.
Package fa3 builds FA(3) invoice XML (KSeF schema 1-0E) deterministically from already computed amounts, and ships the vendored XSD used to validate it.
fsafe
Package fsafe is the one place fv creates files and directories.
Package fsafe is the one place fv creates files and directories.
httpx
Package httpx is the hardened HTTPS client for fv's non-KSeF services (White List, VIES, NBP).
Package httpx is the hardened HTTPS client for fv's non-KSeF services (White List, VIES, NBP).
invoice
Package invoice is the pure computation behind "fv issue": dates, the line description template and the amounts.
Package invoice is the pure computation behind "fv issue": dates, the line description template and the amounts.
ksef
Package ksef is fv's client for the KSeF 2.0 API: fixed per-environment base URLs, a hardened HTTPS transport, KSeF error decoding, safe request logging, the cache of the Ministry of Finance public-key certificates and the certificate login flow.
Package ksef is fv's client for the KSeF 2.0 API: fixed per-environment base URLs, a hardened HTTPS transport, KSeF error decoding, safe request logging, the cache of the Ministry of Finance public-key certificates and the certificate login flow.
ksef/ksefake
Package ksefake is a scripted TLS test server standing in for the KSeF API.
Package ksefake is a scripted TLS test server standing in for the KSeF API.
logging
Package logging provides fv's structured log (fv.log) and the process-wide secret redactor that keeps registered secret values out of log files and printed errors.
Package logging provides fv's structured log (fv.log) and the process-wide secret redactor that keeps registered secret values out of log files and printed errors.
money
Package money holds locale-agnostic amount parsing and VAT arithmetic.
Package money holds locale-agnostic amount parsing and VAT arithmetic.
nbp
Package nbp is the client for the NBP table A (average rates) API.
Package nbp is the client for the NBP table A (average rates) API.
numbering
Package numbering renders invoice numbers from a pattern and derives the counter period.
Package numbering renders invoice numbers from a pattern and derives the counter period.
registry
Package registry resolves party data from the official registries by tax number only: the MF VAT White List for Polish NIPs and EU VIES for EU VAT numbers.
Package registry resolves party data from the official registries by tax number only: the MF VAT White List for Polish NIPs and EU VIES for EU VAT numbers.
secrets
Package secrets reads secrets (KSeF tokens and the like) from the OS keyring, with an environment-variable fallback.
Package secrets reads secrets (KSeF tokens and the like) from the OS keyring, with an environment-variable fallback.
store
Package store is fv's local archive: invoice numbering counters in state.json and one folder per invoice holding invoice.xml, meta.json and upo.xml.
Package store is fv's local archive: invoice numbering counters in state.json and one folder per invoice holding invoice.xml, meta.json and upo.xml.
useragent
Package useragent holds the User-Agent fv sends on every HTTP request.
Package useragent holds the User-Agent fv sends on every HTTP request.
validate
Package validate checks user-supplied identifiers and settings.
Package validate checks user-supplied identifiers and settings.
xades
Package xades builds the KSeF AuthTokenRequest and signs it as an enveloped XAdES-BES signature in pure Go.
Package xades builds the KSeF AuthTokenRequest and signs it as an enveloped XAdES-BES signature in pure Go.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL