add fixture-invoicing example, sample-room wrap, kind cluster support
- examples/fixture-invoicing/: FastAPI + Vue + Postgres demo (4-entity invoice fixture)
- cfg/sample/: wraps the fixture (managed.repos points at examples/)
- ctrl/kind-{up,down,status}.sh + per-room k8s render in soleprint/ctrl/k8s/
- build.py: relative repo paths, resilient rmtree, optional k8s render hook
- cfg/.gitignore: stop ignoring sample/ and standalone/ template rooms
Manifests render cleanly but kind cluster has not been run end-to-end yet.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
64
examples/fixture-invoicing/backend/seed.py
Normal file
64
examples/fixture-invoicing/backend/seed.py
Normal file
@@ -0,0 +1,64 @@
|
||||
"""Seed obviously-fake demo data so the fixture is non-empty on first boot."""
|
||||
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from decimal import Decimal
|
||||
|
||||
from db import SessionLocal
|
||||
from models import Customer, Invoice, LineItem, Payment
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def seed_if_empty() -> None:
|
||||
session = SessionLocal()
|
||||
try:
|
||||
if session.query(Customer).count() > 0:
|
||||
return
|
||||
|
||||
log.info("Seeding fixture data…")
|
||||
acme = Customer(name="Acme Widget Co.", email="billing@acme.example")
|
||||
test = Customer(name="Test Customer 001", email="test@example.invalid")
|
||||
session.add_all([acme, test])
|
||||
session.flush()
|
||||
|
||||
inv1 = Invoice(
|
||||
number="DEMO-2026-001",
|
||||
customer_id=acme.id,
|
||||
issued_at=datetime(2026, 1, 15),
|
||||
due_at=datetime(2026, 2, 15),
|
||||
status="sent",
|
||||
)
|
||||
inv2 = Invoice(
|
||||
number="DEMO-2026-002",
|
||||
customer_id=acme.id,
|
||||
issued_at=datetime(2026, 2, 1),
|
||||
due_at=datetime(2026, 3, 1),
|
||||
status="paid",
|
||||
)
|
||||
inv3 = Invoice(
|
||||
number="DEMO-2026-003",
|
||||
customer_id=test.id,
|
||||
issued_at=datetime(2026, 3, 10),
|
||||
due_at=datetime(2026, 4, 10),
|
||||
status="draft",
|
||||
)
|
||||
session.add_all([inv1, inv2, inv3])
|
||||
session.flush()
|
||||
|
||||
session.add_all([
|
||||
LineItem(invoice_id=inv1.id, description="Widget type A", quantity=10, unit_price=Decimal("19.99")),
|
||||
LineItem(invoice_id=inv1.id, description="Widget type B", quantity=5, unit_price=Decimal("49.00")),
|
||||
LineItem(invoice_id=inv2.id, description="Consulting (hours)", quantity=8, unit_price=Decimal("120.00")),
|
||||
LineItem(invoice_id=inv3.id, description="Placeholder line item", quantity=1, unit_price=Decimal("0")),
|
||||
])
|
||||
|
||||
session.add_all([
|
||||
Payment(invoice_id=inv2.id, amount=Decimal("960.00"), method="transfer", paid_at=datetime(2026, 2, 20)),
|
||||
Payment(invoice_id=inv1.id, amount=Decimal("100.00"), method="card", paid_at=datetime(2026, 2, 1)),
|
||||
])
|
||||
|
||||
session.commit()
|
||||
log.info("Seed complete.")
|
||||
finally:
|
||||
session.close()
|
||||
Reference in New Issue
Block a user