# encoding: utf-8
from datetime import (
    datetime,
    timedelta
)

from msgbus import MBEasyContext
from typing import Union
from utils import get_pos_list
from reportsdata.tefcancellationreport import (
    TefCancellationReportGenerator,
    TefCancellationReportPresenter
)
from tefcancellationreport.repository import OrderRepository


class ReportGenerator(object):

    @staticmethod
    def generate(
        mb_context,  # type: MBEasyContext
        pos_id,      # type: str
        *args        # type: Union[str, unicode]
    ):
        # type: (...) -> tuple

        pos_list = get_pos_list(mb_context)
        initial_date = args[1]
        end_date = args[2]

        order_repository = OrderRepository(
            mb_context=mb_context,
            pos_list=pos_list
        )
        generator = TefCancellationReportGenerator(
            order_repository=order_repository,
            initial_date=initial_date,
            end_date=end_date
        )
        presenter = TefCancellationReportPresenter(38)

        return generator, presenter
