2021-11-04 23:49:56 +08:00
|
|
|
from django_filters.rest_framework import FilterSet
|
|
|
|
from django_filters.filters import *
|
2021-12-26 23:00:08 +08:00
|
|
|
from apps.purchase.models import *
|
2021-12-26 23:24:52 +08:00
|
|
|
from apps.sales.models import *
|
2021-11-04 23:49:56 +08:00
|
|
|
|
|
|
|
|
2021-12-26 23:00:08 +08:00
|
|
|
class PurchaseReportFilter(FilterSet):
|
2021-12-26 23:24:52 +08:00
|
|
|
category = NumberFilter(field_name='goods__category', label='商品分类')
|
|
|
|
creator = NumberFilter(field_name='sales_order__creator', label='创建人')
|
2021-12-26 23:00:08 +08:00
|
|
|
start_date = DateFilter(field_name='purchase_order__create_time', required=True, lookup_expr='gte', label='开始日期')
|
|
|
|
end_date = DateFilter(field_name='purchase_order__create_time', required=True, lookup_expr='lt', label='结束日期')
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = PurchaseGoods
|
2021-12-26 23:24:52 +08:00
|
|
|
fields = ['category', 'creator', 'start_date', 'end_date']
|
|
|
|
|
|
|
|
|
|
|
|
class SalesReportFilter(FilterSet):
|
|
|
|
category = NumberFilter(field_name='goods__category', label='商品分类')
|
|
|
|
creator = NumberFilter(field_name='sales_order__creator', label='创建人')
|
|
|
|
start_date = DateFilter(field_name='sales_order__create_time', required=True, lookup_expr='gte', label='开始日期')
|
|
|
|
end_date = DateFilter(field_name='sales_order__create_time', required=True, lookup_expr='lt', label='结束日期')
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = SalesGoods
|
|
|
|
fields = ['category', 'creator', 'start_date', 'end_date']
|
2021-11-04 23:49:56 +08:00
|
|
|
|
2021-12-26 23:00:08 +08:00
|
|
|
|
2021-12-28 00:26:32 +08:00
|
|
|
class SalesHotGoodsFilter(FilterSet):
|
|
|
|
start_date = DateFilter(field_name='sales_order__create_time', required=True, lookup_expr='gte', label='开始日期')
|
|
|
|
end_date = DateFilter(field_name='sales_order__create_time', required=True, lookup_expr='lt', label='结束日期')
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = SalesGoods
|
|
|
|
fields = ['start_date', 'end_date']
|
|
|
|
|
|
|
|
|
|
|
|
class SalesTrendFilter(FilterSet):
|
|
|
|
start_date = DateFilter(field_name='create_time', required=True, lookup_expr='gte', label='开始日期')
|
|
|
|
end_date = DateFilter(field_name='create_time', required=True, lookup_expr='lt', label='结束日期')
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = SalesOrder
|
|
|
|
fields = ['start_date', 'end_date']
|
|
|
|
|
|
|
|
|
2021-12-28 01:25:57 +08:00
|
|
|
class ProfitTrendFilter(FilterSet):
|
|
|
|
start_date = DateFilter(field_name='sales_order__create_time', required=True, lookup_expr='gte', label='开始日期')
|
|
|
|
end_date = DateFilter(field_name='sales_order__create_time', required=True, lookup_expr='lt', label='结束日期')
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = SalesGoods
|
|
|
|
fields = ['start_date', 'end_date']
|
|
|
|
|
|
|
|
|
2021-12-26 23:00:08 +08:00
|
|
|
__all__ = [
|
2021-12-26 23:24:52 +08:00
|
|
|
'PurchaseReportFilter', 'SalesReportFilter',
|
2021-12-28 01:25:57 +08:00
|
|
|
'SalesHotGoodsFilter', 'SalesTrendFilter', 'ProfitTrendFilter',
|
2021-11-04 23:49:56 +08:00
|
|
|
]
|