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

/**
 * MT750
 * @author wanggang
 * @Date 2023-03-03
 */
public class MT750Validator extends AbsMTValidator {

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

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

        //C1 If any one or more of fields 33B, 71D, and field 73A are present, then field 34B must also be present (Error code(s): C13).
            //如果存在字段33B、71D和字段73A中的任何一个或多个，则字段34B也必须存在,请检查!（错误代码：C13）。
        if (mt750.getField33B()!=null || mt750.getField71D()!=null || mt750.getField73A()!=null){
            if (mt750.getField34B()==null){
                mtResult.addDescription(Language.getLanguage("MT750_C1","[MT750]："));
            }
        }
        //C2 The currency code in the amount fields 32B and 34B must be the same (Error code(s): C02).
            //金额字段32B和34B中的货币代码必须相同,请检查！（错误代码：C02）。
        Field32B field32B = mt750.getField32B();
        Field34B field34B = mt750.getField34B();
        String field32BCurrency = "";
        String field34BCurrency = "";
        if (field32B!=null){
            field32BCurrency = field32B.getCurrency();
        }
        if (field34B!=null){
            field34BCurrency = field34B.getCurrency();
            if (!field32BCurrency.equals(field34BCurrency)){
                mtResult.addDescription(Language.getLanguage("MT750_C2","[MT750]："));
            }
        }
        //   return  mtResult;
    }

}

