Implement issue 1 search, order reuse and tracking

This commit is contained in:
reddaniel110
2026-10-14 11:25:43 +08:00
parent 0e45a58e5b
commit 4aaa6c6a14
17 changed files with 363 additions and 19 deletions
+12
View File
@@ -11,6 +11,10 @@ from security import current_user, db, login_required
TRACKING_FILTERS = {
'open': '待跟进订单',
'work_undelivered': '未交付订单(含部分交货)',
'work_invoice_due': '已交付已收票待付款',
'work_completed': '已完成订单',
'work_other': '其他待跟进 / 待核对',
'prepayment': '需预付款',
'invoice_due': '已收票待付款',
'unpaid': '未付款',
@@ -35,9 +39,17 @@ def tracking_conditions():
completed = and_(current_payment, current_fulfillment, Order.payment_status == 'paid',
Order.delivery_status == 'delivered')
closed = and_(completed, Order.invoice_status == 'received')
work_undelivered = and_(current_fulfillment, Order.delivery_status.in_(('pending', 'partial')))
work_invoice_due = and_(current_fulfillment, current_payment,
Order.delivery_status == 'delivered', Order.invoice_status == 'received',
Order.payment_status.in_(('unpaid', 'partial')))
return {
'open': ~closed,
'closed': closed,
'work_undelivered': work_undelivered,
'work_invoice_due': work_invoice_due,
'work_completed': closed,
'work_other': and_(~closed, ~work_undelivered, ~work_invoice_due),
'prepayment': and_(current_fulfillment, Order.needs_prepayment.is_(True), payment_due),
'invoice_due': and_(current_fulfillment, Order.invoice_status == 'received', payment_due),
'unpaid': and_(current_payment, Order.payment_status == 'unpaid'),