付款收款会计科目过滤

This commit is contained in:
zhangzhiguo 2025-03-10 18:05:42 +08:00
parent 7ff5e1d92a
commit 785132b439
2 changed files with 50 additions and 18 deletions

View File

@ -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());

View File

@ -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);
}
}
}
}