@liuhange/dsh-data-asset-valuation 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { checkCapitalizationTrace, annotateCostReliability } from '../capitalizationTraceGuard.js';
|
|
3
|
+
describe('CapitalizationTraceGuard', () => {
|
|
4
|
+
const config = {
|
|
5
|
+
enabled: true,
|
|
6
|
+
policyRef: '财会〔2025〕33号',
|
|
7
|
+
rule: '不得将以评估等方式得出的金额直接作为入账和调账的依据',
|
|
8
|
+
warningMessage: '评估值仅供参考,不得直接作为入账依据',
|
|
9
|
+
};
|
|
10
|
+
it('enabled时返回警告信息', () => {
|
|
11
|
+
const result = checkCapitalizationTrace(100000, config);
|
|
12
|
+
expect(result.passed).toBe(true);
|
|
13
|
+
expect(result.warning).toBe(config.warningMessage);
|
|
14
|
+
expect(result.policyRef).toBe('财会〔2025〕33号');
|
|
15
|
+
});
|
|
16
|
+
it('disabled时跳过但不报错', () => {
|
|
17
|
+
const result = checkCapitalizationTrace(100000, { ...config, enabled: false });
|
|
18
|
+
expect(result.passed).toBe(true);
|
|
19
|
+
expect(result.warning).toBeNull();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
describe('CostReliabilityMeasurer', () => {
|
|
23
|
+
const config = {
|
|
24
|
+
enabled: true,
|
|
25
|
+
policyRef: '财会〔2023〕11号',
|
|
26
|
+
reliabilityLevels: ['high', 'medium', 'low'],
|
|
27
|
+
criteria: {
|
|
28
|
+
high: '有完整凭证链,成本可直接追溯至原始发票/合同',
|
|
29
|
+
medium: '有部分凭证,成本经合理分摊计算',
|
|
30
|
+
low: '成本为估算值,缺乏完整凭证',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
it('完整凭证→high', () => {
|
|
34
|
+
const result = annotateCostReliability(true, false, config);
|
|
35
|
+
expect(result.level).toBe('high');
|
|
36
|
+
expect(result.criteria).toContain('完整凭证');
|
|
37
|
+
});
|
|
38
|
+
it('部分凭证→medium', () => {
|
|
39
|
+
const result = annotateCostReliability(false, true, config);
|
|
40
|
+
expect(result.level).toBe('medium');
|
|
41
|
+
});
|
|
42
|
+
it('无凭证→low', () => {
|
|
43
|
+
const result = annotateCostReliability(false, false, config);
|
|
44
|
+
expect(result.level).toBe('low');
|
|
45
|
+
});
|
|
46
|
+
it('disabled时默认medium', () => {
|
|
47
|
+
const result = annotateCostReliability(true, false, { ...config, enabled: false });
|
|
48
|
+
expect(result.level).toBe('medium');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=capitalizationTraceGuard.test.js.map
|
package/lib/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { calculateIncomeBasedValue } from './incomeBasedValuation.js';
|
|
|
3
3
|
import { generateValuationReport } from './valuationReportGenerator.js';
|
|
4
4
|
import { validateValuationArgs } from './invariant.js';
|
|
5
5
|
import { checkCapitalizationTrace, annotateCostReliability } from './capitalizationTraceGuard.js';
|
|
6
|
+
import { loadJsonConfig } from '@liuhange/dsh-data-asset-shared';
|
|
6
7
|
export const name = '@liuhange/dsh-data-asset-valuation';
|
|
7
8
|
export const inject = ['tools'];
|
|
8
9
|
export function apply(ctx) {
|
|
@@ -46,10 +47,9 @@ export function apply(ctx) {
|
|
|
46
47
|
async execute(args) {
|
|
47
48
|
try {
|
|
48
49
|
const validated = validateValuationArgs(args);
|
|
49
|
-
const { readFileSync } = await import('node:fs');
|
|
50
50
|
let rulesConfig;
|
|
51
51
|
try {
|
|
52
|
-
rulesConfig =
|
|
52
|
+
rulesConfig = loadJsonConfig('BUSINESS_RULES_PATH', 'config/business-rules.json', '@liuhange/dsh-data-asset-shared/config/business-rules.json');
|
|
53
53
|
}
|
|
54
54
|
catch {
|
|
55
55
|
return JSON.stringify({ error: 'VALUATION_RULES_MISSING', message: '无法加载business-rules.json' });
|
|
@@ -60,8 +60,9 @@ export function apply(ctx) {
|
|
|
60
60
|
}
|
|
61
61
|
let policyDocuments;
|
|
62
62
|
try {
|
|
63
|
-
const policyConfig =
|
|
64
|
-
const
|
|
63
|
+
const policyConfig = loadJsonConfig('POLICY_REFS_PATH', 'config/policy-references.json', '@liuhange/dsh-data-asset-shared/config/policy-references.json');
|
|
64
|
+
const refs = policyConfig.policyReferences;
|
|
65
|
+
const stage = refs?.find(s => s.stage === 'VALUATION');
|
|
65
66
|
policyDocuments = stage?.documents ?? [];
|
|
66
67
|
}
|
|
67
68
|
catch {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liuhange/dsh-data-asset-valuation",
|
|
3
3
|
"description": "Data asset valuation plugin: cost-based (replacement cost - depreciation) + income-based (DCF) dual model",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|