|
@@ -2,6 +2,7 @@ package fi.em.opplugin;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
|
|
|
import kd.bos.exception.KDBizException;
|
|
@@ -18,7 +19,7 @@ import java.util.Map;
|
|
|
public class TravelExpensesOpPlugin extends AbstractOperationServicePlugIn {
|
|
|
private static String nckd_orgamount = "nckd_orgamount"; //组织金额标识
|
|
|
private static String attachmentpanel = "attachmentpanel";//附件标识
|
|
|
- private static String er_tripreimbill_grid = "er_tripreimbill_grid";//差旅报销单标识
|
|
|
+ private static String er_tripreimbursebill = "er_tripreimbursebill";//差旅报销单标识
|
|
|
@Override
|
|
|
public void beginOperationTransaction(BeginOperationTransactionArgs e) {
|
|
|
//获取当前操作单据数组
|
|
@@ -34,18 +35,24 @@ public class TravelExpensesOpPlugin extends AbstractOperationServicePlugIn {
|
|
|
String number = costcompany.getString("number");
|
|
|
//公司id
|
|
|
long id = costcompany.getLong("id");
|
|
|
- //循环费用明细分录
|
|
|
- for (DynamicObject entryentity : info.getDynamicObjectCollection("expenseentryentity")) {
|
|
|
+ BigDecimal Amount = new BigDecimal(0);
|
|
|
+ DynamicObjectCollection tripentry = info.getDynamicObjectCollection("tripentry");
|
|
|
+ //循环差旅明细分录获取报信金额
|
|
|
+ for (DynamicObject entryentity : tripentry) {
|
|
|
+ BigDecimal FOriAmount = entryentity.getBigDecimal("tripapporiamount");
|
|
|
+ Amount=Amount.add(FOriAmount);
|
|
|
+ }
|
|
|
//取当前循环费用明细分录的报销金额
|
|
|
- BigDecimal expenseamount = entryentity.getBigDecimal("expenseamount");
|
|
|
//金额标准查询条件
|
|
|
QFilter nckd_orgamountFilter = new QFilter("nckd_orgfield.number", QCP.equals,number);
|
|
|
nckd_orgamountFilter.and("nckd_combofield", QCP.equals,"B");
|
|
|
+ nckd_orgamountFilter.and("enable", QCP.equals,"1");
|
|
|
DynamicObject[] nckd_orgamountaccount = BusinessDataServiceHelper.load(nckd_orgamount,"id,nckd_orgfield,nckd_combofield",new QFilter[] {nckd_orgamountFilter});
|
|
|
//判断组织是否维护金额,没有则查询集团金额
|
|
|
if(nckd_orgamountaccount.length == 0){
|
|
|
nckd_orgamountFilter = new QFilter("nckd_orgfield.number", QCP.equals,"jxyh");
|
|
|
nckd_orgamountFilter.and("nckd_combofield", QCP.equals,"B");
|
|
|
+ nckd_orgamountFilter.and("enable", QCP.equals,"1");
|
|
|
nckd_orgamountaccount = BusinessDataServiceHelper.load(nckd_orgamount,"id,nckd_orgfield,nckd_combofield",new QFilter[] {nckd_orgamountFilter});
|
|
|
}
|
|
|
//循环数组获取组织金额标准数据包 默认取组织,没有取集团
|
|
@@ -55,24 +62,20 @@ public class TravelExpensesOpPlugin extends AbstractOperationServicePlugIn {
|
|
|
//获取标准金额
|
|
|
BigDecimal nckdAmountfield = dynamicObject.getBigDecimal("nckd_amountfield");
|
|
|
//判断报销金额大于标准金额
|
|
|
- if(expenseamount.compareTo(nckdAmountfield) == 1){
|
|
|
+ if(Amount.compareTo(nckdAmountfield) == 1){
|
|
|
//获取单据信息,并查询单据中的附件字段
|
|
|
- DynamicObject file =BusinessDataServiceHelper.loadSingle(er_tripreimbill_grid,attachmentpanel,new QFilter[]{new QFilter("billno", QFilter.equals, billno)});
|
|
|
+ DynamicObject file =BusinessDataServiceHelper.loadSingle(er_tripreimbursebill,attachmentpanel,new QFilter[]{new QFilter("billno", QFilter.equals, billno)});
|
|
|
//获取单据中附件面板信息
|
|
|
- List<Map<String,Object>> atts= AttachmentServiceHelper.getAttachments(er_tripreimbill_grid,file.getPkValue().toString(),attachmentpanel);
|
|
|
- boolean ispass=true;
|
|
|
+ List<Map<String,Object>> atts= AttachmentServiceHelper.getAttachments(er_tripreimbursebill,file.getPkValue().toString(),attachmentpanel);
|
|
|
//如关联申请页签为空或关联合同页签为空或者附件为空,则在提交时进行提醒:“请关联申请,或者关联合同,或者上传附件进行报销”。
|
|
|
- if(atts.isEmpty()){ispass=false;}
|
|
|
- DynamicObject contractentry = info.getDynamicObject("contractentry");
|
|
|
- if(contractentry == null){ispass=false;}
|
|
|
- DynamicObject writeoffapply = info.getDynamicObject("writeoffapply");
|
|
|
- if(writeoffapply == null){ispass=false;}
|
|
|
- if(ispass){}else{throw new KDBizException("请关联申请,或者关联合同,或者上传附件进行报销!");};
|
|
|
+ //DynamicObjectCollection contractentry = info.getDynamicObjectCollection("contractentry");
|
|
|
+ DynamicObjectCollection writeoffapply = info.getDynamicObjectCollection("writeoffapply");
|
|
|
+ if(atts.isEmpty() && writeoffapply.isEmpty()){
|
|
|
+ throw new KDBizException("请关联申请,或者关联合同,或者上传附件进行报销!");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|