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

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.*;
import com.prowidesoftware.swift.model.mt.mt9xx.MT950;

/**
 * @author zh
 * @create 2023-03-03-10:27
 */
public class MT950Validator extends AbsMTValidator {

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

    @Override
    public void bussinessValidator() {
        //    MtResult mtResult=getMtResult();
        boolean flag = false;
        MT950 mt950 = (MT950) this.getAbstractMT();
        Field60F field60F = mt950.getField60F();
        Field60M field60M = mt950.getField60M();
        String field60Currency = "";
        if(field60F!=null){
            field60Currency = field60F.getCurrency().substring(0,2);
        }
        if(field60M!=null){
            field60Currency = field60M.getCurrency().substring(0,2);
        }
        Field62F field62F = mt950.getField62F();
        Field62M field62M = mt950.getField62M();
        String field62Currency = "";
        if(field62F!=null){
            field62Currency = field62F.getCurrency().substring(0,2);
        }
        if(field62M!=null){
            field62Currency = field62M.getCurrency().substring(0,2);
        }
        if(!field60Currency.equals(field62Currency)){
            flag = true;
        }
        Field64 field64 = mt950.getField64();
        if(field64!=null){
            String field64Currency = field64.getCurrency().substring(0,2);
            if(!field60Currency.equals(field64Currency)){
                flag = true;
            }
        }
        if(flag){
            mtResult.addDescription(Language.getLanguage("MT950_C1","【MT950】"));
        }
        //  return mtResult;
    }
}
