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.mt.mt7xx.MT720;


public class MT720Validator extends AbsMTValidator {
    public MT720Validator(String mtStr, MtResult mtResult) {
        super(mtStr,mtResult);
    }
    @Override
    public void bussinessValidator() {
        //  MtResult mtResult=getMtResult();
        MT720 mt720= (MT720) this.getAbstractMT();

        //C1 When used, fields 42C and 42a must both be present (Error code(s): C90).
            //字段42C和字段42a(42A/42D)必须同时存在，请检查!（错误代码：C90）。
       if(!(mt720.getField42C()!=null && (mt720.getField42A()!=null || mt720.getField42D()!=null))){
               mtResult.addDescription(Language.getLanguage("MT720_C1","[MT720]："));
       }
       //C2 Either fields 42C and 42a together, or field 42M alone,or field 42P alone may be present. No other combination of these fields is allowed (Error code(s): C90).
            //字段42M或字段42P不能与字段42C或字段42a(42A/42D)或字段42P同时存在，请检查!（错误代码：C90）。
        if(mt720.getField42C()!=null || mt720.getField42A()!=null || mt720.getField42D()!=null || mt720.getField42P()!=null){
            if (mt720.getField42M()!=null || mt720.getField42P()!=null){
                mtResult.addDescription(Language.getLanguage("MT720_C2","[MT720]："));
            }

        }
        //C3 Either field 44C or 44D, but not both, may be present (Error code(s): D06).
            //字段44C不能与字段44D同时存在，请检查!（错误代码：D06）。
        if (mt720.getField44C()!=null && mt720.getField44D()!=null){
            mtResult.addDescription(Language.getLanguage("MT720_C3","[MT720]："));
        }
        //C4 Either field 52a or field 50B, but not both, must be present (Error code(s): C06).
            //字段52a(52A/52D)与字段50B，必须存在一个，但不能同时存在,请检查!（错误代码：C06）。
        if ((mt720.getField52A()==null && mt720.getField52D()==null && mt720.getField50B()==null)){
            mtResult.addDescription(Language.getLanguage("MT720_C4","[MT720]："));
        }else if (mt720.getField52A()!=null || mt720.getField52D()!=null){
            if (mt720.getField50B()!=null){
                mtResult.addDescription(Language.getLanguage("MT720_C4","[MT720]："));
            }
        }
        //   return mtResult;
    }
}
