feat: 新增预算费控模型与报销审批流引擎

后端新增预算费控服务和报销单审批流模块,引入申请人费用画像
算法,优化知识库 RAG 运行时和同步逻辑,完善报销单工作流常
量和明细同步,更新差旅报销规则电子表格,前端新增预算分析
组件和数字员工模型,完善审批对话框和洞察面板交互,优化侧
边栏和顶栏样式,补充单元测试。
This commit is contained in:
caoxiaozhu
2026-05-27 17:31:27 +08:00
parent cbb98f4469
commit d4d5d40569
75 changed files with 5393 additions and 686 deletions

View File

@@ -310,6 +310,14 @@ class BudgetSupportMixin:
}
balance = self.get_balance(allocation)
reservation_source_type = self._reservation_source_type_from_claim(claim)
current_reservation = self._find_active_reservation(
source_type=reservation_source_type,
source_id=claim.id,
)
current_reserved_amount = self._money(
current_reservation.amount if current_reservation is not None else Decimal("0.00")
)
over_budget_amount = max(amount - balance.available_amount, Decimal("0.00"))
return {
"matched": True,
@@ -319,6 +327,7 @@ class BudgetSupportMixin:
"claim_amount": str(amount),
"total_amount": str(balance.total_amount),
"reserved_amount": str(balance.reserved_amount),
"current_reserved_amount": str(current_reserved_amount),
"consumed_amount": str(balance.consumed_amount),
"available_amount": str(balance.available_amount),
"usage_rate": str(balance.usage_rate),
@@ -335,6 +344,14 @@ class BudgetSupportMixin:
"project_code": allocation.project_code,
}
@staticmethod
def _reservation_source_type_from_claim(claim: ExpenseClaim) -> str:
claim_no = str(claim.claim_no or "").strip().upper()
expense_type = str(claim.expense_type or "").strip().lower()
if claim_no.startswith(("AP-", "APP-")) or expense_type == "application" or expense_type.endswith("_application"):
return "application"
return "claim"
def _find_allocation_for_claim(self, claim: ExpenseClaim) -> BudgetAllocation | None:
fiscal_year, period_key = self._period_from_claim(claim)
return self._find_allocation_for_dimension(