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

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

/**
 * @Classname GatheringConfirmValidator
 * @Description TODO
 * @Date 2023/12/20 18:43
 * @Created by ZZSLL
 */

public class GatheringConfirmValidator extends AbstractValidator
{
    @Override
    public void validate()
    {
        ExtendedDataEntity[] dataEntities = this.getDataEntities();
        for (ExtendedDataEntity dataEntity : dataEntities) {
            DynamicObject entity = dataEntity.getDataEntity();
            String financeaffirm = entity.getString("yem_financeaffirm");
            String operateKey = this.getOperateKey();
            // 财务确认
            if ("statusconvertcwqr".equals(operateKey)) {
                if ("B".equals(financeaffirm)) {
                    this.addErrorMessage(dataEntity, "财务已确认，不允许重复确认");
                }
            }

            if ("statusconvertcwfqr".equals(operateKey)) {
                if ("A".equals(financeaffirm) || "C".equals(financeaffirm)) {
                    this.addErrorMessage(dataEntity, "财务未确认或已驳回，不允许反确认");
                }
            }
        }
    }
}
