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

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

/**
 * @author hedonghao
 * @date 2023/2/24
 */
public class MT941Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    //20
    private String tranReferenceNum;
    @Status("O")
    @TagName("21")
    @FieldDescription("Related Reference")
    @TagRegex("16x")
    //21
    private String relatedReferen;
    @Status("M")
    @TagName({"25","25P"})
    @FieldDescription("Account Identification")
    @TagRegex({"16x","35x<crlf>4!a2!a2!c[3!c]"})
    //25a
    private ActnoBicAdrTagXXX accountIdentification;
    @Status("M")
    @TagName("28")
    @FieldDescription("Statement Number/Sequence Number")
    @TagRegex("5n[/2n]")
    //28
    private String stattNumSeqNum;
    @Status("O")
    @TagName("13D")
    @FieldDescription("Date/Time Indication")
    @TagRegex("6!n4!n1!x4!n")
    //13D
    private String dateIndication;
    @Status("O")
    @TagName("60F")
    @FieldDescription("Opening Balance")
    @TagRegex("1!a6!n3!a15d")
    //60F
    private DcDateCurAmtTagXXX openingBalance;
    @Status("O")
    @TagName("90D")
    @FieldDescription("Number and Sum of Entries")
    @TagRegex("5n3!a15d")
    //90D
    private DcDateCurAmtTagXXX numberAndSumOfEntriesD;;
    @Status("O")
    @TagName("90C")
    @FieldDescription("Number and Sum of Entries")
    @TagRegex("5n3!a15d")
    //90C
    private DcDateCurAmtTagXXX numberAndSumOfEntriesC;
    @Status("M")
    @TagName("62F")
    @FieldDescription("Book Balance")
    @TagRegex("1!a6!n3!a15d")
    //62F
    private DcDateCurAmtTagXXX bookBalance;
    @Status("O")
    @TagName("64")
    @FieldDescription("Closing Available Balance (Available Funds)")
    @TagRegex("1!a6!n3!a15d")
    //64
    private DcDateCurAmtTagXXX closingAvailableBalance;
    @Status("O")
    @TagName("65")
    @FieldDescription("Forward Available Balance")
    @TagRegex("1!a6!n3!a15d")
    //65
    private List<DcDateCurAmtTagXXX> forwardAvailableBalance;
    @Status("O")
    @TagName("86")
    @FieldDescription("Information to Account Owner")
    @TagRegex("6*65x")
    //86
    private String infoAccontOwner;


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

    public MT941Creator() {
        super();
    }

    public String getTranReferenceNum() {
        return tranReferenceNum;
    }

    public void setTranReferenceNum(String tranReferenceNum) {
        this.tranReferenceNum = tranReferenceNum;
    }

    public String getRelatedReferen() {
        return relatedReferen;
    }

    public void setRelatedReferen(String relatedReferen) {
        this.relatedReferen = relatedReferen;
    }

    public ActnoBicAdrTagXXX getAccountIdentification() {
        return accountIdentification;
    }

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

    public String getStattNumSeqNum() {
        return stattNumSeqNum;
    }

    public void setStattNumSeqNum(String stattNumSeqNum) {
        this.stattNumSeqNum = stattNumSeqNum;
    }

    public String getDateIndication() {
        return dateIndication;
    }

    public void setDateIndication(String dateIndication) {
        this.dateIndication = dateIndication;
    }

    public DcDateCurAmtTagXXX getOpeningBalance() {
        return openingBalance;
    }

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

    public DcDateCurAmtTagXXX getNumberAndSumOfEntriesD() {
        return numberAndSumOfEntriesD;
    }

    public void setNumberAndSumOfEntriesD(DcDateCurAmtTagXXX numberAndSumOfEntriesD) {
        this.numberAndSumOfEntriesD = numberAndSumOfEntriesD;
    }

    public DcDateCurAmtTagXXX getNumberAndSumOfEntriesC() {
        return numberAndSumOfEntriesC;
    }

    public void setNumberAndSumOfEntriesC(DcDateCurAmtTagXXX numberAndSumOfEntriesC) {
        this.numberAndSumOfEntriesC = numberAndSumOfEntriesC;
    }

    public DcDateCurAmtTagXXX getBookBalance() {
        return bookBalance;
    }

    public void setBookBalance(DcDateCurAmtTagXXX bookBalance) {
        this.bookBalance = bookBalance;
    }

    public DcDateCurAmtTagXXX getClosingAvailableBalance() {
        return closingAvailableBalance;
    }

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

    public List<DcDateCurAmtTagXXX> getForwardAvailableBalance() {
        return forwardAvailableBalance;
    }

    public void setForwardAvailableBalance(List<DcDateCurAmtTagXXX> forwardAvailableBalance) {
        this.forwardAvailableBalance = forwardAvailableBalance;
    }

    public String getInfoAccontOwner() {
        return infoAccontOwner;
    }

    public void setInfoAccontOwner(String infoAccontOwner) {
        this.infoAccontOwner = infoAccontOwner;
    }

    /**
     * 需要编写组装报文逻辑，调用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 Tag28Creator(this));
            tagCreateList.add(new Tag13DCreator(this));
            tagCreateList.add(new Tag60FCreator(this));
            tagCreateList.add(new Tag90DCreator(this));
            tagCreateList.add(new Tag90CCreator(this));
            tagCreateList.add(new Tag62FCreator(this));
            tagCreateList.add(new Tag64Creator(this));
            tagCreateList.add(new Tag65Creator(this));
            tagCreateList.add(new Tag86Creator(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;
    }


}
