feat(skd): periodAdditionBegin/End с типом dcscor:Field

GroupItemField может иметь periodAdditionBegin/End:
- xsi:type="xs:dateTime" с конкретной датой
- xsi:type="dcscor:Field" с путём к параметру/полю (например
  "ПараметрыДанных.ДатаНачала"). См. АнализДоходовРасходов @8933.

Раньше эмитили захардкоженный default xs:dateTime 0001-01-01T00:00:00,
теряя любые non-default значения.

decompile: читаем оба элемента, сохраняем как string поля
periodAdditionBegin/End в object form group field (если non-default).
compile: auto-detect типа по pattern (ISO date → xs:dateTime,
иначе → dcscor:Field).

PS и Py compile синхронизированы.
This commit is contained in:
Nick Shirokov
2026-05-24 16:10:15 +03:00
parent fe9d8500dc
commit 19da4df61f
3 changed files with 35 additions and 8 deletions
@@ -1,4 +1,4 @@
# skd-compile v1.89 — Compile 1C DCS from JSON
# skd-compile v1.90 — Compile 1C DCS from JSON
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[string]$DefinitionFile,
@@ -2711,8 +2711,13 @@ function Emit-GroupItems {
X "$indent`t`t<dcsset:groupType>$(Esc-Xml $gt)</dcsset:groupType>"
$pat = if ($field.periodAdditionType) { "$($field.periodAdditionType)" } else { "None" }
X "$indent`t`t<dcsset:periodAdditionType>$(Esc-Xml $pat)</dcsset:periodAdditionType>"
X "$indent`t`t<dcsset:periodAdditionBegin xsi:type=`"xs:dateTime`">0001-01-01T00:00:00</dcsset:periodAdditionBegin>"
X "$indent`t`t<dcsset:periodAdditionEnd xsi:type=`"xs:dateTime`">0001-01-01T00:00:00</dcsset:periodAdditionEnd>"
# Auto-detect: ISO date → xs:dateTime, иначе → dcscor:Field (path).
$pab = if ($field.periodAdditionBegin) { "$($field.periodAdditionBegin)" } else { '0001-01-01T00:00:00' }
$pae = if ($field.periodAdditionEnd) { "$($field.periodAdditionEnd)" } else { '0001-01-01T00:00:00' }
$pabT = if ($pab -match '^\d{4}-\d{2}-\d{2}T') { 'xs:dateTime' } else { 'dcscor:Field' }
$paeT = if ($pae -match '^\d{4}-\d{2}-\d{2}T') { 'xs:dateTime' } else { 'dcscor:Field' }
X "$indent`t`t<dcsset:periodAdditionBegin xsi:type=`"$pabT`">$(Esc-Xml $pab)</dcsset:periodAdditionBegin>"
X "$indent`t`t<dcsset:periodAdditionEnd xsi:type=`"$paeT`">$(Esc-Xml $pae)</dcsset:periodAdditionEnd>"
X "$indent`t</dcsset:item>"
}
}
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# skd-compile v1.89 — Compile 1C DCS from JSON
# skd-compile v1.90 — Compile 1C DCS from JSON
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse
import json
@@ -2192,8 +2192,13 @@ def emit_group_items(lines, group_by, indent):
lines.append(f'{indent}\t\t<dcsset:groupType>{esc_xml(gt)}</dcsset:groupType>')
pat = str(field.get('periodAdditionType', 'None'))
lines.append(f'{indent}\t\t<dcsset:periodAdditionType>{esc_xml(pat)}</dcsset:periodAdditionType>')
lines.append(f'{indent}\t\t<dcsset:periodAdditionBegin xsi:type="xs:dateTime">0001-01-01T00:00:00</dcsset:periodAdditionBegin>')
lines.append(f'{indent}\t\t<dcsset:periodAdditionEnd xsi:type="xs:dateTime">0001-01-01T00:00:00</dcsset:periodAdditionEnd>')
# Auto-detect: ISO date → xs:dateTime, иначе → dcscor:Field (path).
pab = str(field.get('periodAdditionBegin', '0001-01-01T00:00:00'))
pae = str(field.get('periodAdditionEnd', '0001-01-01T00:00:00'))
pab_t = 'xs:dateTime' if re.match(r'^\d{4}-\d{2}-\d{2}T', pab) else 'dcscor:Field'
pae_t = 'xs:dateTime' if re.match(r'^\d{4}-\d{2}-\d{2}T', pae) else 'dcscor:Field'
lines.append(f'{indent}\t\t<dcsset:periodAdditionBegin xsi:type="{pab_t}">{esc_xml(pab)}</dcsset:periodAdditionBegin>')
lines.append(f'{indent}\t\t<dcsset:periodAdditionEnd xsi:type="{pae_t}">{esc_xml(pae)}</dcsset:periodAdditionEnd>')
lines.append(f'{indent}\t</dcsset:item>')
lines.append(f'{indent}</dcsset:groupItems>')
@@ -1,4 +1,4 @@
# skd-decompile v0.72 — Decompile 1C DCS Template.xml to JSON DSL (draft)
# skd-decompile v0.73 — Decompile 1C DCS Template.xml to JSON DSL (draft)
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[Parameter(Mandatory)]
@@ -1936,13 +1936,30 @@ function Get-GroupFields {
$gf = Get-Text $gItem "dcsset:field"
$pat = Get-Text $gItem "dcsset:periodAdditionType"
$gt = Get-Text $gItem "dcsset:groupType"
$isDefault = (-not $pat -or $pat -eq 'None') -and (-not $gt -or $gt -eq 'Items')
# periodAdditionBegin/End: non-default = либо dcscor:Field (path), либо
# date ≠ 0001-01-01T00:00:00. Сохраняем строкой — compile auto-detect тип.
$pabN = $gItem.SelectSingleNode("dcsset:periodAdditionBegin", $ns)
$paeN = $gItem.SelectSingleNode("dcsset:periodAdditionEnd", $ns)
$pab = $null; $pae = $null
if ($pabN) {
$pt = Get-LocalXsiType $pabN
$pv = $pabN.InnerText
if ($pt -eq 'Field' -or ($pv -and $pv -ne '0001-01-01T00:00:00')) { $pab = $pv }
}
if ($paeN) {
$pt = Get-LocalXsiType $paeN
$pv = $paeN.InnerText
if ($pt -eq 'Field' -or ($pv -and $pv -ne '0001-01-01T00:00:00')) { $pae = $pv }
}
$isDefault = (-not $pat -or $pat -eq 'None') -and (-not $gt -or $gt -eq 'Items') -and (-not $pab) -and (-not $pae)
if ($isDefault) {
$gFields += $gf
} else {
$obj = [ordered]@{ field = $gf }
if ($gt -and $gt -ne 'Items') { $obj['groupType'] = $gt }
if ($pat -and $pat -ne 'None') { $obj['periodAdditionType'] = $pat }
if ($pab) { $obj['periodAdditionBegin'] = $pab }
if ($pae) { $obj['periodAdditionEnd'] = $pae }
$gFields += $obj
}
} else {