本设计扩展仪表盘和导出报表功能,在现有界面和报表中增加结算状态的显示。主要涉及:
┌─────────────────────────────────────────────────────────────┐
│ Frontend (React) │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Dashboard.jsx │ │
│ │ - 月度报告: 已结算/未结算收入统计卡片 │ │
│ │ - 人员按供应商明细: 结算状态列 + 未结算行高亮 │ │
│ │ - 年度汇总: 已结算/未结算收入列 (移至底部) │ │
│ └─────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Backend (Flask) │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ work_record_service.py │ │
│ │ - get_monthly_summary(): 增加结算统计字段 │ │
│ │ - get_yearly_summary(): 增加结算统计字段 │ │
│ └─────────────────────────────────────────────────────┘ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ export_service.py │ │
│ │ - 月度报表: 明细+汇总增加结算状态列 │ │
│ │ - 年度报表: 明细+汇总增加结算状态列 │ │
│ └─────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
GET /api/work-records/monthly-summary
扩展返回字段:
{
"year": 2024,
"month": 12,
"total_records": 100,
"total_earnings": 5000.00,
"settled_earnings": 3000.00, # 新增
"unsettled_earnings": 2000.00, # 新增
"top_performers": [...],
"item_breakdown": [...],
"supplier_breakdown": [
{
"person_id": 1,
"person_name": "张三",
"supplier_name": "供应商A",
"earnings": 1000.00,
"is_settled": true # 新增
}
]
}
GET /api/work-records/yearly-summary
扩展返回字段:
{
"year": 2024,
"persons": [
{
"person_id": 1,
"person_name": "张三",
"monthly_earnings": [100, 200, ...],
"yearly_total": 1500.00,
"settled_total": 1000.00, # 新增
"unsettled_total": 500.00 # 新增
}
],
"monthly_totals": [...],
"grand_total": 10000.00,
"settled_grand_total": 7000.00, # 新增
"unsettled_grand_total": 3000.00 # 新增
}
月度报告统计卡片区域
人员按供应商收入明细表格
年度汇总表格
明细表 (Detail Sheet)
月度汇总表 (Monthly Summary Sheet)
明细表 (Detail Sheet)
年度汇总表 (Yearly Summary Sheet)
无需修改数据模型。work_records 表已有 is_settled 字段:
class WorkRecord(db.Model):
# ... existing fields ...
is_settled = db.Column(db.Boolean, nullable=False, default=False)
A property is a characteristic or behavior that should hold true across all valid executions of a system-essentially, a formal statement about what the system should do. Properties serve as the bridge between human-readable specifications and machine-verifiable correctness guarantees.
For any set of work records in a given month, the sum of settled_earnings and unsettled_earnings returned by the monthly summary API SHALL equal total_earnings.
Validates: Requirements 1.3
For any person in the yearly summary, settled_total + unsettled_total SHALL equal yearly_total.
Validates: Requirements 3.2
For any yearly summary response, settled_grand_total + unsettled_grand_total SHALL equal grand_total.
Validates: Requirements 3.2, 3.3
For any work record exported to Excel, the settlement status column SHALL display "已结算" when is_settled is true and "未结算" when is_settled is false.
Validates: Requirements 5.3, 6.3
API Error Handling
Frontend Error Handling
Backend Service Tests
get_monthly_summary() 返回正确的结算统计get_yearly_summary() 返回正确的结算统计Frontend Component Tests
使用 Hypothesis 库进行属性测试:
Settlement Sum Property Test
Export Accuracy Property Test