- Backend: FastAPI app with all models, services, schemas, routes - Admin Panel: Next.js dashboard with all modules (CRM, POS, repairs, warranties, billing, notifications, etc.) - Ecommerce: storefront (submodule) + product catalog - AI Agents: .agents/ skill library for Antigravity IDE - Docs: architecture, billing, notification gateway markdown - Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
26 lines
1.5 KiB
Python
26 lines
1.5 KiB
Python
from sqlalchemy.orm import Session
|
|
from sqlalchemy import select
|
|
from typing import List, Optional
|
|
from app.repositories.base_repository import BaseRepository
|
|
from app.models.ServiceQuoteModel import ServiceJobQuote
|
|
from app.models.ServicePaymentModel import ServicePayment
|
|
|
|
class ServiceQuoteRepository(BaseRepository[ServiceJobQuote]):
|
|
def __init__(self):
|
|
super().__init__(ServiceJobQuote)
|
|
|
|
def get_quotes_for_job(self, db: Session, service_job_id: str) -> List[ServiceJobQuote]:
|
|
stmt = select(ServiceJobQuote).where(ServiceJobQuote.service_job_id == service_job_id).order_by(ServiceJobQuote.version.desc())
|
|
return list(db.execute(stmt).scalars().all())
|
|
|
|
def get_latest_quote_for_job(self, db: Session, service_job_id: str) -> Optional[ServiceJobQuote]:
|
|
stmt = select(ServiceJobQuote).where(ServiceJobQuote.service_job_id == service_job_id).order_by(ServiceJobQuote.version.desc()).limit(1)
|
|
return db.execute(stmt).scalar_one_or_none()
|
|
|
|
def get_payments_for_job(self, db: Session, service_job_id: str) -> List[ServicePayment]:
|
|
stmt = select(ServicePayment).where(ServicePayment.service_job_id == service_job_id).order_by(ServicePayment.created_at.desc())
|
|
return list(db.execute(stmt).scalars().all())
|
|
|
|
def get_payment_by_provider_order_id(self, db: Session, order_id: str) -> Optional[ServicePayment]:
|
|
stmt = select(ServicePayment).where(ServicePayment.provider_order_id == order_id)
|
|
return db.execute(stmt).scalar_one_or_none()
|