from typing import List, Optional

from pydantic import BaseModel


# Base
class BaseItem(BaseModel):
    item_id: str
    item_type: str


class BaseDiscountedItem(BaseModel):
    discount: float
    applied_percentage: float
    discount_identifier: Optional[str]


# Request
class Item(BaseItem):
    price: int


class InstallmentItem(BaseItem):
    upfront_amount: int
    part_amount: int
    parts: int


# Response
class DiscountedItem(Item, BaseDiscountedItem):
    discounted_price: float


class DiscountedItems(BaseModel):
    items: List[DiscountedItem]


class DiscountedInstallmentItem(InstallmentItem, BaseDiscountedItem):
    discounted_upfront_amount: float
    discounted_part_amount: float
    total_discounted_amount: float


class DiscountedInstallmentItems(BaseModel):
    items: List[DiscountedInstallmentItem]


class CouponCalculateResult(BaseModel):
    coupon_percentage: float
    items: List[DiscountedItem]
    total_discount: float


class TieredDiscountResult(BaseModel):
    amount: int
    discount_amount: float
    discounted_amount: float
