forked from erp-dev/erp
feat: red flush and cost
This commit is contained in:
@@ -54,12 +54,14 @@ class PurchaseOrderSerializer(serializers.ModelSerializer):
|
||||
'total_amount', 'diff_quantity', 'total_quantity',
|
||||
'operator', 'operator_name', 'warehouse', 'warehouse_name',
|
||||
'status', 'is_red_flushed', 'red_flush_id', 'red_flushed_at',
|
||||
'balance_before_snapshot',
|
||||
'remarks', 'created_at', 'updated_at', 'items', 'quantity_of_rolls',
|
||||
]
|
||||
read_only_fields = [
|
||||
'id', 'created_at', 'updated_at', 'items', 'supplier_name',
|
||||
'operator_name', 'warehouse_name', 'is_red_flushed',
|
||||
'red_flush_id', 'red_flushed_at',
|
||||
'balance_before_snapshot',
|
||||
]
|
||||
|
||||
|
||||
@@ -142,6 +144,7 @@ class PurchaseOrderView(StockChangeViewMixin, views.APIView):
|
||||
'id': purchase_order.id,
|
||||
'human_id': purchase_order.human_id,
|
||||
'status': purchase_order.status,
|
||||
'balance_before_snapshot': purchase_order.balance_before_snapshot,
|
||||
'message': '采购单创建成功,等待审批',
|
||||
},
|
||||
status=status.HTTP_201_CREATED,
|
||||
|
||||
@@ -58,12 +58,14 @@ class PurchaseReturnOrderSerializer(serializers.ModelSerializer):
|
||||
'total_amount', 'diff_quantity', 'total_quantity',
|
||||
'operator', 'operator_name', 'warehouse', 'warehouse_name',
|
||||
'status', 'is_red_flushed', 'red_flush_id', 'red_flushed_at',
|
||||
'balance_before_snapshot',
|
||||
'remarks', 'created_at', 'updated_at', 'items', 'quantity_of_rolls',
|
||||
]
|
||||
read_only_fields = [
|
||||
'id', 'created_at', 'updated_at', 'items',
|
||||
'supplier_name', 'operator_name', 'warehouse_name',
|
||||
'is_red_flushed', 'red_flush_id', 'red_flushed_at',
|
||||
'balance_before_snapshot',
|
||||
]
|
||||
|
||||
|
||||
@@ -144,6 +146,7 @@ class PurchaseReturnOrderView(StockChangeViewMixin, views.APIView):
|
||||
'id': purchase_return.id,
|
||||
'human_id': purchase_return.human_id,
|
||||
'status': purchase_return.status,
|
||||
'balance_before_snapshot': purchase_return.balance_before_snapshot,
|
||||
'message': '采购退货单创建成功,等待审批',
|
||||
},
|
||||
status=status.HTTP_201_CREATED,
|
||||
|
||||
@@ -55,12 +55,14 @@ class SalesOrderSerializer(serializers.ModelSerializer):
|
||||
'total_amount', 'diff_quantity', 'total_quantity',
|
||||
'operator', 'operator_name', 'warehouse', 'warehouse_name',
|
||||
'status', 'is_red_flushed', 'red_flush_id', 'red_flushed_at',
|
||||
'balance_before_snapshot',
|
||||
'remarks', 'created_at', 'updated_at', 'items', 'quantity_of_rolls',
|
||||
]
|
||||
read_only_fields = [
|
||||
'id', 'created_at', 'updated_at', 'items', 'customer_name',
|
||||
'operator_name', 'warehouse_name', 'is_red_flushed',
|
||||
'red_flush_id', 'red_flushed_at',
|
||||
'balance_before_snapshot',
|
||||
]
|
||||
|
||||
|
||||
@@ -83,6 +85,29 @@ class SalesOrderView(StockChangeViewMixin, views.APIView):
|
||||
queryset = business_models.SalesOrder.objects.filter(merchant=merchant).prefetch_related(
|
||||
'items', 'customer', 'operator', 'warehouse'
|
||||
)
|
||||
|
||||
# Query 参数过滤
|
||||
qp = request.query_params
|
||||
customer_id = qp.get('customer')
|
||||
warehouse_id = qp.get('warehouse')
|
||||
status_value = qp.get('status')
|
||||
kind = qp.get('kind')
|
||||
|
||||
if customer_id:
|
||||
try:
|
||||
queryset = queryset.filter(customer_id=int(customer_id))
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
if warehouse_id:
|
||||
try:
|
||||
queryset = queryset.filter(warehouse_id=int(warehouse_id))
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
if status_value:
|
||||
queryset = queryset.filter(status=status_value)
|
||||
if kind:
|
||||
queryset = queryset.filter(kind=kind)
|
||||
|
||||
paginator = self.pagination_class()
|
||||
page = paginator.paginate_queryset(queryset.order_by('-created_at'), request, view=self)
|
||||
serializer = SalesOrderSerializer(page, many=True)
|
||||
@@ -145,6 +170,7 @@ class SalesOrderView(StockChangeViewMixin, views.APIView):
|
||||
'id': sales_order.id,
|
||||
'human_id': sales_order.human_id,
|
||||
'status': sales_order.status,
|
||||
'balance_before_snapshot': sales_order.balance_before_snapshot,
|
||||
'message': '销售单创建成功,等待审批',
|
||||
},
|
||||
status=status.HTTP_201_CREATED,
|
||||
|
||||
@@ -57,12 +57,14 @@ class SalesReturnOrderSerializer(serializers.ModelSerializer):
|
||||
'total_amount', 'diff_quantity', 'total_quantity', 'quantity_of_rolls',
|
||||
'operator', 'operator_name', 'warehouse', 'warehouse_name',
|
||||
'status', 'is_red_flushed', 'red_flush_id', 'red_flushed_at',
|
||||
'balance_before_snapshot',
|
||||
'remarks', 'created_at', 'updated_at', 'items',
|
||||
]
|
||||
read_only_fields = [
|
||||
'id', 'created_at', 'updated_at', 'items',
|
||||
'customer_name', 'operator_name', 'warehouse_name',
|
||||
'is_red_flushed', 'red_flush_id', 'red_flushed_at',
|
||||
'balance_before_snapshot',
|
||||
]
|
||||
|
||||
|
||||
@@ -143,6 +145,7 @@ class SalesReturnOrderView(StockChangeViewMixin, views.APIView):
|
||||
'id': sales_return.id,
|
||||
'human_id': sales_return.human_id,
|
||||
'status': sales_return.status,
|
||||
'balance_before_snapshot': sales_return.balance_before_snapshot,
|
||||
'message': '销售退货单创建成功,等待审批',
|
||||
},
|
||||
status=status.HTTP_201_CREATED,
|
||||
|
||||
Reference in New Issue
Block a user