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.tag103STP.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

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

public class MT103STPCreator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Sender's Reference")
    @TagRegex("16x")
    //20
    private String sendersReference;
    @Status("O")
    @TagName("13C")
    @FieldDescription("Time Indication")
    @TagRegex("/8c/4!n1!x4!n")
    //13C
    private List<String> timeIndication;
    @Status("M")
    @TagName("23B")
    @FieldDescription("Bank Operation Code")
    @TagRegex("4!c")
    //23B
    private String bankOperationCode;
    @Status("O")
    @TagName("23E")
    @FieldDescription("Instruction Code")
    @TagRegex("4!c[/30x]")
    //23E
    private List<String> instructionCode;
    @Status("O")
    @TagName("26T")
    @FieldDescription("Transaction Type Code")
    @TagRegex("3!c")
    //26T
    private String transactionTypeCode;
    @Status("M")
    @TagName("32A")
    @FieldDescription("Value Date/Currency/Interbank Settled Amount")
    @TagRegex("6!n3!a15d")
    //32A
    private DcDateCurAmtTagXXX valueDateCurrencyInterbankSettledAmount32A;
    @Status("O")
    @TagName("33B")
    @FieldDescription("Currency/Instructed Amount")
    @TagRegex("3!a15d")
    //33B
    private DcDateCurAmtTagXXX currencyInstructedAmount33B;
    @Status("O")
    @TagName("36")
    @FieldDescription("Exchange Rate")
    @TagRegex("12d")
    //36
    private String exchangeRate;
    @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"})
    //50a
    private ActnoBicAdrTagXXX orderingCustomer50a;
    @Status("O")
    @TagName("52A")
    @FieldDescription("Ordering Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]"})
    //52A
    private ActnoBicAdrTagXXX orderingInstitution52A;
    @Status("O")
    @TagName({"53A","53B"})
    @FieldDescription("Sender's Correspondent")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]"})
    //53a
    private ActnoBicAdrTagXXX sendersCorrespondent53a;
    @Status("O")
    @TagName("54A")
    @FieldDescription("Receiver's Correspondent")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]"})
    //54A
    private ActnoBicAdrTagXXX receiversCorrespondent54A;
    @Status("O")
    @TagName("55A")
    @FieldDescription("Third Reimbursement Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]"})
    //55A
    private ActnoBicAdrTagXXX thirdReimbursementInstitution55A;
    @Status("O")
    @TagName("56A")
    @FieldDescription("Intermediary Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]"})
    //56A
    private ActnoBicAdrTagXXX intermediaryInstitution56A;
    @Status("O")
    @TagName("57A")
    @FieldDescription("Account With Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]"})
    //57A
    private ActnoBicAdrTagXXX accountWithInstitution57A;
    @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)"})
    //59a
    private ActnoBicAdrTagXXX beneficiaryCustomer59a;
    @Status("O")
    @TagName({"70"})
    @FieldDescription("Remittance Information")
    @TagRegex({"4*35x"})
    //70
    private String remittanceInformation;
    @Status("M")
    @TagName({"71A"})
    @FieldDescription("Details of Charges")
    @TagRegex({"3!a"})
    //71A
    private String detailsofCharges;
    @Status("O")
    @TagName({"71F"})
    @FieldDescription("Sender's Charges")
    @TagRegex({"3!a15d"})
    //71F
    private List<String> sendersCharges;
    @Status("O")
    @TagName({"71G"})
    @FieldDescription("Receiver's Charges")
    @TagRegex({"3!a15d"})
    //71G
    private String receiversCharges;
    @Status("O")
    @TagName({"72"})
    @FieldDescription("Sender to Receiver Information")
    @TagRegex({"6*35x"})
    //72
    private String sendertoReceiverInformation;
    @Status("O")
    @TagName({"77B"})
    @FieldDescription("Regulatory Reporting")
    @TagRegex({"3*35x"})
    //77B
    private String regulatoryReporting;

    public String getSendersReference() {
        return sendersReference;
    }

    public void setSendersReference(String sendersReference) {
        this.sendersReference = sendersReference;
    }

    public List<String> getTimeIndication() {
        return timeIndication;
    }

    public void setTimeIndication(List<String> timeIndication) {
        this.timeIndication = timeIndication;
    }

    public String getBankOperationCode() {
        return bankOperationCode;
    }

    public void setBankOperationCode(String bankOperationCode) {
        this.bankOperationCode = bankOperationCode;
    }

    public List<String> getInstructionCode() {
        return instructionCode;
    }

    public void setInstructionCode(List<String> instructionCode) {
        this.instructionCode = instructionCode;
    }

    public String getTransactionTypeCode() {
        return transactionTypeCode;
    }

    public void setTransactionTypeCode(String transactionTypeCode) {
        this.transactionTypeCode = transactionTypeCode;
    }

    public DcDateCurAmtTagXXX getValueDateCurrencyInterbankSettledAmount32A() {
        return valueDateCurrencyInterbankSettledAmount32A;
    }

    public void setValueDateCurrencyInterbankSettledAmount32A(DcDateCurAmtTagXXX valueDateCurrencyInterbankSettledAmount32A) {
        this.valueDateCurrencyInterbankSettledAmount32A = valueDateCurrencyInterbankSettledAmount32A;
    }

    public DcDateCurAmtTagXXX getCurrencyInstructedAmount33B() {
        return currencyInstructedAmount33B;
    }

    public void setCurrencyInstructedAmount33B(DcDateCurAmtTagXXX currencyInstructedAmount33B) {
        this.currencyInstructedAmount33B = currencyInstructedAmount33B;
    }

    public String getExchangeRate() {
        return exchangeRate;
    }

    public void setExchangeRate(String exchangeRate) {
        this.exchangeRate = exchangeRate;
    }

    public ActnoBicAdrTagXXX getOrderingCustomer50a() {
        return orderingCustomer50a;
    }

    public void setOrderingCustomer50a(ActnoBicAdrTagXXX orderingCustomer50a) {
        this.orderingCustomer50a = orderingCustomer50a;
    }

    public ActnoBicAdrTagXXX getOrderingInstitution52A() {
        return orderingInstitution52A;
    }

    public void setOrderingInstitution52A(ActnoBicAdrTagXXX orderingInstitution52A) {
        this.orderingInstitution52A = orderingInstitution52A;
    }

    public ActnoBicAdrTagXXX getSendersCorrespondent53a() {
        return sendersCorrespondent53a;
    }

    public void setSendersCorrespondent53a(ActnoBicAdrTagXXX sendersCorrespondent53a) {
        this.sendersCorrespondent53a = sendersCorrespondent53a;
    }

    public ActnoBicAdrTagXXX getReceiversCorrespondent54A() {
        return receiversCorrespondent54A;
    }

    public void setReceiversCorrespondent54A(ActnoBicAdrTagXXX receiversCorrespondent54A) {
        this.receiversCorrespondent54A = receiversCorrespondent54A;
    }

    public ActnoBicAdrTagXXX getThirdReimbursementInstitution55A() {
        return thirdReimbursementInstitution55A;
    }

    public void setThirdReimbursementInstitution55A(ActnoBicAdrTagXXX thirdReimbursementInstitution55A) {
        this.thirdReimbursementInstitution55A = thirdReimbursementInstitution55A;
    }

    public ActnoBicAdrTagXXX getIntermediaryInstitution56A() {
        return intermediaryInstitution56A;
    }

    public void setIntermediaryInstitution56A(ActnoBicAdrTagXXX intermediaryInstitution56A) {
        this.intermediaryInstitution56A = intermediaryInstitution56A;
    }

    public ActnoBicAdrTagXXX getAccountWithInstitution57A() {
        return accountWithInstitution57A;
    }

    public void setAccountWithInstitution57A(ActnoBicAdrTagXXX accountWithInstitution57A) {
        this.accountWithInstitution57A = accountWithInstitution57A;
    }

    public ActnoBicAdrTagXXX getBeneficiaryCustomer59a() {
        return beneficiaryCustomer59a;
    }

    public void setBeneficiaryCustomer59a(ActnoBicAdrTagXXX beneficiaryCustomer59a) {
        this.beneficiaryCustomer59a = beneficiaryCustomer59a;
    }

    public String getRemittanceInformation() {
        return remittanceInformation;
    }

    public void setRemittanceInformation(String remittanceInformation) {
        this.remittanceInformation = remittanceInformation;
    }

    public String getDetailsofCharges() {
        return detailsofCharges;
    }

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

    public List<String> getSendersCharges() {
        return sendersCharges;
    }

    public void setSendersCharges(List<String> sendersCharges) {
        this.sendersCharges = sendersCharges;
    }

    public String getReceiversCharges() {
        return receiversCharges;
    }

    public void setReceiversCharges(String receiversCharges) {
        this.receiversCharges = receiversCharges;
    }

    public String getSendertoReceiverInformation() {
        return sendertoReceiverInformation;
    }

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

    public String getRegulatoryReporting() {
        return regulatoryReporting;
    }

    public void setRegulatoryReporting(String regulatoryReporting) {
        this.regulatoryReporting = regulatoryReporting;
    }

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

    public void pack() {
        //MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList=new ArrayList<>();
        try {
            tagCreateList.add(new Tag13CCreator(this));
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag23BCreator(this));
            tagCreateList.add(new Tag23ECreator(this));
            tagCreateList.add(new Tag26TCreator(this));
            tagCreateList.add(new Tag32ACreator(this));
            tagCreateList.add(new Tag33BCreator(this));
            tagCreateList.add(new Tag36Creator(this));
            tagCreateList.add(new Tag50aCreator(this));
            tagCreateList.add(new Tag52ACreator(this));
            tagCreateList.add(new Tag53aCreator(this));
            tagCreateList.add(new Tag54ACreator(this));
            tagCreateList.add(new Tag55ACreator(this));
            tagCreateList.add(new Tag56ACreator(this));
            tagCreateList.add(new Tag57ACreator(this));
            tagCreateList.add(new Tag59aCreator(this));
            tagCreateList.add(new Tag70Creator(this));
            tagCreateList.add(new Tag71ACreator(this));
            tagCreateList.add(new Tag71GCreator(this));
            tagCreateList.add(new Tag71FCreator(this));
            tagCreateList.add(new Tag72Creator(this));
            tagCreateList.add(new Tag77BCreator(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;
    }
}
