From 601eb2bed74f9ed9ade7f3e065d0378261845866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=94=A6=E9=BA=9F=20=E7=8E=8B?= Date: Fri, 28 Aug 2026 16:10:04 +0800 Subject: [PATCH] =?UTF-8?q?BugFix=20=E4=BF=AE=E6=94=B9=E7=94=9F=E6=95=88?= =?UTF-8?q?=E6=97=A5=E4=B9=8B=E5=90=8E=EF=BC=8Cdetail=E7=9A=84=E7=94=9F?= =?UTF-8?q?=E6=95=88=E6=97=A5=E6=B2=A1=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/margin_template_v2Controller.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/YLErpWeb/Controllers/margin_template_v2Controller.cs b/YLErpWeb/Controllers/margin_template_v2Controller.cs index a0452fae..698c8b88 100644 --- a/YLErpWeb/Controllers/margin_template_v2Controller.cs +++ b/YLErpWeb/Controllers/margin_template_v2Controller.cs @@ -493,12 +493,16 @@ namespace YLErp.Web.Controllers //BUG-14:明细生效日期回写——前端新增行只带占位日期(2020-01-01 前后),此前不回写使新行(含模板拷贝) //落库 0001-01-01,被取数侧 Max(ValueDate) 分组静默丢弃;占位日期对齐本次提交行的最新生效日期,无有效行时用模板生效日期 + //明细生效日期跟主表走:主表有真实生效日期时全部行强制对齐(含复制带入的源模板行日期、行上残留的旧日期), + //否则只改主表日期会出现"模板已生效但明细未生效"的取数断档;主表仍为占位日期时保持原兜底 var placeholderDate = new DateTime(2020, 1, 1); - var effectiveValueDate = marginTemplate.Details - .Where(d => d.ValueDate > placeholderDate) - .Select(d => d.ValueDate) - .DefaultIfEmpty(marginTemplate.ValueDate > placeholderDate ? marginTemplate.ValueDate : placeholderDate) - .Max(); + var detailValueDate = marginTemplate.ValueDate > placeholderDate + ? marginTemplate.ValueDate + : marginTemplate.Details + .Where(d => d.ValueDate > placeholderDate) + .Select(d => d.ValueDate) + .DefaultIfEmpty(placeholderDate) + .Max(); marginTemplate.Details.ForEach(x => { @@ -509,7 +513,7 @@ namespace YLErp.Web.Controllers detail = new margin_template_detail(); yldb.margin_template_detail.Add(detail); } - detail.ValueDate = x.ValueDate > placeholderDate ? x.ValueDate : effectiveValueDate; + detail.ValueDate = detailValueDate; detail.MarginTemplateId = marginTemplate.id; detail.GroupRatio = x.GroupRatio; detail.MarginRatio1 = x.MarginRatio1;