# encoding: utf-8
from mw import MwOperatorNameRetriever

from openedtablesreport import OpenedTablesReport
from openedtablesreport.repository import (
    OrderRepository,
    TableRepository,
)
from utils import get_pos_list


class ReportGenerator(object):
    @staticmethod
    def generate(mb_context, pos_id):
        operator_retriever = MwOperatorNameRetriever(
            mb_context
        )
        table_repository = TableRepository(
            mb_context,
            pos_id
        )
        order_repository = OrderRepository(
            mb_context,
            get_pos_list(mb_context)
        )
        opened_tables_report_generator = OpenedTablesReport(
            table_repository,
            order_repository,
            pos_id,
            operator_retriever
        )
        return opened_tables_report_generator.generate_opened_tables_report(pos_id)

