from typing import List

from report import Presenter  # noqa
from basereport import SimpleReport

from .builders import TableReportHeader, TableReportBody, ReportBuilder
from .dto import TableReportDto  # noqa


class TableReportPresenter(Presenter):
    def __init__(
        self,
        print_by,                   # type: str
        hide_unpriced_items,        # type: bool
        pre_account_with_discount,  # type: bool
        pos_id,                     # type: str
        filtered_seat               # type: str
    ):
        # type: (...) -> None

        self.print_by = print_by
        self.hide_unpriced_items = hide_unpriced_items
        self.pre_account_with_discount = pre_account_with_discount
        self.pos_id = pos_id
        self.filtered_seat = filtered_seat

    def present(self, dto):
        # type: (TableReportDto) -> SimpleReport

        pos_id = self.pos_id
        report_builders = [
            TableReportHeader(dto.header, self.pre_account_with_discount),
            TableReportBody(
                table_report_body_dto=dto.body,
                print_by=self.print_by,
                hide_unpriced_items=self.hide_unpriced_items,
                pre_account_with_discount=self.pre_account_with_discount,
                pos_id=pos_id,
                filtered_seat=self.filtered_seat
            )
        ]  # type: List[ReportBuilder]

        report = []
        for builder in report_builders:
            report.extend(builder.generate())

        return SimpleReport(report, 38)
