付款收款会计科目过滤
This commit is contained in:
parent
7ff5e1d92a
commit
785132b439
|
@ -1,6 +1,7 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.operate;
|
||||
|
||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.ec.contract.opplugin.fund.PaymentApplyFundOp;
|
||||
import kd.ec.contract.opplugin.fund.validator.PaymentMaxAmountValidator;
|
||||
|
@ -11,12 +12,18 @@ import java.util.List;
|
|||
|
||||
public class PaymentApplyFundExtOp extends PaymentApplyFundOp {
|
||||
|
||||
@Override
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
super.onPreparePropertys(e);
|
||||
// e.getFieldKeys().add("zcgj_pricetype");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||
super.onAddValidators(e);
|
||||
List<AbstractValidator> validators = e.getValidators();
|
||||
// 删除标品校验器
|
||||
// validators.removeIf(validator -> validator instanceof PaymentMaxAmountValidator);
|
||||
validators.removeIf(validator -> validator instanceof PaymentMaxAmountValidator);
|
||||
validators.removeIf(validator -> validator instanceof PaymentTypeValidator);
|
||||
// 添加定制二开的校验器(位置放第一位,优先执行)
|
||||
validators.add(0, new PaymentMaxAmountExtValidator());
|
||||
|
|
|
@ -4,10 +4,15 @@ import kd.bos.dataentity.entity.DynamicObject;
|
|||
import kd.bos.dataentity.resource.ResManager;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.ec.basedata.common.utils.CurrencyFormatUtil;
|
||||
import kd.ec.contract.opplugin.fund.validator.PaymentMaxAmountValidator;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -15,28 +20,48 @@ public class PaymentMaxAmountExtValidator extends PaymentMaxAmountValidator {
|
|||
|
||||
@Override
|
||||
protected void maxShouldPayAmountValidate(Map<Long, BigDecimal> contractTypeShouldPayAmountMap, Map<Long, BigDecimal> shouldPayAmountMap, Map<Long, Set<String>> appliedBillMap, ExtendedDataEntity dataEntity, int i, DynamicObject entry, DynamicObject contract) {
|
||||
|
||||
long contractId = contract.getLong("id");
|
||||
BigDecimal maxShouldPayAmount = this.calculateMaxShouldPayAmount(contract);
|
||||
DynamicObject contCurrency = contract.getDynamicObject("currency");
|
||||
if (contCurrency != null) {
|
||||
maxShouldPayAmount = maxShouldPayAmount.setScale(contCurrency.getInt("amtprecision"), 4);
|
||||
}
|
||||
|
||||
BigDecimal curMaxShouldPayAmount = entry.getBigDecimal("maxshouldpayamt");
|
||||
BigDecimal curShouldPayAmount = entry.getBigDecimal("applyoftaxamount");
|
||||
BigDecimal submitShouldPayAmount = (BigDecimal)shouldPayAmountMap.getOrDefault(contractId, BigDecimal.ZERO);
|
||||
BigDecimal totalShouldPayAmount = (BigDecimal)contractTypeShouldPayAmountMap.getOrDefault(contractId, BigDecimal.ZERO);
|
||||
if (totalShouldPayAmount.add(submitShouldPayAmount).compareTo(maxShouldPayAmount) > 0) {
|
||||
if (appliedBillMap.containsKey(contractId)) {
|
||||
QFilter contractIdFilter = new QFilter("id", QCP.equals,contractId);
|
||||
DynamicObject contractObj = BusinessDataServiceHelper.loadSingle("ec_out_contract", "id,zcgj_pricetype", new QFilter[]{contractIdFilter});
|
||||
if(contractObj!=null)
|
||||
{
|
||||
String zcgjPricetype = contractObj.getString("zcgj_pricetype");
|
||||
if(!"bdlbdj".equals(zcgjPricetype)){ //如果支出合同计价方式为不定量不定价时,则移除校验
|
||||
BigDecimal maxShouldPayAmount = this.calculateMaxShouldPayAmount(contract);
|
||||
DynamicObject contCurrency = contract.getDynamicObject("currency");
|
||||
if (contCurrency != null) {
|
||||
maxShouldPayAmount = maxShouldPayAmount.setScale(contCurrency.getInt("amtprecision"), 4);
|
||||
}
|
||||
BigDecimal curMaxShouldPayAmount = entry.getBigDecimal("maxshouldpayamt");
|
||||
BigDecimal curShouldPayAmount = entry.getBigDecimal("applyoftaxamount");
|
||||
BigDecimal submitShouldPayAmount = (BigDecimal)shouldPayAmountMap.getOrDefault(contractId, BigDecimal.ZERO);
|
||||
BigDecimal totalShouldPayAmount = (BigDecimal)contractTypeShouldPayAmountMap.getOrDefault(contractId, BigDecimal.ZERO);
|
||||
if (totalShouldPayAmount.add(submitShouldPayAmount).compareTo(maxShouldPayAmount) > 0) {
|
||||
if (appliedBillMap.containsKey(contractId)) {
|
||||
// Set<String> billNumbers = (Set)appliedBillMap.get(contractId);
|
||||
// this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同付款信息:第%1$s行因受流程中单据(单据号:%2$s)影响,继续提交将超过应付金额上限。在途金额:%3$s。", "PaymentMaxAmountValidator_6", "ec-contract-opplugin", new Object[0]), i + 1, StringUtils.join(billNumbers.toArray(new String[0]), ","), CurrencyFormatUtil.getAfterFormatString(contCurrency, submitShouldPayAmount.add(totalShouldPayAmount.subtract(curShouldPayAmount)))));
|
||||
} else if (maxShouldPayAmount.compareTo(curMaxShouldPayAmount) != 0) {
|
||||
this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同付款信息:第%s行因暂存期间存在其他单据提交审核,导致应付金额上限发生变化,本单数据未刷新,继续提交将超过应付金额上限。", "PaymentMaxAmountValidator_1", "ec-contract-opplugin", new Object[0]), i + 1));
|
||||
} else {
|
||||
this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同付款信息:第%s行本次应付金额不允许超应付金额上限,请确认。", "PaymentMaxAmountValidator_2", "ec-contract-opplugin", new Object[0]), i + 1));
|
||||
} else if (maxShouldPayAmount.compareTo(curMaxShouldPayAmount) != 0) {
|
||||
this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同付款信息:第%s行因暂存期间存在其他单据提交审核,导致应付金额上限发生变化,本单数据未刷新,继续提交将超过应付金额上限。", "PaymentMaxAmountValidator_1", "ec-contract-opplugin", new Object[0]), i + 1));
|
||||
} else {
|
||||
this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("合同付款信息:第%s行本次应付金额不允许超应付金额上限,请确认。", "PaymentMaxAmountValidator_2", "ec-contract-opplugin", new Object[0]), i + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void maxApplyAmountValidate(Map<Long, BigDecimal> shouldPayAmountMap, Map<Long, BigDecimal> deductionAmountMap, Map<String, BigDecimal> contractTypeApplyAmountMap, Map<String, BigDecimal> appliedAmountMap, Map<String, Set<String>> appliedBillMap, ExtendedDataEntity dataEntity, int i, DynamicObject entry, DynamicObject contract, String type, String key) {
|
||||
long contractId = contract.getLong("id");
|
||||
|
||||
QFilter contractIdFilter = new QFilter("id", QCP.equals,contractId);
|
||||
DynamicObject contractObj = BusinessDataServiceHelper.loadSingle("ec_out_contract", "id,zcgj_pricetype", new QFilter[]{contractIdFilter});
|
||||
if(contractObj!=null){
|
||||
String zcgjPricetype = contractObj.getString("zcgj_pricetype");
|
||||
if(!"bdlbdj".equals(zcgjPricetype)){ //如果支出合同计价方式为不定量不定价时,则移除校验
|
||||
super.maxApplyAmountValidate( shouldPayAmountMap, deductionAmountMap, contractTypeApplyAmountMap, appliedAmountMap, appliedBillMap, dataEntity, i, entry, contract, type, key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue