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

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

/**
 * @author zh
 * @create 2023-02-24-16:29
 */
public class MT950Creator extends AbsMTCreator {

    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    private String transactionReferenceNumber;
    @Status("O")
    @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("M")
    @TagName("28C")
    @FieldDescription("Statement Number/Sequence Number")
    @TagRegex("5n[/5n]")
    private String statementSequenceNumber;
    @Status("M")
    @TagName({"60F","60M"})
    @FieldDescription("Opening Balance")
    @TagRegex({"1!a6!n3!a15d","1!a6!n3!a15d"})
    private DcDateCurAmtTagXXX openingBalance;
    @Status("O")
    @TagName("61")
    @FieldDescription("Statement Line")
    @TagRegex("6!n[4!n]2a[1!a]15d1!a3!c16x[//16x]<crlf>[34x]")
    private List<String> statementLine;
    @Status("M")
    @TagName({"62F","62M"})
    @FieldDescription("Closing Balance (Booked Funds)")
    @TagRegex({"1!a6!n3!a15d","1!a6!n3!a15d"})
    private DcDateCurAmtTagXXX closingBalance;
    @Status("O")
    @TagName("64")
    @FieldDescription("Closing Available Balance (Available Funds)")
    @TagRegex("1!a6!n3!a15d")
    private DcDateCurAmtTagXXX closingAvailableBalance;

    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 getStatementSequenceNumber() {
        return statementSequenceNumber;
    }

    public void setStatementSequenceNumber(String statementSequenceNumber) {
        this.statementSequenceNumber = statementSequenceNumber;
    }

    public DcDateCurAmtTagXXX getOpeningBalance() {
        return openingBalance;
    }

    public void setOpeningBalance(DcDateCurAmtTagXXX openingBalance) {
        this.openingBalance = openingBalance;
    }

    public List<String> getStatementLine() {
        return statementLine;
    }

    public void setStatementLine(List<String> statementLine) {
        this.statementLine = statementLine;
    }

    public DcDateCurAmtTagXXX getClosingBalance() {
        return closingBalance;
    }

    public void setClosingBalance(DcDateCurAmtTagXXX closingBalance) {
        this.closingBalance = closingBalance;
    }

    public DcDateCurAmtTagXXX getClosingAvailableBalance() {
        return closingAvailableBalance;
    }

    public void setClosingAvailableBalance(DcDateCurAmtTagXXX closingAvailableBalance) {
        this.closingAvailableBalance = closingAvailableBalance;
    }

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


    /**
     * 需要编写组装报文逻辑，调用set方法即可
     *
     * @return
     */
    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 Tag25aCreator(this));
            tagCreateList.add(new Tag28CCreator(this));
            tagCreateList.add(new Tag60aCreator(this));
            tagCreateList.add(new Tag61Creator(this));
            tagCreateList.add(new Tag62aCreator(this));
            tagCreateList.add(new Tag64Creator(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;
    }
}
