Compare commits
14 Commits
4177536514
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f16f9b516e | ||
|
|
c98a91d0c9 | ||
|
|
37f9fd08fb | ||
|
|
62c55e5f14 | ||
|
|
944142a8ef | ||
|
|
6289385a96 | ||
| ecb9165876 | |||
| 73c9a20d92 | |||
|
|
7ef9e4587e | ||
|
|
14affa9131 | ||
|
|
5ad8d87250 | ||
| 45f851a9c9 | |||
| 1aeb8d47ef | |||
| 2cbb772c2c |
@@ -1,105 +0,0 @@
|
||||
using Kingdee.BOS;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||||
using Kingdee.BOS.Log;
|
||||
using Kingdee.BOS.Orm;
|
||||
using Kingdee.BOS.Orm.DataEntity;
|
||||
using Kingdee.BOS.ServiceHelper;
|
||||
using Kingdee.BOS.Util;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Dynamic;
|
||||
|
||||
namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.AR_SalesVATInvoice.ServicePlugIn
|
||||
{
|
||||
[HotUpdate, Description("销售增值税专用发票_保存后事件")]
|
||||
public class AfterSave : AbstractOperationServicePlugIn
|
||||
{
|
||||
public override void OnPreparePropertys(PreparePropertysEventArgs e)
|
||||
{
|
||||
base.OnPreparePropertys(e);
|
||||
// 根据日志中的实际实体属性名来添加
|
||||
e.FieldKeys.Add("FIDD");
|
||||
e.FieldKeys.Add("FSEQQ");
|
||||
e.FieldKeys.Add("SRCBILLTYPEID"); // 实体属性名(没有F前缀)
|
||||
e.FieldKeys.Add("SRCBILLNO"); // 实体属性名(没有F前缀)
|
||||
e.FieldKeys.Add("FSEQ");
|
||||
}
|
||||
|
||||
public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
|
||||
{
|
||||
base.AfterExecuteOperationTransaction(e);
|
||||
|
||||
foreach (var dataEntity in e.DataEntitys)
|
||||
{
|
||||
var billObj = dataEntity as DynamicObject;
|
||||
if (billObj == null)
|
||||
continue;
|
||||
|
||||
// 获取单据体
|
||||
var entrys = billObj["SALESICENTRY"] as DynamicObjectCollection;
|
||||
if (entrys == null || entrys.Count == 0)
|
||||
continue;
|
||||
|
||||
foreach (var entry in entrys)
|
||||
{
|
||||
// 使用 Id 获取主键值
|
||||
var entryId = Convert.ToInt64(entry.GetPrimaryKeyValue());
|
||||
var fidd = entry["FIDD"];
|
||||
var fiddValue = fidd == null ? 0 : Convert.ToInt64(fidd);
|
||||
|
||||
if (fiddValue > 0)
|
||||
{
|
||||
// FIDD > 0 时,判断是否需要回写
|
||||
var srcBillNo = entry["SRCBILLNO"]?.ToString() ?? "";
|
||||
|
||||
// 判断条件:FIDD != 当前行ID 且 源单编号为空
|
||||
if (fiddValue != entryId && string.IsNullOrWhiteSpace(srcBillNo))
|
||||
{
|
||||
// 查询源单据体信息(FID = fiddValue的明细行)
|
||||
// 这里使用数据库字段名(带F前缀)
|
||||
var sql = $@"/*dialect*/
|
||||
SELECT FSRCBILLTYPEID, FSRCBILLNO, FSEQ
|
||||
FROM T_IV_SALESICENTRY
|
||||
WHERE FENTRYID = {fiddValue}";
|
||||
Logger.Error("销售增值税专用发票", sql, new Exception());
|
||||
Logger.Error("销售增值税专用发票", "78", new Exception());
|
||||
var result = DBServiceHelper.ExecuteDynamicObject(this.Context, sql);
|
||||
if (result == null || result.Count == 0)
|
||||
continue;
|
||||
|
||||
var srcData = result[0];
|
||||
// 注意:SQL查询返回的是数据库字段名(带F前缀)
|
||||
var srcBillTypeId = srcData["FSRCBILLTYPEID"]?.ToString() ?? "";
|
||||
var srcBillNoValue = srcData["FSRCBILLNO"]?.ToString() ?? "";
|
||||
|
||||
// 回写当前单据体:源单类型、源单编号
|
||||
// 这里使用数据库字段名(带F前缀)
|
||||
var updateSql = $@"/*dialect*/
|
||||
UPDATE T_IV_SALESICENTRY
|
||||
SET FSRCBILLTYPEID = '{srcBillTypeId.Replace("'", "''")}',
|
||||
FSRCBILLNO = '{srcBillNoValue.Replace("'", "''")}'
|
||||
WHERE FENTRYID = {entryId}";
|
||||
Logger.Error("销售增值税专用发票", updateSql, new Exception());
|
||||
Logger.Error("销售增值税专用发票", "78", new Exception());
|
||||
DBServiceHelper.Execute(this.Context, updateSql);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIDD <= 0 时,把当前行FID赋值给FIDD,同时把FSEQ赋值给FSEQQ
|
||||
var seq = entry["FSEQ"]?.ToString() ?? "0";
|
||||
var updateSql = $@"/*dialect*/
|
||||
UPDATE T_IV_SALESICENTRY
|
||||
SET FIDD = {entryId},
|
||||
FSEQQ = '{seq.Replace("'", "''")}'
|
||||
WHERE FENTRYID = {entryId}";
|
||||
Logger.Error("销售增值税专用发票", updateSql, new Exception());
|
||||
Logger.Error("销售增值税专用发票", "78", new Exception());
|
||||
DBServiceHelper.Execute(this.Context, updateSql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,16 +74,11 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.Sal_Order
|
||||
}
|
||||
|
||||
//实际户折扣率
|
||||
var F_ActualDiscountRate = settlementPrice == 0 ? 100M : price / settlementPrice * 100;
|
||||
var F_ActualDiscountRate = CalculateActualDiscountRate(price, settlementPrice);
|
||||
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);
|
||||
}
|
||||
|
||||
//销售价格
|
||||
@@ -143,16 +138,12 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.Sal_Order
|
||||
}
|
||||
|
||||
//实际户折扣率
|
||||
var F_ActualDiscountRate = settlementPrice == 0 ? 100M : price / settlementPrice * 100;
|
||||
var F_ActualDiscountRate = CalculateActualDiscountRate(price, settlementPrice);
|
||||
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);
|
||||
}
|
||||
|
||||
//客户
|
||||
@@ -222,19 +213,16 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.Sal_Order
|
||||
}
|
||||
|
||||
//大客户折扣率
|
||||
var F_ActualDiscountRate = settlementPrice == 0 ? 100M : price / settlementPrice * 100;
|
||||
var F_ActualDiscountRate = CalculateActualDiscountRate(price, settlementPrice);
|
||||
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"))
|
||||
{
|
||||
//普通客户折扣率
|
||||
@@ -256,31 +244,28 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.Sal_Order
|
||||
{
|
||||
isBigCustFlag = creditClassification["Number"].ToString().EqualsIgnoreCase("KHXYFL013");
|
||||
}
|
||||
}
|
||||
|
||||
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<decimal>();
|
||||
|
||||
if (materialId_Id > 0)
|
||||
var actualDiscountRate = 0M;
|
||||
var actualDiscountRateList = new List<decimal>();
|
||||
foreach (var entry in entrys)
|
||||
{
|
||||
var tempRate = entry["ActualDiscountRate"].Convert<decimal>();
|
||||
var rowIndex = this.View.Model.GetRowIndex(details, entry);
|
||||
|
||||
if (actualDiscountRate == 0)
|
||||
actualDiscountRate = tempRate;
|
||||
else
|
||||
actualDiscountRate = tempRate < actualDiscountRate ? tempRate : actualDiscountRate;
|
||||
var materialId_Id = entry["MaterialId_Id"].Long2Int();
|
||||
|
||||
var price = entry["TaxPrice"].Convert<decimal>();
|
||||
|
||||
if (materialId_Id > 0)
|
||||
{
|
||||
var tempRate = entry["ActualDiscountRate"].Convert<decimal>();
|
||||
actualDiscountRateList.Add(tempRate);
|
||||
//actualDiscountRate = tempRate < actualDiscountRate ? tempRate : actualDiscountRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (custId_Id > 0)
|
||||
{
|
||||
if (isBigCustFlag)
|
||||
actualDiscountRate = actualDiscountRateList.Count == 0 ? 0M : actualDiscountRateList.Min();
|
||||
|
||||
if (!isBigCustFlag)
|
||||
{
|
||||
//普通客户折扣率
|
||||
this.Model.SetValue("F_CustSaleDiscountRate", actualDiscountRate);
|
||||
@@ -295,5 +280,27 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.Sal_Order
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算实际折扣率
|
||||
/// </summary>
|
||||
/// <param name="price"></param>
|
||||
/// <param name="settlementPrice"></param>
|
||||
/// <returns></returns>
|
||||
private decimal CalculateActualDiscountRate(decimal price, decimal settlementPrice)
|
||||
{
|
||||
var actualDiscountRate = 0M;
|
||||
|
||||
if (price != 0 && settlementPrice == 0)
|
||||
actualDiscountRate = 100;
|
||||
else if (price == 0 && settlementPrice != 0)
|
||||
actualDiscountRate = 0;
|
||||
else if (price == 0 && settlementPrice == 0)
|
||||
actualDiscountRate = 0;
|
||||
else
|
||||
actualDiscountRate = price / settlementPrice;
|
||||
|
||||
return actualDiscountRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
318
Gatedge.K3.Pilot.PlugIn/BOSPlugIn/Sal_Order/Bill2.cs
Normal file
318
Gatedge.K3.Pilot.PlugIn/BOSPlugIn/Sal_Order/Bill2.cs
Normal file
@@ -0,0 +1,318 @@
|
||||
using Gatedge.K3.Pilot.PlugIn.Services.DBService;
|
||||
using Kingdee.BOS.Core.Bill.PlugIn;
|
||||
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;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.Sal_Order
|
||||
{
|
||||
[HotUpdate, Description("销售订单_表单插件")]
|
||||
public class Bill2 : AbstractBillPlugIn
|
||||
{
|
||||
public override void DataChanged(DataChangedEventArgs e)
|
||||
{
|
||||
base.DataChanged(e);
|
||||
//物料
|
||||
if (e.Field.Key.EqualsIgnoreCase("FMaterialId"))
|
||||
{
|
||||
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<decimal>();
|
||||
//表头普通客户折扣率
|
||||
var F_CustSaleDiscountRate = this.View.Model.GetValue("F_CustSaleDiscountRate").Convert<decimal>();
|
||||
|
||||
var materialId_Id = e.NewValue.Long2Int();
|
||||
if (materialId_Id == 0)
|
||||
return;
|
||||
|
||||
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 dal = new BDCustPriceDAL(this.Context);
|
||||
var dateTime = this.View.Model.DataObject["Date"].Convert<DateTime>().ToString("yyyy-MM-dd");
|
||||
var resData = dal.GetMaterialPrice(materialId_Id, custId_Id, dateTime);
|
||||
if (resData != null && resData.Count > 0)
|
||||
{
|
||||
var data = resData[0];
|
||||
|
||||
//销售价格
|
||||
var price = this.Model.GetValue("FTaxPrice", e.Row).Convert<decimal>();
|
||||
//结算价格
|
||||
var settlementPrice = data["F_JSJ"].Convert<decimal>();
|
||||
|
||||
if (isBigCustFlag)
|
||||
{
|
||||
// 大客户结算价
|
||||
var bigCustSettlementPrice = data["F_BIGCUSTSETTLEPRICE"].Convert<decimal>();
|
||||
|
||||
if (bigCustSettlementPrice != 0)
|
||||
settlementPrice = bigCustSettlementPrice;
|
||||
|
||||
this.Model.SetValue("F_BIGCUSTSETTLEPRICE", bigCustSettlementPrice, e.Row);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 协议价
|
||||
var F_AGREEPRICE = data["F_AGREEPRICE"].Convert<decimal>();
|
||||
this.Model.SetValue("F_AGREEPRICE", F_AGREEPRICE, e.Row);
|
||||
}
|
||||
|
||||
//实际户折扣率
|
||||
var F_ActualDiscountRate = CalculateActualDiscountRate(price, settlementPrice);
|
||||
this.Model.SetValue("F_ActualDiscountRate", F_ActualDiscountRate, e.Row);
|
||||
this.View.InvokeFieldUpdateService("F_ActualDiscountRate", e.Row);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//销售价格
|
||||
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<decimal>();
|
||||
//表头普通客户折扣率
|
||||
var F_CustSaleDiscountRate = this.View.Model.GetValue("F_CustSaleDiscountRate").Convert<decimal>();
|
||||
|
||||
var price = e.NewValue.Convert<decimal>();
|
||||
|
||||
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<DateTime>().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<decimal>();
|
||||
|
||||
if (isBigCustFlag)
|
||||
{
|
||||
// 大客户结算价
|
||||
var bigCustSettlementPrice = data["F_BIGCUSTSETTLEPRICE"].Convert<decimal>();
|
||||
|
||||
if (bigCustSettlementPrice != 0)
|
||||
settlementPrice = bigCustSettlementPrice;
|
||||
|
||||
this.Model.SetValue("F_BIGCUSTSETTLEPRICE", bigCustSettlementPrice, e.Row);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 协议价
|
||||
var F_AGREEPRICE = data["F_AGREEPRICE"].Convert<decimal>();
|
||||
this.Model.SetValue("F_AGREEPRICE", F_AGREEPRICE, e.Row);
|
||||
}
|
||||
|
||||
//实际户折扣率
|
||||
var F_ActualDiscountRate = CalculateActualDiscountRate(price, settlementPrice);
|
||||
this.Model.SetValue("F_ActualDiscountRate", F_ActualDiscountRate, e.Row);
|
||||
this.View.InvokeFieldUpdateService("F_ActualDiscountRate", e.Row);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//客户
|
||||
if (e.Field.Key.EqualsIgnoreCase("FCustID"))
|
||||
{
|
||||
var custId_Id = e.NewValue.Long2Int();
|
||||
|
||||
var dal = new BDCustPriceDAL(this.Context);
|
||||
var dateTime = this.View.Model.DataObject["Date"].Convert<DateTime>().ToString("yyyy-MM-dd");
|
||||
var details = this.View.BusinessInfo.GetEntity("FSaleOrderEntry");
|
||||
if (details != null)
|
||||
{
|
||||
//表头大客户折扣率
|
||||
var F_BigCustSaleDiscountRate = this.View.Model.GetValue("F_BigCustSaleDiscountRate").Convert<decimal>();
|
||||
//表头普通客户折扣率
|
||||
var F_CustSaleDiscountRate = this.View.Model.GetValue("F_CustSaleDiscountRate").Convert<decimal>();
|
||||
|
||||
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<decimal>();
|
||||
var settlementPrice = 0M;
|
||||
this.Model.SetValue("F_AGREEPRICE", 0, rowIndex);
|
||||
this.Model.SetValue("F_BIGCUSTSETTLEPRICE", 0, rowIndex);
|
||||
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.Any())
|
||||
{
|
||||
var data = resData.FirstOrDefault();
|
||||
|
||||
//结算价格
|
||||
settlementPrice = data["F_JSJ"].Convert<decimal>();
|
||||
|
||||
if (isBigCustFlag)
|
||||
{
|
||||
// 大客户结算价
|
||||
var bigCustSettlementPrice = data["F_BIGCUSTSETTLEPRICE"].Convert<decimal>();
|
||||
|
||||
if (bigCustSettlementPrice != 0)
|
||||
settlementPrice = bigCustSettlementPrice;
|
||||
|
||||
this.Model.SetValue("F_BIGCUSTSETTLEPRICE", bigCustSettlementPrice, e.Row);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 协议价
|
||||
var F_AGREEPRICE = data["F_AGREEPRICE"].Convert<decimal>();
|
||||
this.Model.SetValue("F_AGREEPRICE", F_AGREEPRICE, rowIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//大客户折扣率
|
||||
var F_ActualDiscountRate = CalculateActualDiscountRate(price, settlementPrice);
|
||||
this.Model.SetValue("F_ActualDiscountRate", F_ActualDiscountRate, rowIndex);
|
||||
this.View.InvokeFieldUpdateService("F_ActualDiscountRate", rowIndex);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//实际折扣率
|
||||
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)
|
||||
{
|
||||
isBigCustFlag = creditClassification["Number"].ToString().EqualsIgnoreCase("KHXYFL013");
|
||||
}
|
||||
|
||||
var actualDiscountRate = 0M;
|
||||
var actualDiscountRateList = new List<decimal>();
|
||||
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<decimal>();
|
||||
|
||||
if (materialId_Id > 0)
|
||||
{
|
||||
var tempRate = entry["ActualDiscountRate"].Convert<decimal>();
|
||||
actualDiscountRateList.Add(tempRate);
|
||||
//actualDiscountRate = tempRate < actualDiscountRate ? tempRate : actualDiscountRate;
|
||||
}
|
||||
}
|
||||
|
||||
actualDiscountRate = actualDiscountRateList.Count == 0 ? 0M : actualDiscountRateList.Min();
|
||||
|
||||
if (!isBigCustFlag)
|
||||
{
|
||||
//普通客户折扣率
|
||||
this.Model.SetValue("F_CustSaleDiscountRate", actualDiscountRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
//大客户折扣率
|
||||
this.Model.SetValue("F_BigCustSaleDiscountRate", actualDiscountRate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算实际折扣率
|
||||
/// </summary>
|
||||
/// <param name="price"></param>
|
||||
/// <param name="settlementPrice"></param>
|
||||
/// <returns></returns>
|
||||
private decimal CalculateActualDiscountRate(decimal price, decimal settlementPrice)
|
||||
{
|
||||
var actualDiscountRate = 0M;
|
||||
|
||||
if (price != 0 && settlementPrice == 0)
|
||||
actualDiscountRate = 100;
|
||||
else if (price == 0 && settlementPrice != 0)
|
||||
actualDiscountRate = 0;
|
||||
else if (price == 0 && settlementPrice == 0)
|
||||
actualDiscountRate = 0;
|
||||
else
|
||||
actualDiscountRate = price / settlementPrice;
|
||||
|
||||
return actualDiscountRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,21 @@
|
||||
using Kingdee.BOS.Core.Bill.PlugIn;
|
||||
using Gatedge.K3.Pilot.PlugIn.Common;
|
||||
using Gatedge.K3.Pilot.PlugIn.Models;
|
||||
using Gatedge.K3.Pilot.PlugIn.Services.DBService;
|
||||
using Kingdee.BOS.App;
|
||||
using Kingdee.BOS.Contracts;
|
||||
using Kingdee.BOS.Core.Bill.PlugIn;
|
||||
using Kingdee.BOS.Core.Const;
|
||||
using Kingdee.BOS.Core.DynamicForm;
|
||||
using Kingdee.BOS.Core.DynamicForm.Operation;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||||
using Kingdee.BOS.Core.List;
|
||||
using Kingdee.BOS.Core.Metadata;
|
||||
using Kingdee.BOS.Core.Metadata.ConvertElement;
|
||||
using Kingdee.BOS.Core.Metadata.ConvertElement.ServiceArgs;
|
||||
using Kingdee.BOS.Orm;
|
||||
using Kingdee.BOS.Orm.DataEntity;
|
||||
using Kingdee.BOS.Util;
|
||||
using Kingdee.K3.BD.NewCode.Core.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -9,10 +25,251 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.Sal_OutStock
|
||||
{
|
||||
|
||||
|
||||
[Description("销售出库单插件"), HotUpdate]
|
||||
public class Bill : AbstractBillPlugIn
|
||||
{
|
||||
|
||||
public override void AfterDoOperation(AfterDoOperationEventArgs e)
|
||||
{
|
||||
base.AfterDoOperation(e);
|
||||
if (e.Operation.Operation.EqualsIgnoreCase("DoPushAOrgBill"))
|
||||
{
|
||||
var dataObj = this.View.Model.DataObject;
|
||||
var entry = dataObj["SAL_OUTSTOCKENTRY"] as DynamicObjectCollection;
|
||||
var dal = new SalOutStockDAL(this.Context);
|
||||
foreach (var item in entry)
|
||||
{
|
||||
var entryId = item["Id"].Long2Int();
|
||||
if (entryId != 0)
|
||||
{
|
||||
var datas = dal.GetSalOutStockSrcPO(entryId);
|
||||
List<ListSelectedRow> selectedRows = new List<ListSelectedRow>();
|
||||
if (datas != null)
|
||||
{
|
||||
foreach (var data in datas)
|
||||
{
|
||||
var outStockQty = item["合计出库数量"].Convert<decimal>();
|
||||
var poInStockQty = item["采购入库数量"].Convert<decimal>();
|
||||
var poDeviQty = item["收料数量"].Convert<decimal>();
|
||||
|
||||
if (outStockQty == poInStockQty)
|
||||
continue;
|
||||
|
||||
selectedRows.Add(new ListSelectedRow("0", item["采购订单分录内码"]?.ToString(), 0, ""));
|
||||
|
||||
var reSaveResult = PushPO2Re(selectedRows);
|
||||
|
||||
var selectRows = reSaveResult.SuccessDataEnity.SelectMany(x => x["PUR_ReceiveEntry"] as DynamicObjectCollection).Select(x => new ListSelectedRow("0", x["Id"].Long2Int().ToString(), 0, "")).ToList();
|
||||
if (selectRows.Count > 0)
|
||||
{
|
||||
var isResult = PushRe2InStock(selectRows);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IOperationResult PushPO2Re(List<ListSelectedRow> selectedRows)
|
||||
{
|
||||
IOperationResult result = null;
|
||||
|
||||
try
|
||||
{
|
||||
string sourceFormId = FormIdConstants.PUR_PurchaseOrder;
|
||||
string targetFormId = FormIdConstants.PUR_ReceiveBill;
|
||||
string convertRuleId = "PUR_PurchaseOrder-PUR_ReceiveBill";
|
||||
//PUR_ReceiveBill-STK_InStock
|
||||
result = DoPustBill(selectedRows, sourceFormId, targetFormId, convertRuleId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = new OperationResult();
|
||||
result.IsSuccess = false;
|
||||
var opResFirst = new OperateResult();
|
||||
opResFirst.Name = ex.Message;
|
||||
opResFirst.Message = ex.Message + "\r\n" + ex.StackTrace;
|
||||
opResFirst.SuccessStatus = false;
|
||||
result.OperateResult.Add(opResFirst);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private IOperationResult PushRe2InStock(List<ListSelectedRow> selectedRows)
|
||||
{
|
||||
IOperationResult result = null;
|
||||
|
||||
try
|
||||
{
|
||||
string sourceFormId = FormIdConstants.PUR_ReceiveBill;
|
||||
string targetFormId = FormIdConstants.STK_InStock;
|
||||
string convertRuleId = "PUR_ReceiveBill-STK_InStock";
|
||||
//PUR_ReceiveBill-STK_InStock
|
||||
result = DoPustBill(selectedRows, sourceFormId, targetFormId, convertRuleId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = new OperationResult();
|
||||
result.IsSuccess = false;
|
||||
var opResFirst = new OperateResult();
|
||||
opResFirst.Name = ex.Message;
|
||||
opResFirst.Message = ex.Message + "\r\n" + ex.StackTrace;
|
||||
opResFirst.SuccessStatus = false;
|
||||
result.OperateResult.Add(opResFirst);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销售订单下推发货通知单
|
||||
/// </summary>
|
||||
/// <param name="selectedRows"></param>
|
||||
/// <returns></returns>
|
||||
private IOperationResult PushSO2De(List<ListSelectedRow> selectedRows)
|
||||
{
|
||||
IOperationResult result = null;
|
||||
|
||||
try
|
||||
{
|
||||
string sourceFormId = FormIdConstants.SAL_SaleOrder;
|
||||
string targetFormId = FormIdConstants.SAL_DELIVERYNOTICE;
|
||||
string convertRuleId = "SaleOrder-DeliveryNotice";
|
||||
//PUR_ReceiveBill-STK_InStock
|
||||
result = DoPustBill(selectedRows, sourceFormId, targetFormId, convertRuleId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = new OperationResult();
|
||||
result.IsSuccess = false;
|
||||
var opResFirst = new OperateResult();
|
||||
opResFirst.Name = ex.Message;
|
||||
opResFirst.Message = ex.Message + "\r\n" + ex.StackTrace;
|
||||
opResFirst.SuccessStatus = false;
|
||||
result.OperateResult.Add(opResFirst);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发货通知单下推销售出库单
|
||||
/// </summary>
|
||||
/// <param name="selectedRows"></param>
|
||||
/// <returns></returns>
|
||||
private IOperationResult PushDe2OS(List<ListSelectedRow> selectedRows)
|
||||
{
|
||||
IOperationResult result = null;
|
||||
|
||||
try
|
||||
{
|
||||
string sourceFormId = FormIdConstants.SAL_DELIVERYNOTICE;
|
||||
string targetFormId = FormIdConstants.SAL_OUTSTOCK;
|
||||
string convertRuleId = "DeliveryNotice-OutStock";
|
||||
//PUR_ReceiveBill-STK_InStock
|
||||
result = DoPustBill(selectedRows, sourceFormId, targetFormId, convertRuleId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = new OperationResult();
|
||||
result.IsSuccess = false;
|
||||
var opResFirst = new OperateResult();
|
||||
opResFirst.Name = ex.Message;
|
||||
opResFirst.Message = ex.Message + "\r\n" + ex.StackTrace;
|
||||
opResFirst.SuccessStatus = false;
|
||||
result.OperateResult.Add(opResFirst);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下推单据
|
||||
/// </summary>
|
||||
/// <param name="selectedRows"></param>
|
||||
/// <param name="sourceFormId"></param>
|
||||
/// <param name="targetFormId"></param>
|
||||
/// <param name="convertRuleId"></param>
|
||||
/// <returns></returns>
|
||||
private IOperationResult DoPustBill(List<ListSelectedRow> selectedRows, string sourceFormId, string targetFormId, string convertRuleId)
|
||||
{
|
||||
IOperationResult result = null;
|
||||
|
||||
try
|
||||
{
|
||||
IConvertService service = ServiceHelper.GetService<IConvertService>();
|
||||
|
||||
//获取元数据服务
|
||||
IMetaDataService metadataService = ServiceHelper.GetService<IMetaDataService>();
|
||||
|
||||
//获取ViewService
|
||||
IViewService viewService = ServiceHelper.GetService<IViewService>();
|
||||
//获取源单元数据
|
||||
|
||||
//获取转换规则
|
||||
var ruleMeta = service.GetConvertRule(this.Context, convertRuleId);
|
||||
|
||||
if (ruleMeta != null)
|
||||
{
|
||||
FormMetadata sourceMetada = metadataService.Load(this.Context, sourceFormId) as FormMetadata;
|
||||
|
||||
var policies = ruleMeta.Rule.Policies;
|
||||
//字段映射关系
|
||||
var policie7002 = policies.FirstOrDefault(x => x.ElementType == 7002) as DefaultConvertPolicyElement;
|
||||
if (policie7002 == null)
|
||||
throw new Exception("转换单据中,字段映射关系类型值:7002不存在。");
|
||||
|
||||
//单据类型映射
|
||||
var policie7009 = policies.FirstOrDefault(x => x.ElementType == 7009) as BillTypeMapPolicyElement;
|
||||
if (policie7009 == null)
|
||||
throw new Exception("转换单据中,单据类型属性类型值:7009不存在。");
|
||||
var billTypeMap = policie7009.BillTypeMaps.FirstOrDefault();
|
||||
|
||||
if (billTypeMap == null)
|
||||
throw new Exception($"转换规则中,源单单据类型不存在!");
|
||||
|
||||
var sourceBillTypeId = billTypeMap.SourceBillTypeId;
|
||||
var targetBillTypeId = billTypeMap.TargetBillTypeId;
|
||||
//设置来源单据类型
|
||||
selectedRows.ForEach(x =>
|
||||
{
|
||||
x.EntryEntityKey = policie7002.SourceEntryKey;
|
||||
});
|
||||
|
||||
var pushArgs = new PushArgs(ruleMeta.Rule, selectedRows.ToArray());
|
||||
pushArgs.TargetBillTypeId = targetBillTypeId;
|
||||
OperateOption option = OperateOption.Create();//选项参数
|
||||
|
||||
option.SetVariableValue(ConvertConst.SelectByBillId, false);//不按照整单下推
|
||||
|
||||
//源单数据转换目标数据
|
||||
ConvertOperationResult convertResult = service.Push(this.Context, pushArgs, option);
|
||||
|
||||
DynamicObject[] destObjs = convertResult.TargetDataEntities.Select(r => r.DataEntity).ToArray();
|
||||
|
||||
FormMetadata destFormMetadata = metadataService.Load(this.Context, targetFormId) as FormMetadata;
|
||||
|
||||
IOperationResult saveResult = ServiceHelper.GetService<ISaveService>().SaveAndAudit(this.Context, destFormMetadata.BusinessInfo, destObjs, OperateOption.Create());
|
||||
|
||||
result = saveResult;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = new OperationResult();
|
||||
result.IsSuccess = false;
|
||||
var opResFirst = new OperateResult();
|
||||
opResFirst.Name = ex.Message;
|
||||
opResFirst.Message = ex.Message + "\r\n" + ex.StackTrace;
|
||||
opResFirst.SuccessStatus = false;
|
||||
result.OperateResult.Add(opResFirst);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
45
Gatedge.K3.Pilot.PlugIn/Common/FormIdConstants.cs
Normal file
45
Gatedge.K3.Pilot.PlugIn/Common/FormIdConstants.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Gatedge.K3.Pilot.PlugIn.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// 常用formId
|
||||
/// </summary>
|
||||
public static class FormIdConstants
|
||||
{
|
||||
/// <summary>
|
||||
/// 采购订单
|
||||
/// </summary>
|
||||
public const string PUR_PurchaseOrder = "PUR_PurchaseOrder";
|
||||
|
||||
/// <summary>
|
||||
/// 收料通知单
|
||||
/// </summary>
|
||||
public const string PUR_ReceiveBill = "PUR_ReceiveBill";
|
||||
|
||||
/// <summary>
|
||||
/// 采购入库单
|
||||
/// </summary>
|
||||
public const string STK_InStock = "STK_InStock";
|
||||
|
||||
/// <summary>
|
||||
/// 销售出库单
|
||||
/// </summary>
|
||||
public const string SAL_OUTSTOCK = "SAL_OUTSTOCK";
|
||||
|
||||
/// <summary>
|
||||
/// 销售订单
|
||||
/// </summary>
|
||||
public const string SAL_SaleOrder = "SAL_SaleOrder";
|
||||
|
||||
/// <summary>
|
||||
/// 发货通知单
|
||||
/// </summary>
|
||||
public const string SAL_DELIVERYNOTICE = "SAL_DELIVERYNOTICE";
|
||||
|
||||
}
|
||||
}
|
||||
@@ -94,13 +94,18 @@
|
||||
<Compile Include="BOSPlugIn\BD_CustPrice\ServicePlugIn\SaveValidator.cs" />
|
||||
<Compile Include="BOSPlugIn\CUST_PAYMENT_PERIOD\List.cs" />
|
||||
<Compile Include="BOSPlugIn\Sal_Order\Bill.cs" />
|
||||
<Compile Include="BOSPlugIn\Sal_Order\Bill2.cs" />
|
||||
<Compile Include="BOSPlugIn\Sal_OutStock\Bill.cs" />
|
||||
<Compile Include="Common\FormIdConstants.cs" />
|
||||
<Compile Include="Models\POPush.cs" />
|
||||
<Compile Include="Models\Validate\PeriodValidity.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Services\DBService\BaseDAL.cs" />
|
||||
<Compile Include="Services\DBService\BDCustPriceDAL.cs" />
|
||||
<Compile Include="Services\DBService\SalOutStockDAL.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="BOSPlugIn\AR_SalesVATInvoice\ServicePlugIn\" />
|
||||
<Folder Include="BOSPlugIn\Sal_Order\ServicePlugIn\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
16
Gatedge.K3.Pilot.PlugIn/Models/POPush.cs
Normal file
16
Gatedge.K3.Pilot.PlugIn/Models/POPush.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Gatedge.K3.Pilot.PlugIn.Models
|
||||
{
|
||||
public class POPush
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int entryId { get; set; }
|
||||
|
||||
public decimal qty { get; set; }
|
||||
}
|
||||
}
|
||||
97
Gatedge.K3.Pilot.PlugIn/Services/DBService/SalOutStockDAL.cs
Normal file
97
Gatedge.K3.Pilot.PlugIn/Services/DBService/SalOutStockDAL.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using Kingdee.BOS;
|
||||
using Kingdee.BOS.Orm.DataEntity;
|
||||
using Kingdee.BOS.ServiceHelper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Gatedge.K3.Pilot.PlugIn.Services.DBService
|
||||
{
|
||||
public class SalOutStockDAL : BaseDAL
|
||||
{
|
||||
public SalOutStockDAL(Context context) : base(context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取销售出库单的订单数据
|
||||
/// </summary>
|
||||
/// <param name="entryId"></param>
|
||||
/// <returns></returns>
|
||||
public DynamicObjectCollection GetSalOutStockSrcPO(int entryId)
|
||||
{
|
||||
var sql = $@"/*dialect*/
|
||||
|
||||
WITH #销售出库单采购入库 AS (
|
||||
SELECT t0.FBILLNO AS '销售出库单'
|
||||
,t0.FDATE AS '销售出库日期'
|
||||
,t0e.FENTRYID AS '销售出库单分录ID'
|
||||
,t0e.FREALQTY AS '出库数量'
|
||||
,SUM(t0e.FREALQTY) OVER (PARTITION BY t3e.FENTRYID) '合计出库数量'
|
||||
,t1.FBILLNO AS '发货通知单'
|
||||
,t1e.FENTRYID AS '发货通知单分录ID'
|
||||
,t1e.FQTY AS '通知数量'
|
||||
,t2.FBILLNO AS '销售订单'
|
||||
,t2e.FENTRYID AS '销售订单分录ID'
|
||||
,t2e.FQTY AS '订单数量'
|
||||
,t3.FBILLNO AS '采购订单'
|
||||
,t3.FDATE AS '采购日期'
|
||||
,t3e.FSEQ AS '采购订单行号'
|
||||
,t3e.FID AS '采购订单内码'
|
||||
,t3e.FENTRYID AS '采购订单分录内码'
|
||||
,t3e.FQTY AS '采购数量'
|
||||
,ISNULL(t4.FACTRECEIVEQTY,0) AS '收料数量'
|
||||
,ISNULL(t4.FREALQTY,0) '采购入库数量'
|
||||
--INTO #销售出库单采购入库
|
||||
FROM T_SAL_OUTSTOCK t0
|
||||
INNER JOIN T_SAL_OUTSTOCKENTRY t0e on t0e.FID = t0.FID
|
||||
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_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_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
|
||||
INNER JOIN T_PUR_POORDERENTRY t3e on t3.FID = t3e.FID AND t2e_lk.FSBILLID = t3e.FID AND t2e_lk.FSID = t3e.FENTRYID
|
||||
AND t3e.FMRPCLOSESTATUS = 'A'
|
||||
INNER JOIN T_PUR_POORDERENTRY_LK t3e_lk on t3e_lk.FENTRYID = t3e.FENTRYID
|
||||
OUTER APPLY (
|
||||
SELECT SUM(t4e.FACTRECEIVEQTY) 'FACTRECEIVEQTY',SUM(ISNULL(t5.FREALQTY,0)) 'FREALQTY'
|
||||
--,STRING_AGG(t4e.FENTRYID,';') '收料单分录ID'
|
||||
--,STRING_AGG(ISNULL(t5.FREALQTY,0),';') '收料单分录入库数量'
|
||||
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 t5e_lk.FSID,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
|
||||
WHERE t3.FCLOSESTATUS = 'A'
|
||||
)
|
||||
SELECT t0.*
|
||||
FROM #销售出库单采购入库 t0
|
||||
WHERE 1 = 1
|
||||
AND t0.销售出库单分录ID = {entryId}
|
||||
ORDER BY t0.采购订单,t0.采购订单行号,t0.销售出库日期,t0.销售出库单分录ID
|
||||
|
||||
";
|
||||
return DBServiceHelper.ExecuteDynamicObject(this.Context, sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
using Kingdee.BOS.Core.Bill.PlugIn;
|
||||
using Kingdee.BOS.Core.Bill.PlugIn;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||||
using Kingdee.BOS.Util;
|
||||
using System.ComponentModel;
|
||||
|
||||
@@ -9,7 +9,7 @@ using Kingdee.BOS.Util;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.AR_SalesVATInvoice.ServicePlugIn
|
||||
namespace Pilot_KD_Parino.AR_SalesVATInvoice.ServicePlugIn
|
||||
{
|
||||
[HotUpdate, Description("销售增值税专用发票_保存后事件")]
|
||||
public class AfterSave : AbstractOperationServicePlugIn
|
||||
@@ -23,82 +23,93 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.AR_SalesVATInvoice.ServicePlugIn
|
||||
e.FieldKeys.Add("SRCBILLTYPEID"); // 实体属性名(没有F前缀)
|
||||
e.FieldKeys.Add("SRCBILLNO"); // 实体属性名(没有F前缀)
|
||||
e.FieldKeys.Add("SEQ");
|
||||
e.FieldKeys.Add("BILLNO"); // 单据编号(主表字段)
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void EndOperationTransaction(EndOperationTransactionArgs e)
|
||||
{
|
||||
base.EndOperationTransaction(e);
|
||||
foreach (var dataEntity in e.DataEntitys)
|
||||
try
|
||||
{
|
||||
var billObj = dataEntity as DynamicObject;
|
||||
if (billObj == null)
|
||||
continue;
|
||||
|
||||
// 获取单据体
|
||||
var entrys = billObj["SALESICENTRY"] as DynamicObjectCollection;
|
||||
if (entrys == null || entrys.Count == 0)
|
||||
continue;
|
||||
|
||||
foreach (var entry in entrys)
|
||||
foreach (var dataEntity in e.DataEntitys)
|
||||
{
|
||||
// 使用 Id 获取主键值
|
||||
var entryId = Convert.ToInt64(entry.GetPrimaryKeyValue());
|
||||
var fidd = entry["FIDD"];
|
||||
var fiddValue = fidd == null ? 0 : Convert.ToInt64(fidd);
|
||||
var billObj = dataEntity as DynamicObject;
|
||||
if (billObj == null)
|
||||
continue;
|
||||
|
||||
if (fiddValue > 0)
|
||||
// 获取单据体
|
||||
var entrys = billObj["SALESICENTRY"] as DynamicObjectCollection;
|
||||
if (entrys == null || entrys.Count == 0)
|
||||
continue;
|
||||
|
||||
foreach (var entry in entrys)
|
||||
{
|
||||
// FIDD > 0 时,判断是否需要回写
|
||||
var srcBillNo = entry["SRCBILLNO"]?.ToString() ?? "";
|
||||
// 使用 Id 获取主键值
|
||||
var entryId = Convert.ToInt64(entry.GetPrimaryKeyValue());
|
||||
var fidd = entry["FIDD"];
|
||||
var fiddValue = fidd == null ? 0 : Convert.ToInt64(fidd);
|
||||
|
||||
// 判断条件:FIDD != 当前行ID 且 源单编号为空
|
||||
if (fiddValue != entryId && string.IsNullOrWhiteSpace(srcBillNo))
|
||||
if (fiddValue > 0)
|
||||
{
|
||||
// 查询源单据体信息(FID = fiddValue的明细行)
|
||||
// 这里使用数据库字段名(带F前缀)
|
||||
var sql = $@"/*dialect*/
|
||||
SELECT FSRCBILLTYPEID, FSRCBILLNO, FSEQ
|
||||
FROM T_IV_SALESICENTRY
|
||||
WHERE FENTRYID = {fiddValue}";
|
||||
Logger.Error("销售增值税专用发票", sql, new Exception());
|
||||
Logger.Error("销售增值税专用发票", "78", new Exception());
|
||||
var result = DBServiceHelper.ExecuteDynamicObject(this.Context, sql);
|
||||
if (result == null || result.Count == 0)
|
||||
continue;
|
||||
// FIDD > 0 时,判断是否需要回写
|
||||
var srcBillNo = entry["SRCBILLNO"]?.ToString() ?? "";
|
||||
|
||||
var srcData = result[0];
|
||||
// 注意:SQL查询返回的是数据库字段名(带F前缀)
|
||||
var srcBillTypeId = srcData["FSRCBILLTYPEID"]?.ToString() ?? "";
|
||||
var srcBillNoValue = srcData["FSRCBILLNO"]?.ToString() ?? "";
|
||||
// 判断条件:FIDD != 当前行ID 且 源单编号为空
|
||||
if (fiddValue != entryId && string.IsNullOrWhiteSpace(srcBillNo))
|
||||
{
|
||||
// 通过源分录ID(FIDD)查询源单据的单据编号
|
||||
string srcBillNoFromSource = "";
|
||||
|
||||
// 回写当前单据体:源单类型、源单编号
|
||||
// 这里使用数据库字段名(带F前缀)
|
||||
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 = '{srcBillNoFromSource.Replace("'", "''")}'
|
||||
WHERE FENTRYID = {entryId}";
|
||||
Logger.Error("销售增值税专用发票_回写源单信息", updateSql, new Exception());
|
||||
DBServiceHelper.Execute(this.Context, updateSql);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIDD <= 0 时,把当前行FID赋值给FIDD,同时把FSEQ赋值给FSEQQ
|
||||
var seq = entry["SEQ"]?.ToString() ?? "0";
|
||||
var updateSql = $@"/*dialect*/
|
||||
UPDATE T_IV_SALESICENTRY
|
||||
SET FSRCBILLTYPEID = '{srcBillTypeId.Replace("'", "''")}',
|
||||
FSRCBILLNO = '{srcBillNoValue.Replace("'", "''")}'
|
||||
SET FIDD = {entryId},
|
||||
FSEQQ = '{seq.Replace("'", "''")}'
|
||||
WHERE FENTRYID = {entryId}";
|
||||
Logger.Error("销售增值税专用发票", updateSql, new Exception());
|
||||
Logger.Error("销售增值税专用发票", "78", new Exception());
|
||||
DBServiceHelper.Execute(this.Context, updateSql);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIDD <= 0 时,把当前行FID赋值给FIDD,同时把FSEQ赋值给FSEQQ
|
||||
var seq = entry["SEQ"]?.ToString() ?? "0";
|
||||
var updateSql = $@"/*dialect*/
|
||||
UPDATE T_IV_SALESICENTRY
|
||||
SET FIDD = {entryId},
|
||||
FSEQQ = '{seq.Replace("'", "''")}'
|
||||
WHERE FENTRYID = {entryId}";
|
||||
Logger.Error("销售增值税专用发票", updateSql, new Exception());
|
||||
Logger.Error("销售增值税专用发票", "78", new Exception());
|
||||
DBServiceHelper.Execute(this.Context, updateSql);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error("销售增值税专用发票出错了:", ex.Message, new Exception());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Pilot_KD_Parino.Common
|
||||
Row previousRowNew = (Row)table.Rows[1];
|
||||
Row previousRowthreeNew = (Row)table.Rows[2];
|
||||
Row previousRowfourNew = (Row)table.Rows[3];
|
||||
for (int i = 1; i <=3; i++)
|
||||
for (int i = 1; i <= 3; i++)
|
||||
{
|
||||
table.Rows[i].Remove();
|
||||
}
|
||||
@@ -146,7 +146,7 @@ namespace Pilot_KD_Parino.Common
|
||||
int j = 0;
|
||||
foreach (var Row in Rows)
|
||||
{
|
||||
Row newRowthree = table.InsertRow(previousRowthree, 1+j);
|
||||
Row newRowthree = table.InsertRow(previousRowthree, 1 + j);
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
newRowthree.Cells[i].ReplaceText("{" + i.ToString() + "}", Convert.ToString(Row[i]));
|
||||
@@ -1019,7 +1019,7 @@ namespace Pilot_KD_Parino.Common
|
||||
{
|
||||
FBILLNO = "";
|
||||
Id = "";
|
||||
|
||||
|
||||
// 调用保存操作
|
||||
IOperationResult saveResult = BusinessDataServiceHelper.Save(
|
||||
ctx,
|
||||
@@ -1058,10 +1058,10 @@ namespace Pilot_KD_Parino.Common
|
||||
else if (saveResult.IsSuccess == false)
|
||||
{
|
||||
saveResult.IsShowMessage = true;
|
||||
|
||||
|
||||
//billView.ShowErrMessage(saveResult.InteractionContext.SimpleMessage);
|
||||
|
||||
var dd=saveResult.ValidationErrors.FirstOrDefault();
|
||||
|
||||
var dd = saveResult.ValidationErrors.FirstOrDefault();
|
||||
if (dd != null)
|
||||
billView.ShowErrMessage(dd.Message);
|
||||
else
|
||||
|
||||
@@ -7,6 +7,7 @@ using Kingdee.BOS.Log;
|
||||
using Kingdee.BOS.Orm.DataEntity;
|
||||
using Kingdee.BOS.ServiceHelper;
|
||||
using Kingdee.BOS.Util;
|
||||
using NPOI.Util;
|
||||
using Pilot_KD_Parino.Common;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
@@ -153,8 +154,11 @@ namespace Pilot_KD_Parino.Sal_Order
|
||||
if (FSaleOrderEntry_Link.Count > 0)
|
||||
{
|
||||
var details = FSaleOrderEntry_Link[0]["FSaleOrderEntry_Link"] as DynamicObjectCollection;
|
||||
//string sdas=JsonHelper.ToJson(details);
|
||||
// Logger.Error("销售订单上游订单的xx ", sdas, new Exception());
|
||||
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");
|
||||
|
||||
@@ -164,7 +168,7 @@ namespace Pilot_KD_Parino.Sal_Order
|
||||
|
||||
if (entrys != null && entrys.Count > 0)
|
||||
{
|
||||
string yuanF_contractnumber = FEntity["F_contractnumber"].ToString();
|
||||
string yuanF_contractnumber = "";
|
||||
int i = 0;
|
||||
foreach (var entry in entrys)
|
||||
{
|
||||
@@ -173,14 +177,26 @@ namespace Pilot_KD_Parino.Sal_Order
|
||||
i++;
|
||||
|
||||
var sBillId = entry == null ? 0 : entry["sBillId"].Long2Int();
|
||||
//销售订单找到上游的销售订单
|
||||
string getSourceSql = $@"/*dialect*/select F_CONTRACTNUMBER from T_SAL_ORDER where fid={sBillId} ";
|
||||
var dt333 = DBServiceHelper.ExecuteDynamicObject(this.Context, getSourceSql);
|
||||
if (dt333 == null || dt333.Count == 0)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
yuanF_contractnumber = dt333.FirstOrDefault()["F_CONTRACTNUMBER"].ToString();
|
||||
}
|
||||
|
||||
//获取退货类型字段
|
||||
var F_Returntype = FEntity["F_Returntype"];
|
||||
|
||||
//获取纸质合同号
|
||||
string F_contractnumber = FEntity["F_contractnumber"].ToString();
|
||||
|
||||
Logger.Error("销售订单上游订单的合同号", yuanF_contractnumber, new Exception());
|
||||
Logger.Error("销售订单上游订单的合同号"+ i.ToString(), yuanF_contractnumber, new Exception());
|
||||
int dashPosition;
|
||||
if (F_contractnumber.Contains("-TH"))
|
||||
{
|
||||
|
||||
42
修改合同号一些列订单.txt
Normal file
42
修改合同号一些列订单.txt
Normal file
@@ -0,0 +1,42 @@
|
||||
select F_CONTRACTNUMBER, * from T_SAL_ORDER
|
||||
where fbillno='PL-XSDD20251200583'
|
||||
|
||||
--update T_SAL_ORDER set F_CONTRACTNUMBER='P202512090017-HH01'
|
||||
--where fbillno='PL-XSDD20251200583'
|
||||
|
||||
|
||||
select F_Papercontract, * from T_SAL_DELIVERYNOTICE
|
||||
where FBillNo='SEOUT25121086'
|
||||
|
||||
--update T_SAL_DELIVERYNOTICE set F_Papercontract='P202512090017-HH01'
|
||||
--where FBillNo='SEOUT25121086'
|
||||
|
||||
select F_contractnumber,* from T_SAL_OUTSTOCK
|
||||
where FBillNo='PL-XSCKD20251200647'
|
||||
|
||||
--update T_SAL_OUTSTOCK set F_contractnumber='P202512090017-HH01'
|
||||
--where FBillNo='PL-XSCKD20251200647'
|
||||
|
||||
|
||||
select F_Paperpro,* from T_AR_RECEIVABLE
|
||||
where FBillNo='PL-XSCKD20251200647'
|
||||
|
||||
|
||||
--update T_AR_RECEIVABLE set F_Paperpro='P202512090017-HH01'
|
||||
--where FBillNo='PL-XSCKD20251200647'
|
||||
|
||||
select F_Paper,* from T_AR_RECEIVABLEENTRY
|
||||
where fid=129824
|
||||
|
||||
--update T_AR_RECEIVABLEENTRY set F_Paper='P202512090017-HH01'
|
||||
--where fid=129824
|
||||
|
||||
select * from T_PRD_MO a
|
||||
where FBillNo='PL-MO20251201392'
|
||||
|
||||
|
||||
select F_ZZHTH,* from T_PRD_MOENTRY b
|
||||
where fid=129745
|
||||
|
||||
--update T_PRD_MOENTRY set F_ZZHTH='P202512090017-HH01'
|
||||
--where fid=129745
|
||||
131
查询.sql
131
查询.sql
@@ -1,61 +1,70 @@
|
||||
SELECT t0.FBILLNO AS '<EFBFBD><EFBFBD><EFBFBD>۳<EFBFBD><EFBFBD>ⵥ'
|
||||
,t5_l.FNAME '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֯'
|
||||
,t6_l.FNAME '<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>֯'
|
||||
,t0e.FENTRYID AS '<EFBFBD><EFBFBD><EFBFBD>۳<EFBFBD><EFBFBD>ⵥ<EFBFBD><EFBFBD>¼ID'
|
||||
,t0e.FREALQTY AS '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t0e_m.FNUMBER AS '<EFBFBD><EFBFBD><EFBFBD>۳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t1.FBILLNO AS '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪ͨ<EFBFBD><EFBFBD>'
|
||||
,t1e.FENTRYID AS '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼ID'
|
||||
,t1e.FQTY AS '֪ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t1e_m.FNUMBER AS '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t2.FBILLNO AS '<EFBFBD><EFBFBD><EFBFBD>۶<EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t2e.FENTRYID AS '<EFBFBD><EFBFBD><EFBFBD>۶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼ID'
|
||||
,t2e.FQTY AS '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t2e_m.FNUMBER AS '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t3.FBILLNO AS '<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t3e.FSEQ AS '<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD>'
|
||||
,t3e.FENTRYID AS '<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼ID'
|
||||
,t3e.FQTY AS '<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t3.FPURCHASEORGID
|
||||
,ISNULL(t4.FACTRECEIVEQTY,0) AS '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,ISNULL(t4.FREALQTY,0) '<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
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
|
||||
--DROP TABLE IF EXISTS #<23><><EFBFBD>۳<EFBFBD><DBB3>ⵥ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>
|
||||
WITH #<EFBFBD><EFBFBD><EFBFBD>۳<EFBFBD><EFBFBD>ⵥ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS (
|
||||
SELECT t0.FBILLNO AS '<EFBFBD><EFBFBD><EFBFBD>۳<EFBFBD><EFBFBD>ⵥ'
|
||||
,t0e.FENTRYID AS '<EFBFBD><EFBFBD><EFBFBD>۳<EFBFBD><EFBFBD>ⵥ<EFBFBD><EFBFBD>¼ID'
|
||||
,t0e.FREALQTY AS '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,SUM(t0e.FREALQTY) OVER (PARTITION BY t3e.FENTRYID) '<EFBFBD>ϼƳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t1.FBILLNO AS '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪ͨ<EFBFBD><EFBFBD>'
|
||||
,t1e.FENTRYID AS '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼ID'
|
||||
,t1e.FQTY AS '֪ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t2.FBILLNO AS '<EFBFBD><EFBFBD><EFBFBD>۶<EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t2e.FENTRYID AS '<EFBFBD><EFBFBD><EFBFBD>۶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼ID'
|
||||
,t2e.FQTY AS '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t3.FBILLNO AS '<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t3.FDATE AS '<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,t3e.FSEQ AS '<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD>'
|
||||
,t3e.FENTRYID AS '<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼ID'
|
||||
,t3e.FQTY AS '<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,ISNULL(t4.FACTRECEIVEQTY,0) AS '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
,ISNULL(t4.FREALQTY,0) '<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
--,ISNULL(t4.<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>¼ID,'') '<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>¼ID'
|
||||
--,ISNULL(t4.<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'') '<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
--INTO #<23><><EFBFBD>۳<EFBFBD><DBB3>ⵥ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>
|
||||
FROM T_SAL_OUTSTOCK t0
|
||||
INNER JOIN T_SAL_OUTSTOCKENTRY t0e on t0e.FID = t0.FID
|
||||
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_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_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
|
||||
INNER JOIN T_PUR_POORDERENTRY t3e on t3.FID = t3e.FID AND t2e_lk.FSBILLID = t3e.FID AND t2e_lk.FSID = t3e.FENTRYID
|
||||
AND t3e.FMRPCLOSESTATUS = 'A'
|
||||
INNER JOIN T_PUR_POORDERENTRY_LK t3e_lk on t3e_lk.FENTRYID = t3e.FENTRYID
|
||||
OUTER APPLY (
|
||||
SELECT SUM(t4e.FACTRECEIVEQTY) 'FACTRECEIVEQTY',SUM(ISNULL(t5.FREALQTY,0)) 'FREALQTY'
|
||||
--,STRING_AGG(t4e.FENTRYID,';') '<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>¼ID'
|
||||
--,STRING_AGG(ISNULL(t5.FREALQTY,0),';') '<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
||||
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 t5e_lk.FSID,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
|
||||
WHERE t3.FCLOSESTATUS = 'A'
|
||||
--AND t0e.FREALQTY != ISNULL(t4.FREALQTY,0)
|
||||
--ORDER BY t3e.FID,t3e.FENTRYID
|
||||
)
|
||||
SELECT t0.*
|
||||
FROM #<23><><EFBFBD>۳<EFBFBD><DBB3>ⵥ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD> t0
|
||||
WHERE 1=1
|
||||
--AND t0.<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> != t0.<EFBFBD>ϼƳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
--AND t0.<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> < t0.<EFBFBD>ϼƳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
--AND t0.<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> > t0.<EFBFBD>ϼƳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
AND t0.<EFBFBD><EFBFBD><EFBFBD>۳<EFBFBD><EFBFBD>ⵥ<EFBFBD><EFBFBD>¼ID = 107059
|
||||
--AND t0.<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> != t0.<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Reference in New Issue
Block a user