入库单提交时校验已冲销金额
This commit is contained in:
parent
e2a8a7f155
commit
17a68ff852
|
|
@ -0,0 +1,79 @@
|
||||||
|
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 MaterialinCheckBoltamountOp extends AbstractOperationServicePlugIn {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(MaterialinCheckBoltamountOp.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_prepayentry.zcgj_alreadyboltamount");//已冲销金额
|
||||||
|
e.getFieldKeys().add("zcgj_prepayentry.zcgj_prepayamount");//预付金额
|
||||||
|
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();//入库单
|
||||||
|
String isprepay = dataEntity.getString("zcgj_isprepay");
|
||||||
|
if("10".equals(isprepay)){
|
||||||
|
DynamicObjectCollection prepayentryCollection = dataEntity.getDynamicObjectCollection("zcgj_prepayentry");//冲销预付分录
|
||||||
|
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");//本次冲销金额
|
||||||
|
BigDecimal prepayamount = prepay.getBigDecimal("zcgj_prepayamount");//预付金额
|
||||||
|
DynamicObject paymentapply = BusinessDataServiceHelper.loadSingle(sourceapplybillid, "ec_paymentapply");//工程资金付款申请单
|
||||||
|
if (paymentapply != null) {
|
||||||
|
DynamicObjectCollection entryentityCollection = paymentapply.getDynamicObjectCollection("entryentity");
|
||||||
|
|
||||||
|
for (DynamicObject dynamicObject : entryentityCollection) {
|
||||||
|
long pkValue = (long)dynamicObject.getPkValue();
|
||||||
|
if(pkValue==sourceapplyentryid){
|
||||||
|
BigDecimal yreversalamount = dynamicObject.getBigDecimal("zcgj_yreversalamount");//付款申请单已冲销金额+入库单本次冲销金额
|
||||||
|
yreversalamount = yreversalamount.add(boltamount);
|
||||||
|
if(prepayamount.subtract(yreversalamount).compareTo(BigDecimal.ZERO) < 0){
|
||||||
|
this.addFatalErrorMessage(extendedDataEntity, String.format("冲销预付分录第%d行,累计冲销金额超过预付金额!",seq));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue