【功能实现】表单输入一个金额按照规则平摊到每一行 + 组织间结算时获取这个价格;
【优点】无论公有云、混合云还是私有云都可用;
【缺点】调试起来很麻烦;
【风险】一定要好好检查SQL语句,建议不要直接影响原有字段的值,用自定义字段先测试(完美熟练SQL的忽略);
【案列】销售出库单表头加一个“内部结算总价”字段,表体加上一个“行内部结算价”字段,通过点击按钮,按照一定规则将内部结算总价平摊到表体每一行的结算价字段上,在进行组织间结算时,可以获取这个内部价用于结算;
1.销售出库单字段准备好:
2.创建组织间结算字段准备好:
3.销售出库单注册Python插件,实现输入价格,点击按钮分到行
我们来看下效果
好,说明出库单上的价格分摊已经好了
4.创建结算清单注册插件,实现获取出库单上分好的价格
我们来看下效果,现在是空白的:
点下按钮
好,完美实现!
5.两个插件源码:(PS:结算清单上的Python插件由我同事写的,我直接拿来修改的,感谢!)
出库单:
import clr
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.Bill.PlugIn import *
from Kingdee.BOS.Core.Bill.PlugIn.Args import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *
def ButtonClick(e):
if(e.Key.lower() == "f_sbra_button"):
zke = this.Model.GetValue("F_SBRA_Decimal")
zj = this.Model.GetValue("FBillAllAmount")
if(zke <= 0):
this.View.ShowMessage("请先输入内部结算价税合计!")
else:
entity = this.Model.BillBusinessInfo.GetEntity("FEntity")
entrys = this.Model.GetEntityDataObject(entity)
for entry in entrys:
mxjshj = entry["AllAmount"]
mxsl = entry["RealQty"]
bl = mxjshj/zj
nbjshj = bl*zke
nbhsdj = nbjshj/mxsl
this.Model.SetValue("F_SBRA_Price",nbhsdj,entrys.IndexOf(entry))
this.View.InvokeFieldUpdateService("F_SBRA_Price",entrys.IndexOf(entry))
this.Model.SetValue("F_SBRA_Amount",nbjshj,entrys.IndexOf(entry))
this.View.InvokeFieldUpdateService("F_SBRA_Amount",entrys.IndexOf(entry))
mxdhj = 0
for entry in entrys:
jshjmx = entry["F_SBRA_Amount"]
mxdhj = mxdhj + jshjmx
cy = 0
if(mxdhj > zke):
cy = mxdhj - zke
dyhjg = this.Model.GetValue("F_SBRA_Amount",0)
hjj = dyhjg - cy
this.Model.SetValue("F_SBRA_Amount",hjj,0)
this.View.InvokeFieldUpdateService("F_SBRA_Amount",0)
dyhdj = this.Model.GetValue("FPriceUnitQty",0)
djj = hjj/dyhdj
this.Model.SetValue("F_SBRA_Price",djj,0)
this.View.InvokeFieldUpdateService("F_SBRA_Price",0)
else:
cy = zke - mxdhj
dyhjgds = this.Model.GetValue("F_SBRA_Amount",0)
hjks = dyhjgds+cy
this.Model.SetValue("F_SBRA_Amount",hjks,0)
this.View.InvokeFieldUpdateService("F_SBRA_Amount",0)
dyhdjqa = this.Model.GetValue("FPriceUnitQty",0)
djjaa = hjks/dyhdjqa
this.Model.SetValue("F_SBRA_Price",djjaa,0)
this.View.InvokeFieldUpdateService("F_SBRA_Price",0)
结算清单:
import clr
clr.AddReference('Kingdee.BOS.ServiceHelper')
clr.AddReference('mscorlib')
from Kingdee.BOS.ServiceHelper import *
def AfterEntryBarItemClick(e):
if(e.BarItemKey.lower()=="sbra_tbbutton_1"):
entrys = this.Model.DataObject["ResultEntity"]
for e in entrys:
t = e['BizFormName']
if(t=="销售出库单"):
entryid = e["EntryId"]
result = GetInfo(entryid)
if(result <> None):
this.Model.SetValue('F_SBRA_Decimal1',result[0],entrys.IndexOf(e))
this.Model.SetValue('F_SBRA_Decimal',result[1],entrys.IndexOf(e))
this.View.InvokeFieldUpdateService("F_SBRA_Decimal",entrys.IndexOf(e))
def GetInfo(entryId):
sql = '''select a.F_SBRA_PRICE,a.F_SBRA_AMOUNT
from T_SAL_OUTSTOCKENTRY a inner join T_SAL_OUTSTOCK b on a.fid = b.fid inner join T_SAL_OUTSTOCKENTRY_r c on a.fentryid = c.fentryid
where a.fentryid = {0}
'''.format(entryId)
return DBServiceHelper.ExecuteDynamicObject(this.Context,sql)[0]