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

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

/**
 * @author liusheng
 * @date 2023/2/27
 */
public class MT103REMITCreator 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 valueDateCurrencyInterbankSettledAmount;
    @Status("O")
    @TagName("33B")
    @FieldDescription("Currency/Instructed Amount")
    @TagRegex("3!a15d")
    //33B
    private DcDateCurAmtTagXXX currencyInstructedAmount;
    @Status("O")
    @TagName("36")
    @FieldDescription("Exchange Rate")
    @TagRegex("12d")
    //36
    private String exchangeRate;
    @Status("M")
    @TagName({"50A", "50F", "50K"})
    @FieldDescription("Ordering Customer")
    @TagRegex({"[/34x]\r\n4!a2!a2!c[3!c]", "35x\r\n4*(1!n/33x)", "[/34x]\r\n4*35x"})
    //50a
    private ActnoBicAdrTagXXX orderingCustomer;
    @Status("O")
    @TagName("51A")
    @FieldDescription("Sending Institution")
    @TagRegex("[/1!a][/34x]\r\n4!a2!a2!c[3!c]")
    //51A
    private ActnoBicAdrTagXXX sendingInstitution;
    @Status("O")
    @TagName({"52A", "52D"})
    @FieldDescription("Ordering Institution")
    @TagRegex({"[/1!a][/34x]\r\n4!a2!a2!c[3!c]", "[/1!a][/34x]\r\n4*35x"})
    //52a
    private ActnoBicAdrTagXXX orderingInstitution;
    @Status("O")
    @TagName({"53A", "53B", "53D"})
    @FieldDescription("Sender's Correspondent")
    @TagRegex({"[/1!a][/34x]\r\n4!a2!a2!c[3!c]", "[/1!a][/34x]\r\n[35x]", "[/1!a][/34x]\r\n4*35x"})
    //53a
    private ActnoBicAdrTagXXX sendersCorrespondent;
    @Status("O")
    @TagName({"54A", "54B", "54D"})
    @FieldDescription("Receiver's Correspondent")
    @TagRegex({"[/1!a][/34x]\r\n4!a2!a2!c[3!c]", "[/1!a][/34x]\r\n[35x]", "[/1!a][/34x]\r\n4*35x"})
    //54a
    private ActnoBicAdrTagXXX receiversCorrespondent;
    @Status("O")
    @TagName({"55A", "55B", "55D"})
    @FieldDescription("Third Reimbursement Institution")
    @TagRegex({"[/1!a][/34x]\r\n4!a2!a2!c[3!c]", "[/1!a][/34x]\r\n[35x]", "[/1!a][/34x]\r\n4*35x"})
    //55a
    private ActnoBicAdrTagXXX thirdReimbursementInstitution;
    @Status("O")
    @TagName({"56A", "56C", "56D"})
    @FieldDescription("Intermediary Institution")
    @TagRegex({"[/1!a][/34x]\r\n4!a2!a2!c[3!c]", "/34x", "[/1!a][/34x]\r\n4*35x"})
    //56a
    private ActnoBicAdrTagXXX intermediaryInstitution;
    @Status("O")
    @TagName({"57A", "57B", "57C", "57D"})
    @FieldDescription("Account With Institution")
    @TagRegex({"[/1!a][/34x]\r\n4!a2!a2!c[3!c]", "[/1!a][/34x]\r\n[35x]", "/34x", "[/1!a][/34x]\r\n4*35x"})
    //57a
    private ActnoBicAdrTagXXX accountWithInstitution;
    @Status("O")
    @TagName({"59", "59A", "59F"})
    @FieldDescription("Beneficiary Customer")
    @TagRegex({"[/34x]\r\n4*35x", "[/34x]\r\n4!a2!a2!c[3!c]", "[/34x]\r\n4*(1!n/33x)"})
    //59a
    private ActnoBicAdrTagXXX beneficiaryCustomer;
    @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;
    @Status("M")
    @TagName("77T")
    @FieldDescription("Envelope Contents")
    @TagRegex("9000z")
    //77T
    private String envelopeContents;

    public MT103REMITCreator() {super();}
    public MT103REMITCreator(String msgType) throws Exception{
        super(msgType);
    }

    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 getValueDateCurrencyInterbankSettledAmount() {
        return valueDateCurrencyInterbankSettledAmount;
    }

    public void setValueDateCurrencyInterbankSettledAmount(DcDateCurAmtTagXXX valueDateCurrencyInterbankSettledAmount) {
        this.valueDateCurrencyInterbankSettledAmount = valueDateCurrencyInterbankSettledAmount;
    }

    public DcDateCurAmtTagXXX getCurrencyInstructedAmount() {
        return currencyInstructedAmount;
    }

    public void setCurrencyInstructedAmount(DcDateCurAmtTagXXX currencyInstructedAmount) {
        this.currencyInstructedAmount = currencyInstructedAmount;
    }

    public String getExchangeRate() {
        return exchangeRate;
    }

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

    public ActnoBicAdrTagXXX getOrderingCustomer() {
        return orderingCustomer;
    }

    public void setOrderingCustomer(ActnoBicAdrTagXXX orderingCustomer) {
        this.orderingCustomer = orderingCustomer;
    }

    public ActnoBicAdrTagXXX getSendingInstitution() {
        return sendingInstitution;
    }

    public void setSendingInstitution(ActnoBicAdrTagXXX sendingInstitution) {
        this.sendingInstitution = sendingInstitution;
    }

    public ActnoBicAdrTagXXX getOrderingInstitution() {
        return orderingInstitution;
    }

    public void setOrderingInstitution(ActnoBicAdrTagXXX orderingInstitution) {
        this.orderingInstitution = orderingInstitution;
    }

    public ActnoBicAdrTagXXX getSendersCorrespondent() {
        return sendersCorrespondent;
    }

    public void setSendersCorrespondent(ActnoBicAdrTagXXX sendersCorrespondent) {
        this.sendersCorrespondent = sendersCorrespondent;
    }

    public ActnoBicAdrTagXXX getReceiversCorrespondent() {
        return receiversCorrespondent;
    }

    public void setReceiversCorrespondent(ActnoBicAdrTagXXX receiversCorrespondent) {
        this.receiversCorrespondent = receiversCorrespondent;
    }

    public ActnoBicAdrTagXXX getThirdReimbursementInstitution() {
        return thirdReimbursementInstitution;
    }

    public void setThirdReimbursementInstitution(ActnoBicAdrTagXXX thirdReimbursementInstitution) {
        this.thirdReimbursementInstitution = thirdReimbursementInstitution;
    }

    public ActnoBicAdrTagXXX getIntermediaryInstitution() {
        return intermediaryInstitution;
    }

    public void setIntermediaryInstitution(ActnoBicAdrTagXXX intermediaryInstitution) {
        this.intermediaryInstitution = intermediaryInstitution;
    }

    public ActnoBicAdrTagXXX getAccountWithInstitution() {
        return accountWithInstitution;
    }

    public void setAccountWithInstitution(ActnoBicAdrTagXXX accountWithInstitution) {
        this.accountWithInstitution = accountWithInstitution;
    }

    public ActnoBicAdrTagXXX getBeneficiaryCustomer() {
        return beneficiaryCustomer;
    }

    public void setBeneficiaryCustomer(ActnoBicAdrTagXXX beneficiaryCustomer) {
        this.beneficiaryCustomer = beneficiaryCustomer;
    }

    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 String getEnvelopeContents() {
        return envelopeContents;
    }

    public void setEnvelopeContents(String envelopeContents) {
        this.envelopeContents = envelopeContents;
    }
    public void pack() {
       // MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList = new ArrayList<>();
        try{
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag13CCreator(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 Tag51ACreator(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 Tag71ACreator(this));
            tagCreateList.add(new Tag71FCreator(this));
            tagCreateList.add(new Tag71GCreator(this));
            tagCreateList.add(new Tag72Creator(this));
            tagCreateList.add(new Tag77BCreator(this));
            tagCreateList.add(new Tag77TCreator(this));

            dealTags(tagCreateList);

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