|
@@ -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");
|
|
|
|
|
|
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 writeoffapply = info.getDynamicObjectCollection("writeoffapply");
|
|
|
+ if(atts.isEmpty() && writeoffapply.isEmpty()){
|
|
|
+ throw new KDBizException("请关联申请,或者关联合同,或者上传附件进行报销!");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|