79 lines
3.0 KiB
Markdown
79 lines
3.0 KiB
Markdown
# Financial Management Module
|
||
|
||
## Overview
|
||
This module provides comprehensive financial management capabilities with order-level granularity for receivables and payments. It integrates seamlessly with the existing contract management and order management modules.
|
||
|
||
## Features Implemented
|
||
|
||
### 2.4.1 收支管理
|
||
|
||
#### 应收款管理(订单维度优化)
|
||
- **自动立应收**: 按订单生成应收计划,每个订单对应独立应收记录
|
||
- **账期监控**: 按订单维度跟踪账期,超期30天自动推送通知,合同详情页汇总展示应收状态
|
||
|
||
#### 收款管理(新增订单关联)
|
||
- **收款录入**: 财务录入收款时关联订单,系统校验收款金额≤订单应收金额
|
||
- **收款分配**: 支持同一笔收款覆盖多个订单的批量关联和手动分配比例
|
||
- **凭证生成**: 收款凭证同时显示合同编号与订单编号,便于财务对账
|
||
|
||
#### 订单与合同的财务数据联动
|
||
- **合同层面**: 自动汇总所有关联订单的总应收/已收款/剩余应收金额,展示合同收款完成率
|
||
- **订单层面**: 完成收款后自动更新订单状态,并同步触发合同履约进度
|
||
|
||
#### 支出管理
|
||
- **支出关联**: 提交支出需关联已核销(确认收款的审批)对应合同的已收款
|
||
|
||
## Database Schema
|
||
|
||
### Core Tables
|
||
- `receivables`: 应收记录表(按订单维度)
|
||
- `receipts`: 收款记录表
|
||
- `receipt_allocations`: 收款分配表(处理多订单分配)
|
||
- `payments`: 支出记录表
|
||
- `financial_vouchers`: 财务凭证表
|
||
|
||
### Key Relationships
|
||
- 应收记录关联订单和合同
|
||
- 收款记录通过分配表关联多个订单
|
||
- 财务凭证关联合同和订单
|
||
- 支出记录关联已核销收款的合同
|
||
|
||
## Integration Points
|
||
|
||
### Contract Management Module
|
||
- 自动从订单生成应收记录
|
||
- 收款完成后触发合同履约进度更新
|
||
- 合同财务数据汇总展示
|
||
|
||
### Order Management Module
|
||
- 订单状态自动更新为"已收款"
|
||
- 订单财务数据实时同步
|
||
|
||
### RBAC Module
|
||
- 多租户数据隔离(org_id)
|
||
- 用户权限控制
|
||
|
||
## Usage
|
||
|
||
### Initialization
|
||
```python
|
||
from financial_management import load_financial_management
|
||
load_financial_management()
|
||
```
|
||
|
||
### Key Functions
|
||
- `create_receivable_from_order(order_id, org_id)`: 从订单创建应收记录
|
||
- `create_receipt(receipt_data, user_id, org_id)`: 创建收款记录
|
||
- `get_contract_financial_summary(contract_id, org_id)`: 获取合同财务汇总
|
||
- `send_overdue_notifications(org_id, days_overdue=30)`: 发送逾期通知
|
||
- `create_payment(payment_data, user_id, org_id)`: 创建支出记录
|
||
|
||
## Scheduled Tasks
|
||
- **Daily Overdue Notification**: 每天上午10点检查逾期应收记录并发送通知
|
||
|
||
## Development Standards
|
||
- Follows module-development-spec directory structure
|
||
- Uses sqlor-database-module for database operations
|
||
- Implements bricks-framework for frontend interfaces
|
||
- Adheres to database-table-definition-spec and crud-definition-spec
|
||
- Production-ready code with complete error handling and validation |