|
@@ -0,0 +1,117 @@
|
|
|
|
+//
|
|
|
|
+// Source code recreated from a .class file by IntelliJ IDEA
|
|
|
|
+// (powered by FernFlower decompiler)
|
|
|
|
+//
|
|
|
|
+
|
|
|
|
+package kd.fi.er.validator;
|
|
|
|
+
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.Iterator;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
|
+import kd.bos.dataentity.resource.ResManager;
|
|
|
|
+import kd.bos.entity.ExtendedDataEntity;
|
|
|
|
+import kd.bos.entity.validate.AbstractValidator;
|
|
|
|
+import kd.fi.er.business.servicehelper.LoanBalanceServiceHelper;
|
|
|
|
+import kd.fi.er.business.utils.ErCommonUtils;
|
|
|
|
+import kd.fi.er.common.ErBillStatusEnum;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+
|
|
|
|
+public class TripReqSubmitValidatorEx extends AbstractValidator {
|
|
|
|
+ public TripReqSubmitValidatorEx() {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void validate() {
|
|
|
|
+ ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
|
|
|
+ ExtendedDataEntity[] var2 = dataEntities;
|
|
|
|
+ int var3 = dataEntities.length;
|
|
|
|
+
|
|
|
|
+ for(int var4 = 0; var4 < var3; ++var4) {
|
|
|
|
+ ExtendedDataEntity dataEntity = var2[var4];
|
|
|
|
+ DynamicObject dynamicObject = dataEntity.getDataEntity();
|
|
|
|
+ if (dynamicObject.getDynamicObject("applier") == null) {
|
|
|
|
+ this.addErrorMessage(dataEntity, ResManager.loadKDString("申请人为空,请联系管理员设置。", "TripReqSubmitValidator_20", "fi-er-opplugin", new Object[0]));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String billStatus = dynamicObject.getString("billstatus");
|
|
|
|
+ boolean isLoan = dynamicObject.getBoolean("isloan");
|
|
|
|
+ boolean istravelers = dynamicObject.getBoolean("istravelers");
|
|
|
|
+ if (!ErBillStatusEnum.A.toString().equals(billStatus) && !ErBillStatusEnum.D.toString().equals(billStatus)) {
|
|
|
|
+ if (!isLoan) {
|
|
|
|
+ this.addErrorMessage(dataEntity, ResManager.loadKDString("出差申请单需先暂存后才能提交。", "TripReqSubmitValidator_10", "fi-er-opplugin", new Object[0]));
|
|
|
|
+ } else {
|
|
|
|
+ this.addErrorMessage(dataEntity, ResManager.loadKDString("暂存的出差申请单(借)才允许提交。", "TripReqSubmitValidator_11", "fi-er-opplugin", new Object[0]));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (isLoan) {
|
|
|
|
+ Date repaydate = dynamicObject.getDate("repaymentdate");
|
|
|
|
+ Date bizdate = dynamicObject.getDate("bizdate");
|
|
|
|
+ if (repaydate == null || repaydate.before(bizdate)) {
|
|
|
|
+ this.addErrorMessage(dataEntity, ResManager.loadKDString("预计还款日期应晚于申请日期。", "TripReqSubmitValidator_12", "fi-er-opplugin", new Object[0]));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ DynamicObjectCollection accountEntrys = dynamicObject.getDynamicObjectCollection("accountentry");
|
|
|
|
+ if (accountEntrys == null || accountEntrys.isEmpty()) {
|
|
|
|
+ this.addErrorMessage(dataEntity, ResManager.loadKDString("请填写收款信息。", "TripReqSubmitValidator_3", "fi-er-opplugin", new Object[0]));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Integer> indexs = new ArrayList();
|
|
|
|
+ int index = 1;
|
|
|
|
+
|
|
|
|
+ DynamicObject accountEntry;
|
|
|
|
+ for(Iterator var15 = accountEntrys.iterator(); var15.hasNext(); ++index) {
|
|
|
|
+ accountEntry = (DynamicObject)var15.next();
|
|
|
|
+ accountEntry = accountEntry.getDynamicObject("payerbank");
|
|
|
|
+ if (accountEntry != null && !accountEntry.getBoolean("enable")) {
|
|
|
|
+ indexs.add(index);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!indexs.isEmpty()) {
|
|
|
|
+ this.addErrorMessage(dataEntity, ResManager.loadKDString("收款信息第%s行中的开户银行已被禁用。", "TripReqSubmitValidator_14", "fi-er-opplugin", new Object[]{indexs.toString().replaceAll("[^\\d|,]", "").replaceAll(",", ",")}));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ BigDecimal totalReceiveAmount = BigDecimal.ZERO;
|
|
|
|
+ Iterator var23 = accountEntrys.iterator();
|
|
|
|
+
|
|
|
|
+ while(var23.hasNext()) {
|
|
|
|
+ accountEntry = (DynamicObject)var23.next();
|
|
|
|
+ BigDecimal receiveAmount = accountEntry.getBigDecimal("receiveamount");
|
|
|
|
+ totalReceiveAmount = totalReceiveAmount.add(receiveAmount);
|
|
|
|
+ if (accountEntry.getDynamicObject("accountcurrency") == null) {
|
|
|
|
+ this.addErrorMessage(dataEntity, ResManager.loadKDString("请填写收款信息币种。", "TripReqSubmitValidator_13", "fi-er-opplugin", new Object[0]));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ BigDecimal encashamount = dynamicObject.getBigDecimal("encashamount");
|
|
|
|
+ if (totalReceiveAmount.compareTo(encashamount) != 0) {
|
|
|
|
+ this.addErrorMessage(dataEntity, ResManager.loadKDString("付现金额和收款金额合计不相等,请核对申请金额、收款金额。", "TripReqSubmitValidator_7", "fi-er-opplugin", new Object[0]));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Set<Long> itemSet = (Set)dynamicObject.getDynamicObjectCollection("tripentry").stream().map((row) -> {
|
|
|
|
+ return ErCommonUtils.getPk(row.getDynamicObject("tripexpenseitem"));
|
|
|
|
+ }).filter((pk) -> {
|
|
|
|
+ return pk != null;
|
|
|
|
+ }).collect(Collectors.toSet());
|
|
|
|
+ String msg = LoanBalanceServiceHelper.getloanBillMsg(dynamicObject.getDynamicObject("company"), dynamicObject.getDynamicObject("applier"), itemSet);
|
|
|
|
+ if (StringUtils.isNotBlank(msg)) {
|
|
|
|
+ this.addFatalErrorMessage(dataEntity, msg);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|