anaf-sync
Scheduled local archiver for RO e-Factura invoices, built on anafpy. Each run lists every message in ANAF's 60-day retention window, downloads the ones it hasn't seen before, and files them under paths rendered from a template of invoice variables. Runs on Windows, Linux, and macOS.
Design rationale lives in DESIGN.md; conventions for working on the codebase in CLAUDE.md.
Install
uv tool install anaf-sync # from a published wheel
# or, from this checkout:
uv tool install --from . anaf-sync
Authentication
anaf-sync reuses the anafpy login — the same one the anafpy MCP server uses:
anafpy auth login(browser OAuth with your ANAF certificate) writes the token set to the OS credential store (or a JSON file).- Set
ANAFPY_CLIENT_IDandANAFPY_CLIENT_SECRETin the environment (or a.envfile) so scheduled runs can refresh expired tokens.
Optional, mirroring anafpy: ANAFPY_TOKEN_STORE_BACKEND=file and
ANAFPY_TOKEN_STORE=~/.anafpy/tokens.json for headless hosts without a
credential store.
Configure
anaf-sync init # writes a commented config.toml
anaf-sync status # shows where it lives on your platform
The interesting part is the path template:
[output]
directory = "~/Facturi"
template = "{cif}/{direction}/{issue_date:%Y}/{issue_date:%m}/{issue_date:%Y-%m-%d}_{number}_{partner_name}"
artifacts = ["zip", "pdf"] # also: xml, signature, metadata
Templates use Python format syntax over the invoice's context: number,
issue_date / due_date (real dates — strftime specs work), currency,
total, kind, direction, cif, seller_name/seller_cif,
buyer_name/buyer_cif, partner_name/partner_cif (the other party),
message_id, request_id, message_type, created. Substituted values are
sanitised for the filesystem; literal / in the template creates folders; each
artifact appends its own extension.
Run
anaf-sync sync --dry-run # see what would be downloaded
anaf-sync sync # download everything new
Runs are idempotent: a state file records archived message ids, so overlapping 60-day windows never duplicate work, and anything ANAF is about to purge has already been captured.
Schedule
anaf-sync schedule install --every 6h # or --daily-at 07:30
anaf-sync schedule status
anaf-sync schedule remove
This registers the sync with the OS scheduler — Task Scheduler on Windows,
a systemd user timer on Linux (loginctl enable-linger $USER to run while
logged out), launchd on macOS. No daemon of its own.
Development
uv sync
uv run pytest
uv run ruff check src tests && uv run black --check src tests && uv run mypy src
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anaf_sync-0.1.0.tar.gz.
File metadata
- Download URL: anaf_sync-0.1.0.tar.gz
- Upload date:
- Size: 84.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3d54f2c9e2135cc5972e081f1553a03b4c296b2166db5db0e2b1f9c29905b7b
|
|
| MD5 |
d7224684c7aa86c41a0d2d4482d5a0c0
|
|
| BLAKE2b-256 |
e49d116d41c06981e0b4b218302c5be3abbdaa77dbf1f3699d247ccd9e3003d0
|
Provenance
The following attestation bundles were made for anaf_sync-0.1.0.tar.gz:
Publisher:
release.yml on robert-malai/anaf-sync
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anaf_sync-0.1.0.tar.gz -
Subject digest:
f3d54f2c9e2135cc5972e081f1553a03b4c296b2166db5db0e2b1f9c29905b7b - Sigstore transparency entry: 2205510972
- Sigstore integration time:
-
Permalink:
robert-malai/anaf-sync@296b31bece227d4345f96f19f9994be406e323b2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/robert-malai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@296b31bece227d4345f96f19f9994be406e323b2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file anaf_sync-0.1.0-py3-none-any.whl.
File metadata
- Download URL: anaf_sync-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65a75722f00d3e3d5745e4465a05581b81c87a9b666c9cc1da820f411370257f
|
|
| MD5 |
b780ff9c46cb813617aa33ce15f41a35
|
|
| BLAKE2b-256 |
8e2a1efcf2e504be1f64e610a73212fdd40c842ce4ed8bb0994aaac17f4eea2c
|
Provenance
The following attestation bundles were made for anaf_sync-0.1.0-py3-none-any.whl:
Publisher:
release.yml on robert-malai/anaf-sync
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anaf_sync-0.1.0-py3-none-any.whl -
Subject digest:
65a75722f00d3e3d5745e4465a05581b81c87a9b666c9cc1da820f411370257f - Sigstore transparency entry: 2205510977
- Sigstore integration time:
-
Permalink:
robert-malai/anaf-sync@296b31bece227d4345f96f19f9994be406e323b2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/robert-malai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@296b31bece227d4345f96f19f9994be406e323b2 -
Trigger Event:
push
-
Statement type: