Pydantic schemas and repository interfaces for invoice management
Project description
Pydantic Invoices
Type-safe Pydantic schemas and repository interfaces for invoice management systems.
Installation
pip install pydantic-invoices
# or
uv add pydantic-invoices
Usage
Using Schemas
from pydantic_invoices import Invoice, InvoiceCreate, Client, ClientCreate
from pydantic_invoices.schemas import InvoiceStatus, InvoiceType
from datetime import datetime
# Create invoice data
invoice_data = InvoiceCreate(
number="INV-001",
client_id=1,
company_id=1,
issue_date=datetime.now(),
due_date=datetime.now(),
status=InvoiceStatus.DRAFT,
type=InvoiceType.STANDARD,
payment_terms="Net 30",
lines=[],
)
# Validate and use
invoice = Invoice(id=1, **invoice_data.model_dump())
Invoice Statuses & Types
The library supports a strict state machine workflow:
- Statuses:
DRAFT,SENT,PAID,PARTIALLY_PAID,CANCELLED,REFUNDED,CREDITED. - Types:
STANDARD,CREDIT_NOTE. - Linking:
Credit Notescan be linked to original invoices viaoriginal_invoice_id.
Implementing Repository Interfaces
from pydantic_invoices.interfaces import InvoiceRepository, ClientRepository
from pydantic_invoices import Invoice, InvoiceCreate, Client
class MyInvoiceRepo(InvoiceRepository):
def create(self, entity: InvoiceCreate) -> Invoice:
# Your implementation
pass
def get_by_id(self, id: int) -> Invoice | None:
# Your implementation
pass
# ... implement other methods
Architecture
See System Diagram for a visual overview of the entities and their relationships.
Features
- ✅ Type-safe Pydantic v2 schemas
- ✅ Repository pattern interfaces
- ✅ No implementation dependencies
- ✅ Fully typed with mypy support
- ✅ Clean separation of concerns
- ✅ Support for Credit Notes and Strict Lifecycle
Schemas Included
Invoice,InvoiceCreate,InvoiceUpdateInvoiceLine,InvoiceLineCreateClient,ClientCreate,ClientUpdatePayment,PaymentCreateCompany,CompanyCreate,CompanyUpdateProduct,ProductCreate,ProductUpdatePaymentNote,PaymentNoteCreate,PaymentNoteUpdateAuditLog
Interfaces Included
BaseRepository- Generic CRUD operationsInvoiceRepository- Invoice-specific operationsClientRepository- Client managementPaymentRepository- Payment trackingCompanyRepository- Company managementProductRepository- Product catalogPaymentNoteRepository- Payment instructions
License
MIT
Project details
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 pydantic_invoices-1.3.1.tar.gz.
File metadata
- Download URL: pydantic_invoices-1.3.1.tar.gz
- Upload date:
- Size: 55.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f401577e73bd9cc67aa4739c220bb98687e324212c0accf0aa1ac1a4fc08d530
|
|
| MD5 |
34877b27a88caa08f10bc89468b3275b
|
|
| BLAKE2b-256 |
e1db79a8da194335947f4be44aa5e3e026944f1955aef478c288c76a2eaf67bc
|
File details
Details for the file pydantic_invoices-1.3.1-py3-none-any.whl.
File metadata
- Download URL: pydantic_invoices-1.3.1-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faca829a48ee5d7b30644afaa5d4d824132cee8775762c156b1e1b034e3c60f4
|
|
| MD5 |
a7b30e330d6374a51483266cc1ecd541
|
|
| BLAKE2b-256 |
d415bb909e8fa8729f72f6a940c58c80492de82b20b2e63794fb555c5b81c8b4
|