mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-09-21 17:55:53 +03:00
fix(skd): сохранять явные startDate/endDate в top-level StandardPeriod parameter
Параметр типа StandardPeriod с variant=Custom может иметь явные даты,
отличающиеся от default 0001-01-01T00:00:00 (например endDate=23:59:59).
См. АнализПричинБлокировкиВычетаНДС @941.
Раньше decompile сохранял variant только если ≠Custom (для Custom —
ничего), и compile эмитил захардкоженные 0001-01-01T00:00:00 для обеих
дат. Теряли явное время.
decompile: для StandardPeriod с явными датами (любая ≠00:00:00) →
object form {variant: Custom, startDate, endDate}.
compile (PS+Py): Emit-ParamValue принимает dict val с variant/startDate/
endDate; для Custom без явных дат сохраняется текущий fallback на
0001-01-01T00:00:00.
Sample30 total: 620 → 618 строк diff.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# skd-compile v1.96 — Compile 1C DCS from JSON
|
# skd-compile v1.97 — Compile 1C DCS from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[string]$DefinitionFile,
|
[string]$DefinitionFile,
|
||||||
@@ -1502,7 +1502,23 @@ function Emit-ParamValue {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
$valStr = "$val"
|
# val может быть строкой (variant only) или объектом {variant, startDate?, endDate?}.
|
||||||
|
$valIsDict = ($val -is [hashtable]) -or ($val -is [System.Collections.IDictionary]) -or ($val -is [PSCustomObject])
|
||||||
|
$variantStr = $null
|
||||||
|
$sdStr = $null
|
||||||
|
$edStr = $null
|
||||||
|
if ($valIsDict) {
|
||||||
|
if ($val -is [PSCustomObject]) {
|
||||||
|
if ($val.PSObject.Properties['variant']) { $variantStr = "$($val.variant)" }
|
||||||
|
if ($val.PSObject.Properties['startDate']) { $sdStr = "$($val.startDate)" }
|
||||||
|
if ($val.PSObject.Properties['endDate']) { $edStr = "$($val.endDate)" }
|
||||||
|
} else {
|
||||||
|
if ($val.Contains('variant')) { $variantStr = "$($val['variant'])" }
|
||||||
|
if ($val.Contains('startDate')) { $sdStr = "$($val['startDate'])" }
|
||||||
|
if ($val.Contains('endDate')) { $edStr = "$($val['endDate'])" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$valStr = if ($variantStr) { $variantStr } else { "$val" }
|
||||||
|
|
||||||
if ($type -eq "StandardPeriod") {
|
if ($type -eq "StandardPeriod") {
|
||||||
# Platform-pattern: startDate/endDate эмитятся ТОЛЬКО для variant=Custom.
|
# Platform-pattern: startDate/endDate эмитятся ТОЛЬКО для variant=Custom.
|
||||||
@@ -1510,8 +1526,10 @@ function Emit-ParamValue {
|
|||||||
X "$indent<value xsi:type=`"v8:StandardPeriod`">"
|
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:variant xsi:type=`"v8:StandardPeriodVariant`">$(Esc-Xml $valStr)</v8:variant>"
|
||||||
if ($valStr -eq 'Custom') {
|
if ($valStr -eq 'Custom') {
|
||||||
X "$indent`t<v8:startDate>0001-01-01T00:00:00</v8:startDate>"
|
$sdOut = if ($sdStr) { $sdStr } else { '0001-01-01T00:00:00' }
|
||||||
X "$indent`t<v8:endDate>0001-01-01T00:00:00</v8:endDate>"
|
$edOut = if ($edStr) { $edStr } else { '0001-01-01T00:00:00' }
|
||||||
|
X "$indent`t<v8:startDate>$(Esc-Xml $sdOut)</v8:startDate>"
|
||||||
|
X "$indent`t<v8:endDate>$(Esc-Xml $edOut)</v8:endDate>"
|
||||||
}
|
}
|
||||||
X "$indent</value>"
|
X "$indent</value>"
|
||||||
} elseif ($type -match '^date') {
|
} elseif ($type -match '^date') {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# skd-compile v1.96 — Compile 1C DCS from JSON
|
# skd-compile v1.97 — Compile 1C DCS from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
@@ -1040,15 +1040,25 @@ def emit_param_value(lines, type_str, val, indent, value_list_allowed=False):
|
|||||||
emit_empty_value(lines, type_str, indent, '', value_list_allowed)
|
emit_empty_value(lines, type_str, indent, '', value_list_allowed)
|
||||||
return
|
return
|
||||||
|
|
||||||
val_str = str(val)
|
# val может быть строкой (variant only) или dict {variant, startDate?, endDate?}.
|
||||||
|
variant_str = None
|
||||||
|
sd_str = None
|
||||||
|
ed_str = None
|
||||||
|
if isinstance(val, dict):
|
||||||
|
variant_str = str(val.get('variant')) if val.get('variant') is not None else None
|
||||||
|
sd_str = str(val['startDate']) if 'startDate' in val else None
|
||||||
|
ed_str = str(val['endDate']) if 'endDate' in val else None
|
||||||
|
val_str = variant_str if variant_str else str(val)
|
||||||
|
|
||||||
if type_str == 'StandardPeriod':
|
if type_str == 'StandardPeriod':
|
||||||
# Platform-pattern: startDate/endDate ТОЛЬКО для variant=Custom.
|
# Platform-pattern: startDate/endDate ТОЛЬКО для variant=Custom.
|
||||||
lines.append(f'{indent}<value xsi:type="v8:StandardPeriod">')
|
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:variant xsi:type="v8:StandardPeriodVariant">{esc_xml(val_str)}</v8:variant>')
|
||||||
if val_str == 'Custom':
|
if val_str == 'Custom':
|
||||||
lines.append(f'{indent}\t<v8:startDate>0001-01-01T00:00:00</v8:startDate>')
|
sd_out = sd_str if sd_str else '0001-01-01T00:00:00'
|
||||||
lines.append(f'{indent}\t<v8:endDate>0001-01-01T00:00:00</v8:endDate>')
|
ed_out = ed_str if ed_str else '0001-01-01T00:00:00'
|
||||||
|
lines.append(f'{indent}\t<v8:startDate>{esc_xml(sd_out)}</v8:startDate>')
|
||||||
|
lines.append(f'{indent}\t<v8:endDate>{esc_xml(ed_out)}</v8:endDate>')
|
||||||
lines.append(f'{indent}</value>')
|
lines.append(f'{indent}</value>')
|
||||||
elif type_str and re.match(r'^date', type_str):
|
elif type_str and re.match(r'^date', type_str):
|
||||||
lines.append(f'{indent}<value xsi:type="xs:dateTime">{esc_xml(val_str)}</value>')
|
lines.append(f'{indent}<value xsi:type="xs:dateTime">{esc_xml(val_str)}</value>')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# skd-decompile v0.79 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
# skd-decompile v0.80 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -755,8 +755,18 @@ function Build-Parameter {
|
|||||||
$vType = Get-LocalXsiType $valueNode
|
$vType = Get-LocalXsiType $valueNode
|
||||||
if ($vType -eq 'StandardPeriod') {
|
if ($vType -eq 'StandardPeriod') {
|
||||||
$variant = Get-Text $valueNode "v8:variant"
|
$variant = Get-Text $valueNode "v8:variant"
|
||||||
if ($variant -and $variant -ne 'Custom') { $valueDisplay = $variant }
|
$sd = Get-Text $valueNode "v8:startDate"
|
||||||
# Custom with explicit dates → object form (handled below via needsObject)
|
$ed = Get-Text $valueNode "v8:endDate"
|
||||||
|
$hasExplicitDates = ($sd -and $sd -ne '0001-01-01T00:00:00') -or ($ed -and $ed -ne '0001-01-01T00:00:00')
|
||||||
|
if ($hasExplicitDates) {
|
||||||
|
# Custom с явными датами → object form {variant, startDate, endDate}
|
||||||
|
$valueDisplay = [ordered]@{ variant = $variant }
|
||||||
|
if ($sd) { $valueDisplay['startDate'] = $sd }
|
||||||
|
if ($ed) { $valueDisplay['endDate'] = $ed }
|
||||||
|
} elseif ($variant -and $variant -ne 'Custom') {
|
||||||
|
$valueDisplay = $variant
|
||||||
|
}
|
||||||
|
# Custom без явных дат — valueDisplay = null, compile подставит 0001-01-01.
|
||||||
} elseif ($vType -eq 'DesignTimeValue') {
|
} elseif ($vType -eq 'DesignTimeValue') {
|
||||||
$valueDisplay = $valueNode.InnerText
|
$valueDisplay = $valueNode.InnerText
|
||||||
} elseif ($vType -eq 'LocalStringType') {
|
} elseif ($vType -eq 'LocalStringType') {
|
||||||
|
|||||||
Reference in New Issue
Block a user