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

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

/**
 * @author liusheng
 * @date 2023/2/27
 */
public class MT111Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Sender's Reference")
    @TagRegex("16x")
    //20
    private String sendersReference;

    @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 amount;

    @Status("O")
    @TagName({"52A", "52B", "52D"})
    @FieldDescription("Drawer Bank")
    @TagRegex({"[/1!a][/34x]\r\n4!a2!a2!c[3!c]", "[/1!a][/34x]\r\n[35x]", "[/1!a][/34x]\r\n4*35x"})
    //52a
    private ActnoBicAdrTagXXX drawerBank;

    @Status("O")
    @TagName("59")
    @FieldDescription("Payee")
    @TagRegex("[/34x]\r\n4*35x")
    //59
    private ActnoBicAdrTagXXX payee;

    @Status("O")
    @TagName("75")
    @FieldDescription("Queries")
    @TagRegex("6*35x")
    //75
    private String queries;


    public MT111Creator() {super();}

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

    public String getSendersReference() {
        return sendersReference;
    }

    public void setSendersReference(String sendersReference) {
        this.sendersReference = sendersReference;
    }

    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 DcDateCurAmtTagXXX getAmount() {
        return amount;
    }

    public void setAmount(DcDateCurAmtTagXXX amount) {
        this.amount = amount;
    }

    public ActnoBicAdrTagXXX getDrawerBank() {
        return drawerBank;
    }

    public void setDrawerBank(ActnoBicAdrTagXXX drawerBank) {
        this.drawerBank = drawerBank;
    }

    public ActnoBicAdrTagXXX getPayee() {
        return payee;
    }

    public void setPayee(ActnoBicAdrTagXXX payee) {
        this.payee = payee;
    }

    public String getQueries() {
        return queries;
    }

    public void setQueries(String queries) {
        this.queries = queries;
    }

    @Override
    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 Tag75Creator(this));

            dealTags(tagCreateList);

            mtResult.setMessage(abstractMT.message());
        }catch (Exception e){
            e.printStackTrace();
            mtResult.setSuccess(false);
            mtResult.addDescription(e.getLocalizedMessage());
        }
      //  return mtResult;
    }

}
