fix: 盘点

This commit is contained in:
Czw996 2021-12-28 22:38:47 +08:00
parent 821666332f
commit ef03991550
5 changed files with 42 additions and 6 deletions

View file

@ -288,6 +288,8 @@ class ChargeOrderViewSet(BaseViewSet, ListModelMixin, RetrieveModelMixin, Create
"""作废"""
charge_order = self.get_object()
charge_order.is_void = True
charge_order.save(update_fields=['is_void'])
account = charge_order.account
amount_before = account.balance_amount
@ -396,6 +398,8 @@ class AccountTransferRecordViewSet(BaseViewSet, ListModelMixin, RetrieveModelMix
"""作废"""
account_transfer_record = self.get_object()
account_transfer_record.is_void = True
account_transfer_record.save(update_fields=['is_void'])
out_account = account_transfer_record.out_account
transfer_out_amount = account_transfer_record.transfer_amount

View file

@ -5,6 +5,10 @@ class InventoryWarningPermission(ModelPermission):
code = 'inventory_warning'
class ShelfLifeWarningPermission(ModelPermission):
code = 'shelf_life_warning'
class StockInReminderPermission(ModelPermission):
code = 'stock_in_reminder'
@ -14,6 +18,6 @@ class StockOutReminderPermission(ModelPermission):
__all__ = [
'InventoryWarningPermission',
'InventoryWarningPermission', 'ShelfLifeWarningPermission',
'StockInReminderPermission', 'StockOutReminderPermission',
]

View file

@ -21,10 +21,12 @@ class InventoryWarningViewSet(BaseViewSet, ListModelMixin):
permission_classes = [IsAuthenticated, InventoryWarningPermission]
queryset = Inventory.objects.all()
def get_queryset(self):
return super().get_queryset().filter(goods__enable_inventory_warning=True, goods__is_active=True)
@extend_schema(responses={200: InventoryWarningResponse})
def list(self, request, *args, **kwargs):
queryset = self.get_queryset()
queryset = queryset.filter(goods__enable_inventory_warning=True, goods__is_active=True)
queryset = queryset.select_related('goods', 'goods__unit')
queryset = queryset.values('goods').annotate(
goods_number=F('goods__number'), goods_name=F('goods__name'),
@ -43,6 +45,17 @@ class InventoryWarningViewSet(BaseViewSet, ListModelMixin):
return self.get_paginated_response(queryset)
class ShelfLifeWarningViewSet(BaseViewSet, ListModelMixin):
"""保质期预警"""
permission_classes = [IsAuthenticated, ShelfLifeWarningPermission]
queryset = Batch.objects.all()
def get_queryset(self):
return super().get_queryset().filter(goods__enable_batch_control=True, goods__is_active=True,
goods__shelf_life_days__isnull=False, has_stock=True)
class SalesTaskReminderViewSet(BaseViewSet, ListModelMixin):
"""销售任务提醒"""

View file

@ -22,6 +22,9 @@ class PurchaseReportViewSet(BaseViewSet):
search_fields = ['goods__number', 'goods__name']
queryset = PurchaseGoods.objects.all()
def get_queryset(self):
return super().get_queryset().filter(purchase__order__is_void=False)
@extend_schema(parameters=[PurchaseReportParameter],
responses={200: PurchaseReportStatisticResponse})
@action(detail=False, methods=['get'])
@ -82,6 +85,9 @@ class SalesReportViewSet(BaseViewSet):
search_fields = ['goods__number', 'goods__name']
queryset = SalesGoods.objects.all()
def get_queryset(self):
return super().get_queryset().filter(sales__order__is_void=False)
@extend_schema(parameters=[SalesReportParameter],
responses={200: SalesReportStatisticResponse})
@action(detail=False, methods=['get'])
@ -142,6 +148,9 @@ class SalesHotGoodsViewSet(BaseViewSet, ListModelMixin):
filterset_class = SalesHotGoodsFilter
queryset = SalesGoods.objects.all()
def get_queryset(self):
return super().get_queryset().filter(sales__order__is_void=False)
@extend_schema(parameters=[SalesHotGoodsParameter], responses={200: SalesHotGoodsResponse})
def list(self, request, *args, **kwargs):
queryset = self.filter_queryset(self.get_queryset())
@ -164,6 +173,9 @@ class SalesTrendViewSet(BaseViewSet, ListModelMixin):
filterset_class = SalesTrendFilter
queryset = SalesOrder.objects.all()
def get_queryset(self):
return super().get_queryset().filter(is_void=False)
@extend_schema(parameters=[SalesTrendParameter], responses={200: SalesTrendResponse})
def list(self, request, *args, **kwargs):
queryset = self.filter_queryset(self.get_queryset())
@ -185,6 +197,9 @@ class ProfitTrendViewSet(BaseViewSet, ListModelMixin):
filterset_class = ProfitTrendFilter
queryset = SalesGoods.objects.all()
def get_queryset(self):
return super().get_queryset().filter(sales__order__is_void=False)
@extend_schema(parameters=[ProfitTrendParameter], responses={200: ProfitTrendResponse})
def list(self, request, *args, **kwargs):
queryset = self.filter_queryset(self.get_queryset())
@ -206,11 +221,12 @@ class FinanceStatisticViewSet(FunctionViewSet):
"""收支统计"""
def list(self, request, *args, **kwargs):
PaymentOrder.objects.filter().values('number', 'create_time', 'total_amount', suppliser_)
PaymentOrder.objects.filter().values('number', 'create_time', 'total_amount',
suppliser_number=F('suppier__number'),
supplier_name=F('supplier__name'))
return Response()
__all__ = [
'PurchaseReportViewSet', 'SalesReportViewSet',

View file

@ -24,8 +24,7 @@ class StockCheckOrderViewSet(BaseViewSet, ListModelMixin, RetrieveModelMixin, Cr
select_related_fields = ['warehouse', 'handler', 'creator']
prefetch_related_fields = ['stock_check_goods_set', 'stock_check_goods_set__goods',
'stock_check_goods_set__goods__unit',
'stock_check_goods_set__stock_check_batchs',
'stock_check_goods_set__stock_check_batchs__batch']
'stock_check_goods_set__stock_check_batchs']
queryset = StockCheckOrder.objects.all()
@transaction.atomic