支出合同结算 金额校验
This commit is contained in:
parent
781c1591ba
commit
ef76a2b705
|
@ -0,0 +1,77 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.operate;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 工序分摊金额校验
|
||||
*/
|
||||
public class OutContractSettleProcessCheckExtOp extends AbstractOperationServicePlugIn {
|
||||
|
||||
@Override
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
super.onPreparePropertys(e);
|
||||
e.getFieldKeys().add("itementry");
|
||||
e.getFieldKeys().add("itementry.oftaxamount");
|
||||
e.getFieldKeys().add("itementry.amount");
|
||||
e.getFieldKeys().add("zcgj_allprocessbytax");
|
||||
e.getFieldKeys().add("zcgj_processallocatentity");
|
||||
e.getFieldKeys().add("contract");
|
||||
//e.getFieldKeys().add("contract.zcgj_pricetype");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||
super.onAddValidators(e);
|
||||
//当前所在的组织是属于矿山下的
|
||||
e.getValidators().add(new ValidatorExt());
|
||||
}
|
||||
|
||||
class ValidatorExt extends AbstractValidator {
|
||||
@Override
|
||||
public void validate() {
|
||||
ExtendedDataEntity[] extendedDataEntities = this.getDataEntities();
|
||||
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
|
||||
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
|
||||
DynamicObject contract = dataEntity.getDynamicObject("contract");
|
||||
boolean isByPrincetax = dataEntity.getBoolean("zcgj_allprocessbytax");//获取按价税合计分摊工序复合按钮
|
||||
if (contract != null) {
|
||||
DynamicObject contractObj = BusinessDataServiceHelper.loadSingle(contract.getLong("id"), "ec_out_contract", "zcgj_pricetype");
|
||||
//不定量不定价合同和总价包干合同,zjbg,bdlbdj
|
||||
if (contractObj.getString("zcgj_pricetype").equals("zjbg")
|
||||
|| contractObj.getString("zcgj_pricetype").equals("bdlbdj")) {
|
||||
DynamicObjectCollection itementryCollection = dataEntity.getDynamicObjectCollection("itementry");
|
||||
int i = 1;
|
||||
for (DynamicObject itementry : itementryCollection) {
|
||||
BigDecimal oftaxamount = itementry.getBigDecimal("oftaxamount");
|
||||
BigDecimal amount = itementry.getBigDecimal("amount");
|
||||
DynamicObjectCollection processallocatentityCollection = itementry.getDynamicObjectCollection("zcgj_processallocatentity");
|
||||
BigDecimal totalPaAmount = BigDecimal.ZERO;
|
||||
for (DynamicObject dynamicObject : processallocatentityCollection) {
|
||||
totalPaAmount = totalPaAmount.add(dynamicObject.getBigDecimal("zcgj_pa_amount"));
|
||||
}
|
||||
if (isByPrincetax) {
|
||||
if (totalPaAmount.compareTo(oftaxamount) != 0) {
|
||||
this.addFatalErrorMessage(extendedDataEntity, "合同支付项第" + i + "条的价税合计金额与工序分摊金额之和不等,请重新核对并调整分摊金额,以确保两者相等。");
|
||||
}
|
||||
} else {
|
||||
if (totalPaAmount.compareTo(amount) != 0) {
|
||||
this.addFatalErrorMessage(extendedDataEntity, "合同支付项第" + i + "条的价金额(不含税)与工序分摊金额之和不等,请重新核对并调整分摊金额,以确保两者相等。");
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue