@chenchaolong/plugin-trade-compliance-workbench 1.0.3 → 1.0.4
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.
- package/README.md +5 -3
- package/dist/lib/demo-data.service.d.ts.map +1 -1
- package/dist/lib/demo-data.service.js +1 -3
- package/dist/lib/demo-data.service.js.map +1 -1
- package/dist/lib/entities/index.d.ts +2 -2
- package/dist/lib/entities/index.d.ts.map +1 -1
- package/dist/lib/entities/index.js +2 -2
- package/dist/lib/entities/index.js.map +1 -1
- package/dist/lib/entities/shared.entity.d.ts +1 -5
- package/dist/lib/entities/shared.entity.d.ts.map +1 -1
- package/dist/lib/entities/shared.entity.js +1 -16
- package/dist/lib/entities/shared.entity.js.map +1 -1
- package/dist/lib/legacy-schema-cleanup.d.ts +9 -0
- package/dist/lib/legacy-schema-cleanup.d.ts.map +1 -0
- package/dist/lib/legacy-schema-cleanup.js +28 -0
- package/dist/lib/legacy-schema-cleanup.js.map +1 -0
- package/dist/lib/remote-components/trade-compliance-workbench/app.css +3268 -1
- package/dist/lib/remote-components/trade-compliance-workbench/app.js +5 -5
- package/dist/lib/remote-ui/app-source.d.ts.map +1 -1
- package/dist/lib/remote-ui/app-source.js +7 -6
- package/dist/lib/remote-ui/app-source.js.map +1 -1
- package/dist/lib/remote-ui/bridge.d.ts +6 -1
- package/dist/lib/remote-ui/bridge.d.ts.map +1 -1
- package/dist/lib/remote-ui/bridge.js +60 -10
- package/dist/lib/remote-ui/bridge.js.map +1 -1
- package/dist/lib/remote-ui/components/data-grid.js +1 -1
- package/dist/lib/remote-ui/components/data-grid.js.map +1 -1
- package/dist/lib/remote-ui/components/forms.js +2 -2
- package/dist/lib/remote-ui/components/forms.js.map +1 -1
- package/dist/lib/remote-ui/components/layout.d.ts +5 -1
- package/dist/lib/remote-ui/components/layout.d.ts.map +1 -1
- package/dist/lib/remote-ui/components/layout.js +23 -3
- package/dist/lib/remote-ui/components/layout.js.map +1 -1
- package/dist/lib/remote-ui/model.d.ts.map +1 -1
- package/dist/lib/remote-ui/model.js +11 -11
- package/dist/lib/remote-ui/model.js.map +1 -1
- package/dist/lib/remote-ui/pages/analytics.js +1 -1
- package/dist/lib/remote-ui/pages/analytics.js.map +1 -1
- package/dist/lib/remote-ui/pages/catalogs.js +14 -14
- package/dist/lib/remote-ui/pages/catalogs.js.map +1 -1
- package/dist/lib/remote-ui/pages/contracts.js +3 -3
- package/dist/lib/remote-ui/pages/contracts.js.map +1 -1
- package/dist/lib/remote-ui/pages/files.js +5 -5
- package/dist/lib/remote-ui/pages/files.js.map +1 -1
- package/dist/lib/remote-ui/pages/home.d.ts +18 -62
- package/dist/lib/remote-ui/pages/home.d.ts.map +1 -1
- package/dist/lib/remote-ui/pages/home.js +25 -131
- package/dist/lib/remote-ui/pages/home.js.map +1 -1
- package/dist/lib/remote-ui/pages/procurement.js +11 -11
- package/dist/lib/remote-ui/pages/procurement.js.map +1 -1
- package/dist/lib/remote-ui/pages/sales.js +8 -8
- package/dist/lib/remote-ui/pages/sales.js.map +1 -1
- package/dist/lib/remote-ui/pages/settings.d.ts +0 -3
- package/dist/lib/remote-ui/pages/settings.d.ts.map +1 -1
- package/dist/lib/remote-ui/pages/settings.js +7 -56
- package/dist/lib/remote-ui/pages/settings.js.map +1 -1
- package/dist/lib/remote-ui/settings-contracts.d.ts +2 -16
- package/dist/lib/remote-ui/settings-contracts.d.ts.map +1 -1
- package/dist/lib/remote-ui/settings-contracts.js +2 -2
- package/dist/lib/remote-ui/settings-contracts.js.map +1 -1
- package/dist/lib/remote-ui/sidebar-state.d.ts +5 -0
- package/dist/lib/remote-ui/sidebar-state.d.ts.map +1 -0
- package/dist/lib/remote-ui/sidebar-state.js +18 -0
- package/dist/lib/remote-ui/sidebar-state.js.map +1 -0
- package/dist/lib/runtime-validation.d.ts +0 -1
- package/dist/lib/runtime-validation.d.ts.map +1 -1
- package/dist/lib/runtime-validation.js +0 -17
- package/dist/lib/runtime-validation.js.map +1 -1
- package/dist/lib/types.d.ts +2 -10
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +2 -2
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/view-parameters.d.ts +3 -0
- package/dist/lib/view-parameters.d.ts.map +1 -0
- package/dist/lib/view-parameters.js +23 -0
- package/dist/lib/view-parameters.js.map +1 -0
- package/dist/lib/workbench-view.provider.d.ts +0 -3
- package/dist/lib/workbench-view.provider.d.ts.map +1 -1
- package/dist/lib/workbench-view.provider.js +4 -2
- package/dist/lib/workbench-view.provider.js.map +1 -1
- package/dist/lib/workbench.plugin.d.ts +4 -1
- package/dist/lib/workbench.plugin.d.ts.map +1 -1
- package/dist/lib/workbench.plugin.js +12 -4
- package/dist/lib/workbench.plugin.js.map +1 -1
- package/dist/lib/workbench.service.d.ts +4 -8
- package/dist/lib/workbench.service.d.ts.map +1 -1
- package/dist/lib/workbench.service.js +8 -24
- package/dist/lib/workbench.service.js.map +1 -1
- package/package.json +3 -1
- package/dist/lib/domain/risk-notice.d.ts +0 -59
- package/dist/lib/domain/risk-notice.d.ts.map +0 -1
- package/dist/lib/domain/risk-notice.js +0 -30
- package/dist/lib/domain/risk-notice.js.map +0 -1
|
@@ -9,7 +9,7 @@ import { mkdtemp, readFile, rm } from 'node:fs/promises';
|
|
|
9
9
|
import { tmpdir } from 'node:os';
|
|
10
10
|
import { join } from 'node:path';
|
|
11
11
|
import { finished } from 'node:stream/promises';
|
|
12
|
-
import { BankAccountSettings, CompanySanctionMatch, CompanySettings, ControlledCatalogBatch, ControlledCatalogImportIssue, ControlledGoodsRecord, Customer, CustomerContract, CustomerContractAnalysisRun, CustomerContractClause, CustomerContractClauseAnalysis, DerivedSalesOrderManualData, GeneratedSalesFile, ImportTask, ManagedAsset, MonthlySafeExchangeRate, ProductComplianceMatch, ProfitRuleSettings, PurchaseOrder, PurchaseOrderLine,
|
|
12
|
+
import { BankAccountSettings, CompanySanctionMatch, CompanySettings, ControlledCatalogBatch, ControlledCatalogImportIssue, ControlledGoodsRecord, Customer, CustomerContract, CustomerContractAnalysisRun, CustomerContractClause, CustomerContractClauseAnalysis, DerivedSalesOrderManualData, GeneratedSalesFile, ImportTask, ManagedAsset, MonthlySafeExchangeRate, ProductComplianceMatch, ProfitRuleSettings, PurchaseOrder, PurchaseOrderLine, SanctionCatalogBatch, SanctionCatalogImportIssue, SanctionedCompanyRecord, SettingsHistory, Supplier } from './entities/index.js';
|
|
13
13
|
import { CatalogTypes, ClauseTypes, CustomerProfitRateStatuses, DomainError, DomainErrorCodes, RefundValidationMethods, SalesPaymentStatuses, SanctionHitStatuses } from './types.js';
|
|
14
14
|
import { deriveSalesLine, assertReceivedAmount } from './domain/finance.js';
|
|
15
15
|
import { parseCustomerContractNo, parsePurchaseContractNo } from './domain/contract-number.js';
|
|
@@ -17,9 +17,8 @@ import { isProductNameMatch, normalizeExactName, normalizeForProductMatch, norma
|
|
|
17
17
|
import { importTaskTimedOut, nextSettingsRevision, normalizeOptionalDecimalInput } from './domain/workflow.js';
|
|
18
18
|
import { renderImportIssuesWorkbook } from './domain/import-issues.js';
|
|
19
19
|
import { BUILTIN_COMPANY_LOGO_STORAGE_ID, DEFAULT_BANKS, DEFAULT_COMPANY, DEFAULT_PROFIT_RULE } from './domain/default-settings.js';
|
|
20
|
-
import { DEFAULT_RISK_NOTICE } from './domain/risk-notice.js';
|
|
21
20
|
import { TradeComplianceFileStorage } from './adapters/file-storage.js';
|
|
22
|
-
import { parseBankAccountType, parseExchangeRateInput, parseExpectedRevision,
|
|
21
|
+
import { parseBankAccountType, parseExchangeRateInput, parseExpectedRevision, validateBankSettingsInput, validateProfitSettingsInput, validatePurchaseLineDiscriminators, validateTaxRates } from './runtime-validation.js';
|
|
23
22
|
const DEFAULT_IMPORT_ISSUE_EXPORT_MAX_ROWS = 50_000;
|
|
24
23
|
const HARD_IMPORT_ISSUE_EXPORT_MAX_ROWS = 100_000;
|
|
25
24
|
const CUSTOMER_REANALYSIS_TIMEOUT_MS = 20 * 60 * 1000;
|
|
@@ -28,7 +27,6 @@ const CATALOG_RISK_RECOMMENDATIONS = {
|
|
|
28
27
|
DUAL_USE: '建议核验军民两用物项许可要求,并在出口前完成合规审批',
|
|
29
28
|
OVERSEAS_SANCTION: '建议核验海外制裁限制及交易对手风险,并在交易前完成合规审批'
|
|
30
29
|
};
|
|
31
|
-
export { DEFAULT_RISK_NOTICE };
|
|
32
30
|
export async function writeWorkbookFile(filePath, populate, openOutput = createWriteStream) {
|
|
33
31
|
const output = openOutput(filePath);
|
|
34
32
|
const closed = finished(output, { cleanup: true });
|
|
@@ -52,18 +50,16 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
|
|
|
52
50
|
this.storage = storage;
|
|
53
51
|
}
|
|
54
52
|
async bootstrapSettings(scope) {
|
|
55
|
-
const riskRepo = this.dataSource.getRepository(RiskNoticeSettings);
|
|
56
53
|
const profitRepo = this.dataSource.getRepository(ProfitRuleSettings);
|
|
57
54
|
const companyRepo = this.dataSource.getRepository(CompanySettings);
|
|
58
55
|
const bankRepo = this.dataSource.getRepository(BankAccountSettings);
|
|
59
56
|
const builtinLogo = await this.ensureBuiltinCompanyLogo(scope);
|
|
60
|
-
const [
|
|
61
|
-
this.ensureSettingsDefault(riskRepo, activeScope(scope), { ...auditScope(scope), content: DEFAULT_RISK_NOTICE, revision: 1 }),
|
|
57
|
+
const [profit, company, ...banks] = await Promise.all([
|
|
62
58
|
this.ensureSettingsDefault(profitRepo, activeScope(scope), { ...auditScope(scope), ...DEFAULT_PROFIT_RULE, revision: 1 }),
|
|
63
59
|
this.ensureSettingsDefault(companyRepo, activeScope(scope), { ...auditScope(scope), ...DEFAULT_COMPANY, logoFileId: builtinLogo.id, revision: 1 }),
|
|
64
60
|
...DEFAULT_BANKS.map(defaults => this.ensureSettingsDefault(bankRepo, { ...activeScope(scope), bankType: defaults.bankType }, { ...auditScope(scope), ...defaults, revision: 1 }))
|
|
65
61
|
]);
|
|
66
|
-
return {
|
|
62
|
+
return { profit, company, banks };
|
|
67
63
|
}
|
|
68
64
|
async ensureBuiltinCompanyLogo(scope) {
|
|
69
65
|
const repo = this.dataSource.getRepository(ManagedAsset);
|
|
@@ -88,14 +84,13 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
|
|
|
88
84
|
return row;
|
|
89
85
|
}
|
|
90
86
|
async dashboard(scope) {
|
|
91
|
-
const [
|
|
92
|
-
this.bootstrapSettings(scope),
|
|
87
|
+
const [controlledRiskCount, sanctionRiskCount, unlinkedPurchaseCount, unlinkedCustomerCount] = await Promise.all([
|
|
93
88
|
this.dataSource.getRepository(ProductComplianceMatch).count({ where: { ...activeScope(scope), deletedAt: IsNull() } }),
|
|
94
89
|
this.dataSource.getRepository(CompanySanctionMatch).count({ where: { ...activeScope(scope), deletedAt: IsNull() } }),
|
|
95
90
|
this.countUnlinkedPurchases(scope),
|
|
96
91
|
this.countUnlinkedCustomers(scope)
|
|
97
92
|
]);
|
|
98
|
-
return {
|
|
93
|
+
return { controlledRiskCount, sanctionRiskCount, unlinkedPurchaseCount, unlinkedCustomerCount };
|
|
99
94
|
}
|
|
100
95
|
async listControlledGoods(scope, query = {}) {
|
|
101
96
|
return this.pagedCatalogQuery(ControlledGoodsRecord, ControlledCatalogBatch, scope, query, {
|
|
@@ -1209,22 +1204,15 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
|
|
|
1209
1204
|
async listGeneratedFiles(scope, query = {}) { return this.pagedQuery(GeneratedSalesFile, scope, query, ['salesOrderNoSnapshot', 'documentNo', 'fileName'], { customerContractId: query.parameters?.customerContractId, purchaseOrderId: query.parameters?.purchaseOrderId, fileType: query.parameters?.fileType }); }
|
|
1210
1205
|
async settings(scope) {
|
|
1211
1206
|
await this.bootstrapSettings(scope);
|
|
1212
|
-
const [
|
|
1213
|
-
this.dataSource.getRepository(RiskNoticeSettings).findOne({ where: activeScope(scope) }),
|
|
1207
|
+
const [profit, company, banks, rates] = await Promise.all([
|
|
1214
1208
|
this.dataSource.getRepository(ProfitRuleSettings).findOne({ where: activeScope(scope) }),
|
|
1215
1209
|
this.dataSource.getRepository(CompanySettings).findOne({ where: activeScope(scope) }),
|
|
1216
1210
|
this.dataSource.getRepository(BankAccountSettings).find({ where: activeScope(scope), order: { bankType: 'ASC' } }),
|
|
1217
1211
|
this.dataSource.getRepository(MonthlySafeExchangeRate).find({ where: { ...activeScope(scope), deletedAt: IsNull() }, order: { year: 'DESC', month: 'DESC' } })
|
|
1218
1212
|
]);
|
|
1219
|
-
return {
|
|
1213
|
+
return { company, banks, profit, rates };
|
|
1220
1214
|
}
|
|
1221
1215
|
async saveSettings(scope, type, input, expectedRevision) {
|
|
1222
|
-
if (type === 'risk') {
|
|
1223
|
-
const changes = {};
|
|
1224
|
-
if ('content' in input)
|
|
1225
|
-
changes.content = sanitizeRiskNoticeContent(input.content);
|
|
1226
|
-
return this.persistSettings(scope, 'RISK', RiskNoticeSettings, activeScope(scope), settingsCreateScope(scope), changes, expectedRevision);
|
|
1227
|
-
}
|
|
1228
1216
|
if (type === 'company') {
|
|
1229
1217
|
const changes = {};
|
|
1230
1218
|
for (const field of ['logoFileId', 'companyNameZh', 'companyNameEn', 'unifiedSocialCreditCode', 'addressZh', 'addressEn', 'phone', 'email'])
|
|
@@ -1247,8 +1235,6 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
|
|
|
1247
1235
|
return this.persistMonthlyRate(scope, input, { ...parsed, sourceReference }, expectedRevision);
|
|
1248
1236
|
}
|
|
1249
1237
|
async restoreSettingsDefault(scope, input) {
|
|
1250
|
-
if (input.settingsType === 'risk')
|
|
1251
|
-
return this.persistSettings(scope, 'RISK', RiskNoticeSettings, activeScope(scope), settingsCreateScope(scope), { content: DEFAULT_RISK_NOTICE }, input.expectedRevision, 'RESTORE_DEFAULT');
|
|
1252
1238
|
if (input.settingsType === 'company') {
|
|
1253
1239
|
const builtinLogo = await this.ensureBuiltinCompanyLogo(scope);
|
|
1254
1240
|
return this.persistCompanySettings(scope, { ...DEFAULT_COMPANY, logoFileId: builtinLogo.id }, input.expectedRevision, 'RESTORE_DEFAULT');
|
|
@@ -2005,8 +1991,6 @@ function settingsSnapshot(settingsType, row) {
|
|
|
2005
1991
|
const revision = Number(value.revision);
|
|
2006
1992
|
if (!Number.isInteger(revision) || revision < 1)
|
|
2007
1993
|
throw new DomainError(DomainErrorCodes.INVALID_INPUT, '设置修订号无效', { settingsType, revision: value.revision });
|
|
2008
|
-
if (settingsType === 'RISK')
|
|
2009
|
-
return { settingsType, snapshotVersion: 'v1', revision, content: String(value.content ?? '') };
|
|
2010
1994
|
if (settingsType === 'COMPANY')
|
|
2011
1995
|
return { settingsType, snapshotVersion: 'v1', revision, logoFileId: nullableSnapshotText(value.logoFileId), companyNameZh: nullableSnapshotText(value.companyNameZh), companyNameEn: nullableSnapshotText(value.companyNameEn), unifiedSocialCreditCode: nullableSnapshotText(value.unifiedSocialCreditCode), addressZh: nullableSnapshotText(value.addressZh), addressEn: nullableSnapshotText(value.addressEn), phone: nullableSnapshotText(value.phone), email: nullableSnapshotText(value.email) };
|
|
2012
1996
|
if (settingsType === 'BANK')
|