mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 20:45:44 +00:00
[React] Order tables (#5860)
* Factor out custom component for displaying project code information in a table * Bump API version * Update order serializers - Annotate 'completed_lines' to each order type * Build out columns for ReturnOrderTable * Improvements to PurchaseOrderTable * Building out SalesOrderTable * Column tweaks * Factor out project code column * Factor out status column * Factor out description column * Factor out more columns * More refactoring * Center status labels * Fix for PurchaseOrderLineItemTable * Improve rendering * Remove unused imports * Refactor TotalPriceColumn * Add generic currency column for rendering currency / money values
This commit is contained in:
@ -2,11 +2,15 @@
|
||||
|
||||
|
||||
# InvenTree API version
|
||||
INVENTREE_API_VERSION = 145
|
||||
INVENTREE_API_VERSION = 147
|
||||
|
||||
"""
|
||||
Increment this API version number whenever there is a significant change to the API that any clients need to know about
|
||||
|
||||
v147 -> 2023-11-04: https://github.com/inventree/InvenTree/pull/5860
|
||||
- Adds "completed_lines" field to SalesOrder API endpoint
|
||||
- Adds "completed_lines" field to PurchaseOrder API endpoint
|
||||
|
||||
v146 -> 2023-11-02: https://github.com/inventree/InvenTree/pull/5822
|
||||
- Extended SSO Provider endpoint to contain if a provider is configured
|
||||
- Adds API endpoints for Email Address model
|
||||
|
@ -29,8 +29,8 @@ from InvenTree.serializers import (InvenTreeAttachmentSerializer,
|
||||
InvenTreeModelSerializer,
|
||||
InvenTreeMoneySerializer)
|
||||
from InvenTree.status_codes import (PurchaseOrderStatusGroups,
|
||||
ReturnOrderStatus, SalesOrderStatusGroups,
|
||||
StockStatus)
|
||||
ReturnOrderLineStatus, ReturnOrderStatus,
|
||||
SalesOrderStatusGroups, StockStatus)
|
||||
from part.serializers import PartBriefSerializer
|
||||
from users.serializers import OwnerSerializer
|
||||
|
||||
@ -58,6 +58,9 @@ class AbstractOrderSerializer(serializers.Serializer):
|
||||
# Number of line items in this order
|
||||
line_items = serializers.IntegerField(read_only=True)
|
||||
|
||||
# Number of completed line items (this is an annotated field)
|
||||
completed_lines = serializers.IntegerField(read_only=True)
|
||||
|
||||
# Human-readable status text (read-only)
|
||||
status_text = serializers.CharField(source='get_status_display', read_only=True)
|
||||
|
||||
@ -107,6 +110,7 @@ class AbstractOrderSerializer(serializers.Serializer):
|
||||
'target_date',
|
||||
'description',
|
||||
'line_items',
|
||||
'completed_lines',
|
||||
'link',
|
||||
'project_code',
|
||||
'project_code_detail',
|
||||
@ -211,6 +215,10 @@ class PurchaseOrderSerializer(TotalPriceMixin, AbstractOrderSerializer, InvenTre
|
||||
"""
|
||||
queryset = AbstractOrderSerializer.annotate_queryset(queryset)
|
||||
|
||||
queryset = queryset.annotate(
|
||||
completed_lines=SubqueryCount('lines', filter=Q(quantity__lte=F('received')))
|
||||
)
|
||||
|
||||
queryset = queryset.annotate(
|
||||
overdue=Case(
|
||||
When(
|
||||
@ -743,10 +751,15 @@ class SalesOrderSerializer(TotalPriceMixin, AbstractOrderSerializer, InvenTreeMo
|
||||
"""Add extra information to the queryset.
|
||||
|
||||
- Number of line items in the SalesOrder
|
||||
- Number of completed line items in the SalesOrder
|
||||
- Overdue status of the SalesOrder
|
||||
"""
|
||||
queryset = AbstractOrderSerializer.annotate_queryset(queryset)
|
||||
|
||||
queryset = queryset.annotate(
|
||||
completed_lines=SubqueryCount('lines', filter=Q(quantity__lte=F('shipped')))
|
||||
)
|
||||
|
||||
queryset = queryset.annotate(
|
||||
overdue=Case(
|
||||
When(
|
||||
@ -1503,6 +1516,10 @@ class ReturnOrderSerializer(AbstractOrderSerializer, TotalPriceMixin, InvenTreeM
|
||||
"""Custom annotation for the serializer queryset"""
|
||||
queryset = AbstractOrderSerializer.annotate_queryset(queryset)
|
||||
|
||||
queryset = queryset.annotate(
|
||||
completed_lines=SubqueryCount('lines', filter=~Q(outcome=ReturnOrderLineStatus.PENDING.value))
|
||||
)
|
||||
|
||||
queryset = queryset.annotate(
|
||||
overdue=Case(
|
||||
When(
|
||||
|
Reference in New Issue
Block a user