新增单据需要生成凭证时,需重写后台bean方法.
1.单据实体上添加voucherNumber(凭证号),voucherDate(凭证日期)字段
2.重写后台controllerBean
@Override
protected void _reverseSave(Context ctx, IObjectPK srcBillPK,
IObjectValue srcBillVO, BOTBillOperStateEnum billOperStateEnum,
IObjectValue relationInfo) throws BOSException, EASBizException {
reverseSave(ctx, srcBillPK, srcBillVO, billOperStateEnum, relationInfo);
}
public static void reverseSave(Context ctx, IObjectPK srcBillPK, IObjectValue srcBillVO, BOTBillOperStateEnum bOTBillOperStateEnum, IObjectValue bOTRelationInfo) throws BOSException, EASBizException {
BOTRelationInfo relation = (BOTRelationInfo) bOTRelationInfo;
BOSObjectType bosType = BOSUuid.read(relation.getDestObjectID()).getType();
if (bosType.equals((new VoucherInfo()).getBOSType())) {
CoreBillBaseInfo model = (CoreBillBaseInfo) srcBillVO;
// 删除凭证
if (bOTBillOperStateEnum.equals(BOTBillOperStateEnum.DELETE)) {
model.put(FLD_FIVOUCHERED, new Integer(0));
// 以下设置单据的凭证信息
model.put(FLD_VOUCHERNUMBER, null);
model.put(FLD_VOUCHERDATE, null);
}
// 生成凭证
else {
String voucherID = relation.getDestObjectID();
VoucherInfo voucherInfo = (VoucherInfo) VoucherFactory.getLocalInstance(ctx).getValue(new ObjectStringPK(voucherID));
model.put(FLD_FIVOUCHERED, new Integer(1));
// 以下设置单据的凭证信息
model.put(FLD_VOUCHERNUMBER, voucherInfo.getNumber());
model.put(FLD_VOUCHERDATE, voucherInfo.getBookedDate());
}
BOSObjectType bosObjectType = srcBillVO.getBOSType();
ICoreBillBase iCoreBillBase = (ICoreBillBase) BOSObjectFactory.createBOSObject(ctx, bosObjectType);
iCoreBillBase.reverseSave(srcBillPK, (CoreBillBaseInfo) srcBillVO);
}
}