public override void OnAfterCreateLink(CreateLinkEventArgs e)
{
base.OnAfterCreateLink(e);
ExtendedDataEntity[] bills = e.TargetExtendedDataEntities.FindByEntityKey("FBillHead");
foreach (var item in bills)
{
//收款明细
Entity entityType = e.TargetBusinessInfo.GetEntity("FRECEIVEBILLENTRY");
DynamicObjectCollection MxEntityRows = entityType.DynamicProperty.GetValue(item.DataEntity) as DynamicObjectCollection;
//源单明细
Entity SourcesType = e.TargetBusinessInfo.GetEntity("FRECEIVEBILLSRCENTRY");
DynamicObjectCollection SourceBillRows = SourcesType.DynamicProperty.GetValue(item.DataEntity) as DynamicObjectCollection;
//获取自定义参数
object OmsAmount = null;
Object OmsDate = null;
object OmsBankCode = null;
bool isGet = this.Option.TryGetVariableValue("OmsAmount", out OmsAmount);
this.Option.TryGetVariableValue("OmsDate", out OmsDate);
this.Option.TryGetVariableValue("OmsBankCode", out OmsBankCode);
if (isGet && SourceBillRows.Count > 0 && MxEntityRows.Count > 0)
{
//单据日期
if (OmsDate != null)
{
item.DataEntity["Date"] = OmsDate;
}
//明细行
MxEntityRows[0]["RECTOTALAMOUNTFOR"] = OmsAmount; //表体应收金额
MxEntityRows[0]["RECTOTALAMOUNT"] = OmsAmount; //表体应收金额本位币
MxEntityRows[0]["REALRECAMOUNTFOR"] = OmsAmount; //表体实收金额
MxEntityRows[0]["FREALRECAMOUNT"] = OmsAmount; //表体实收金额本位币
MxEntityRows[0]["SETTLERECAMOUNTFOR"] = OmsAmount; //表体折后金额
MxEntityRows[0]["SETTLERECAMOUNT"] = OmsAmount; //表体折后金额本位币
MxEntityRows[0]["RECAMOUNTFOR_E"] = OmsAmount; //表体收款金额
MxEntityRows[0]["RECAMOUNT_E"] = OmsAmount; //表体收款金额本位币
//退款关联金额
//MxEntityRows[0]["ReFundAmount"] = 0; //退款关联金额强制置为0
//我方银行账号
if (OmsBankCode != null)
{
var findResult = Common.CommonHelper.GetDynamicObject(Context, "CN_BANKACNT", string.Format("FNumber='{0}'", OmsBankCode));
if (findResult.isSuccess)
{
MxEntityRows[0]["ACCOUNTID_ID"] = findResult.data[0];
MxEntityRows[0]["ACCOUNTID"] = findResult.data;
}
}
//源单明细
SourceBillRows[0]["REALRECAMOUNT"] = OmsAmount; //源单明细本次收款金额
SourceBillRows[0]["FREALRECAMOUNTFOR"] = OmsAmount; //源单明细本次收款金额本位币
//SourceBillRows[0]["FASSORDERAMOUNT"] = OmsAmount; //源单明细本关联订单金额
//单据头
item.DataEntity["RECEIVEAMOUNTFOR"] = OmsAmount; //表头应收金额
item.DataEntity["RECEIVEAMOUNT"] = OmsAmount; //表头应收金额本位币
item.DataEntity["REALRECAMOUNTFOR"] = OmsAmount; //表头实收金额
item.DataEntity["REALRECAMOUNT"] = OmsAmount; //表头实收金额本位币
item.DataEntity["RECAMOUNTFOR"] = OmsAmount; //表头收款金额
item.DataEntity["RECAMOUNT"] = OmsAmount; //表头收款金额本位币
}
}
}
推荐阅读