from django_filters import rest_framework as filters
from apps.pum.models import PuPlanItem, PuPlan, PuOrder


class PuPlanFilter(filters.FilterSet):
    class Meta:
        model = PuPlan
        fields = {
            "state": ["exact", "in"]
        }


class PuPlanItemFilter(filters.FilterSet):
    class Meta:
        model = PuPlanItem
        fields = {
            "material": ["exact"],
            "pu_plan": ["exact"],
            "pu_plan__state": ["exact", "in"],
            "pu_order": ["exact", 'isnull'],
            "pu_order__state": ["exact", "in"]
        }


class PuOrderFilter(filters.FilterSet):
    class Meta:
        model = PuOrder
        fields = {
            "supplier": ["exact"],
            "delivery_date": ["exact", "gte", "lte"],
            "state": ["exact", "in"],
        }
