mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-10 16:14:54 +03:00
fix(skd-compile): startDate/endDate в StandardPeriod ТОЛЬКО для variant=Custom
Анализ корпуса ERP/БСП (671 отчёт): из 635 StandardPeriod values только 93 (все Custom) имели <v8:startDate>/<v8:endDate>. Остальные 542 варианта (ThisMonth, LastYear, Today, ThisQuarter, FromBeginningOfThisYear и т.д.) эмитятся БЕЗ дат — это canonical platform-pattern. Раньше compile добавлял boilerplate 0001-01-01 даты ко всем вариантам независимо от типа. Снапшоты регенерированы. sample30: −138 строк (1330 → 1192).
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.81 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.82 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -1496,12 +1496,14 @@ function Emit-ParamValue {
|
||||
$valStr = "$val"
|
||||
|
||||
if ($type -eq "StandardPeriod") {
|
||||
# val is a period variant string like "LastMonth" or "Custom".
|
||||
# Always emit startDate/endDate to match how 1C Designer saves the schema.
|
||||
# Platform-pattern: startDate/endDate эмитятся ТОЛЬКО для variant=Custom.
|
||||
# Для всех остальных вариантов (ThisMonth, LastYear, Today, ...) — без дат.
|
||||
X "$indent<value xsi:type=`"v8:StandardPeriod`">"
|
||||
X "$indent`t<v8:variant xsi:type=`"v8:StandardPeriodVariant`">$(Esc-Xml $valStr)</v8:variant>"
|
||||
X "$indent`t<v8:startDate>0001-01-01T00:00:00</v8:startDate>"
|
||||
X "$indent`t<v8:endDate>0001-01-01T00:00:00</v8:endDate>"
|
||||
if ($valStr -eq 'Custom') {
|
||||
X "$indent`t<v8:startDate>0001-01-01T00:00:00</v8:startDate>"
|
||||
X "$indent`t<v8:endDate>0001-01-01T00:00:00</v8:endDate>"
|
||||
}
|
||||
X "$indent</value>"
|
||||
} elseif ($type -match '^date') {
|
||||
X "$indent<value xsi:type=`"xs:dateTime`">$(Esc-Xml $valStr)</value>"
|
||||
@@ -2575,7 +2577,8 @@ function Emit-DataParameters {
|
||||
} elseif ($null -ne $dp.value) {
|
||||
$vtype = "$($dp.valueType)"
|
||||
if (($dp.value -is [PSCustomObject] -or $dp.value -is [hashtable]) -and ($dp.value.variant)) {
|
||||
# StandardPeriod (PSCustomObject from JSON / hashtable from shorthand parser)
|
||||
# StandardPeriod (PSCustomObject from JSON / hashtable from shorthand parser).
|
||||
# Platform-pattern: startDate/endDate ТОЛЬКО для variant=Custom.
|
||||
$_sd = $null; $_ed = $null
|
||||
if ($dp.value -is [PSCustomObject]) {
|
||||
if ($dp.value.PSObject.Properties['startDate']) { $_sd = "$($dp.value.startDate)" }
|
||||
@@ -2584,12 +2587,15 @@ function Emit-DataParameters {
|
||||
if ($dp.value.Contains('startDate')) { $_sd = "$($dp.value['startDate'])" }
|
||||
if ($dp.value.Contains('endDate')) { $_ed = "$($dp.value['endDate'])" }
|
||||
}
|
||||
if (-not $_sd) { $_sd = '0001-01-01T00:00:00' }
|
||||
if (-not $_ed) { $_ed = '0001-01-01T00:00:00' }
|
||||
$_variantStr = "$($dp.value.variant)"
|
||||
X "$indent`t`t<dcscor:value xsi:type=`"v8:StandardPeriod`">"
|
||||
X "$indent`t`t`t<v8:variant xsi:type=`"v8:StandardPeriodVariant`">$(Esc-Xml "$($dp.value.variant)")</v8:variant>"
|
||||
X "$indent`t`t`t<v8:startDate>$(Esc-Xml $_sd)</v8:startDate>"
|
||||
X "$indent`t`t`t<v8:endDate>$(Esc-Xml $_ed)</v8:endDate>"
|
||||
X "$indent`t`t`t<v8:variant xsi:type=`"v8:StandardPeriodVariant`">$(Esc-Xml $_variantStr)</v8:variant>"
|
||||
if ($_variantStr -eq 'Custom') {
|
||||
if (-not $_sd) { $_sd = '0001-01-01T00:00:00' }
|
||||
if (-not $_ed) { $_ed = '0001-01-01T00:00:00' }
|
||||
X "$indent`t`t`t<v8:startDate>$(Esc-Xml $_sd)</v8:startDate>"
|
||||
X "$indent`t`t`t<v8:endDate>$(Esc-Xml $_ed)</v8:endDate>"
|
||||
}
|
||||
X "$indent`t`t</dcscor:value>"
|
||||
} elseif ($vtype -match '^[a-zA-Z]+:') {
|
||||
# Полный xsi:type из decompile (например "xs:boolean", "dcscor:DesignTimeValue").
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.81 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.82 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -1035,11 +1035,12 @@ def emit_param_value(lines, type_str, val, indent, value_list_allowed=False):
|
||||
val_str = str(val)
|
||||
|
||||
if type_str == 'StandardPeriod':
|
||||
# Always emit startDate/endDate to match how 1C Designer saves the schema.
|
||||
# Platform-pattern: startDate/endDate ТОЛЬКО для variant=Custom.
|
||||
lines.append(f'{indent}<value xsi:type="v8:StandardPeriod">')
|
||||
lines.append(f'{indent}\t<v8:variant xsi:type="v8:StandardPeriodVariant">{esc_xml(val_str)}</v8:variant>')
|
||||
lines.append(f'{indent}\t<v8:startDate>0001-01-01T00:00:00</v8:startDate>')
|
||||
lines.append(f'{indent}\t<v8:endDate>0001-01-01T00:00:00</v8:endDate>')
|
||||
if val_str == 'Custom':
|
||||
lines.append(f'{indent}\t<v8:startDate>0001-01-01T00:00:00</v8:startDate>')
|
||||
lines.append(f'{indent}\t<v8:endDate>0001-01-01T00:00:00</v8:endDate>')
|
||||
lines.append(f'{indent}</value>')
|
||||
elif type_str and re.match(r'^date', type_str):
|
||||
lines.append(f'{indent}<value xsi:type="xs:dateTime">{esc_xml(val_str)}</value>')
|
||||
@@ -2091,13 +2092,15 @@ def emit_data_parameters(lines, items, indent):
|
||||
val = dp['value']
|
||||
vtype = str(dp.get('valueType') or '')
|
||||
if isinstance(val, dict) and val.get('variant'):
|
||||
# StandardPeriod (с явными датами или boilerplate)
|
||||
sd = str(val.get('startDate') or '0001-01-01T00:00:00')
|
||||
ed = str(val.get('endDate') or '0001-01-01T00:00:00')
|
||||
# StandardPeriod. Platform-pattern: startDate/endDate ТОЛЬКО для variant=Custom.
|
||||
variant_str = str(val['variant'])
|
||||
lines.append(f'{indent}\t\t<dcscor:value xsi:type="v8:StandardPeriod">')
|
||||
lines.append(f'{indent}\t\t\t<v8:variant xsi:type="v8:StandardPeriodVariant">{esc_xml(str(val["variant"]))}</v8:variant>')
|
||||
lines.append(f'{indent}\t\t\t<v8:startDate>{esc_xml(sd)}</v8:startDate>')
|
||||
lines.append(f'{indent}\t\t\t<v8:endDate>{esc_xml(ed)}</v8:endDate>')
|
||||
lines.append(f'{indent}\t\t\t<v8:variant xsi:type="v8:StandardPeriodVariant">{esc_xml(variant_str)}</v8:variant>')
|
||||
if variant_str == 'Custom':
|
||||
sd = str(val.get('startDate') or '0001-01-01T00:00:00')
|
||||
ed = str(val.get('endDate') or '0001-01-01T00:00:00')
|
||||
lines.append(f'{indent}\t\t\t<v8:startDate>{esc_xml(sd)}</v8:startDate>')
|
||||
lines.append(f'{indent}\t\t\t<v8:endDate>{esc_xml(ed)}</v8:endDate>')
|
||||
lines.append(f'{indent}\t\t</dcscor:value>')
|
||||
elif re.match(r'^[a-zA-Z]+:', vtype):
|
||||
# Полный xsi:type из decompile (например "xs:boolean", "dcscor:DesignTimeValue").
|
||||
|
||||
@@ -35,8 +35,6 @@
|
||||
</valueType>
|
||||
<value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<useRestriction>false</useRestriction>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
@@ -170,8 +168,6 @@
|
||||
<dcscor:parameter>Период</dcscor:parameter>
|
||||
<dcscor:value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</dcscor:value>
|
||||
<dcsset:userSettingID>UUID-001</dcsset:userSettingID>
|
||||
</dcscor:item>
|
||||
|
||||
@@ -65,8 +65,6 @@
|
||||
</valueType>
|
||||
<value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<useRestriction>false</useRestriction>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
@@ -141,8 +139,6 @@
|
||||
<dcscor:parameter>Период</dcscor:parameter>
|
||||
<dcscor:value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</dcscor:value>
|
||||
<dcsset:userSettingID>UUID-002</dcsset:userSettingID>
|
||||
</dcscor:item>
|
||||
|
||||
@@ -60,8 +60,6 @@
|
||||
</valueType>
|
||||
<value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<useRestriction>false</useRestriction>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
@@ -148,8 +146,6 @@
|
||||
<dcscor:parameter>Период</dcscor:parameter>
|
||||
<dcscor:value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</dcscor:value>
|
||||
<dcsset:userSettingID>UUID-002</dcsset:userSettingID>
|
||||
</dcscor:item>
|
||||
|
||||
@@ -57,8 +57,6 @@
|
||||
</valueType>
|
||||
<value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<useRestriction>false</useRestriction>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
|
||||
@@ -100,8 +100,6 @@
|
||||
</valueType>
|
||||
<value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<useRestriction>false</useRestriction>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
|
||||
@@ -78,8 +78,6 @@
|
||||
</valueType>
|
||||
<value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<useRestriction>false</useRestriction>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
@@ -358,8 +356,6 @@
|
||||
<dcscor:parameter>Период</dcscor:parameter>
|
||||
<dcscor:value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</dcscor:value>
|
||||
<dcsset:userSettingID>UUID-003</dcsset:userSettingID>
|
||||
</dcscor:item>
|
||||
|
||||
@@ -35,8 +35,6 @@
|
||||
</valueType>
|
||||
<value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<useRestriction>false</useRestriction>
|
||||
</parameter>
|
||||
|
||||
@@ -35,8 +35,6 @@
|
||||
</valueType>
|
||||
<value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<useRestriction>false</useRestriction>
|
||||
</parameter>
|
||||
|
||||
@@ -41,8 +41,6 @@
|
||||
</valueType>
|
||||
<value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<useRestriction>false</useRestriction>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
|
||||
@@ -35,8 +35,6 @@
|
||||
</valueType>
|
||||
<value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<useRestriction>false</useRestriction>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
@@ -106,8 +104,6 @@
|
||||
<dcscor:parameter>ПериодОтчета</dcscor:parameter>
|
||||
<dcscor:value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</dcscor:value>
|
||||
<dcsset:userSettingID>UUID-001</dcsset:userSettingID>
|
||||
</dcscor:item>
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
</valueType>
|
||||
<value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<useRestriction>false</useRestriction>
|
||||
</parameter>
|
||||
|
||||
@@ -65,8 +65,6 @@
|
||||
</valueType>
|
||||
<value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<useRestriction>false</useRestriction>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
@@ -141,8 +139,6 @@
|
||||
<dcscor:parameter>Период</dcscor:parameter>
|
||||
<dcscor:value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</dcscor:value>
|
||||
<dcsset:userSettingID>UUID-002</dcsset:userSettingID>
|
||||
</dcscor:item>
|
||||
|
||||
@@ -75,8 +75,6 @@
|
||||
</valueType>
|
||||
<value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<useRestriction>false</useRestriction>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
@@ -154,8 +152,6 @@
|
||||
<dcscor:parameter>Период</dcscor:parameter>
|
||||
<dcscor:value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</dcscor:value>
|
||||
<dcsset:userSettingID>UUID-002</dcsset:userSettingID>
|
||||
</dcscor:item>
|
||||
|
||||
@@ -65,8 +65,6 @@
|
||||
</valueType>
|
||||
<value xsi:type="v8:StandardPeriod">
|
||||
<v8:variant xsi:type="v8:StandardPeriodVariant">LastMonth</v8:variant>
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<useRestriction>false</useRestriction>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
|
||||
Reference in New Issue
Block a user