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

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.AbsMTCreator;
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.mt1xx.tag.tag191.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

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

public class MT191Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    //20
    private String transactionReferenceNumber;
    @Status("M")
    @TagName("21")
    @FieldDescription("Related Reference")
    @TagRegex("16x")
    //21
    private String relatedReference;
    @Status("M")
    @TagName("32B")
    @FieldDescription("Currency Code, Amount")
    @TagRegex("3!a15d")
    //32B
    private DcDateCurAmtTagXXX currencyCodeAmount32B;
    @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"})
    //52a
    private ActnoBicAdrTagXXX orderingInstitution52a;
    @Status("O")
    @TagName({"57A","57B","57D"})
    @FieldDescription("Account With Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    //57a
    private ActnoBicAdrTagXXX accountWithInstitution57a;
    @Status("M")
    @TagName({"71B"})
    @FieldDescription("Details of Charges")
    @TagRegex({"6*35x"})
    //71B
    private String detailsofCharges;
    @Status("O")
    @TagName({"72"})
    @FieldDescription("Sender to Receiver Information")
    @TagRegex({"6*35x"})
    //72
    private String sendertoReceiverInformation;

    public String getTransactionReferenceNumber() {
        return transactionReferenceNumber;
    }

    public void setTransactionReferenceNumber(String transactionReferenceNumber) {
        this.transactionReferenceNumber = transactionReferenceNumber;
    }

    public String getRelatedReference() {
        return relatedReference;
    }

    public void setRelatedReference(String relatedReference) {
        this.relatedReference = relatedReference;
    }

    public DcDateCurAmtTagXXX getCurrencyCodeAmount32B() {
        return currencyCodeAmount32B;
    }

    public void setCurrencyCodeAmount32B(DcDateCurAmtTagXXX currencyCodeAmount32B) {
        this.currencyCodeAmount32B = currencyCodeAmount32B;
    }

    public String getDetailsofCharges() {
        return detailsofCharges;
    }

    public void setDetailsofCharges(String detailsofCharges) {
        this.detailsofCharges = detailsofCharges;
    }

    public String getSendertoReceiverInformation() {
        return sendertoReceiverInformation;
    }

    public void setSendertoReceiverInformation(String sendertoReceiverInformation) {
        this.sendertoReceiverInformation = sendertoReceiverInformation;
    }

    public ActnoBicAdrTagXXX getOrderingInstitution52a() {
        return orderingInstitution52a;
    }

    public void setOrderingInstitution52a(ActnoBicAdrTagXXX orderingInstitution52a) {
        this.orderingInstitution52a = orderingInstitution52a;
    }

    public ActnoBicAdrTagXXX getAccountWithInstitution57a() {
        return accountWithInstitution57a;
    }

    public void setAccountWithInstitution57a(ActnoBicAdrTagXXX accountWithInstitution57a) {
        this.accountWithInstitution57a = accountWithInstitution57a;
    }

    //    public MT191Creator(String jsonData) throws Exception {
//        super(jsonData);
//    }
    public MT191Creator(String msgType)  {
    super(msgType);
}


    public void pack() {
        //MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList=new ArrayList<>();
        try {
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag21Creator(this));
            tagCreateList.add(new Tag32BCreator(this));
            tagCreateList.add(new Tag52aCreator(this));
            tagCreateList.add(new Tag57aCreator(this));
            tagCreateList.add(new Tag71BCreator(this));
            tagCreateList.add(new Tag72Creator(this));

            dealTags(tagCreateList);

            mtResult.setMessage(abstractMT.message());
        } catch (Exception e) {
            e.printStackTrace();
            mtResult.setSuccess(false);
            mtResult.addDescription(e.getLocalizedMessage());
        }

        //return mtResult;

    }

    public MtResult unpack() {
        return null;
    }
}
