收款单审核时候自动核销(多张认领的应收单)
【问题】
因为这里收款单不是由应收下推过来的,需要一张收款单核销多张应收单,人工核销很费时费力
【方法】
在收款单前面二开一个销售回款认领单,可以加上认领的哪些应收单(房地产收款时候提交的请款单就是从应收单下推的),
第一种:在收款单审核的时候自动核销。
第二种:在手工核销界面,增加按钮,根据认领的应收单以及收款类型自动匹配借方应收单并勾选
【详细】
在收款单审核时候自动核销相关联的多张认领的应收单(细节包含收款计划的认领金额),就可以废除手工核销操作,不需要人工一张张寻找。
第一种:在收款单审核的时候自动核销。
Int64 FID = 0;
foreach (var data in e.DataEntitys)
{
FID = Convert.ToInt64(data["Id"]);
}
List<SpecialMatchDateForUser> dataList = new List<SpecialMatchDateForUser>();
string str_search = string.Format(@"select t1.fid,t2.fentryid,t2.fseq,t2.fpayamountfor-t2.frelatehadpayamount as famount,F_MXC_CLAIMAMOUNT from t_ar_receivable t1
inner join t_ar_receivableplan t2 on t2.fid=t1.fid
left join T_AR_RECEIVEBILLSUb t3 on t3.F_MXC_receivableNO=fbillno and F_MXC_SKPlan=F_adf_Assistant where
t3.fentryID in (select fentryID from T_AR_RECEIVEBILLSUb where FentryID=(select FentryID from T_AR_RECEIVEBILLSRCENTRY where fid={0})) ", FID);
DynamicObjectCollection docData = DBUtils.ExecuteDynamicObject(this.Context, str_search);
if (docData == null || docData.Count <= 0)
{
return;
}
//构造核销对象
foreach (var obj in docData)
{
SpecialMatchDateForUser userData = new SpecialMatchDateForUser();
userData.FBillId = Convert.ToInt64(obj["FID"]);
userData.FEntryID = Convert.ToInt64(obj["FENTRYID"]);
userData.FFormId = BusinessObjectConst.AR_RECEIVABLE;
userData.FMatchType = MatchType.RecableRec.ToString();
// 认领金额
userData.FTheMatchAmount = Convert.ToDecimal(obj["F_MXC_CLAIMAMOUNT"]);
dataList.Add(userData);
}
foreach (var data in e.DataEntitys)
{
long billId = Convert.ToInt64(data["ID"]);
DynamicObjectCollection objs = data["RECEIVEBILLENTRY"] as DynamicObjectCollection;
foreach (var entry in objs)
{
SpecialMatchDateForUser userData = new SpecialMatchDateForUser();
userData.FBillId = billId;
userData.FEntryID = Convert.ToInt64(entry["ID"]);
userData.FFormId = BusinessObjectConst.AR_RECEIVEBILL;
userData.FMatchType = MatchType.RecableRec.ToString();
// userData.FSeq = Convert.ToInt64(entry["Seq"]);
userData.FTheMatchAmount = Convert.ToDecimal(entry["RECTOTALAMOUNTFOR"]) - Convert.ToDecimal(entry["ReFundAmount"]);
dataList.Add(userData);
}
}
//构造核销参数
MatchParameters para = new MatchParameters();
para.MatchType = "3";
para.MatchMethodID = 36; //外部匹配核销,38是手工特殊核销,也就是先走匹配,匹配之后剩余的金额会进行特殊核销
//36外部特殊(匹配核销)
para.UserId = this.Context.UserId;
para.SelectedSchemeId = new List<object> { 20008 };// 核销方案内码
para.SpecialMatch = false;///外部特殊(匹配核销)
para.MatchFromId = "AP_PayMatck";
para.BatchGeneRecord = false;//应收收款特殊核销合并产生核销记录
// para.IsBadDebt
//调用接口
// var o = Kingdee.K3.FIN.Contracts.ServiceFactory.GetService< MatchService>(this.Context);
Kingdee.K3.FIN.App.Core.Match.MatchService matchService = new MatchService();
IOperationResult result= matchService.SpecialMatchForUser(this.Context, para, dataList);
// matchService.SpecialMatch(this.Context, para, dataList);
---------------------------------------------------------------------------
代码特别说明:
用这个接口“ Kingdee.K3.FIN.Contracts.ServiceFactory.GetService”:提示需要认证
"服务未注册:Kingdee.K3.FIN.App.Core.Match.MatchService, Kingdee.K3.FIN.App.Core, Version=8.1.620.12, Culture=neutral, PublicKeyToken=null"
直接跳过用下面这个“ Kingdee.K3.FIN.App.Core.Match.MatchService”接口即可。
---------------------------------------------------------------------------
第二种:在应收收款手工核销界面增加按钮自动勾选匹配的应收单。
效果图:
按钮代码:
if (e.BarItemKey == "MXC_tbCLAIM")
{
//
////借方
Entity FDebitEntry = this.Model.BillBusinessInfo.GetEntity("FDebitEntry");
DynamicObjectCollection rowsDebit = base.Model.GetEntityDataObject(FDebitEntry);
//贷方
Entity FCreditEntry = this.Model.BillBusinessInfo.GetEntity("FCreditEntry");
DynamicObjectCollection rows = base.Model.GetEntityDataObject(FCreditEntry);
int Index = this.Model.GetEntryCurrentRowIndex("FCreditEntry");
DynamicObject objs = rows[Index];
string FSRCBILLNO = objs["FSRCBILLNOC"].ToString();
string str = @"select F_MXC_PayRequestNO,F_MXC_SEQ,F_MXC_receivableNO,F_MXC_SKPlan,p.fname SKPlanName,F_MXC_PAYAMOUNTFOR,F_MXC_CLAIMAMOUNT from T_AR_RECEIVEBILL a
left join T_AR_RECEIVEBILLSRCENTRY b on a.fid=b.fid
left join T_AR_RECEIVEBILLSUb c on c.fentryid=b.fentryid
left join T_SaleOrderPlan_l p on p.fid=F_MXC_SKPlan where fbillno='" + FSRCBILLNO + "'";
DynamicObjectCollection Objsubs = DBServiceHelper.ExecuteDynamicObject(this.Context, str);
string F_MXC_receivableNO = "";
string F_MXC_SKPlan = "";
string F_MXC_receivableNO_d = "";
string F_MXC_SKPlan_d = "";
decimal FMaxMatchAmountD = 0;
foreach (DynamicObject Objsub in Objsubs)
{
F_MXC_receivableNO = Objsub["F_MXC_receivableNO"].ToString();
F_MXC_SKPlan = Objsub["SKPlanName"].ToString();
FMaxMatchAmountD = decimal.Parse(Objsub["F_MXC_CLAIMAMOUNT"].ToString());
int rowIndex = 0;
foreach (DynamicObject Obj in rowsDebit)
{
F_MXC_receivableNO_d = Obj["FSRCBILLNOD"].ToString();
F_MXC_SKPlan_d = Obj["F_adf_AssistantD"].ToString();
if (F_MXC_receivableNO == F_MXC_receivableNO_d && F_MXC_SKPlan == F_MXC_SKPlan_d)
{
this.Model.SetValue("FTheIsMatchD", true, rowIndex);
this.Model.SetValue("FMaxMatchAmountD", FMaxMatchAmountD, rowIndex);
}
rowIndex = rowIndex + 1;
}
}
}
收款单审核时候自动核销(多张认领的应收单)
本文2024-09-16 17:33:15发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-16451.html