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

import com.brilliance.isc.swift.objmtconvert.annotation.FieldDescription;
import com.brilliance.isc.swift.objmtconvert.annotation.Status;
import com.brilliance.isc.swift.objmtconvert.annotation.TagName;
import com.brilliance.isc.swift.objmtconvert.annotation.TagRegex;
import com.brilliance.isc.swift.objmtconvert.model.AbsTagCreate;
import com.brilliance.isc.swift.objmtconvert.model.commontag.ActnoBicAdrTagXXX;
import com.brilliance.isc.swift.objmtconvert.model.commontag.DcDateCurAmtTagXXX;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.tag.tag202common.*;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.tag.tag202cov.TagB33BCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.tag.tag202cov.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

import java.util.ArrayList;
import java.util.List;

public class MT202COVCreator extends MT202Creator {
    @Status("M")
    @TagName({"50A","50F","50K"})
    @FieldDescription("Ordering Customer")
    @TagRegex({"[/34x]<crlf>4!a2!a2!c[3!c]","35x<crlf>4*(1!n/33x)","[/34x]<crlf>4*35x"})
    //B50a
    private ActnoBicAdrTagXXX orderingCustomerB;
    @Status("O")
    @TagName({"52A","52D"})
    @FieldDescription("Ordering Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>4*35x"})
    //B52a
    private ActnoBicAdrTagXXX orderingInstitutionB;
    @Status("O")
    @TagName({"56A","56C","56D"})
    @FieldDescription("Intermediary Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","/34x","[/1!a][/34x]<crlf>4*35x"})
    //B56a
    private ActnoBicAdrTagXXX intermediaryInstitutionB;
    @Status("O")
    @TagName({"57A","57B","57C","57D"})
    @FieldDescription("Account With Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","/34x","[/1!a][/34x]<crlf>4*35x"})
    //B57a
    private ActnoBicAdrTagXXX accountWithInstitutionB;
    @Status("M")
    @TagName({"59","59A","59F"})
    @FieldDescription("Beneficiary Customer")
    @TagRegex({"[/34x]<crlf>4*35x","[/34x]<crlf>4!a2!a2!c[3!c]","[/34x]<crlf>4*(1!n/33x)"})
    //B59a
    private ActnoBicAdrTagXXX beneficiaryCustomerB;
    @Status("O")
    @TagName("70")
    @FieldDescription("Remittance Information")
    @TagRegex("4*35x")
    //B70
    private String remittanceInformationB;
    @Status("O")
    @TagName("72")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex("6*35x")
    //B72
    private String sendertoReceiverInformationB;
    @Status("O")
    @TagName("33B")
    @FieldDescription("Currency/Instructed Amount")
    @TagRegex("3!a15d")
    //B33B
    private DcDateCurAmtTagXXX currencyAmountB;

    public ActnoBicAdrTagXXX getOrderingCustomerB() {
        return orderingCustomerB;
    }

    public void setOrderingCustomerB(ActnoBicAdrTagXXX orderingCustomerB) {
        this.orderingCustomerB = orderingCustomerB;
    }

    public ActnoBicAdrTagXXX getOrderingInstitutionB() {
        return orderingInstitutionB;
    }

    public void setOrderingInstitutionB(ActnoBicAdrTagXXX orderingInstitutionB) {
        this.orderingInstitutionB = orderingInstitutionB;
    }

    public ActnoBicAdrTagXXX getIntermediaryInstitutionB() {
        return intermediaryInstitutionB;
    }

    public void setIntermediaryInstitutionB(ActnoBicAdrTagXXX intermediaryInstitutionB) {
        this.intermediaryInstitutionB = intermediaryInstitutionB;
    }

    public ActnoBicAdrTagXXX getAccountWithInstitutionB() {
        return accountWithInstitutionB;
    }

    public void setAccountWithInstitutionB(ActnoBicAdrTagXXX accountWithInstitutionB) {
        this.accountWithInstitutionB = accountWithInstitutionB;
    }

    public ActnoBicAdrTagXXX getBeneficiaryCustomerB() {
        return beneficiaryCustomerB;
    }

    public void setBeneficiaryCustomerB(ActnoBicAdrTagXXX beneficiaryCustomerB) {
        this.beneficiaryCustomerB = beneficiaryCustomerB;
    }

    public String getRemittanceInformationB() {
        return remittanceInformationB;
    }

    public void setRemittanceInformationB(String remittanceInformationB) {
        this.remittanceInformationB = remittanceInformationB;
    }

    public String getSendertoReceiverInformationB() {
        return sendertoReceiverInformationB;
    }

    public void setSendertoReceiverInformationB(String sendertoReceiverInformationB) {
        this.sendertoReceiverInformationB = sendertoReceiverInformationB;
    }

    public DcDateCurAmtTagXXX getCurrencyAmountB() {
        return currencyAmountB;
    }

    public void setCurrencyAmountB(DcDateCurAmtTagXXX currencyAmountB) {
        this.currencyAmountB = currencyAmountB;
    }

    public MT202COVCreator() {
        super();
    }




    public MT202COVCreator(String msgType) {
        super(msgType);
    }

    @Override
    public void pack() {

       // MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList = new ArrayList();
        try {
//            tagCreateList.addAll(mt202COVCreator.addTagList());
            tagCreateList.add(new Tag13CCreator(this));
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag21Creator(this));
            tagCreateList.add(new Tag32ACreator(this));
            tagCreateList.add(new Tag52aCreator(this));
            tagCreateList.add(new Tag53aCreator(this));
            tagCreateList.add(new Tag54aCreator(this));
            tagCreateList.add(new Tag56aCreator(this));
            tagCreateList.add(new Tag57aCreator(this));
            tagCreateList.add(new Tag58aCreator(this));
            tagCreateList.add(new Tag72Creator(this));

            tagCreateList.add(new TagB33BCreator(this));
            tagCreateList.add(new TagB50aCreator(this));
            tagCreateList.add(new TagB52aCreator(this));
            tagCreateList.add(new TagB56aCreator(this));
            tagCreateList.add(new TagB57aCreator(this));
            tagCreateList.add(new TagB59aCreator(this));
            tagCreateList.add(new TagB70Creator(this));
            tagCreateList.add(new TagB72Creator(this));
            dealTags(tagCreateList);
            mtResult.setMessage(abstractMT.message());
        }catch (Exception e){
            e.printStackTrace();
            mtResult.setSuccess(false);
            mtResult.addDescription(e.getLocalizedMessage());
        }

        // return mtResult;
    }
}
