From 73c9a20d924da117f89b280e589c33ae1fa0d0f6 Mon Sep 17 00:00:00 2001 From: yuyubo <1870149533@qq.com> Date: Fri, 12 Dec 2025 19:35:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=93=E7=A5=A8=E5=A4=8D=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ServicePlugIn/AfterSave.cs | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/Pilot_KD_Parino/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs b/Pilot_KD_Parino/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs index 7b0fa4a..8aa3de5 100644 --- a/Pilot_KD_Parino/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs +++ b/Pilot_KD_Parino/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs @@ -58,20 +58,34 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.AR_SalesVATInvoice.ServicePlugIn // 判断条件:FIDD != 当前行ID 且 源单编号为空 if (fiddValue != entryId && string.IsNullOrWhiteSpace(srcBillNo)) { - // 从当前单据主表获取单据编号(实体属性名:BILLNO) - var billNo = billObj["BILLNO"]?.ToString() ?? ""; + // 通过源分录ID(FIDD)查询源单据的单据编号 + string srcBillNoFromSource = ""; + + var querySql = $@"/*dialect*/ +SELECT A.FBILLNO +FROM T_IV_SALESIC A +INNER JOIN T_IV_SALESICENTRY B ON A.FID = B.FID +WHERE B.FENTRYID = {fiddValue}"; + + var result = DBServiceHelper.ExecuteDynamicObject(this.Context, querySql); + if (result != null && result.Count > 0) + { + srcBillNoFromSource = result[0]["FBILLNO"]?.ToString() ?? ""; + } + + + // 固定源单类型为"销售增值税专用发票" var srcBillType = "IV_SALESIC"; - // 回写当前单据体:源单类型、源单编号 + // 回写当前单据体:源单类型、源单编号(使用源单据的编号) // 这里使用数据库字段名(带F前缀) var updateSql = $@"/*dialect*/ UPDATE T_IV_SALESICENTRY SET FSRCBILLTYPEID = '{srcBillType.Replace("'", "''")}', - FSRCBILLNO = '{billNo.Replace("'", "''")}' + FSRCBILLNO = '{srcBillNoFromSource.Replace("'", "''")}' WHERE FENTRYID = {entryId}"; - Logger.Error("销售增值税专用发票", updateSql, new Exception()); - Logger.Error("销售增值税专用发票", "78", new Exception()); + Logger.Error("销售增值税专用发票_回写源单信息", updateSql, new Exception()); DBServiceHelper.Execute(this.Context, updateSql); } } @@ -95,6 +109,7 @@ WHERE FENTRYID = {entryId}"; { Logger.Error("销售增值税专用发票出错了:", ex.Message, new Exception()); } + } } -} \ No newline at end of file +}