feat: 新增预算中心本体与风险规则评分回填
后端新增预算本体解析模块和风险规则评分回填服务,优化规则 生成本体对齐和提示词构建,增强费用类型关键词和本体验证, 完善报销查询和审计接口,前端预算中心页面增加对话框和本 体工具函数,重构审计页面元数据和视图模型,补充单元测试。
This commit is contained in:
91
web/tests/budget-ontology.test.mjs
Normal file
91
web/tests/budget-ontology.test.mjs
Normal file
@@ -0,0 +1,91 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import {
|
||||
BUDGET_EXPENSE_TYPE_OPTIONS,
|
||||
BUDGET_ONTOLOGY_FIELDS,
|
||||
BUDGET_QUARTER_OPTIONS,
|
||||
BUDGET_YEAR_OPTIONS,
|
||||
buildBudgetOntologyContext
|
||||
} from '../src/utils/budgetOntology.js'
|
||||
|
||||
test('budget ontology fields expose required budget center keys', () => {
|
||||
const requiredKeys = BUDGET_ONTOLOGY_FIELDS
|
||||
.filter((field) => field.required)
|
||||
.map((field) => field.key)
|
||||
|
||||
assert.deepEqual(requiredKeys, [
|
||||
'budget_period',
|
||||
'department',
|
||||
'cost_center',
|
||||
'budget_owner',
|
||||
'budget_version',
|
||||
'budget_status',
|
||||
'budget_subject',
|
||||
'budget_amount',
|
||||
'warning_threshold',
|
||||
'control_action'
|
||||
])
|
||||
})
|
||||
|
||||
test('budget ontology context maps dialog fields to ontology payload', () => {
|
||||
const context = buildBudgetOntologyContext({
|
||||
form: {
|
||||
budgetYear: '2026',
|
||||
budgetQuarter: 'Q2',
|
||||
departmentCode: 'MARKET-DEPT',
|
||||
budgetOwner: '张晓明',
|
||||
budgetVersion: 'V1.0(初始版本)',
|
||||
budgetStatus: '编制中',
|
||||
budgetDescription: '市场部预算编制'
|
||||
},
|
||||
departments: [
|
||||
{ code: 'MARKET-DEPT', name: '市场部', costCenter: 'CC-4100' }
|
||||
],
|
||||
rows: [
|
||||
{
|
||||
budgetSubject: '差旅费',
|
||||
budgetSubjectCode: 'travel',
|
||||
budgetAmount: '600,000.00',
|
||||
warningThreshold: '80%',
|
||||
controlAction: '提醒',
|
||||
budgetRemark: '差旅相关费用'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
assert.equal(context.document_type, 'budget_plan')
|
||||
assert.equal(context.conversation_scenario, 'budget')
|
||||
assert.equal(context.budget_header.budget_period, '2026年Q2')
|
||||
assert.equal(context.budget_header.budget_year, '2026')
|
||||
assert.equal(context.budget_header.budget_quarter, 'Q2')
|
||||
assert.equal(context.budget_header.department, '市场部')
|
||||
assert.equal(context.budget_header.cost_center, 'CC-4100')
|
||||
assert.equal(context.budget_details[0].budget_subject_code, 'travel')
|
||||
assert.equal(context.budget_details[0].expense_type, 'travel')
|
||||
assert.equal(context.budget_details[0].expense_type_label, '差旅费')
|
||||
assert.equal(context.budget_details[0].warning_threshold, '80%')
|
||||
})
|
||||
|
||||
test('budget expense type options expose real expense type codes', () => {
|
||||
const optionCodes = BUDGET_EXPENSE_TYPE_OPTIONS.map((item) => item.value)
|
||||
|
||||
assert.deepEqual(optionCodes, [
|
||||
'travel',
|
||||
'hotel',
|
||||
'transport',
|
||||
'meal',
|
||||
'meeting',
|
||||
'marketing',
|
||||
'office',
|
||||
'training',
|
||||
'software',
|
||||
'communication',
|
||||
'welfare'
|
||||
])
|
||||
})
|
||||
|
||||
test('budget center exposes separate year and quarter dimensions', () => {
|
||||
assert.deepEqual(BUDGET_YEAR_OPTIONS, ['2026', '2027', '2028'])
|
||||
assert.deepEqual(BUDGET_QUARTER_OPTIONS, ['Q1', 'Q2', 'Q3', 'Q4'])
|
||||
})
|
||||
Reference in New Issue
Block a user