41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
from datetime import date
|
|
from typing import Optional
|
|
|
|
from pydantic import Field, condecimal
|
|
|
|
from app.models.payment import PaymentMethod
|
|
from app.schemas.base import BaseSchema, BaseSchemaIDTimestamps
|
|
|
|
|
|
class PaymentBase(BaseSchema):
|
|
"""Base schema for payment."""
|
|
amount: condecimal(ge=0, decimal_places=2) = Field(..., description="Payment amount")
|
|
payment_date: date = Field(default_factory=date.today)
|
|
payment_method: PaymentMethod
|
|
reference: Optional[str] = None
|
|
notes: Optional[str] = None
|
|
invoice_id: int
|
|
|
|
|
|
class PaymentCreate(PaymentBase):
|
|
"""Schema for creating a payment."""
|
|
pass
|
|
|
|
|
|
class PaymentUpdate(BaseSchema):
|
|
"""Schema for updating a payment."""
|
|
amount: Optional[condecimal(ge=0, decimal_places=2)] = None
|
|
payment_date: Optional[date] = None
|
|
payment_method: Optional[PaymentMethod] = None
|
|
reference: Optional[str] = None
|
|
notes: Optional[str] = None
|
|
|
|
|
|
class PaymentInDBBase(PaymentBase, BaseSchemaIDTimestamps):
|
|
"""Base schema for payment in database."""
|
|
pass
|
|
|
|
|
|
class Payment(PaymentInDBBase):
|
|
"""Schema for payment."""
|
|
pass |