Skip to content

Instantly share code, notes, and snippets.

@Aciid
Created October 9, 2025 19:30
Show Gist options
  • Save Aciid/247dd33d1ed7ae9b1bcc49205172ab75 to your computer and use it in GitHub Desktop.
Save Aciid/247dd33d1ed7ae9b1bcc49205172ab75 to your computer and use it in GitHub Desktop.

Implement Full Procountor Bookkeeping Suite

Approach

Generate router modules for all 27 API categories from the OpenAPI spec. Each router will:

  • Use the existing ProcountorClient via app/dependencies.py
  • Define endpoint stubs that extract path/query params and forward to the client
  • Use generic dict[str, Any] for request/response bodies
  • Include docstrings from the OpenAPI spec summaries

Implementation Steps

  1. Parse OpenAPI spec - Extract all paths, methods, parameters, and summaries grouped by tag

  2. Generate router modules - Create app/routers/ directory with one file per tag:

    • invoices.py (26 endpoints)
    • ledger_receipts.py (8 endpoints)
    • business_partners.py (15 endpoints)
    • payments.py (14 endpoints)
    • payrolls.py (14 endpoints)
    • employees.py (23 endpoints)
    • products.py (10 endpoints)
    • company.py (10 endpoints)
    • persons.py (8 endpoints)
    • bank_statements.py (7 endpoints)
    • dimensions.py (5 endpoints)
    • attachments.py (5 endpoints)
    • users.py (5 endpoints)
    • bank_accounts.py (4 endpoints)
    • currencies.py (4 endpoints)
    • factoring_contracts.py (4 endpoints)
    • vats.py (3 endpoints)
    • reference_payments.py (3 endpoints)
    • reports.py (3 endpoints)
    • integrations.py (3 endpoints)
    • sie_file.py (2 endpoints)
    • fiscal_years.py (2 endpoints)
    • chart_of_accounts.py (1 endpoint)
    • journal.py (1 endpoint)
    • session_info.py (1 endpoint)
    • health.py (1 endpoint)
    • (webhooks already implemented in app/webhooks.py)
  3. Register all routers - Update app/main.py to import and include all 26 new routers

  4. Remove generic proxy - Delete app/routers.py since specific routers will replace it

  5. Update docs - Update README with new endpoint structure

Key Files

  • app/main.py - register all routers with appropriate prefixes/tags
  • app/routers/*.py - new router modules (26 files)
  • Delete: app/routers.py (replaced by specific routers)

Example Router Pattern

# app/routers/invoices.py
from typing import Any
from fastapi import APIRouter, Depends, Path, Query
from ..dependencies import procountor_client
from ..procountor_client import ProcountorClient

router = APIRouter(prefix="/invoices", tags=["Invoices"])

@router.get("")
async def get_invoices(
    client: ProcountorClient = Depends(procountor_client),
    status: str | None = Query(None),
) -> dict[str, Any]:
    """Search invoices."""
    response = await client.request("GET", "/invoices", params={"status": status})
    response.raise_for_status()
    return response.json()

@router.get("/{invoice_id}")
async def get_invoice(
    invoice_id: int = Path(...),
    client: ProcountorClient = Depends(procountor_client),
) -> dict[str, Any]:
    """Get invoice by ID."""
    response = await client.request("GET", f"/invoices/{invoice_id}")
    response.raise_for_status()
    return response.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment