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

import com.brilliance.isc.swift.objmtconvert.model.AbsMTValidator;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import com.brilliance.isc.swift.objmtconvert.util.Constans;
import com.brilliance.isc.swift.objmtconvert.util.Language;
import com.prowidesoftware.swift.model.field.*;
import com.prowidesoftware.swift.model.mt.mt2xx.MT210;

import java.util.List;

/**
 * @author huangmengyuan
 * @create 2023/3/6
 */
public class MT210Validator extends AbsMTValidator {
    public MT210Validator(String mtStr, MtResult mtResult) {
        super(mtStr, mtResult);
    }

    public MT210Validator() {
    }

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

        List<Field32B> field32B = mt210.getField32B();
        if (field32B.size() > 10) {
//            mtResult.addDescription("【MT210】中循环域不能超过十次,请检查");
            mtResult.addDescription(Language.getLanguage("MT210_C1","【MT210】"));
        }
        for (Field32B field : field32B) {
            if (!field.getCurrency().equals(field32B.get(0).getCurrency())) {
//                mtResult.addDescription("【MT210】中循环域内Field32B金额类型需保持一致，请检查");
                mtResult.addDescription(Language.getLanguage("MT210_C2_1","【MT210】"));
            }
        }


        List<MT210.SequenceA> sequenceAList = mt210.getSequenceAList();
        for (MT210.SequenceA tags : sequenceAList) {
            if (tags.containsTag(50)){
                if (tags.containsTag(52)){
//                    mtResult.addDescription("【MT210】中如果循环域中50或者50C或者50F存在,那么52A或者52D不能存在,请检查");
                    mtResult.addDescription(Language.getLanguage("MT210_C2_2","【MT210】"));
                }
            }
            if (!tags.containsTag(50)){
                if (!tags.containsTag(52)){
//                    mtResult.addDescription("【MT210】中循环域中50或者50C或者50F存或者52A或者52D必须有一个存在,请检查");
                    mtResult.addDescription(Language.getLanguage("MT210_C3","【MT210】"));
                }
            }
        }



        //  return mtResult;
    }
}
