This project has been archived by its maintainers, and is no longer receiving any updates.
peresmichael-tax-sdk
Python client for the Novabook tax service. Record sales, amend them, log
tax payments, and query your tax position at any point in time — with
pydantic validation built in. The Python twin of
@peresmichael/tax-sdk
on npm.
pip install peresmichael-tax-sdk
Usage
from datetime import datetime, timezone
from tax_sdk import TaxClient
tax = TaxClient(base_url="https://tax.peresmichael.com")
# record a sale
tax.sale(
date=datetime.now(timezone.utc),
invoice_id="3419027d-960f-4e8f-b8b7-f7b2b4791824",
items=[{"item_id": "02db47b6-fe68-4005-a827-24c6e962f3df", "cost": 1099, "tax_rate": 0.2}],
)
# amend an item later — even before its sale has been recorded
tax.amend(date=date, invoice_id=invoice_id, item_id=item_id, cost=798, tax_rate=0.15)
# record a payment towards the tax owed
tax.tax_payment(date=date, amount=15000)
# your tax position at any date, past or future
position = tax.position(datetime.now(timezone.utc))
print(position.tax_position)
All amounts are integers in pennies. Cost 1099 is £10.99. Dates can be
datetime objects (naive ones are taken as UTC) or ISO 8601 strings.
There is an AsyncTaxClient with exactly the same methods for asyncio
code — await tax.sale(...) and so on.
Methods
| Method | What it does |
|---|---|
sale(date=, invoice_id=, items=) |
Records a sales event (one or more items on an invoice). |
amend(date=, invoice_id=, item_id=, cost=, tax_rate=) |
Changes an item's cost/tax rate from a given date. Works even if the sale arrives later. |
tax_payment(date=, amount=) |
Records a payment made towards the tax owed. |
position(date) |
Returns the tax owed as of that date, in pennies, with the date and request_id. |
health() |
True when the service is reachable. |
Options
TaxClient(
base_url="https://...", # required
retries=3, # attempts per call, 1 disables retrying
headers={...}, # extra headers on every request
timeout=10.0, # seconds per attempt
transport=..., # custom httpx transport (proxies, testing)
)
Good to know
- Writes are queued, not instant.
sale,amendandtax_paymentreturn when the service has durably accepted the event (HTTP 202). Aposition()read in the same instant may not include it yet — wait a moment or poll if you need read-after-write. - Retries are automatic and safe. The service ignores duplicate submissions of the same event for five minutes, so a retried timeout can never double-count a sale.
- Keep the
request_id. Every result includes one; it is the reference the service can trace your exact request by if a number ever needs explaining. Pass your own viasale(..., request_id=...)to correlate with your systems. - Errors are typed. Invalid input raises a pydantic
ValidationErrorlocally, before any network call. Service errors raiseTaxApiErrorwithstatus,code,messageand therequest_idto quote.
from tax_sdk import TaxApiError
try:
tax.sale(date=date, invoice_id=invoice_id, items=items)
except TaxApiError as err:
print(err.status, err.code, err.request_id)
Requirements
Python 3.10+. Depends on httpx and pydantic v2. Fully type-annotated
(py.typed).
Models and validation in this package mirror the service's own zod schemas, so they always match what the API accepts.
Metadata
Release files for peresmichael-tax-sdk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| peresmichael_tax_sdk-0.1.0.tar.gz | 29.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| peresmichael_tax_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.4 kB
Release files / peresmichael_tax_sdk-0.1.0.tar.gz
| Download URL | peresmichael_tax_sdk-0.1.0.tar.gz |
|---|---|
| Size | 29.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6ab945629d69c671567ac1ee19f0acc91be493255a1de83ad56dd20ba6ce445
|
|
BLAKE2b-256 checksum How to use checksums |
65d9b66551ae3266a5715cee0ea223ca63de42bf761de5da732ed3e8885565a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / peresmichael_tax_sdk-0.1.0-py3-none-any.whl
| Download URL | peresmichael_tax_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d7d480b490d201b1537957e4a07713f32d7e41de34fa4a1db5529f9761a349c4
|
|
BLAKE2b-256 checksum How to use checksums |
5766142f20ed9f41e1da1606acb971da247598f9df6baea80a2636ab5187483f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|