import django_filters
from ..core.types.common import DateRangeInput, IntRangeInput, PriceRangeInput
from ..utils.filters import filter_by_query_param, filter_range_field
from ..core.filters import EnumFilter, ObjectTypeFilter
from ...payment.models import Payment



def filter_created_at(qs, _, value):
    return filter_range_field(qs, "created__date", value)

class PaymentFilter(django_filters.FilterSet):
    created = ObjectTypeFilter(
        input_class=DateRangeInput, method=filter_created_at
    )

    class Meta:
        model = Payment
        fields = [
            "created",
        ]


import django_filters
from ..core.types.common import DateRangeInput, IntRangeInput, PriceRangeInput
from ..utils.filters import filter_by_query_param, filter_range_field
from ..core.filters import EnumFilter, ObjectTypeFilter
from ...payment.models import Payment



def filter_created_at(qs, _, value):
    return filter_range_field(qs, "created__date", value)

class PaymentFilter(django_filters.FilterSet):
    created = ObjectTypeFilter(
        input_class=DateRangeInput, method=filter_created_at
    )

    class Meta:
        model = Payment
        fields = [
            "created",
        ]

