from typing import List

from mw_helper import ensure_iterable

from production.model import ProductionOrder
from ._OrderCondition import OrderCondition


class SaleTypeCondition(OrderCondition):
    def __init__(self, sale_types):
        # type: (List[str]) -> None

        self.valid_sale_types = ensure_iterable(sale_types)
        self.valid_sale_types = [x.lower() for x in self.valid_sale_types]

    def evaluate(self, order):
        # type: (ProductionOrder) -> bool

        return order.sale_type.lower() in self.valid_sale_types
