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

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

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

/**
 * @author zh
 * @create 2023-02-24-11:15
 */
public class MT910Creator extends AbsMTCreator {

    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    private String transactionReferenceNumber;
    @Status("M")
    @TagName("21")
    @FieldDescription("Related Reference")
    @TagRegex("16x")
    private String relatedReference;
    @Status("M")
    @TagName({"25","25P"})
    @FieldDescription("Account Identification")
    @TagRegex({"35x","35x<crlf>4!a2!a2!c[3!c]"})
    private ActnoBicAdrTagXXX accountIdentification;
    @Status("O")
    @TagName("13D")
    @FieldDescription("Date/Time Indication")
    @TagRegex("6!n4!n1!x4!n")
    private String dateTimeIndication;
    @Status("M")
    @TagName("32A")
    @FieldDescription("Value Date, Currency Code, Amount")
    @TagRegex("6!n3!a15d")
    private DcDateCurAmtTagXXX dateCurrencyAmount;
    @Status("O")
    @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"})
    private ActnoBicAdrTagXXX orderingCustomer;
    @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"})
    private ActnoBicAdrTagXXX orderingInstitution;
    @Status("O")
    @TagName({"56A","56D"})
    @FieldDescription("Intermediary")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX intermediary;
    @Status("O")
    @TagName("72")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex("6*35x")
    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 ActnoBicAdrTagXXX getAccountIdentification() {
        return accountIdentification;
    }

    public void setAccountIdentification(ActnoBicAdrTagXXX accountIdentification) {
        this.accountIdentification = accountIdentification;
    }

    public String getDateTimeIndication() {
        return dateTimeIndication;
    }

    public void setDateTimeIndication(String dateTimeIndication) {
        this.dateTimeIndication = dateTimeIndication;
    }

    public DcDateCurAmtTagXXX getDateCurrencyAmount() {
        return dateCurrencyAmount;
    }

    public void setDateCurrencyAmount(DcDateCurAmtTagXXX dateCurrencyAmount) {
        this.dateCurrencyAmount = dateCurrencyAmount;
    }

    public ActnoBicAdrTagXXX getOrderingCustomer() {
        return orderingCustomer;
    }

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

    public ActnoBicAdrTagXXX getOrderingInstitution() {
        return orderingInstitution;
    }

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

    public ActnoBicAdrTagXXX getIntermediary() {
        return intermediary;
    }

    public void setIntermediary(ActnoBicAdrTagXXX intermediary) {
        this.intermediary = intermediary;
    }

    public String getSenderToReceiverInformation() {
        return senderToReceiverInformation;
    }

    public void setSenderToReceiverInformation(String senderToReceiverInformation) {
        this.senderToReceiverInformation = senderToReceiverInformation;
    }

    public MT910Creator(String msgType)  {
    super(msgType);
}
    public void pack() {
        // MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList = new ArrayList<>();
        try {
            tagCreateList.add(new Tag13DCreator(this));
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag21Creator(this));
            tagCreateList.add(new Tag25aCreator(this));
            tagCreateList.add(new Tag32ACreator(this));
            tagCreateList.add(new Tag50aCreator(this));
            tagCreateList.add(new Tag52aCreator(this));
            tagCreateList.add(new Tag56aCreator(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;

    }
}
