支出财务确认单提交时冲销金额校验插件
This commit is contained in:
parent
696a84f1b9
commit
a61824e72f
|
|
@ -0,0 +1,81 @@
|
|||
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.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 支出财务确认单提交时冲销金额校验插件
|
||||
*/
|
||||
public class MaterialinbillReversalamountCkOp extends AbstractOperationServicePlugIn {
|
||||
|
||||
private static final Log log = LogFactory.getLog(MaterialinbillReversalamountCkOp.class);
|
||||
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
e.getFieldKeys().add("zcgj_prepayentry");
|
||||
e.getFieldKeys().add("zcgj_prepayentry.zcgj_sourceapplybillid");
|
||||
e.getFieldKeys().add("zcgj_prepayentry.zcgj_sourceapplyentryid");
|
||||
e.getFieldKeys().add("zcgj_prepayentry.zcgj_boltamount");
|
||||
e.getFieldKeys().add("zcgj_isprepay");
|
||||
}
|
||||
|
||||
@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();//支出财务确认单
|
||||
DynamicObjectCollection entryEntityCollection = dataEntity.getDynamicObjectCollection("zcgj_prepayentry");//付款信息分录
|
||||
for (int i = 0; i < entryEntityCollection.size(); i++) {
|
||||
DynamicObject entryEntity = entryEntityCollection.get(i);
|
||||
DynamicObjectCollection prepayentryCollection = dataEntity.getDynamicObjectCollection("zcgj_prepayentry");//冲销预付分录
|
||||
String isprepay = dataEntity.getString("zcgj_isprepay");
|
||||
if("10".equals(isprepay)){
|
||||
if(prepayentryCollection == null || prepayentryCollection.isEmpty()){
|
||||
this.addFatalErrorMessage(extendedDataEntity, String.format("请录入冲销预付明细数据!"));
|
||||
}else{
|
||||
int seq = 0;
|
||||
for (DynamicObject prepay : prepayentryCollection) {
|
||||
seq++;
|
||||
long sourceapplybillid = prepay.getLong("zcgj_sourceapplybillid");
|
||||
long sourceapplyentryid = prepay.getLong("zcgj_sourceapplyentryid");
|
||||
BigDecimal boltamount = prepay.getBigDecimal("zcgj_boltamount");//入库单冲销金额
|
||||
DynamicObject paymentapply = BusinessDataServiceHelper.loadSingle(sourceapplybillid, "ec_paymentapply");//工程资金付款申请单
|
||||
if (paymentapply != null) {
|
||||
DynamicObjectCollection entryentityCollection = paymentapply.getDynamicObjectCollection("entryentity");
|
||||
|
||||
for (DynamicObject dynamicObject : entryentityCollection) {
|
||||
BigDecimal thisrealpayamt = dynamicObject.getBigDecimal("thisrealpayamt");//付款申请单本次实付金额
|
||||
long pkValue = (long)dynamicObject.getPkValue();
|
||||
if(pkValue==sourceapplyentryid){
|
||||
BigDecimal zcgjYreversalamount = dynamicObject.getBigDecimal("zcgj_yreversalamount");
|
||||
zcgjYreversalamount = zcgjYreversalamount.add(boltamount);
|
||||
if(thisrealpayamt.subtract(zcgjYreversalamount).compareTo(BigDecimal.ZERO) < 0){
|
||||
this.addFatalErrorMessage(extendedDataEntity, String.format("冲销预付分录第%d行,冲销金额超限!",seq));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue