package com.yem.wm.es.salescontrac.validator;

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

/**
 * @author zhouc
 * @date 2024/4/22 21:18
 * @className SalescontracSubmitVaildator
 * @description
 */
public class SalescontracSubmitVaildator extends AbstractValidator {
    @Override
    public void validate() {
        ExtendedDataEntity[] dataEntities = this.getDataEntities();
        for (ExtendedDataEntity dataEntitie : dataEntities) {
            DynamicObject dataEntity = dataEntitie.getDataEntity();
            DynamicObject yem_currency = dataEntity.getDynamicObject("yem_currency");
            DynamicObject yem_currencybase = dataEntity.getDynamicObject("yem_currencybase");
            DynamicObject yem_internationalrate = dataEntity.getDynamicObject("yem_internationalrate");
            if (yem_currency != null && yem_currencybase != null) {
                if (yem_currency.getLong("id") != yem_currencybase.getLong("id")) {
                    if (yem_internationalrate == null) {
                        String msg = "结算币别不等于本位币，收款天数必录！";
                        this.addErrorMessage(dataEntitie, msg);
                    }
                }
            }
        }
    }
}
