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.Constans;
import com.brilliance.isc.swift.objmtconvert.util.Language;
import com.prowidesoftware.swift.model.field.*;
import com.prowidesoftware.swift.model.mt.mt7xx.MT752;
import com.prowidesoftware.swift.model.mt.mt7xx.MT754;

import java.util.Objects;

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

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

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

        if (!Objects.isNull(mt754.getField72Z()) && !Objects.isNull(mt754.getField77())) {
            mtResult.addDescription(Language.getLanguage("MT754_C1","【MT754】"));
        }
        if (Objects.isNull(mt754.getField72Z()) && Objects.isNull(mt754.getField77())) {
            mtResult.addDescription(Language.getLanguage("MT754_C1","【MT754】"));
        }
        if (!Objects.isNull(mt754.getField53A()) || !Objects.isNull(mt754.getField53B()) || !Objects.isNull(mt754.getField53D())) {
            if (!Objects.isNull(mt754.getField57A()) || !Objects.isNull(mt754.getField57B()) || !Objects.isNull(mt754.getField57D())) {
                mtResult.addDescription(Language.getLanguage("MT754_C2","【MT754】"));
            }
        }
        if (Objects.isNull(mt754.getField53A()) && Objects.isNull(mt754.getField53B()) && Objects.isNull(mt754.getField53D())) {
            if (Objects.isNull(mt754.getField57A()) && Objects.isNull(mt754.getField57B()) && Objects.isNull(mt754.getField57D())) {
                mtResult.addDescription(Language.getLanguage("MT754_C2","【MT754】"));
            }
        }
            Field32A field32A = mt754.getField32A();
            Field32B field32B = mt754.getField32B();
            String field32Currency = "";
            if (field32A != null) {
                field32Currency = field32A.getCurrency();
            }
            if (field32B != null) {
                field32Currency = field32B.getCurrency();
            }
            Field34A field34A = mt754.getField34A();
            Field34B field34B = mt754.getField34B();
            String field34Currency = "";
            if (field34A != null) {
                field34Currency = field34A.getCurrency();
                if (!field34Currency.equals(field32Currency)) {
                    mtResult.addDescription(Language.getLanguage("MT754_C3","【MT754】"));
                }
            }
            if (field34B != null) {
                field34Currency = field34B.getCurrency();
                if (!field34Currency.equals(field32Currency)) {
                    mtResult.addDescription(Language.getLanguage("MT754_C3","【MT754】"));
                }
            }
        //     return mtResult;
        }
}

