from datetime import datetime

from typing import (
    Dict,
    List,
    Optional,
)
from order_api.dto import Order as OrderApi
from ._ServiceTender import ServiceTender


# noinspection PyShadowingBuiltins
class Table(object):

    def __init__(
        self,                       # type: Table
        table_id,                   # type: str
        order_id=None,              # type: Optional[str]
        user_id=None,               # type: Optional[str]
        table_mode=None,            # type: Optional[str]
        table_name=None,            # type: Optional[str]
        tabs_names=None,            # type: Optional[Dict[str, str]]
        orders=None,                # type: Optional[List[OrderApi]]
        total_amount=None,          # type: Optional[float]
        tip_rate=None,              # type: Optional[float]
        tip=None,                   # type: Optional[float]
        service_seats=None,         # type: Optional[int]
        total_per_seat=None,        # type: Optional[float]
        total_discounts=None,       # type: Optional[float]
        start_date=None,            # type: Optional[datetime]
        service_tenders=None,       # type: List[ServiceTender]
        status=0,                   # type: Optional[int]
        tip_base_amount=0,          # type: Optional[float]
    ):
        # type: (...) -> None

        self.table_id = table_id
        self.order_id = order_id
        self.user_id = user_id
        self.table_mode = table_mode
        self.table_name = table_name
        self.tabs_names = tabs_names or {}
        self.orders = orders or []
        self.total_amount = total_amount or 0.0
        self.tip_rate = tip_rate or 0.0
        self.tip = tip or 0.0
        self.service_seats = service_seats or 0
        self.total_per_seat = total_per_seat or 0.0
        self.total_discounts = total_discounts or 0.0
        self.start_date = start_date
        self.service_tenders = service_tenders or []
        self.status = status
        self.tip_base_amount = tip_base_amount

        self.sub_total_amount = 0.0         # type: float
        self.detailed_discounts = {}        # type: Dict
        self.detailed_payments = {}         # type: Dict
        self.user_name = None               # type: Optional[str]
        self.promotional_tenders = 0.0      # type: float
        self.detailed_tip_excluded = {}     # type: Dict
        self.discount_groups = {}           # type: Dict
