1.发货通知单保存时,根据对应条件勾选是否预发货
This commit is contained in:
93
Pilot_KD_Parino/SAL_DELIVERYNOTICE/ServicePlugIn/Save.py
Normal file
93
Pilot_KD_Parino/SAL_DELIVERYNOTICE/ServicePlugIn/Save.py
Normal file
@@ -0,0 +1,93 @@
|
||||
#引入clr运行库
|
||||
import clr
|
||||
#添加对cloud插件开发的常用组件引用
|
||||
clr.AddReference('System')
|
||||
clr.AddReference('System.Data')
|
||||
clr.AddReference('Kingdee.BOS')
|
||||
clr.AddReference('Kingdee.BOS.Core')
|
||||
clr.AddReference('Kingdee.BOS.App')
|
||||
clr.AddReference('Kingdee.BOS.App.Core')
|
||||
clr.AddReference('Kingdee.BOS.Contracts')
|
||||
clr.AddReference('Kingdee.BOS.DataEntity')
|
||||
clr.AddReference('Kingdee.BOS.ServiceHelper')
|
||||
#dairycloud基础库中的常用实体对象(分命名空间导入,不会递归导入)
|
||||
from Kingdee.BOS.Core import *
|
||||
from Kingdee.BOS.Util import *
|
||||
from Kingdee.BOS.Core.Bill import *
|
||||
from Kingdee.BOS.Core.List import *
|
||||
from Kingdee.BOS.Core.Bill.PlugIn import *
|
||||
from Kingdee.BOS.Orm.DataEntity import *
|
||||
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
|
||||
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *
|
||||
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
|
||||
from Kingdee.BOS.Core.Metadata.ConvertElement.ServiceArgs import *
|
||||
from System import *
|
||||
from System.Data import *
|
||||
from Kingdee.BOS.App.Data import *
|
||||
from Kingdee.BOS.App import *
|
||||
from Kingdee.BOS.Orm import *
|
||||
from Kingdee.BOS.Contracts import *
|
||||
from System.Collections.Generic import List
|
||||
from Kingdee.BOS.ServiceHelper import *
|
||||
from Kingdee.BOS.App.Core import *
|
||||
|
||||
def OnPreparePropertys(e):
|
||||
e.FieldKeys.Add("FAllAmount");
|
||||
e.FieldKeys.Add("FBillAllAmount");
|
||||
e.FieldKeys.Add("F_SFYFH");
|
||||
e.FieldKeys.Add("FSaleOrgId");
|
||||
|
||||
def BeforeDoSaveExecute(e):
|
||||
# if this.FormOperation.OperationId == 8:
|
||||
for entity in e.DataEntities:
|
||||
if entity["SaleOrgId_Id"] != 100303:
|
||||
continue;
|
||||
|
||||
if entity["DocumentStatus"] != "Z" and entity["DocumentStatus"] != "C":
|
||||
continue;
|
||||
|
||||
billId = entity["Id"]
|
||||
# raise Exception(JsonUtil.Serialize(entity))
|
||||
entries = entity["SAL_DELIVERYNOTICEENTRY"]
|
||||
idList = List[str]()
|
||||
for idx,entry in enumerate(entries):
|
||||
|
||||
entityLink = entry["FEntity_Link"]
|
||||
if entityLink != None and entityLink.Count > 0:
|
||||
link = entityLink[0]
|
||||
idList.Add(link["SBillId"])
|
||||
|
||||
if idList is None or len(idList) == 0:
|
||||
continue;
|
||||
|
||||
sql = """/*dialect*/
|
||||
SELECT SUM(t0.F_Amount) '累计核销金额',SUM(t0p.FRECADVANCEAMOUNT) '款到发货应收金额',SUM(t0p.CountTotal) '收款计划条数',SUM(ISNULL(t1.FALLAMOUNT,0)) '累计已发货金额'
|
||||
FROM T_SAL_ORDER t0
|
||||
CROSS APPLY (
|
||||
SELECT SUM(t0p.FRECADVANCEAMOUNT) 'FRECADVANCEAMOUNT',COUNT(1) 'CountTotal'
|
||||
FROM T_SAL_ORDERPLAN t0p
|
||||
INNER JOIN T_BD_RECCONDITION_L t1_l on t1_l.FID = t0p.F_RECCONDITIONID
|
||||
AND t1_l.FLOCALEID = 2052 AND CHARINDEX('款到发货',t1_l.FNAME) = 1
|
||||
WHERE t0.FID = t0p.FID
|
||||
) t0p
|
||||
OUTER APPLY (
|
||||
SELECT SUM(t1e_f.FALLAMOUNT) FALLAMOUNT
|
||||
FROM T_SAL_DELIVERYNOTICEENTRY_LK t1e_lk
|
||||
INNER JOIN T_SAL_DELIVERYNOTICEENTRY_F t1e_f on t1e_f.FENTRYID = t1e_lk.FENTRYID
|
||||
WHERE t1e_lk .FSID = t0.FID AND t1e_f.FID != {1}
|
||||
) t1
|
||||
WHERE t0.FID IN ({0})
|
||||
""".format(",".join(set(idList)), billId)
|
||||
res = DBServiceHelper.ExecuteDynamicObject(this.Context, sql)
|
||||
if res != None and res.Count > 0:
|
||||
# raise Exception(JsonUtil.Serialize(res))
|
||||
item = res[0]
|
||||
|
||||
currAmount = entity["SAL_DELIVERYNOTICEFIN"][0]["BillAllAmount"]
|
||||
# raise Exception(str(currAmount))
|
||||
isYFHFlag = item["累计核销金额"] < item["款到发货应收金额"]
|
||||
isYFHFlag1 = isYFHFlag == True and (item["收款计划条数"] == 1)
|
||||
isYFHFlag2 = isYFHFlag == True and (True if isYFHFlag1 else ((item["累计核销金额"] - item["累计已发货金额"]) < currAmount))
|
||||
entity["F_SFYFH"] = '是' if isYFHFlag2 == True else '否'
|
||||
|
||||
return;
|
||||
Reference in New Issue
Block a user