package com.yem.wm.fm.gathering.validator;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.validate.AbstractValidator;

public class GatheringValidator extends AbstractValidator {
    @Override
    public void validate() {
        ExtendedDataEntity[]  datas = this.getDataEntities();
        for(ExtendedDataEntity temp:datas) {
            DynamicObject bill = temp.getDataEntity();
            DynamicObject dynamicObject = bill.getDynamicObject("org");
            DynamicObject dynamicObject1 = bill.getDynamicObject("yem_finorg");
            DynamicObject dynamicObject2 = bill.getDynamicObject("yem_receiptaccount");
            if (null!=dynamicObject){
                String string = dynamicObject.getString("number");
                if ("110".equals(string)){
                    if (dynamicObject1!=null){
                        String string1 = dynamicObject1.getString("number");
                        if ("116".equals(string1)){
                            extracted(temp, dynamicObject2);
                        }else if ("".equals(string1)){
                            extracted(temp, dynamicObject2);
                        }
                    }else {
                        extracted(temp, dynamicObject2);
                    }
                }else {
                    extracted(temp, dynamicObject2);
                }
            }
        }
    }

    private void extracted(ExtendedDataEntity temp, DynamicObject dynamicObject2) {
        if (dynamicObject2 ==null){
            this.addErrorMessage(temp,"收款名称为空，请填写后提交！！！");
        }
    }
}
