优化代码

This commit is contained in:
xiaoshi 2024-12-12 18:19:57 +08:00
parent c6013debf5
commit 99704e85eb
2 changed files with 41 additions and 36 deletions

View File

@ -30,21 +30,22 @@ public class InContractSettlementValidator extends InContractSettleValidator {
QFilter f1 = new QFilter("id", "=", id); QFilter f1 = new QFilter("id", "=", id);
DynamicObject incontractsettle = BusinessDataServiceHelper.loadSingle("ec_in_contract_settle", new QFilter[]{f1}); DynamicObject incontractsettle = BusinessDataServiceHelper.loadSingle("ec_in_contract_settle", new QFilter[]{f1});
DynamicObjectCollection itementry = incontractsettle.getDynamicObjectCollection("itementry"); DynamicObjectCollection itementry = incontractsettle.getDynamicObjectCollection("itementry");
if(itementry == null) {
if(itementry.isEmpty()) {
this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项不能为空", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0]));
}
DynamicObject contract = BusinessDataServiceHelper.loadSingle(dataEntity.getDataEntity().getDynamicObject("contract").getPkValue(), "ec_in_contract");
BigDecimal totalSettleOfTaxAmount = contract.getBigDecimal("totalsettleoftaxamount");
BigDecimal totalOfTaxAmount = contract.getBigDecimal("totaloftaxamount");
DynamicObject contractType = contract.getDynamicObject("contracttype");
DynamicObject contractAttr = contractType == null ? null : contractType.getDynamicObject("contattr");
boolean validateAmount = true;
if (contractAttr != null) {
contractAttr = BusinessDataServiceHelper.loadSingle(contractAttr.getPkValue(), "ec_contattr");
validateAmount = !StringUtils.equals("09", contractAttr.getString("basictype"));
}
}
// DynamicObjectCollection payitemdetailap = incontractsettle.getDynamicObjectCollection("payitemdetailap"); // DynamicObjectCollection payitemdetailap = incontractsettle.getDynamicObjectCollection("payitemdetailap");
if(itementry.isEmpty()) {
this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项不能为空", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0]));
}
DynamicObject contract = BusinessDataServiceHelper.loadSingle(dataEntity.getDataEntity().getDynamicObject("contract").getPkValue(), "ec_in_contract");
BigDecimal totalSettleOfTaxAmount = contract.getBigDecimal("totalsettleoftaxamount");
BigDecimal totalOfTaxAmount = contract.getBigDecimal("totaloftaxamount");
DynamicObject contractType = contract.getDynamicObject("contracttype");
DynamicObject contractAttr = contractType == null ? null : contractType.getDynamicObject("contattr");
boolean validateAmount = true;
if (contractAttr != null) {
contractAttr = BusinessDataServiceHelper.loadSingle(contractAttr.getPkValue(), "ec_contattr");
validateAmount = !StringUtils.equals("09", contractAttr.getString("basictype"));
}
// if (validateAmount && settleOfTaxAmount.compareTo(totalOfTaxAmount.subtract(totalSettleOfTaxAmount)) > 0) { // if (validateAmount && settleOfTaxAmount.compareTo(totalOfTaxAmount.subtract(totalSettleOfTaxAmount)) > 0) {
// this.addErrorMessage(dataEntity, ResManager.loadKDString("本期结算价税合计不能大于合同剩余金额价税合计", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0])); // this.addErrorMessage(dataEntity, ResManager.loadKDString("本期结算价税合计不能大于合同剩余金额价税合计", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0]));
// } // }

View File

@ -20,33 +20,37 @@ public class OutContractSettlementValidator extends OutContractSettleValidator {
long id = dataEntity.getDataEntity().getLong("id"); long id = dataEntity.getDataEntity().getLong("id");
QFilter f1 = new QFilter("id", "=", id); QFilter f1 = new QFilter("id", "=", id);
DynamicObject incontractsettle = BusinessDataServiceHelper.loadSingle("ec_in_contract_settle", new QFilter[]{f1}); DynamicObject incontractsettle = BusinessDataServiceHelper.loadSingle("ec_in_contract_settle", new QFilter[]{f1});
DynamicObjectCollection itementry = incontractsettle.getDynamicObjectCollection("itementry"); if(incontractsettle!=null){
DynamicObjectCollection itementry = incontractsettle.getDynamicObjectCollection("itementry");
// DynamicObjectCollection payitemdetailap = incontractsettle.getDynamicObjectCollection("payitemdetailap"); // DynamicObjectCollection payitemdetailap = incontractsettle.getDynamicObjectCollection("payitemdetailap");
if(itementry.isEmpty()) { if(itementry.isEmpty()) {
this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项不能为空", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0])); this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项不能为空", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0]));
}
if (contractTemp == null) {
this.addErrorMessage(dataEntity, ResManager.loadKDString("合同不可为空。", "OutContractSettleValidator_5", "ec-contract-opplugin", new Object[0]));
return false;
} else {
DynamicObject contract = BusinessDataServiceHelper.loadSingle(dataEntity.getDataEntity().getDynamicObject("contract").getPkValue(), "ec_out_contract");
BigDecimal totalSettleOfTaxAmount = contract.getBigDecimal("totalsettleoftaxamount");
BigDecimal totalOfTaxAmount = contract.getBigDecimal("totaloftaxamount");
DynamicObject contractType = contract.getDynamicObject("contracttype");
DynamicObject contractAttr = contractType == null ? null : contractType.getDynamicObject("contattr");
boolean validateAmount = true;
if (contractAttr != null) {
contractAttr = BusinessDataServiceHelper.loadSingle(contractAttr.getPkValue(), "ec_contattr");
validateAmount = !StringUtils.equals("09", contractAttr.getString("basictype"));
} }
if (contractTemp == null) {
if (validateAmount && settleOfTaxAmount.compareTo(totalOfTaxAmount.subtract(totalSettleOfTaxAmount)) > 0) { this.addErrorMessage(dataEntity, ResManager.loadKDString("合同不可为空。", "OutContractSettleValidator_5", "ec-contract-opplugin", new Object[0]));
// this.addErrorMessage(dataEntity, ResManager.loadKDString("本期结算价税合计不能大于合同剩余金额价税合计", "OutContractSettleValidator_0", "ec-contract-opplugin", new Object[0])); return false;
return true;
} else { } else {
return true; DynamicObject contract = BusinessDataServiceHelper.loadSingle(dataEntity.getDataEntity().getDynamicObject("contract").getPkValue(), "ec_out_contract");
BigDecimal totalSettleOfTaxAmount = contract.getBigDecimal("totalsettleoftaxamount");
BigDecimal totalOfTaxAmount = contract.getBigDecimal("totaloftaxamount");
DynamicObject contractType = contract.getDynamicObject("contracttype");
DynamicObject contractAttr = contractType == null ? null : contractType.getDynamicObject("contattr");
boolean validateAmount = true;
if (contractAttr != null) {
contractAttr = BusinessDataServiceHelper.loadSingle(contractAttr.getPkValue(), "ec_contattr");
validateAmount = !StringUtils.equals("09", contractAttr.getString("basictype"));
}
if (validateAmount && settleOfTaxAmount.compareTo(totalOfTaxAmount.subtract(totalSettleOfTaxAmount)) > 0) {
// this.addErrorMessage(dataEntity, ResManager.loadKDString("本期结算价税合计不能大于合同剩余金额价税合计", "OutContractSettleValidator_0", "ec-contract-opplugin", new Object[0]));
return true;
} else {
return true;
}
} }
} }
} }
return true;
} }
} }