mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-08-07 12:10:21 +03:00
feat(meta-validate): add cross-object register-registrar check
Detect configDir by walking up from object path to find Configuration.xml. For AccumulationRegister, AccountingRegister, CalculationRegister, and InformationRegister (RecorderSubordinate) scan Documents/*.xml to verify at least one document references the register in RegisterRecords. Warn if no registrar found. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
c2b90a97ef
commit
ca328e3e8f
@@ -54,6 +54,19 @@ if (-not (Test-Path $ObjectPath)) {
|
||||
|
||||
$resolvedPath = (Resolve-Path $ObjectPath).Path
|
||||
|
||||
# --- Detect config directory (for cross-object checks) ---
|
||||
|
||||
$script:configDir = $null
|
||||
$probe = Split-Path $resolvedPath
|
||||
for ($depth = 0; $depth -lt 4; $depth++) {
|
||||
if (-not $probe) { break }
|
||||
if (Test-Path (Join-Path $probe "Configuration.xml")) {
|
||||
$script:configDir = $probe
|
||||
break
|
||||
}
|
||||
$probe = Split-Path $probe
|
||||
}
|
||||
|
||||
# --- Output infrastructure ---
|
||||
|
||||
$script:errors = 0
|
||||
@@ -990,6 +1003,38 @@ if ($propsNode) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Register: must have at least one registrar document
|
||||
$registerTypes = @("AccumulationRegister","AccountingRegister","CalculationRegister","InformationRegister")
|
||||
if ($registerTypes -contains $mdType -and $script:configDir -and $objName -ne "(unknown)") {
|
||||
$needsRegistrar = $true
|
||||
# InformationRegister with WriteMode=Independent does not need a registrar
|
||||
if ($mdType -eq "InformationRegister") {
|
||||
$writeMode = $propsNode.SelectSingleNode("md:WriteMode", $ns)
|
||||
if (-not $writeMode -or $writeMode.InnerText -ne "RecorderSubordinate") {
|
||||
$needsRegistrar = $false
|
||||
}
|
||||
}
|
||||
if ($needsRegistrar) {
|
||||
$regRef = "$mdType.$objName"
|
||||
$docsDir = Join-Path $script:configDir "Documents"
|
||||
$hasRegistrar = $false
|
||||
if (Test-Path $docsDir) {
|
||||
$docXmls = Get-ChildItem $docsDir -Filter "*.xml" -File -ErrorAction SilentlyContinue
|
||||
foreach ($docXml in $docXmls) {
|
||||
$content = [System.IO.File]::ReadAllText($docXml.FullName, [System.Text.Encoding]::UTF8)
|
||||
if ($content.Contains($regRef)) {
|
||||
$hasRegistrar = $true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if (-not $hasRegistrar) {
|
||||
Report-Warn "10. $mdType`: no registrar document found (none references '$regRef' in RegisterRecords)"
|
||||
$check10Issues++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($check10Ok -and $check10Issues -eq 0) {
|
||||
|
||||
Reference in New Issue
Block a user