package com.brilliance.isc.swift.objmtconvert.model.busvalidator.mt7xx;


import com.brilliance.isc.swift.objmtconvert.model.AbsMTValidator;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import com.brilliance.isc.swift.objmtconvert.util.Language;
import com.prowidesoftware.swift.model.field.Field32B;
import com.prowidesoftware.swift.model.field.Field33A;
import com.prowidesoftware.swift.model.field.Field33B;
import com.prowidesoftware.swift.model.mt.mt7xx.MT752;

import java.util.Objects;

/**
 * MT750
 * @author wanggang
 * @Date 2023-3-3
 */
public class MT752Validator extends AbsMTValidator {

    public MT752Validator(String mtStr, MtResult mtResult)
    {
        super(mtStr,mtResult);
    }

    @Override
    public void bussinessValidator() {
        //  MtResult mtResult = getMtResult();
        MT752 mt752= (MT752)this.getAbstractMT();

        if (!Objects.isNull(mt752.getField32B()) && !Objects.isNull(mt752.getField71D())){
            if (Objects.isNull(mt752.getField33A()) && Objects.isNull(mt752.getField33B())){
                mtResult.addDescription(Language.getLanguage("MT752_C1","【MT752】"));
            }
        }
        Field33B field33B = mt752.getField33B();
        Field33A field33A = mt752.getField33A();
        String field33Currency = "";
        if(field33B!=null){
            field33Currency = field33B.getCurrency();
        }
        if(field33A!=null){
            field33Currency = field33A.getCurrency();
        }
        Field32B field32B = mt752.getField32B();
        if(field32B!=null){
            String field32Currency = field32B.getCurrency();
            if(!field33Currency.equals(field32Currency)){
                mtResult.addDescription(Language.getLanguage("MT752_C2","【MT752】"));
            }
        }
        //  return  mtResult;
    }

}
