from logging import Logger
from typing import (
    Optional,
    Union,
    List,
)

from production.model import (
    ProductionOrder,
)

from ._OrderChangerProductionBox import OrderChangerProductionBox


class NonComboFilterBox(OrderChangerProductionBox):
    def __init__(
        self,               # type: NonComboFilterBox
        name,               # type: str
        sons,               # type: Union[str, List[str]]
        logger=None,        # type: Optional[Logger]
    ):
        # type: (...) -> None

        super(NonComboFilterBox, self).__init__(name=name, sons=sons, logger=logger)

    def change_order(
        self,       # type: NonComboFilterBox
        order,      # type: ProductionOrder
    ):
        # type: (...) -> ProductionOrder

        filtered_items = []
        for item in order.items:
            if item.item_type == "COMBO":
                item.items = []
                filtered_items.append(item)

        order.items = filtered_items
        return order
