无合同付款不校验合同相关信息
This commit is contained in:
parent
70570de660
commit
6a088cb815
|
@ -0,0 +1,221 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package kd.ec.contract.opplugin.fund.validator;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.resource.ResManager;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
import kd.ec.basedata.common.enums.BillStatusEnum;
|
||||
import kd.ec.basedata.common.enums.ContractStatusEnum;
|
||||
import kd.ec.basedata.common.enums.PlanAmtTypeEnum;
|
||||
import kd.ec.basedata.common.utils.ContTypeAmtUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PaymentDeductionValidator extends AbstractValidator {
|
||||
public PaymentDeductionValidator() {
|
||||
}
|
||||
|
||||
public void validate() {
|
||||
String operateKey = this.getOperateKey();
|
||||
if (StringUtils.equals("submit", operateKey) || StringUtils.equals("audit", operateKey)) {
|
||||
this.deductionValidate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void deductionValidate() {
|
||||
Map<String, BigDecimal> contractTypeDeductionMap = new HashMap(16);
|
||||
Map<String, BigDecimal> contractTypeApplyMap = new HashMap(16);
|
||||
Map<Long, BigDecimal> contractDeductionMap = new HashMap(16);
|
||||
Map<Long, BigDecimal> contractLastAmountMap = new HashMap(16);
|
||||
Set<Long> operateBillIds = new HashSet(this.dataEntities.length);
|
||||
ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
||||
ExtendedDataEntity[] var7 = dataEntities;
|
||||
int var8 = dataEntities.length;
|
||||
|
||||
int var9;
|
||||
DynamicObject contract;
|
||||
label62:
|
||||
for(var9 = 0; var9 < var8; ++var9) {
|
||||
ExtendedDataEntity dataEntity = var7[var9];
|
||||
operateBillIds.add((Long)dataEntity.getBillPkId());
|
||||
DynamicObject paymentApply = dataEntity.getDataEntity();
|
||||
DynamicObjectCollection entryCol = paymentApply.getDynamicObjectCollection("entryentity");
|
||||
Iterator var13 = entryCol.iterator();
|
||||
|
||||
while(true) {
|
||||
DynamicObject entry;
|
||||
do {
|
||||
if (!var13.hasNext()) {
|
||||
continue label62;
|
||||
}
|
||||
|
||||
entry = (DynamicObject)var13.next();
|
||||
contract = entry.getDynamicObject("contract");
|
||||
} while(contract!=null && !contract.getBoolean("isdednewest"));
|
||||
|
||||
if(contract != null){
|
||||
BigDecimal thisDeduction = entry.getBigDecimal("thisdeduction");
|
||||
BigDecimal contractDeduction = (BigDecimal)contractDeductionMap.getOrDefault(contract.getLong("id"), BigDecimal.ZERO);
|
||||
contractDeductionMap.put(contract.getLong("id"), contractDeduction.add(thisDeduction));
|
||||
String type = entry.getString("paymenttype");
|
||||
String contractStatus;
|
||||
BigDecimal lastContractAmount;
|
||||
if (StringUtils.equals(type, PlanAmtTypeEnum.BALANCE.getValue()) || StringUtils.equals(type, PlanAmtTypeEnum.SETTLEPAYMENT.getValue()) || StringUtils.equals(type, PlanAmtTypeEnum.PROGRESSPAYMENT.getValue())) {
|
||||
contractStatus = contract.getString("id") + ":" + type;
|
||||
lastContractAmount = (BigDecimal)contractTypeDeductionMap.getOrDefault(contractStatus, BigDecimal.ZERO);
|
||||
contractTypeDeductionMap.put(contractStatus, lastContractAmount.add(thisDeduction));
|
||||
BigDecimal applyAmount = entry.getBigDecimal("thisapplyoftax");
|
||||
BigDecimal contractTypeApplyAmount = (BigDecimal)contractTypeApplyMap.getOrDefault(contractStatus, BigDecimal.ZERO);
|
||||
contractTypeApplyMap.put(contractStatus, contractTypeApplyAmount.add(applyAmount));
|
||||
}
|
||||
|
||||
if (!contractLastAmountMap.containsKey(contract.getLong("id"))) {
|
||||
contractStatus = contract.getString("contstatus");
|
||||
lastContractAmount = StringUtils.equals(contractStatus, ContractStatusEnum.OVERSETTLE.getValue()) ? contract.getBigDecimal("apptaxamount") : contract.getBigDecimal("totaloftaxamount");
|
||||
contractLastAmountMap.put(contract.getLong("id"), lastContractAmount);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, BigDecimal> couldApplyAmountMap = this.getCouldApplyAmountMap(contractTypeDeductionMap, contractLastAmountMap, operateBillIds);
|
||||
ExtendedDataEntity[] var24 = dataEntities;
|
||||
var9 = dataEntities.length;
|
||||
|
||||
for(int var25 = 0; var25 < var9; ++var25) {
|
||||
ExtendedDataEntity dataEntity = var24[var25];
|
||||
DynamicObject paymentApply = dataEntity.getDataEntity();
|
||||
DynamicObjectCollection entryCol = paymentApply.getDynamicObjectCollection("entryentity");
|
||||
Iterator var29 = entryCol.iterator();
|
||||
|
||||
while(var29.hasNext()) {
|
||||
contract = (DynamicObject)var29.next();
|
||||
contract = contract.getDynamicObject("contract");
|
||||
if (contract != null && contract.getBoolean("isdednewest")) {
|
||||
String type = contract.getString("paymenttype");
|
||||
BigDecimal deductionSurplus = ContTypeAmtUtil.getPrePaymentSurplusContainSubmit(contract.getLong("id"), operateBillIds);
|
||||
this.forceDeductionValidate(contractTypeDeductionMap, contractTypeApplyMap, couldApplyAmountMap, dataEntity, contract, type, deductionSurplus);
|
||||
this.deductionSurplusValidate(contractDeductionMap, dataEntity, contract, deductionSurplus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void deductionSurplusValidate(Map<Long, BigDecimal> contractDeductionMap, ExtendedDataEntity dataEntity, DynamicObject contract, BigDecimal deductionSurplus) {
|
||||
BigDecimal thisDeduction = (BigDecimal)contractDeductionMap.getOrDefault(contract.getLong("id"), BigDecimal.ZERO);
|
||||
if (thisDeduction.compareTo(deductionSurplus) > 0) {
|
||||
this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%s】预付款抵扣已超额,请修改本期预付款抵扣金额。", "PaymentDeductionValidator_6", "ec-contract-opplugin", new Object[0]), contract.getString("name")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void forceDeductionValidate(Map<String, BigDecimal> contractTypeDeductionMap, Map<String, BigDecimal> contractTypeApplyMap, Map<String, BigDecimal> couldApplyAmountMap, ExtendedDataEntity dataEntity, DynamicObject contract, String type, BigDecimal deductionSurplus) {
|
||||
if (StringUtils.equals(PlanAmtTypeEnum.SETTLEPAYMENT.getValue(), type) || StringUtils.equals(PlanAmtTypeEnum.BALANCE.getValue(), type) || StringUtils.equals(PlanAmtTypeEnum.PROGRESSPAYMENT.getValue(), type)) {
|
||||
String key = contract.getString("id") + ":" + type;
|
||||
BigDecimal thisDeduction = (BigDecimal)contractTypeDeductionMap.getOrDefault(key, BigDecimal.ZERO);
|
||||
BigDecimal thisApplyAmount = (BigDecimal)contractTypeApplyMap.getOrDefault(key, BigDecimal.ZERO);
|
||||
BigDecimal couldApplyAmount = (BigDecimal)couldApplyAmountMap.getOrDefault(key, BigDecimal.ZERO);
|
||||
if (deductionSurplus.subtract(thisDeduction).compareTo(couldApplyAmount.subtract(thisApplyAmount)) > 0) {
|
||||
String typeName = StringUtils.equals(PlanAmtTypeEnum.SETTLEPAYMENT.getValue(), type) ? ResManager.loadKDString("结算款", "PaymentDeductionValidator_7", "ec-contract-opplugin", new Object[0]) : (StringUtils.equals(PlanAmtTypeEnum.BALANCE.getValue(), type) ? ResManager.loadKDString("尾款", "PaymentDeductionValidator_8", "ec-contract-opplugin", new Object[0]) : ResManager.loadKDString("进度款", "PaymentDeductionValidator_9", "ec-contract-opplugin", new Object[0]));
|
||||
this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同【%1$s】待抵扣的金额已经超出%2$s的可申请金额,继续付款会导致后续尾款或质保金无法付款,请先进行抵扣。", "PaymentDeductionValidator_10", "ec-contract-opplugin", new Object[0]), contract.getString("name"), typeName));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected Map<String, BigDecimal> getCouldApplyAmountMap(Map<String, BigDecimal> contractTypeDeductionMap, Map<Long, BigDecimal> contractLastAmountMap, Set<Long> operateBillIds) {
|
||||
Map<String, BigDecimal> couldApplyAmountMap = new HashMap(16);
|
||||
Iterator var5 = contractTypeDeductionMap.entrySet().iterator();
|
||||
|
||||
while(var5.hasNext()) {
|
||||
Map.Entry<String, BigDecimal> entry = (Map.Entry)var5.next();
|
||||
String key = (String)entry.getKey();
|
||||
String[] contractAndType = key.split(":");
|
||||
long contractId = Long.parseLong(contractAndType[0]);
|
||||
BigDecimal lastAmount = (BigDecimal)contractLastAmountMap.getOrDefault(contractId, BigDecimal.ZERO);
|
||||
String type = contractAndType[1];
|
||||
BigDecimal ratio;
|
||||
BigDecimal totalApplyAmount;
|
||||
if (StringUtils.equals(PlanAmtTypeEnum.BALANCE.getValue(), type)) {
|
||||
ratio = ContTypeAmtUtil.getRatio(contractId, PlanAmtTypeEnum.BOND.getValue(), BigDecimal.ZERO);
|
||||
totalApplyAmount = lastAmount.multiply(ratio).divide(new BigDecimal(100), 10, 4);
|
||||
BigDecimal prePaymentSurplus = ContTypeAmtUtil.getPrePaymentSurplusContainSubmit(contractId, operateBillIds);
|
||||
BigDecimal contractShouldPayAmount = this.getContractShouldPayAmount(contractId, operateBillIds);
|
||||
couldApplyAmountMap.put(key, lastAmount.subtract(contractShouldPayAmount).subtract(totalApplyAmount).add(prePaymentSurplus));
|
||||
} else if (StringUtils.equals(PlanAmtTypeEnum.PROGRESSPAYMENT.getValue(), type)) {
|
||||
ratio = this.getProgressTotalRatio(contractId);
|
||||
totalApplyAmount = this.getContractTypeApplyAmount(contractId, type, operateBillIds);
|
||||
couldApplyAmountMap.put(key, lastAmount.multiply(ratio).divide(new BigDecimal(100), 10, 4).subtract(totalApplyAmount));
|
||||
} else if (StringUtils.equals(PlanAmtTypeEnum.SETTLEPAYMENT.getValue(), type)) {
|
||||
ratio = ContTypeAmtUtil.getRatio(contractId, type, new BigDecimal(100));
|
||||
totalApplyAmount = this.getContractTypeApplyAmount(contractId, type, operateBillIds);
|
||||
couldApplyAmountMap.put(key, lastAmount.multiply(ratio).divide(new BigDecimal(100), 10, 4).subtract(totalApplyAmount));
|
||||
}
|
||||
}
|
||||
|
||||
return couldApplyAmountMap;
|
||||
}
|
||||
|
||||
protected BigDecimal getContractTypeApplyAmount(long contractId, String type, Set<Long> operateBillIds) {
|
||||
QFilter filter = new QFilter("id", "not in", operateBillIds);
|
||||
filter.and("billstatus", "in", new String[]{BillStatusEnum.AUDIT.getValue(), BillStatusEnum.SUBMIT.getValue()});
|
||||
filter.and("entryentity.contract", "=", contractId);
|
||||
filter.and("entryentity.paymenttype", "=", type);
|
||||
DynamicObjectCollection appliedEntries = QueryServiceHelper.query("ec_paymentapply", "entryentity.thisapplyoftax", new QFilter[]{filter});
|
||||
BigDecimal totalApplyAmount = BigDecimal.ZERO;
|
||||
|
||||
DynamicObject appliedEntry;
|
||||
for(Iterator var8 = appliedEntries.iterator(); var8.hasNext(); totalApplyAmount = totalApplyAmount.add(appliedEntry.getBigDecimal("entryentity.thisapplyoftax"))) {
|
||||
appliedEntry = (DynamicObject)var8.next();
|
||||
}
|
||||
|
||||
return totalApplyAmount;
|
||||
}
|
||||
|
||||
protected BigDecimal getProgressTotalRatio(long contractId) {
|
||||
QFilter filter = new QFilter("contract", "=", contractId);
|
||||
filter.and("type", "=", PlanAmtTypeEnum.PROGRESSPAYMENT.getValue());
|
||||
DynamicObjectCollection objs = QueryServiceHelper.query("ecpf_conttypeamt", "ratio", new QFilter[]{filter});
|
||||
BigDecimal totalRatio = BigDecimal.ZERO;
|
||||
|
||||
DynamicObject obj;
|
||||
for(Iterator var6 = objs.iterator(); var6.hasNext(); totalRatio = totalRatio.add(obj.getBigDecimal("ratio"))) {
|
||||
obj = (DynamicObject)var6.next();
|
||||
}
|
||||
|
||||
return totalRatio;
|
||||
}
|
||||
|
||||
protected BigDecimal getContractShouldPayAmount(long contractId, Set<Long> operateBillIds) {
|
||||
QFilter filter = new QFilter("id", "not in", operateBillIds);
|
||||
filter.and("billstatus", "in", new String[]{BillStatusEnum.AUDIT.getValue(), BillStatusEnum.SUBMIT.getValue()});
|
||||
filter.and("entryentity.contract", "=", contractId);
|
||||
DynamicObjectCollection appliedEntries = QueryServiceHelper.query("ec_paymentapply", "entryentity.applyoftaxamount", new QFilter[]{filter});
|
||||
BigDecimal totalShouldPayAmount = BigDecimal.ZERO;
|
||||
|
||||
DynamicObject entry;
|
||||
for(Iterator var7 = appliedEntries.iterator(); var7.hasNext(); totalShouldPayAmount = totalShouldPayAmount.add(entry.getBigDecimal("entryentity.applyoftaxamount"))) {
|
||||
entry = (DynamicObject)var7.next();
|
||||
}
|
||||
|
||||
return totalShouldPayAmount;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,195 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package kd.ec.ecpf.opplugin;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.resource.ResManager;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
import kd.ec.basedata.common.enums.BillStatusEnum;
|
||||
|
||||
class PaymentApplyInvoiceValidator extends AbstractValidator {
|
||||
PaymentApplyInvoiceValidator() {
|
||||
}
|
||||
|
||||
public void validate() {
|
||||
String operateKey = this.getOperateKey();
|
||||
if (StringUtils.equals(operateKey, "submit")) {
|
||||
this.validateMultiRateContract();
|
||||
this.validateInvoiceSumAmount();
|
||||
this.validateInvoiceApplyAmount();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void validateMultiRateContract() {
|
||||
ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
||||
ExtendedDataEntity[] var2 = dataEntities;
|
||||
int var3 = dataEntities.length;
|
||||
|
||||
for(int var4 = 0; var4 < var3; ++var4) {
|
||||
ExtendedDataEntity dataEntity = var2[var4];
|
||||
DynamicObject bill = dataEntity.getDataEntity();
|
||||
DynamicObjectCollection entries = bill.getDynamicObjectCollection("entryentity");
|
||||
|
||||
for(int i = 0; i < entries.size(); ++i) {
|
||||
DynamicObject entry = (DynamicObject)entries.get(i);
|
||||
DynamicObject contract = entry.getDynamicObject("contract");
|
||||
DynamicObjectCollection subEntries = entry.getDynamicObjectCollection("subentryentity");
|
||||
if (contract!=null && contract.getBoolean("ismultirate") && (subEntries == null || subEntries.isEmpty())) {
|
||||
this.addWarningMessage(dataEntity, String.format(ResManager.loadKDString("合同【%s】未添加发票,税额可能存在偏差,请确认。", "PaymentApplyInvoiceValidateOp_0", "ec-ecpf-opplugin", new Object[0]), contract.getString("name")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void validateInvoiceSumAmount() {
|
||||
ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
||||
ExtendedDataEntity[] var2 = dataEntities;
|
||||
int var3 = dataEntities.length;
|
||||
|
||||
for(int var4 = 0; var4 < var3; ++var4) {
|
||||
ExtendedDataEntity dataEntity = var2[var4];
|
||||
DynamicObject bill = dataEntity.getDataEntity();
|
||||
DynamicObjectCollection entries = bill.getDynamicObjectCollection("entryentity");
|
||||
|
||||
for(int i = 0; i < entries.size(); ++i) {
|
||||
DynamicObject entry = (DynamicObject)entries.get(i);
|
||||
BigDecimal shouldPayAmount = entry.getBigDecimal("applyoftaxamount");
|
||||
DynamicObjectCollection subEntries = entry.getDynamicObjectCollection("subentryentity");
|
||||
if (subEntries == null || subEntries.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
|
||||
BigDecimal applyAmount;
|
||||
for(Iterator var13 = subEntries.iterator(); var13.hasNext(); amount = amount.add(applyAmount)) {
|
||||
DynamicObject object = (DynamicObject)var13.next();
|
||||
applyAmount = object.getBigDecimal("applyinvoftaxamt");
|
||||
}
|
||||
|
||||
if (shouldPayAmount.compareTo(amount) != 0) {
|
||||
this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同付款信息分录第%s行的本次应付金额与对应的进项发票分录本次申请金额合计不相等", "PaymentApplyInvoiceValidateOp_1", "ec-ecpf-opplugin", new Object[0]), i + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void validateInvoiceApplyAmount() {
|
||||
ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
||||
Map<Long, BigDecimal> invoiceApplyAmounts = new HashMap(16);
|
||||
ExtendedDataEntity[] var3 = dataEntities;
|
||||
int var4 = dataEntities.length;
|
||||
|
||||
BigDecimal totalApplyAmount;
|
||||
label123:
|
||||
for(int var5 = 0; var5 < var4; ++var5) {
|
||||
ExtendedDataEntity dataEntity = var3[var5];
|
||||
DynamicObject bill = dataEntity.getDataEntity();
|
||||
DynamicObjectCollection contractEntries = bill.getDynamicObjectCollection("entryentity");
|
||||
if (contractEntries != null && !contractEntries.isEmpty()) {
|
||||
Iterator var9 = contractEntries.iterator();
|
||||
|
||||
while(true) {
|
||||
DynamicObjectCollection invoiceEntries;
|
||||
do {
|
||||
do {
|
||||
if (!var9.hasNext()) {
|
||||
continue label123;
|
||||
}
|
||||
|
||||
DynamicObject contractEntry = (DynamicObject)var9.next();
|
||||
invoiceEntries = contractEntry.getDynamicObjectCollection("subentryentity");
|
||||
} while(invoiceEntries == null);
|
||||
} while(invoiceEntries.isEmpty());
|
||||
|
||||
Iterator var12 = invoiceEntries.iterator();
|
||||
|
||||
while(var12.hasNext()) {
|
||||
DynamicObject invoiceEntry = (DynamicObject)var12.next();
|
||||
DynamicObject invoice = invoiceEntry.getDynamicObject("invoice");
|
||||
if (invoice != null) {
|
||||
long invoiceId = invoice.getLong("id");
|
||||
totalApplyAmount = invoiceEntry.getBigDecimal("applyinvoftaxamt");
|
||||
totalApplyAmount = totalApplyAmount == null ? BigDecimal.ZERO : totalApplyAmount;
|
||||
invoiceApplyAmounts.put(invoiceId, ((BigDecimal)invoiceApplyAmounts.getOrDefault(invoiceId, BigDecimal.ZERO)).add(totalApplyAmount));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!invoiceApplyAmounts.isEmpty()) {
|
||||
QFilter filter = new QFilter("entryentity.subentryentity.invoice", "in", invoiceApplyAmounts.keySet());
|
||||
filter.and("billstatus", "in", new String[]{BillStatusEnum.AUDIT.getValue(), BillStatusEnum.SUBMIT.getValue()});
|
||||
DynamicObjectCollection existInvoices = QueryServiceHelper.query("ec_paymentapply", "entryentity.subentryentity.invoice,entryentity.subentryentity.applyinvoftaxamt", new QFilter[]{filter});
|
||||
if (existInvoices != null && !existInvoices.isEmpty()) {
|
||||
Iterator var21 = existInvoices.iterator();
|
||||
|
||||
while(var21.hasNext()) {
|
||||
DynamicObject existInvoice = (DynamicObject)var21.next();
|
||||
long invoiceId = existInvoice.getLong("entryentity.subentryentity.invoice");
|
||||
BigDecimal applyAmount = existInvoice.getBigDecimal("entryentity.subentryentity.applyinvoftaxamt");
|
||||
invoiceApplyAmounts.put(invoiceId, ((BigDecimal)invoiceApplyAmounts.getOrDefault(invoiceId, BigDecimal.ZERO)).add(applyAmount));
|
||||
}
|
||||
}
|
||||
|
||||
ExtendedDataEntity[] var22 = dataEntities;
|
||||
int var24 = dataEntities.length;
|
||||
|
||||
label87:
|
||||
for(int var26 = 0; var26 < var24; ++var26) {
|
||||
ExtendedDataEntity dataEntity = var22[var26];
|
||||
DynamicObject bill = dataEntity.getDataEntity();
|
||||
DynamicObjectCollection contractEntries = bill.getDynamicObjectCollection("entryentity");
|
||||
if (contractEntries != null && !contractEntries.isEmpty()) {
|
||||
Iterator var31 = contractEntries.iterator();
|
||||
|
||||
while(true) {
|
||||
DynamicObjectCollection invoiceEntries;
|
||||
do {
|
||||
do {
|
||||
if (!var31.hasNext()) {
|
||||
continue label87;
|
||||
}
|
||||
|
||||
DynamicObject contractEntry = (DynamicObject)var31.next();
|
||||
invoiceEntries = contractEntry.getDynamicObjectCollection("subentryentity");
|
||||
} while(invoiceEntries == null);
|
||||
} while(invoiceEntries.isEmpty());
|
||||
|
||||
Iterator var34 = invoiceEntries.iterator();
|
||||
|
||||
while(var34.hasNext()) {
|
||||
DynamicObject invoiceEntry = (DynamicObject)var34.next();
|
||||
DynamicObject invoice = invoiceEntry.getDynamicObject("invoice");
|
||||
if (invoice != null) {
|
||||
totalApplyAmount = (BigDecimal)invoiceApplyAmounts.getOrDefault(invoice.getLong("id"), BigDecimal.ZERO);
|
||||
BigDecimal totalOfTax = invoice.getBigDecimal("totaloftaxamount");
|
||||
totalOfTax = totalOfTax == null ? BigDecimal.ZERO : totalOfTax;
|
||||
if (totalApplyAmount.compareTo(totalOfTax) > 0) {
|
||||
this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("发票【%s】累计申请含税金额超过发票总含税金额,请检查。", "PaymentApplyInvoiceValidateOp_2", "ec-ecpf-opplugin", new Object[0]), invoice.getString("invoiceno")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,26 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.operate;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.EntityMetadataCache;
|
||||
import kd.bos.entity.MainEntityType;
|
||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.ec.contract.opplugin.fund.PaymentApplyFundOp;
|
||||
import kd.ec.contract.opplugin.fund.validator.PaymentMaxAmountValidator;
|
||||
import kd.ec.contract.opplugin.fund.validator.PaymentTypeValidator;
|
||||
import kd.ec.contract.opplugin.validator.ContractMeasureValidator;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PaymentApplyFundExtOp extends PaymentApplyFundOp {
|
||||
|
||||
|
@ -29,4 +41,74 @@ public class PaymentApplyFundExtOp extends PaymentApplyFundOp {
|
|||
//validators.add(0, new PaymentMaxAmountExtValidator());
|
||||
|
||||
}
|
||||
|
||||
protected void updateContTypeAmtTotalShowAmt(DynamicObject[] dataEntities) {
|
||||
Map<Long, BigDecimal> contractDeductionMap = new HashMap(16);
|
||||
DynamicObject[] var3 = dataEntities;
|
||||
int var4 = dataEntities.length;
|
||||
|
||||
label50:
|
||||
for(int var5 = 0; var5 < var4; ++var5) {
|
||||
DynamicObject paymentApply = var3[var5];
|
||||
DynamicObjectCollection entryCol = paymentApply.getDynamicObjectCollection("entryentity");
|
||||
Iterator var8 = entryCol.iterator();
|
||||
|
||||
while(true) {
|
||||
while(true) {
|
||||
if (!var8.hasNext()) {
|
||||
continue label50;
|
||||
}
|
||||
|
||||
DynamicObject entry = (DynamicObject)var8.next();
|
||||
DynamicObject contract = entry.getDynamicObject("contract");
|
||||
if(contract != null){
|
||||
BigDecimal thisApplyOfTaxAmt = entry.getBigDecimal("applyoftaxamount");
|
||||
BigDecimal deduction = entry.getBigDecimal("thisdeduction");
|
||||
BigDecimal contractDeduction = (BigDecimal)contractDeductionMap.getOrDefault(contract.getLong("id"), BigDecimal.ZERO);
|
||||
contractDeductionMap.put(contract.getLong("id"), contractDeduction.add(deduction));
|
||||
String type = entry.getString("paymenttype");
|
||||
QFilter contractFilter = new QFilter("contract", "=", contract.getLong("id"));
|
||||
QFilter typeFilter = new QFilter("type", "=", type);
|
||||
DynamicObject node = entry.getDynamicObject("paynode");
|
||||
String nodeText = entry.getString("paynodetext");
|
||||
if (node != null) {
|
||||
typeFilter.and("paynode", "=", node.getPkValue());
|
||||
} else if (StringUtils.isNotEmpty(nodeText)) {
|
||||
typeFilter.and("node", "=", nodeText);
|
||||
}
|
||||
|
||||
DynamicObject[] contTypeAmts = BusinessDataServiceHelper.load("ecpf_conttypeamt", "totalshowamt,totaldeductionamt", new QFilter[]{contractFilter, typeFilter});
|
||||
if (contTypeAmts != null && contTypeAmts.length != 0) {
|
||||
DynamicObject[] var28 = contTypeAmts;
|
||||
int var26 = contTypeAmts.length;
|
||||
|
||||
for(int var27 = 0; var27 < var26; ++var27) {
|
||||
DynamicObject contTypeAmt = var28[var27];
|
||||
BigDecimal totalShowAmt = contTypeAmt.getBigDecimal("totalshowamt");
|
||||
contTypeAmt.set("totalshowamt", totalShowAmt.add(thisApplyOfTaxAmt));
|
||||
BigDecimal totalDeduction = contTypeAmt.getBigDecimal("totaldeductionamt");
|
||||
contTypeAmt.set("totaldeductionamt", totalDeduction.add(deduction));
|
||||
}
|
||||
|
||||
SaveServiceHelper.save(contTypeAmts);
|
||||
} else {
|
||||
BigDecimal payRate = entry.getBigDecimal("controlrate");
|
||||
MainEntityType entityType = EntityMetadataCache.getDataEntityType("ecpf_conttypeamt");
|
||||
DynamicObject newContTypeAmtObj = new DynamicObject(entityType);
|
||||
newContTypeAmtObj.set("contract", contract);
|
||||
newContTypeAmtObj.set("type", type);
|
||||
newContTypeAmtObj.set("ratio", payRate);
|
||||
newContTypeAmtObj.set("totalshowamt", thisApplyOfTaxAmt);
|
||||
newContTypeAmtObj.set("totaldeductionamt", deduction);
|
||||
newContTypeAmtObj.set("paynode", entry.get("paynode"));
|
||||
newContTypeAmtObj.set("node", entry.get("paynode") == null ? entry.get("paynodetext") : "");
|
||||
SaveServiceHelper.save(new DynamicObject[]{newContTypeAmtObj});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.updatePrePaymentDeduction(contractDeductionMap, true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue