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

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

/**
 * @author liuliang
 * @date 2023/2/24
 */

public class MT112Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    //20
    private String transactionReferenceNumber;
    @Status("M")
    @TagName("21")
    @FieldDescription("Cheque Number")
    @TagRegex("16x")
    //21
    private String chequeNumber;
    @Status("M")
    @TagName("30")
    @FieldDescription("Date of Issue")
    @TagRegex("6!n")
    //30
    private String dateofIssue;
    @Status("M")
    @TagName({"32A","32B"})
    @FieldDescription("Amount")
    @TagRegex({"6!n3!a15d","3!a15d"})
    //32a
    private DcDateCurAmtTagXXX amount32a;
    @Status("O")
    @TagName({"52A","52B","52D"})
    @FieldDescription("Drawer Bank")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    //52a
    private ActnoBicAdrTagXXX drawerBank52a;
    @Status("O")
    @TagName("59")
    @FieldDescription("Payee")
    @TagRegex("[/34x]<crlf>4*35x")
    //59
//    private String payee;
    private ActnoBicAdrTagXXX payee59;
    @Status("M")
    @TagName("76")
    @FieldDescription("Answers")
    @TagRegex("6*35x")
    //76
    private String answers;


    public String getTransactionReferenceNumber() {
        return transactionReferenceNumber;
    }

    public void setTransactionReferenceNumber(String transactionReferenceNumber) {
        this.transactionReferenceNumber = transactionReferenceNumber;
    }

    public String getChequeNumber() {
        return chequeNumber;
    }

    public void setChequeNumber(String chequeNumber) {
        this.chequeNumber = chequeNumber;
    }

    public String getDateofIssue() {
        return dateofIssue;
    }

    public void setDateofIssue(String dateofIssue) {
        this.dateofIssue = dateofIssue;
    }


    public ActnoBicAdrTagXXX getPayee59() {
        return payee59;
    }

    public void setPayee59(ActnoBicAdrTagXXX payee59) {
        this.payee59 = payee59;
    }

    public String getAnswers() {
        return answers;
    }

    public void setAnswers(String answers) {
        this.answers = answers;
    }

    public DcDateCurAmtTagXXX getAmount32a() {
        return amount32a;
    }

    public void setAmount32a(DcDateCurAmtTagXXX amount32a) {
        this.amount32a = amount32a;
    }

    public ActnoBicAdrTagXXX getDrawerBank52a() {
        return drawerBank52a;
    }

    public void setDrawerBank52a(ActnoBicAdrTagXXX drawerBank52a) {
        this.drawerBank52a = drawerBank52a;
    }

    //    public MT112Creator(String jsonData) throws Exception {
//        super(jsonData);
//    }
    public MT112Creator(String msgType)  {
    super(msgType);
}


    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 Tag30Creator(this));
            tagCreateList.add(new Tag32aCreator(this));
            tagCreateList.add(new Tag52aCreator(this));
            tagCreateList.add(new Tag59Creator(this));
            tagCreateList.add(new Tag76Creator(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;
    }
}
