1
0
forked from erp-dev/erp

fix: business cancel service merged

This commit is contained in:
2026-06-11 15:33:31 +08:00
parent 65564f772a
commit 80db7867f4
18 changed files with 574 additions and 125 deletions

View File

@@ -517,13 +517,27 @@ class PrintingJob(ModelBase):
@property
def billed_quantity(self) -> Decimal:
"""
开单数量:所有关联销售明细数量之和
开单数量:所有关联的非作废销售明细数量之和
"""
from business.models import SalesOrderItem
from business.models import SalesOrderStatusEnum
total = self.sales_order_items.aggregate(total=models.Sum('quantity')).get('total')
total = self.sales_order_items.exclude(
sales_order__status=SalesOrderStatusEnum.CANCELLED,
).aggregate(total=models.Sum('quantity')).get('total')
return total or Decimal('0')
@property
def is_sales_order_bound(self) -> bool:
"""是否已被非作废销售单明细绑定。"""
from business.models import SalesOrderStatusEnum
cached = getattr(self, '_is_sales_order_bound_cache', None)
if cached is not None:
return bool(cached)
return self.sales_order_items.exclude(
sales_order__status=SalesOrderStatusEnum.CANCELLED,
).exists()
@property
def status(self) -> str:
"""