diff --git a/.gitignore b/.gitignore index 469ba0c..c611020 100644 --- a/.gitignore +++ b/.gitignore @@ -117,3 +117,5 @@ /Gatedge.K3.Pilot.PlugIn/obj/Debug/Gatedge.K3.Pilot.PlugIn.csproj.CoreCompileInputs.cache /Gatedge.K3.Pilot.PlugIn/obj/Debug/Gatedge.K3.Pilot.PlugIn.dll /Gatedge.K3.Pilot.PlugIn/obj/Debug/Gatedge.K3.Pilot.PlugIn.pdb +/Gatedge.K3.Pilot.PlugIn/.vs/Gatedge.K3.Pilot.PlugIn.csproj.dtbcache.json +/NoPackageMachine/.vs/NoPackageMachine.csproj.dtbcache.json diff --git a/Gatedge.K3.Pilot.PlugIn/.vs/Gatedge.K3.Pilot.PlugIn.csproj.dtbcache.json b/Gatedge.K3.Pilot.PlugIn/.vs/Gatedge.K3.Pilot.PlugIn.csproj.dtbcache.json deleted file mode 100644 index 88a1310..0000000 --- a/Gatedge.K3.Pilot.PlugIn/.vs/Gatedge.K3.Pilot.PlugIn.csproj.dtbcache.json +++ /dev/null @@ -1 +0,0 @@ -{"RootPath":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn","ProjectFileName":"Gatedge.K3.Pilot.PlugIn.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"BOSPlugIn\\BD_CustPrice\\Bill.cs"},{"SourceFile":"BOSPlugIn\\BD_CustPrice\\ServicePlugIn\\Save.cs"},{"SourceFile":"BOSPlugIn\\BD_CustPrice\\ServicePlugIn\\SaveValidator.cs"},{"SourceFile":"BOSPlugIn\\CUST_PAYMENT_PERIOD\\List.cs"},{"SourceFile":"BOSPlugIn\\Sal_Order\\Bill.cs"},{"SourceFile":"Models\\Validate\\PeriodValidity.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Services\\DBService\\BaseDAL.cs"},{"SourceFile":"Services\\DBService\\BDCustPriceDAL.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"}],"References":[{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.BOS.App.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.BOS.App.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.BOS.Contracts.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.BOS.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.BOS.DataEntity.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.BOS.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.BOS.ServiceHelper.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.BOS.VerificationHelper.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.BOS.Web.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.BOS.Web.HTML.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.BOS.Web.HTML.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.BOS.WebApi.FormService.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.K3.BD.Contracts.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.K3.BD.NewCode.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.K3.BD.ServiceHelper.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Kingdee.K3.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"D:\\pairuodaima\\Gatedge.K3.Pilot.PlugIn\\bin\\Debug\\Gatedge.K3.Pilot.PlugIn.dll","OutputItemRelativePath":"Gatedge.K3.Pilot.PlugIn.dll"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]} \ No newline at end of file diff --git a/Gatedge.K3.Pilot.PlugIn/BOSPlugIn/Sal_Order/Bill.cs b/Gatedge.K3.Pilot.PlugIn/BOSPlugIn/Sal_Order/Bill.cs index 9e3a9cf..9f1ac53 100644 --- a/Gatedge.K3.Pilot.PlugIn/BOSPlugIn/Sal_Order/Bill.cs +++ b/Gatedge.K3.Pilot.PlugIn/BOSPlugIn/Sal_Order/Bill.cs @@ -4,6 +4,7 @@ using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.Util; using Kingdee.K3.BD.NewCode.Core.Utils; +using Kingdee.K3.Core.SCM.IOS; using System; using System.Collections.Generic; using System.ComponentModel; @@ -24,7 +25,12 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.Sal_Order { this.Model.SetValue("F_AGREEPRICE", 0, e.Row); this.Model.SetValue("F_BIGCUSTSETTLEPRICE", 0, e.Row); - this.Model.SetValue("F_BigCustDiscRate", 0, e.Row); + this.Model.SetValue("F_ActualDiscountRate", 0, e.Row); + + //表头大客户折扣率 + var F_BigCustSaleDiscountRate = this.View.Model.GetValue("F_BigCustSaleDiscountRate").Convert(); + //表头普通客户折扣率 + var F_CustSaleDiscountRate = this.View.Model.GetValue("F_CustSaleDiscountRate").Convert(); var materialId_Id = e.NewValue.Long2Int(); if (materialId_Id == 0) @@ -34,27 +40,119 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.Sal_Order if (custId_Id == 0) return; + bool isBigCustFlag = false; + var custId = this.View.Model.DataObject["CustId"] as DynamicObject; + var creditClassification = custId["F_CreditClassification"] as DynamicObject; + if (creditClassification != null && creditClassification["Number"] != null) + { + isBigCustFlag = creditClassification["Number"].ToString().EqualsIgnoreCase("KHXYFL013"); + } + var dal = new BDCustPriceDAL(this.Context); - var dateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + var dateTime = this.View.Model.DataObject["Date"].Convert().ToString("yyyy-MM-dd"); var resData = dal.GetMaterialPrice(materialId_Id, custId_Id, dateTime); if (resData != null && resData.Count > 0) { var data = resData[0]; - // 协议价 - var F_AGREEPRICE = data["F_AGREEPRICE"].Convert(); - this.Model.SetValue("F_AGREEPRICE", F_AGREEPRICE, e.Row); + //销售价格 + var price = this.Model.GetValue("FTaxPrice", e.Row).Convert(); + //结算价格 + var settlementPrice = data["F_JSJ"].Convert(); - // 大客户结算价 - var F_BIGCUSTSETTLEPRICE = data["F_BIGCUSTSETTLEPRICE"].Convert(); - this.Model.SetValue("F_BIGCUSTSETTLEPRICE", F_BIGCUSTSETTLEPRICE, e.Row); + if (isBigCustFlag) + { + // 大客户结算价 + settlementPrice = data["F_BIGCUSTSETTLEPRICE"].Convert(); + this.Model.SetValue("F_BIGCUSTSETTLEPRICE", settlementPrice, e.Row); + } + else + { + // 协议价 + var F_AGREEPRICE = data["F_AGREEPRICE"].Convert(); + this.Model.SetValue("F_AGREEPRICE", F_AGREEPRICE, e.Row); + } - //大客户折扣率 - var F_BigCustDiscRate = data["F_BIGCUSTDISCRATE"].Convert(); - this.Model.SetValue("F_BigCustDiscRate", F_BigCustDiscRate, e.Row); + //实际户折扣率 + var F_ActualDiscountRate = settlementPrice == 0 ? 100M : price / settlementPrice * 100; + this.Model.SetValue("F_ActualDiscountRate", F_ActualDiscountRate, e.Row); + this.View.InvokeFieldUpdateService("F_ActualDiscountRate", e.Row); } + ////普通客户折扣率 + //this.Model.SetValue("F_CustSaleDiscountRate", F_CustSaleDiscountRate); + ////大客户折扣率 + //this.Model.SetValue("F_BigCustSaleDiscountRate", F_BigCustSaleDiscountRate); + } + + //销售价格 + if (e.Field.Key.EqualsIgnoreCase("FTaxPrice")) + { + this.Model.SetValue("F_AGREEPRICE", 0, e.Row); + this.Model.SetValue("F_BIGCUSTSETTLEPRICE", 0, e.Row); + this.Model.SetValue("F_ActualDiscountRate", 0, e.Row); + + //表头大客户折扣率 + var F_BigCustSaleDiscountRate = this.View.Model.GetValue("F_BigCustSaleDiscountRate").Convert(); + //表头普通客户折扣率 + var F_CustSaleDiscountRate = this.View.Model.GetValue("F_CustSaleDiscountRate").Convert(); + + var price = e.NewValue.Convert(); + + var custId_Id = this.View.Model.DataObject["CustId_Id"].Long2Int(); + if (custId_Id == 0) + return; + + bool isBigCustFlag = false; + var custId = this.View.Model.DataObject["CustId"] as DynamicObject; + var creditClassification = custId["F_CreditClassification"] as DynamicObject; + if (creditClassification != null && creditClassification["Number"] != null) + { + isBigCustFlag = creditClassification["Number"].ToString().EqualsIgnoreCase("KHXYFL013"); + } + + var materialId = this.View.Model.GetValue("FMaterialId", e.Row) as DynamicObject; + var materialId_Id = 0; + + var dal = new BDCustPriceDAL(this.Context); + var dateTime = this.View.Model.DataObject["Date"].Convert().ToString("yyyy-MM-dd"); + + if (materialId != null) + materialId_Id = materialId["Id"].Long2Int(); + + var resData = dal.GetMaterialPrice(materialId_Id, custId_Id, dateTime); + if (resData != null && resData.Count > 0) + { + var data = resData[0]; + + //结算价格 + var settlementPrice = data["F_JSJ"].Convert(); + + if (isBigCustFlag) + { + // 大客户结算价 + settlementPrice = data["F_BIGCUSTSETTLEPRICE"].Convert(); + this.Model.SetValue("F_BIGCUSTSETTLEPRICE", settlementPrice, e.Row); + } + else + { + // 协议价 + var F_AGREEPRICE = data["F_AGREEPRICE"].Convert(); + this.Model.SetValue("F_AGREEPRICE", F_AGREEPRICE, e.Row); + } + + //实际户折扣率 + var F_ActualDiscountRate = settlementPrice == 0 ? 100M : price / settlementPrice * 100; + this.Model.SetValue("F_ActualDiscountRate", F_ActualDiscountRate, e.Row); + this.View.InvokeFieldUpdateService("F_ActualDiscountRate", e.Row); + + } + + ////普通客户折扣率 + //this.Model.SetValue("F_CustSaleDiscountRate", F_CustSaleDiscountRate); + ////大客户折扣率 + //this.Model.SetValue("F_BigCustSaleDiscountRate", F_BigCustSaleDiscountRate); } //客户 @@ -63,59 +161,139 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.Sal_Order var custId_Id = e.NewValue.Long2Int(); var dal = new BDCustPriceDAL(this.Context); - var dateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + var dateTime = this.View.Model.DataObject["Date"].Convert().ToString("yyyy-MM-dd"); var details = this.View.BusinessInfo.GetEntity("FSaleOrderEntry"); if (details != null) { + //表头大客户折扣率 + var F_BigCustSaleDiscountRate = this.View.Model.GetValue("F_BigCustSaleDiscountRate").Convert(); + //表头普通客户折扣率 + var F_CustSaleDiscountRate = this.View.Model.GetValue("F_CustSaleDiscountRate").Convert(); + var entrys = this.View.Model.GetEntityDataObject(details); + + bool isBigCustFlag = false; + if (custId_Id > 0) + { + var custId = this.View.Model.DataObject["CustId"] as DynamicObject; + var creditClassification = custId["F_CreditClassification"] as DynamicObject; + if (creditClassification != null && creditClassification["Number"] != null) + { + isBigCustFlag = creditClassification["Number"].ToString().EqualsIgnoreCase("KHXYFL013"); + } + } + foreach (var entry in entrys) { var rowIndex = this.View.Model.GetRowIndex(details, entry); var materialId_Id = entry["MaterialId_Id"].Long2Int(); - + + var price = entry["TaxPrice"].Convert(); + var settlementPrice = 0M; this.Model.SetValue("F_AGREEPRICE", 0, rowIndex); this.Model.SetValue("F_BIGCUSTSETTLEPRICE", 0, rowIndex); - this.Model.SetValue("F_BigCustDiscRate", 0, rowIndex); - - var F_SettlementP = 0M; + this.Model.SetValue("F_ActualDiscountRate", 0, rowIndex); if (materialId_Id > 0 && custId_Id > 0) { var resData = dal.GetMaterialPrice(materialId_Id, custId_Id, dateTime); - if (resData != null && resData.Count > 0) + if (resData != null && resData.Any()) { - var data = resData[0]; + var data = resData.FirstOrDefault(); - // 协议价 - var F_AGREEPRICE = data["F_AGREEPRICE"].Convert(); - this.Model.SetValue("F_AGREEPRICE", F_AGREEPRICE, rowIndex); + //结算价格 + settlementPrice = data["F_JSJ"].Convert(); - // 大客户结算价 - var F_BIGCUSTSETTLEPRICE = data["F_BIGCUSTSETTLEPRICE"].Convert(); - this.Model.SetValue("F_BIGCUSTSETTLEPRICE", F_BIGCUSTSETTLEPRICE, rowIndex); - - //大客户折扣率 - var F_BigCustDiscRate = data["F_BIGCUSTDISCRATE"].Convert(); - this.Model.SetValue("F_BigCustDiscRate", F_BigCustDiscRate, rowIndex); - - F_SettlementP = F_BIGCUSTSETTLEPRICE * (F_BigCustDiscRate == 0 ? 1 : (F_BigCustDiscRate / 100)); + if (isBigCustFlag) + { + // 大客户结算价 + settlementPrice = data["F_BIGCUSTSETTLEPRICE"].Convert(); + this.Model.SetValue("F_BIGCUSTSETTLEPRICE", settlementPrice, rowIndex); + } + else + { + // 协议价 + var F_AGREEPRICE = data["F_AGREEPRICE"].Convert(); + this.Model.SetValue("F_AGREEPRICE", F_AGREEPRICE, rowIndex); + } } } - if (F_SettlementP != 0) + //大客户折扣率 + var F_ActualDiscountRate = settlementPrice == 0 ? 100M : price / settlementPrice * 100; + this.Model.SetValue("F_ActualDiscountRate", F_ActualDiscountRate, rowIndex); + this.View.InvokeFieldUpdateService("F_ActualDiscountRate", rowIndex); + + } + + ////普通客户折扣率 + //this.Model.SetValue("F_CustSaleDiscountRate", F_CustSaleDiscountRate); + ////大客户折扣率 + //this.Model.SetValue("F_BigCustSaleDiscountRate", F_BigCustSaleDiscountRate); + } + } + + if (e.Field.Key.EqualsIgnoreCase("F_ActualDiscountRate")) + { + //普通客户折扣率 + this.Model.SetValue("F_CustSaleDiscountRate", 0); + //大客户折扣率 + this.Model.SetValue("F_BigCustSaleDiscountRate", 0); + + var details = this.View.BusinessInfo.GetEntity("FSaleOrderEntry"); + if (details != null) + { + var entrys = this.View.Model.GetEntityDataObject(details); + bool isBigCustFlag = false; + var custId_Id = this.View.Model.DataObject["CustId_Id"].Long2Int(); + if (custId_Id > 0) + { + var custId = this.View.Model.DataObject["CustId"] as DynamicObject; + var creditClassification = custId["F_CreditClassification"] as DynamicObject; + if (creditClassification != null && creditClassification["Number"] != null) { - this.Model.SetValue("F_SettlementP", F_SettlementP, rowIndex); + isBigCustFlag = creditClassification["Number"].ToString().EqualsIgnoreCase("KHXYFL013"); } - else if(materialId_Id > 0) + } + + var actualDiscountRate = 0M; + foreach (var entry in entrys) + { + var rowIndex = this.View.Model.GetRowIndex(details, entry); + + var materialId_Id = entry["MaterialId_Id"].Long2Int(); + + var price = entry["TaxPrice"].Convert(); + + if (materialId_Id > 0) { - var materialId = entry["MaterialId"] as DynamicObject; - this.Model.SetValue("F_SettlementP", materialId["F_JSJ"].Convert(), rowIndex); + var tempRate = entry["ActualDiscountRate"].Convert(); + + if (actualDiscountRate == 0) + actualDiscountRate = tempRate; + else + actualDiscountRate = tempRate < actualDiscountRate ? tempRate : actualDiscountRate; + } + } + + if (custId_Id > 0) + { + if (isBigCustFlag) + { + //普通客户折扣率 + this.Model.SetValue("F_CustSaleDiscountRate", actualDiscountRate); + } + else + { + //大客户折扣率 + this.Model.SetValue("F_BigCustSaleDiscountRate", actualDiscountRate); } } } } + } } } \ No newline at end of file diff --git a/Gatedge.K3.Pilot.PlugIn/BOSPlugIn/Sal_OutStock/Bill.cs b/Gatedge.K3.Pilot.PlugIn/BOSPlugIn/Sal_OutStock/Bill.cs new file mode 100644 index 0000000..df5c687 --- /dev/null +++ b/Gatedge.K3.Pilot.PlugIn/BOSPlugIn/Sal_OutStock/Bill.cs @@ -0,0 +1,18 @@ +using Kingdee.BOS.Core.Bill.PlugIn; +using Kingdee.BOS.Util; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.Sal_OutStock +{ + + [Description("销售出库单插件"), HotUpdate] + public class Bill : AbstractBillPlugIn + { + + } +} diff --git a/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj b/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj index 8097635..26cf29c 100644 --- a/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj +++ b/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj @@ -94,12 +94,15 @@ + - + + + copy $(TargetPath) "D:\Program Files (x86)\Kingdee\K3Cloud\WebSite\Bin\$(TargetFileName)" diff --git a/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj.user b/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj.user new file mode 100644 index 0000000..a607660 --- /dev/null +++ b/Gatedge.K3.Pilot.PlugIn/Gatedge.K3.Pilot.PlugIn.csproj.user @@ -0,0 +1,6 @@ + + + + ShowAllFiles + + \ No newline at end of file diff --git a/Gatedge.K3.Pilot.PlugIn/Services/DBService/BDCustPriceDAL.cs b/Gatedge.K3.Pilot.PlugIn/Services/DBService/BDCustPriceDAL.cs index 7ad04b3..776e168 100644 --- a/Gatedge.K3.Pilot.PlugIn/Services/DBService/BDCustPriceDAL.cs +++ b/Gatedge.K3.Pilot.PlugIn/Services/DBService/BDCustPriceDAL.cs @@ -33,6 +33,7 @@ SELECT t0.FMATERIALID,t0.FNUMBER,t0.FUSEORGID ,t0_l.FNAME,t0_l.FSPECIFICATION,ISNULL(t1.F_AGREEPRICE,0) AS F_AGREEPRICE ,ISNULL(t2.F_BIGCUSTSETTLEPRICE,0) AS F_BIGCUSTSETTLEPRICE ,ISNULL(t2.F_BIGCUSTDISCRATE,0) AS F_BIGCUSTDISCRATE + ,t0.F_JSJ FROM T_BD_MATERIAL t0 INNER JOIN T_BD_MATERIAL_L t0_l on t0_l.FMATERIALID = t0.FMATERIALID AND t0_l.FLOCALEID = 2052 OUTER APPLY ( diff --git a/Gatedge.K3.Pilot.PlugIn/bin/Debug/Newtonsoft.Json.dll b/Gatedge.K3.Pilot.PlugIn/bin/Debug/Newtonsoft.Json.dll new file mode 100644 index 0000000..d593ed6 Binary files /dev/null and b/Gatedge.K3.Pilot.PlugIn/bin/Debug/Newtonsoft.Json.dll differ diff --git a/NoPackageMachine/.vs/NoPackageMachine.csproj.dtbcache.json b/NoPackageMachine/.vs/NoPackageMachine.csproj.dtbcache.json deleted file mode 100644 index 36bbfcb..0000000 --- a/NoPackageMachine/.vs/NoPackageMachine.csproj.dtbcache.json +++ /dev/null @@ -1 +0,0 @@ -{"RootPath":"D:\\pairuodaima\\NoPackageMachine","ProjectFileName":"NoPackageMachine.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"GetSingleLuoJi.cs"},{"SourceFile":"GetSonMachines.cs"},{"SourceFile":"Model\\SalOrderEntryModel.cs"},{"SourceFile":"Model\\SalOrderModel.cs"},{"SourceFile":"NoPackageMaterialForm.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Model\\SonMachine.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"}],"References":[{"Reference":"D:\\pairuodaima\\Component\\EZ.DB.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\K3Cloud.WebApi.Client.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.BOS.App.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.BOS.App.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.BOS.ApprovalFlow.PlugIns.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.BOS.BusinessEntity.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.BOS.Contracts.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.BOS.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.BOS.DataEntity.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.BOS.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.BOS.ServiceHelper.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.BOS.VerificationHelper.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.BOS.Web.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.BOS.WebApi.Client.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.BOS.WebApi.FormService.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.BOS.WebApi.ServicesStub.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.FIN.App.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.FIN.CB.App.Report.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.FIN.HS.App.Report.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.MFG.App.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.MFG.PLN.App.MrpModel.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.SCM.App.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.SCM.App.Credit.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.SCM.App.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.SCM.App.Sal.ServicePlugIn.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.SCM.App.Stock.Report.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.SCM.Business.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.SCM.Common.BusinessEntity.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.SCM.Contracts.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.SCM.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.SCM.ServiceHelper.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\Component\\Kingdee.K3.SCM.Stock.Business.PlugIn.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\pairuodaima\\packages\\Newtonsoft.Json.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"D:\\pairuodaima\\NoPackageMachine\\bin\\Debug\\NoPackageMachine.dll","OutputItemRelativePath":"NoPackageMachine.dll"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]} \ No newline at end of file diff --git a/NoPackageMachine/NoPackageMachine.csproj.user b/NoPackageMachine/NoPackageMachine.csproj.user new file mode 100644 index 0000000..a607660 --- /dev/null +++ b/NoPackageMachine/NoPackageMachine.csproj.user @@ -0,0 +1,6 @@ + + + + ShowAllFiles + + \ No newline at end of file diff --git a/Pilot_KD_Parino/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs b/Pilot_KD_Parino/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs index c87eee1..7740491 100644 --- a/Pilot_KD_Parino/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs +++ b/Pilot_KD_Parino/AR_SalesVATInvoice/ServicePlugIn/AfterSave.cs @@ -20,16 +20,15 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.AR_SalesVATInvoice.ServicePlugIn // 根据日志中的实际实体属性名来添加 e.FieldKeys.Add("FIDD"); e.FieldKeys.Add("FSEQQ"); - e.FieldKeys.Add("SRCBILLTYPEID"); // 实体属性名(没有F前缀) - e.FieldKeys.Add("SRCBILLNO"); // 实体属性名(没有F前缀) - e.FieldKeys.Add("SEQ"); - e.FieldKeys.Add("BILLNO"); // 单据编号(主表字段) + e.FieldKeys.Add("FSRCBILLTYPEID"); + e.FieldKeys.Add("FSRCBILLNO"); } - - public override void EndOperationTransaction(EndOperationTransactionArgs e) + public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e) { - base.EndOperationTransaction(e); + base.AfterExecuteOperationTransaction(e); + + foreach (var dataEntity in e.DataEntitys) { var billObj = dataEntity as DynamicObject; @@ -56,17 +55,26 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.AR_SalesVATInvoice.ServicePlugIn // 判断条件:FIDD != 当前行ID 且 源单编号为空 if (fiddValue != entryId && string.IsNullOrWhiteSpace(srcBillNo)) { - // 从当前单据主表获取单据编号(实体属性名:BILLNO) - var billNo = billObj["BILLNO"]?.ToString() ?? ""; - // 固定源单类型为"销售增值税专用发票" - var srcBillType = "IV_SALESIC"; + // 查询源单据体信息(主键=FIDD的明细行) + var sql = $@"/*dialect*/ +SELECT FSRCBILLTYPEID, FSRCBILLNO, FSEQ +FROM T_IV_SALESICENTRY +WHERE FENTRYID = {fiddValue}"; + Logger.Error("销售增值税专用发票", sql, new Exception()); + var result = DBServiceHelper.ExecuteDynamicObject(this.Context, sql); + if (result == null || result.Count == 0) + continue; + Logger.Error("销售增值税专用发票", "69", new Exception()); + var srcData = result[0]; + var srcBillTypeId = srcData["FSRCBILLTYPEID"]; + var srcBillNoValue = srcData["FSRCBILLNO"]; // 回写当前单据体:源单类型、源单编号 // 这里使用数据库字段名(带F前缀) var updateSql = $@"/*dialect*/ UPDATE T_IV_SALESICENTRY -SET FSRCBILLTYPEID = '{srcBillType.Replace("'", "''")}', - FSRCBILLNO = '{billNo.Replace("'", "''")}' +SET FSRCBILLTYPEID = '{srcBillTypeId}', + FSRCBILLNO = '{srcBillNoValue}' WHERE FENTRYID = {entryId}"; Logger.Error("销售增值税专用发票", updateSql, new Exception()); Logger.Error("销售增值税专用发票", "78", new Exception()); diff --git a/Pilot_KD_Parino/Pilot_KD_Parino.csproj b/Pilot_KD_Parino/Pilot_KD_Parino.csproj index 47db624..a66117b 100644 --- a/Pilot_KD_Parino/Pilot_KD_Parino.csproj +++ b/Pilot_KD_Parino/Pilot_KD_Parino.csproj @@ -51,22 +51,6 @@ False bin\Debug\Castle.Core.dll - - False - ..\..\..\派诺-裴豪\派诺功能\代码\Pilot_KD_Parino (2)\Pilot_KD_Parino\Pilot_KD_Parino\bin\Debug\DevExpress.Data.v13.1.dll - - - False - ..\..\..\派诺-裴豪\派诺功能\代码\Pilot_KD_Parino (2)\Pilot_KD_Parino\Pilot_KD_Parino\bin\Debug\DevExpress.Printing.v13.1.Core.dll - - - False - ..\..\..\派诺-裴豪\派诺功能\代码\Pilot_KD_Parino (2)\Pilot_KD_Parino\Pilot_KD_Parino\bin\Debug\DevExpress.Utils.v13.1.dll - - - False - ..\..\..\派诺-裴豪\派诺功能\代码\Pilot_KD_Parino (2)\Pilot_KD_Parino\Pilot_KD_Parino\bin\Debug\DevExpress.XtraEditors.v13.1.dll - ..\..\..\派诺-裴豪\派诺功能\代码\Pilot_KD_Parino (2)\Pilot_KD_Parino\Pilot_KD_Parino\bin\Debug\DocumentFormat.OpenXml.dll diff --git a/Pilot_KD_Parino/Pilot_KD_Parino.csproj.user b/Pilot_KD_Parino/Pilot_KD_Parino.csproj.user index a607660..0b24643 100644 --- a/Pilot_KD_Parino/Pilot_KD_Parino.csproj.user +++ b/Pilot_KD_Parino/Pilot_KD_Parino.csproj.user @@ -1,6 +1,6 @@ - ShowAllFiles + ProjectFiles \ No newline at end of file diff --git a/Pilot_KD_Parino/QPHY_AutoWrire/Bill3.cs b/Pilot_KD_Parino/QPHY_AutoWrire/Bill3.cs index 3cae348..00b0cae 100644 --- a/Pilot_KD_Parino/QPHY_AutoWrire/Bill3.cs +++ b/Pilot_KD_Parino/QPHY_AutoWrire/Bill3.cs @@ -1,5 +1,4 @@ -using DevExpress.Xpo.DB; -using Kingdee.BOS.Core.DynamicForm; +using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Core.DynamicForm.PlugIn; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Orm.DataEntity; @@ -10,8 +9,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Pilot_KD_Parino.QPHY_AutoWrire.Bill2; namespace Pilot_KD_Parino.QPHY_AutoWrire diff --git a/Pilot_KD_Parino/QPHY_AutoWrire/Bill5.cs b/Pilot_KD_Parino/QPHY_AutoWrire/Bill5.cs index 4a7f3b0..b2812f4 100644 --- a/Pilot_KD_Parino/QPHY_AutoWrire/Bill5.cs +++ b/Pilot_KD_Parino/QPHY_AutoWrire/Bill5.cs @@ -1,27 +1,12 @@ -using DevExpress.Data.Linq; -using DevExpress.Data.PLinq.Helpers; -using DocumentFormat.OpenXml.Drawing.Spreadsheet; -using FarPoint.Excel; -using Kingdee.BOS.App.Core.Utils; -using Kingdee.BOS.BusinessEntity.BusinessFlow; -using Kingdee.BOS.Core.CommonFilter; +using Kingdee.BOS.Core.CommonFilter; using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Core.DynamicForm.PlugIn; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel; -using Kingdee.BOS.Core.Enums; -using Kingdee.BOS.Core.List; -using Kingdee.BOS.Core.Msg; -using Kingdee.BOS.Core.Report.PlugIn.Args; using Kingdee.BOS.JSON; -using Kingdee.BOS.Log; -using Kingdee.BOS.Orm; using Kingdee.BOS.Orm.DataEntity; -using Kingdee.BOS.Orm.Exceptions; -using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Util; using Newtonsoft.Json; -using NPOI.SS.Formula.Functions; using Pilot_KD_Parino.Common; using System; using System.Collections.Generic; @@ -29,10 +14,6 @@ using System.ComponentModel; using System.Data; using System.Globalization; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web.UI.WebControls; -using static Kingdee.BOS.BusinessEntity.YunZhiJia.ERPInfoEnum; using static Pilot_KD_Parino.QPHY_AutoWrire.Bill2; using static Pilot_KD_Parino.QPHY_AutoWrire.Bill3; diff --git a/Pilot_KD_Parino/QPHY_AutoWrireRecord/HeXiaoJiLuSave.cs b/Pilot_KD_Parino/QPHY_AutoWrireRecord/HeXiaoJiLuSave.cs index 4859bef..537a79b 100644 --- a/Pilot_KD_Parino/QPHY_AutoWrireRecord/HeXiaoJiLuSave.cs +++ b/Pilot_KD_Parino/QPHY_AutoWrireRecord/HeXiaoJiLuSave.cs @@ -52,7 +52,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrireRecord //GROUP BY a.FBILLNO,a.F_AMOUNT "; string sql = $@"/*dialect*/SELECT bb.F_CONTRACTNUMBER,bb.F_AMOUNT,fin.FBillAllAmount,bb.F_expenses, bb.FBILLNO - ,(bb.ZhengShuHeJi+bb.F_expenses-bb.F_AMOUNT) AS XiaoFamount + ,(bb.F_TOTALPOSITIVEAMOUNT+bb.F_expenses-bb.F_AMOUNT) AS XiaoFamount ,b.FALLAMOUNT22 FROM T_AutoWrireRecordEntry b INNER JOIN dbo.ZZV_SalOrder bb diff --git a/Pilot_KD_Parino/QPHY_AutoWrireRecord/HeXiaoJiLuYanZheng.cs b/Pilot_KD_Parino/QPHY_AutoWrireRecord/HeXiaoJiLuYanZheng.cs index c8fc7c5..5ba688e 100644 --- a/Pilot_KD_Parino/QPHY_AutoWrireRecord/HeXiaoJiLuYanZheng.cs +++ b/Pilot_KD_Parino/QPHY_AutoWrireRecord/HeXiaoJiLuYanZheng.cs @@ -1,18 +1,10 @@ -using DevExpress.Data.PLinq.Helpers; -using Kingdee.BOS; -using Kingdee.BOS.App; -using Kingdee.BOS.App.Data; -using Kingdee.BOS.Contracts; -using Kingdee.BOS.Core.DynamicForm; +using Kingdee.BOS; using Kingdee.BOS.Core.DynamicForm.PlugIn; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; -using Kingdee.BOS.Core.Metadata; -using Kingdee.BOS.Core.Metadata.FieldElement; using Kingdee.BOS.Log; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Util; -using Org.BouncyCastle.Asn1.X509; using Pilot_KD_Parino.Common; using System; using System.ComponentModel; @@ -38,7 +30,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrireRecord //获取单据Id string Id = sheet["Id"].ToString(); string sql = $@"/*dialect*/SELECT bb.F_CONTRACTNUMBER,bb.F_AMOUNT,fin.FBillAllAmount,bb.F_expenses, bb.FBILLNO - ,(bb.ZhengShuHeJi+bb.F_expenses-bb.F_AMOUNT) AS XiaoFamount + ,(bb.F_TOTALPOSITIVEAMOUNT+bb.F_expenses-bb.F_AMOUNT) AS XiaoFamount ,b.FALLAMOUNT22 FROM T_AutoWrireRecordEntry b INNER JOIN dbo.ZZV_SalOrder bb diff --git a/Pilot_KD_Parino/Sal_Order/SaleOrderContractnumber.cs b/Pilot_KD_Parino/Sal_Order/SaleOrderContractnumber.cs index 450d519..63c059c 100644 --- a/Pilot_KD_Parino/Sal_Order/SaleOrderContractnumber.cs +++ b/Pilot_KD_Parino/Sal_Order/SaleOrderContractnumber.cs @@ -23,203 +23,215 @@ namespace Pilot_KD_Parino.Sal_Order public override void BeforeDoSaveExecute(BeforeDoSaveExecuteEventArgs e) { - base.BeforeDoSaveExecute(e); - var FEntity = e.DataEntities[0]; - var FNAME1 = FEntity["BillTypeId_Id"].ToString(); - if (FNAME1.ToString() == "a300e2620037435492aed9842875b451" && FNAME1 != null) + try { - - var json = JsonUtil.Serialize(FEntity); - //Logger.Error("销售订单保存前刷正确的合同号", json, new Exception()); - var fid = FEntity["id"]; + base.BeforeDoSaveExecute(e); + var FEntity = e.DataEntities[0]; + var FNAME1 = FEntity["BillTypeId_Id"].ToString(); - var sql3333 = $@"SELECT F_contractnumber FROM dbo.T_SAL_ORDER WHERE fid={fid} and F_contractnumber !='' "; - var sqlDS33 = DBUtils.ExecuteDynamicObject(this.Context, sql3333); - if (sqlDS33 != null && sqlDS33.Count > 0) - { - string contractnumber = sqlDS33[0]["F_contractnumber"].ToString(); - //Logger.Error("销售订单保存前刷正确的合同号2", contractnumber, new Exception()); - FEntity["F_contractnumber"] = contractnumber; - - - return; - } - else + if (FNAME1.ToString() == "a300e2620037435492aed9842875b451" && FNAME1 != null) { - var formID = FEntity["FFormId"]; - //销售订单新变更单 - if (formID.ToString() == "SAL_XORDER") + var json = JsonUtil.Serialize(FEntity); + //Logger.Error("销售订单保存前刷正确的合同号", json, new Exception()); + var fid = FEntity["id"]; + + var sql3333 = $@"SELECT F_contractnumber FROM dbo.T_SAL_ORDER WHERE fid={fid} and F_contractnumber !='' "; + var sqlDS33 = DBUtils.ExecuteDynamicObject(this.Context, sql3333); + if (sqlDS33 != null && sqlDS33.Count > 0) { + string contractnumber = sqlDS33[0]["F_contractnumber"].ToString(); + //Logger.Error("销售订单保存前刷正确的合同号2", contractnumber, new Exception()); + FEntity["F_contractnumber"] = contractnumber; + + return; - if (FNAME1.ToString() == "a300e2620037435492aed9842875b451" && FNAME1 != null) + } + else + { + + var formID = FEntity["FFormId"]; + //销售订单新变更单 + if (formID.ToString() == "SAL_XORDER") { - var FSaleOrderEntry_Link = FEntity["SaleOrderEntry"] as DynamicObjectCollection; - if (FSaleOrderEntry_Link.Count > 0) + return; + if (FNAME1.ToString() == "a300e2620037435492aed9842875b451" && FNAME1 != null) { - var details = FSaleOrderEntry_Link[0]["FSaleOrderEntry_Link"] as DynamicObjectCollection; - //var FbiLLNO = this.View.Model.GetValue("FBILLNO"); - - if (details != null) + var FSaleOrderEntry_Link = FEntity["SaleOrderEntry"] as DynamicObjectCollection; + if (FSaleOrderEntry_Link.Count > 0) { - var entrys = details; - if (entrys != null && entrys.Count > 0) + var details = FSaleOrderEntry_Link[0]["FSaleOrderEntry_Link"] as DynamicObjectCollection; + //var FbiLLNO = this.View.Model.GetValue("FBILLNO"); + + if (details != null) { - foreach (var entry in entrys) + var entrys = details; + if (entrys != null && entrys.Count > 0) { - - var sBillId = entry == null ? 0 : entry["sBillId"].Long2Int(); - - //获取退货类型字段 - var F_Returntype = FEntity["F_Returntype"]; - - //获取纸质合同号 - String F_contractnumber = FEntity["F_contractnumber"].ToString(); - string yuanF_contractnumber = F_contractnumber; - int dashPosition; - if (F_contractnumber.Contains("-TH")) + string yuanF_contractnumber = FEntity["F_contractnumber"].ToString(); + foreach (var entry in entrys) { - dashPosition = F_contractnumber.IndexOf("-TH"); - F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber; - } - else if (F_contractnumber.Contains("-HH")) - { - dashPosition = F_contractnumber.IndexOf("-HH"); - F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber; - } - else - { - dashPosition = -2; - } - var sql = string.Format(@"SELECT COUNT(*) AS FNUMBER FROM T_SAL_ORDERENTRY_LK WHERE FSBILLID = '{0}'AND FRULEID = 'SaleOrder-ReturnSaleOrder'", sBillId); - var sqlDS = DBUtils.ExecuteDynamicObject(this.Context, sql); - String F_contractnumber2 = FEntity["F_contractnumber"].ToString(); - int number; - if (F_contractnumber2.Contains("-") && dashPosition != -2) - { - number = F_contractnumber2.Substring(F_contractnumber2.Length - 2).Long2Int(); - } - else - { - number = sqlDS[0]["FNUMBER"].Long2Int(); - number += 1; - //if (number == 1) + var sBillId = entry == null ? 0 : entry["sBillId"].Long2Int(); + + //获取退货类型字段 + var F_Returntype = FEntity["F_Returntype"]; + + //获取纸质合同号 + String F_contractnumber = FEntity["F_contractnumber"].ToString(); + + int dashPosition; + if (F_contractnumber.Contains("-TH")) + { + + dashPosition = F_contractnumber.IndexOf("-TH"); + F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber; + } + else if (F_contractnumber.Contains("-HH")) + { + dashPosition = F_contractnumber.IndexOf("-HH"); + F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber; + } + else + { + dashPosition = -2; + } + var sql = string.Format(@"SELECT COUNT(*) AS FNUMBER FROM T_SAL_ORDERENTRY_LK WHERE FSBILLID = '{0}'AND FRULEID = 'SaleOrder-ReturnSaleOrder'", sBillId); + var sqlDS = DBUtils.ExecuteDynamicObject(this.Context, sql); + String F_contractnumber2 = FEntity["F_contractnumber"].ToString(); + int number; + if (F_contractnumber2.Contains("-") && dashPosition != -2) + { + number = F_contractnumber2.Substring(F_contractnumber2.Length - 2).Long2Int(); + } + else + { + number = sqlDS[0]["FNUMBER"].Long2Int(); + number += 1; + //if (number == 1) + //{ + // number += 1; + //} + } + + string F_contractnumber1; + + int IFnumber = sqlDS[0]["FNUMBER"].Long2Int(); + + if (IFnumber != 0 && !F_Returntype.IsNullOrEmpty()) + { + F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + number.ToString(); + FEntity["F_contractnumber"] = F_contractnumber1; + break; + } + else if (!F_Returntype.IsNullOrEmpty()) + { + F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + '1'; + + FEntity["F_contractnumber"] = F_contractnumber1; + break; + } + //else if (IFnumber != 0 && !F_Returntype.IsNullOrEmpty()) //{ - // number += 1; + //} + + } - - string F_contractnumber1; - - int IFnumber = sqlDS[0]["FNUMBER"].Long2Int(); - - if (IFnumber != 0 && !F_Returntype.IsNullOrEmpty()) - { - F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + number.ToString(); - FEntity["F_contractnumber"] = F_contractnumber1; - break; - } - else if (!F_Returntype.IsNullOrEmpty()) - { - F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + '1'; - - FEntity["F_contractnumber"] = F_contractnumber1; - break; - } - //else if (IFnumber != 0 && !F_Returntype.IsNullOrEmpty()) - //{ - - //} - - } } } } } - } - //销售订单 - else if (formID.ToString() == "SAL_SaleOrder") - { - var FNAME = FEntity["BillTypeId_Id"].ToString(); - if (FNAME == "a300e2620037435492aed9842875b451" && FNAME != null) + //销售订单 + else if (formID.ToString() == "SAL_SaleOrder") { - var FSaleOrderEntry_Link = FEntity["SaleOrderEntry"] as DynamicObjectCollection; - if (FSaleOrderEntry_Link.Count > 0) + var FNAME = FEntity["BillTypeId_Id"].ToString(); + if (FNAME == "a300e2620037435492aed9842875b451" && FNAME != null) { - var details = FSaleOrderEntry_Link[0]["FSaleOrderEntry_Link"] as DynamicObjectCollection; - - - //var details = this.View.BusinessInfo.GetEntity("FSaleOrderEntry_Link"); - //var FbiLLNO = this.View.Model.GetValue("FID"); - - if (details != null) + var FSaleOrderEntry_Link = FEntity["SaleOrderEntry"] as DynamicObjectCollection; + if (FSaleOrderEntry_Link.Count > 0) { - var entrys = details; - if (entrys != null && entrys.Count > 0) + var details = FSaleOrderEntry_Link[0]["FSaleOrderEntry_Link"] as DynamicObjectCollection; + //string sdas=JsonHelper.ToJson(details); + // Logger.Error("销售订单上游订单的xx ", sdas, new Exception()); + //var details = this.View.BusinessInfo.GetEntity("FSaleOrderEntry_Link"); + //var FbiLLNO = this.View.Model.GetValue("FID"); + + if (details != null) { - foreach (var entry in entrys) + var entrys = details; + + if (entrys != null && entrys.Count > 0) { - - var sBillId = entry == null ? 0 : entry["sBillId"].Long2Int(); - - //获取退货类型字段 - var F_Returntype = FEntity["F_Returntype"]; - - //获取纸质合同号 - String F_contractnumber = FEntity["F_contractnumber"].ToString(); - string yuanF_contractnumber = F_contractnumber; - int dashPosition; - if (F_contractnumber.Contains("-TH")) + string yuanF_contractnumber = FEntity["F_contractnumber"].ToString(); + int i = 0; + foreach (var entry in entrys) { + if (i > 0) + return; + i++; - dashPosition = F_contractnumber.IndexOf("-TH"); - F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber; - } - else if (F_contractnumber.Contains("-HH")) - { - dashPosition = F_contractnumber.IndexOf("-HH"); - F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber; - } - else - { - dashPosition = -2; - } + var sBillId = entry == null ? 0 : entry["sBillId"].Long2Int(); - var sql = string.Format(@"SELECT COUNT(*) AS FNUMBER FROM T_SAL_ORDERENTRY_LK WHERE FSBILLID = '{0}' AND FRULEID = 'SaleOrder-ReturnSaleOrder'", sBillId); - var sqlDS = DBUtils.ExecuteDynamicObject(this.Context, sql); - String F_contractnumber2 = F_contractnumber; - int number; - if (F_contractnumber2.Contains("-") && dashPosition != -2) - { - number = F_contractnumber2.Substring(F_contractnumber2.Length - 2).Long2Int(); - } - else - { - number = sqlDS[0]["FNUMBER"].Long2Int(); - number += 1; - //if (number == 1) - //{ - // number += 1; - //} - } + //获取退货类型字段 + var F_Returntype = FEntity["F_Returntype"]; - string F_contractnumber1; + //获取纸质合同号 + string F_contractnumber = FEntity["F_contractnumber"].ToString(); - int IFnumber = sqlDS[0]["FNUMBER"].Long2Int(); + Logger.Error("销售订单上游订单的合同号", yuanF_contractnumber, new Exception()); + int dashPosition; + if (F_contractnumber.Contains("-TH")) + { - if (IFnumber != 0 && !F_Returntype.IsNullOrEmpty()) - { - F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + number.ToString(); - FEntity["F_contractnumber"]= F_contractnumber1; - break; - } - else if (!F_Returntype.IsNullOrEmpty() ) - { - F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + '1'; - FEntity["F_contractnumber"] = F_contractnumber1; - break; + dashPosition = F_contractnumber.IndexOf("-TH"); + F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber; + } + else if (F_contractnumber.Contains("-HH")) + { + dashPosition = F_contractnumber.IndexOf("-HH"); + F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber; + } + else + { + dashPosition = -2; + } + + var sql = string.Format(@"SELECT COUNT(*) AS FNUMBER FROM T_SAL_ORDERENTRY_LK WHERE FSBILLID = '{0}' AND FRULEID = 'SaleOrder-ReturnSaleOrder'", sBillId); + var sqlDS = DBUtils.ExecuteDynamicObject(this.Context, sql); + string F_contractnumber2 = F_contractnumber; + int number; + if (F_contractnumber2.Contains("-") && dashPosition != -2) + { + number = F_contractnumber2.Substring(F_contractnumber2.Length - 2).Long2Int(); + } + else + { + number = sqlDS[0]["FNUMBER"].Long2Int(); + number += 1; + //if (number == 1) + //{ + // number += 1; + //} + } + + string F_contractnumber1; + + int IFnumber = sqlDS[0]["FNUMBER"].Long2Int(); + + if (IFnumber != 0 && !F_Returntype.IsNullOrEmpty()) + { + F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + number.ToString(); + FEntity["F_contractnumber"] = F_contractnumber1; + break; + } + else if (!F_Returntype.IsNullOrEmpty()) + { + F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + '1'; + FEntity["F_contractnumber"] = F_contractnumber1; + break; + } } } } @@ -229,6 +241,10 @@ namespace Pilot_KD_Parino.Sal_Order } } } + catch (Exception ex) + { + Logger.Error("销售订单保存前刷正确的合同号报错:", ex.Message, new Exception()); + } } //public override void BeforeUpdateValue(BeforeUpdateValueEventArgs e) diff --git a/Pilot_KD_Parino/bin/Debug/DevExpress.Data.v13.1.dll b/Pilot_KD_Parino/bin/Debug/DevExpress.Data.v13.1.dll deleted file mode 100644 index f8e5b4f..0000000 Binary files a/Pilot_KD_Parino/bin/Debug/DevExpress.Data.v13.1.dll and /dev/null differ diff --git a/Pilot_KD_Parino/bin/Debug/DevExpress.Printing.v13.1.Core.dll b/Pilot_KD_Parino/bin/Debug/DevExpress.Printing.v13.1.Core.dll deleted file mode 100644 index d6d6b43..0000000 Binary files a/Pilot_KD_Parino/bin/Debug/DevExpress.Printing.v13.1.Core.dll and /dev/null differ diff --git a/Pilot_KD_Parino/bin/Debug/DevExpress.Utils.v13.1.dll b/Pilot_KD_Parino/bin/Debug/DevExpress.Utils.v13.1.dll deleted file mode 100644 index 143cbc7..0000000 Binary files a/Pilot_KD_Parino/bin/Debug/DevExpress.Utils.v13.1.dll and /dev/null differ diff --git a/Pilot_KD_Parino/bin/Debug/DevExpress.XtraEditors.v13.1.dll b/Pilot_KD_Parino/bin/Debug/DevExpress.XtraEditors.v13.1.dll deleted file mode 100644 index a157f79..0000000 Binary files a/Pilot_KD_Parino/bin/Debug/DevExpress.XtraEditors.v13.1.dll and /dev/null differ diff --git a/Pilot_KD_Parino/bin/Debug/GZ_KD_Parino.dll b/Pilot_KD_Parino/bin/Debug/GZ_KD_Parino.dll new file mode 100644 index 0000000..141360e Binary files /dev/null and b/Pilot_KD_Parino/bin/Debug/GZ_KD_Parino.dll differ diff --git a/查询.sql b/查询.sql new file mode 100644 index 0000000..d36ddb7 --- /dev/null +++ b/查询.sql @@ -0,0 +1,61 @@ +SELECT t0.FBILLNO AS '۳ⵥ' + ,t5_l.FNAME '֯' + ,t6_l.FNAME 'ɹ֯' + ,t0e.FENTRYID AS '۳ⵥ¼ID' + ,t0e.FREALQTY AS '' + ,t0e_m.FNUMBER AS '۳' + ,t1.FBILLNO AS '֪ͨ' + ,t1e.FENTRYID AS '֪ͨ¼ID' + ,t1e.FQTY AS '֪ͨ' + ,t1e_m.FNUMBER AS '֪ͨ' + ,t2.FBILLNO AS '۶' + ,t2e.FENTRYID AS '۶¼ID' + ,t2e.FQTY AS '' + ,t2e_m.FNUMBER AS '' + ,t3.FBILLNO AS 'ɹ' + ,t3e.FSEQ AS 'ɹк' + ,t3e.FENTRYID AS 'ɹ¼ID' + ,t3e.FQTY AS 'ɹ' + ,t3.FPURCHASEORGID + ,ISNULL(t4.FACTRECEIVEQTY,0) AS '' + ,ISNULL(t4.FREALQTY,0) 'ɹ' +FROM T_SAL_OUTSTOCK t0 + INNER JOIN T_SAL_OUTSTOCKENTRY t0e on t0e.FID = t0.FID + INNER JOIN T_BD_MATERIAL t0e_m on t0e_m.FMATERIALID = t0e.FMATERIALID + INNER JOIN T_SAL_OUTSTOCKENTRY_LK t0e_lk on t0e.FENTRYID = t0e_lk.FENTRYID + AND t0e_lk.FSTABLENAME = 'T_SAL_DELIVERYNOTICEENTRY' + INNER JOIN T_SAL_DELIVERYNOTICE t1 on t1.FID = t0e_lk.FSBILLID + INNER JOIN T_SAL_DELIVERYNOTICEENTRY t1e on t1.FID = t1e.FID AND t0e_lk.FSBILLID = t1e.FID AND t0e_lk.FSID = t1e.FENTRYID + INNER JOIN T_BD_MATERIAL t1e_m on t1e_m.FMATERIALID = t0e.FMATERIALID + INNER JOIN T_SAL_DELIVERYNOTICEENTRY_LK t1e_lk on t1e.FENTRYID = t1e_lk.FENTRYID + AND t1e_lk.FSTABLENAME = 'T_SAL_ORDERENTRY' + INNER JOIN T_SAL_ORDER t2 on t2.FID = t1e_lk.FSBILLID + INNER JOIN T_SAL_ORDERENTRY t2e on t1e_lk.FSBILLID = t2e.FID AND t1e_lk.FSID = t2e.FENTRYID + INNER JOIN T_BD_MATERIAL t2e_m on t2e_m.FMATERIALID = t0e.FMATERIALID + INNER JOIN T_SAL_ORDERENTRY_LK t2e_lk on t2e.FENTRYID = t2e_lk.FENTRYID + AND t2e_lk.FSTABLENAME = 't_PUR_POOrderEntry' + INNER JOIN T_PUR_POORDER t3 on t2e_lk.FSBILLID = t3.FID + --AND t3.FBILLNO = 'XN-CGDD2025091000001' + INNER JOIN T_PUR_POORDERENTRY t3e on t3.FID = t3e.FID AND t2e_lk.FSBILLID = t3e.FID AND t2e_lk.FSID = t3e.FENTRYID + INNER JOIN T_PUR_POORDERENTRY_LK t3e_lk on t3e_lk.FENTRYID = t3e.FENTRYID + OUTER APPLY ( + SELECT SUM(t4e.FACTRECEIVEQTY) 'FACTRECEIVEQTY',SUM(t5.FREALQTY) 'FREALQTY' + FROM T_PUR_RECEIVE t4 + INNER JOIN T_PUR_RECEIVEENTRY t4e on t4e.FID = t4.FID + INNER JOIN T_PUR_RECEIVEENTRY_LK t4e_lk on t4e_lk.FENTRYID = t4e.FENTRYID + AND t4e_lk.FSTABLENAME = 'T_PUR_POORDERENTRY' + OUTER APPLY ( + SELECT SUM(t5e.FREALQTY) 'FREALQTY' + FROM T_STK_INSTOCK t5 + INNER JOIN T_STK_INSTOCKENTRY t5e on t5.fID = t5e.FID + INNER JOIN T_STK_INSTOCKENTRY_LK t5e_lk on t5e_lk.FENTRYID = t5e.FENTRYID + AND t5e_lk.FSTABLENAME = 'T_PUR_RECEIVEENTRY' + WHERE t5e_lk.FSBILLID = t4e.FID AND t5e_lk.FSID = t4e.FENTRYID + GROUP BY t5e_lk.FSID + ) t5 + WHERE t3e.FENTRYID = t4e_lk.FSID AND t3e.FID = t4e_lk.FSBILLID + GROUP BY t4e_lk.FSID + ) t4 + INNER JOIN T_ORG_ORGANIZATIONS_L t5_l on t5_l.FORGID = t0.FSALEORGID AND t5_l.FLOCALEID = 2052 + INNER JOIN T_ORG_ORGANIZATIONS_L t6_l on t6_l.FORGID = t3.FPURCHASEORGID AND t6_l.FLOCALEID = 2052 +ORDER BY t3e.FID,t3e.FENTRYID \ No newline at end of file