Skip to main content

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 Notes can be linked to original invoices via original_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, InvoiceUpdate
  • InvoiceLine, InvoiceLineCreate
  • Client, ClientCreate, ClientUpdate
  • Payment, PaymentCreate
  • Company, CompanyCreate, CompanyUpdate
  • Product, ProductCreate, ProductUpdate
  • PaymentNote, PaymentNoteCreate, PaymentNoteUpdate
  • AuditLog

Interfaces Included

  • BaseRepository - Generic CRUD operations
  • InvoiceRepository - Invoice-specific operations
  • ClientRepository - Client management
  • PaymentRepository - Payment tracking
  • CompanyRepository - Company management
  • ProductRepository - Product catalog
  • PaymentNoteRepository - 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

pydantic_invoices-1.3.0.tar.gz (54.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_invoices-1.3.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_invoices-1.3.0.tar.gz.

File metadata

  • Download URL: pydantic_invoices-1.3.0.tar.gz
  • Upload date:
  • Size: 54.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","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

Hashes for pydantic_invoices-1.3.0.tar.gz
Algorithm Hash digest
SHA256 d67c954958b6f873c1a55dfc0f6bbab4fb4a3970c5dd235fe5f83ab585a14756
MD5 63bf4255bfcc4c04034be4a03aaa5b89
BLAKE2b-256 00f9865235a5e98c3d948c0865439ba434128e524c5565660666f6d9f86ee85b

See more details on using hashes here.

File details

Details for the file pydantic_invoices-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: pydantic_invoices-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","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

Hashes for pydantic_invoices-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7aff4693a1810e2a4bc83f4f15d4cbf4da8143fadad74a740f2bda3263871399
MD5 f61ab0cfe436301f9abb701212f5c58d
BLAKE2b-256 87cec3e9728d0856b87c1c91bedf3953f3a922d5e405c2f584587e2bf99ed0db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page