from sqlalchemy.orm import Session

from app.models.reimbursement import ReimbursementRequest
from app.repositories.reimbursement import ReimbursementRepository
from app.schemas.reimbursement import ReimbursementCreate


class ReimbursementService:
    def __init__(self, db: Session) -> None:
        self.repository = ReimbursementRepository(db)

    def list_reimbursements(self) -> list[ReimbursementRequest]:
        return self.repository.list()

    def get_reimbursement(self, request_id: str) -> ReimbursementRequest | None:
        return self.repository.get(request_id)

    def create_reimbursement(self, payload: ReimbursementCreate) -> ReimbursementRequest:
        request = ReimbursementRequest(**payload.model_dump(), status="draft")
        return self.repository.create(request)
