一、添加F7字段
字段为基础资料,类型选择【授信额度管理】;
二、插件表单逻辑
方式一:F7事件处理
1.添加registerListener监听F7字段;
2.beforf7中添加传递参数:
CreditLimitUseBean creditLimitUse = getCreditLimitUseInfo(prop);
//key值为KEY_F7PARAM
FormShowParameter sp = evt.getFormShowParameter(); sp.setCustomParam(CreditLimitUseBean.KEY_F7PARAM, creditLimitUse); sp.setCloseCallBack(new CloseCallBack(this, prop));
3、getCreditLimitUseInfo方法的赋值逻辑:
protected CreditLimitUseBean getCreditLimitUseInfo(String fieldF7) {
//单据id,如果没有先赋值
Long id = (Long) getModel().getValue("id");
if (id == null || id.equals(0L)) {
id = DB.genLongId(getModel().getDataEntityType().getName());
getModel().setValue("id", id);
}
CreditLimitUseBean useBean = new CreditLimitUseBean();
useBean.setPkId(id);
useBean.setEntityName(this.getModel().getDataEntityType().getName());
//是否预占
useBean.setPreOccupy(isPreOccupy());
//授信主体
useBean.setOrgId(0L);
//授信机构类别(可使用枚举CreditFinTypeEnum,默认是合作金融机构)
useBean.setCreditFinType(CreditFinTypeEnum.FINORG.getValue());
//授信机构
useBean.setFinOrgId(0L);
useBean.setCurrencyId(0L);
//授信类别(贷款中取融资品种关联的授信类别)
useBean.setCreditTypeId(getCreditTypeId());
//融资品种(视业务场景赋值,可为空)
useBean.setCreditVariety("");
//预占用单据(该单据存在预占、或上游单据预占)
useBean.setSourceBillId(getSourceBillId());
useBean.setSourceType(getSourceType());
//业务单据分录id,不是分录占用,默认当前单据id(同一个单据分录多次占用时必须通过该字段区分,
如果分录没有id,需要提前赋值分录id)
useBean.setSourceBillEntryId(0L);
//开始、结束日期
useBean.setStartDate(date);
useBean.setEndDate(date);
//业务单据金额字段
useBean.setMaxAmt(0);
useBean.setBizAmt(0));
//占用比例
useBean.setCreditRatio(默认占用比例);
//授信额度字段(已选择额度单)
DynamicObject creditLimit = creditLimit = (DynamicObject)getModel().getValue(fieldF7, entryCurrentRowIndex);
useBean.setCreditLimitId(creditLimit!=null ? creditLimit.getLong(TmcBillDataProp.HEAD_ID) : null);
return useBean;
}
方式二:继承标准插件
1.继承kd.tmc.fbp.formplugin.common.AbstractCreditLimitEditPlugin插件:
2.重写相关方法,可参考kd.tmc.cfm.formplugin.loanbill.LoanBillCreditLimitPlugin:
getBizPropertys (), 配置关键字段:授信主体、授信机构、金额、开始/结束日期、币别
creditType():授信类别(取值逻辑视业务场景定)
通过上面两种方式中的一种处理后,点击F7会自动贷款授信额度列表选择,自动过滤符合条件的额度单;
三、操作中调用授信接口调用
1.授信占用
在操作的事务中调用授信占用接口,如单据submit操作插件
CreditLimitServiceHelper.confirmCreditLimit(letterCredit, null, true, letterCredit.getDate(LetterCreditProp.HEAD_BIZDATE));
2.授信取消占用
在操作事务中调用授信取消占用,如单据unsubmit中:
CreditLimitServiceHelper.cancelCreditLimit(letterCredit, null,false);
3.授信返还
授信返还,如在融资还款的审核操作中调用:
CreditLimitServiceHelper.returnCreditLimit(sourBill, credit, false, payAmount, returnId, isLast, payDate);
4.授信取消返还
授信取消返还,如在融资还款的反审核操作中调用:
CreditLimitServiceHelper.cancelReturnCreditLimit(sourBill, credit, false, payAmount, returnId)
推荐阅读