# encoding: utf-8

from typing import Any, Tuple

from justificationdiscountreport.repository import JustificationDiscountRepository
from reportsdata.justificationdiscountreport import (
    JustificationDiscountReportGenerator,
    JustificationDiscountReportPresenter,
)


class ReportGenerator(object):
    @staticmethod
    def generate(
        mb_context,     # type: Any
        pos_id,         # type: str
        *args           # type: str
    ):
        # type: (...) -> Tuple[JustificationDiscountReportGenerator, JustificationDiscountReportPresenter]

        initial_date = args[4]
        end_date = args[5]
        operator_id = None if args[6] == '0' else args[6]

        repository = JustificationDiscountRepository(
            mb_context=mb_context,
            pos_id=pos_id,

        )
        generator = JustificationDiscountReportGenerator(
            repository=repository,
            initial_date=initial_date,
            end_date=end_date,
            operator_id=operator_id,
            pos_id=pos_id,
        )

        presenter = JustificationDiscountReportPresenter(
            columns=38,
        )

        return generator, presenter
