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.tag940.*;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.mt9XXAbsCreator.MT940AbsCreator;
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 MT940Creator 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;
    //61，86
    private List<MT940AbsCreator> mt940AbsCreators;
    @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;
    @Status("O")
    @TagName("65")
    @FieldDescription("Forward Available Balance")
    @TagRegex("1!a6!n3!a15d")
    private List<DcDateCurAmtTagXXX> forwardAvailableBalance;
    @Status("O")
    @TagName("86")
    @FieldDescription("Information to Account Owner")
    @TagRegex("6*65x")
    private String informationToAccountOwner;

    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<MT940AbsCreator> getMt940AbsCreators() {
        return mt940AbsCreators;
    }

    public void setMt940AbsCreators(List<MT940AbsCreator> mt940AbsCreators) {
        this.mt940AbsCreators = mt940AbsCreators;
    }

    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 List<DcDateCurAmtTagXXX> getForwardAvailableBalance() {
        return forwardAvailableBalance;
    }

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

    public String getInformationToAccountOwner() {
        return informationToAccountOwner;
    }

    public void setInformationToAccountOwner(String informationToAccountOwner) {
        this.informationToAccountOwner = informationToAccountOwner;
    }

    public MT940Creator(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 TagCycleCreator(this));
            tagCreateList.add(new Tag62aCreator(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;
    }
}
