package com.brilliance.isc.swift.objmtconvert.model.mt7xx;

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.mt7xx.tag.tag756.*;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag756.Tag20Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag756.Tag21Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag759.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import lombok.Data;

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

@Data
public class MT756Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Sender's Reference")
    @TagRegex("16x")
    //20
    private String sendersReference;
    @Status("M")
    @TagName("21")
    @FieldDescription("Presenting Bank's Reference")
    @TagRegex("16x")
    //21
    private String presentingBanksReference;
    @Status("M")
    @TagName("32B")
    @FieldDescription("Total Amount Claimed")
    @TagRegex("3!a15d")
    //32B
    private DcDateCurAmtTagXXX totalAmountClaimed;
    @Status("M")
    @TagName("33A")
    @FieldDescription("Amount Reimbursed or Paid")
    @TagRegex("6!n3!a15d")
    //33A
    private DcDateCurAmtTagXXX amountReimbursedOrPaid;
    @Status("O")
    @TagName({"53A","53B","53D"})
    @FieldDescription("Sender's Correspondent")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    //53a
    private ActnoBicAdrTagXXX sendersCorrespondent;
    @Status("O")
    @TagName({"54A","54B","54D"})
    @FieldDescription("Receiver's Correspondent")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    //54a
    private ActnoBicAdrTagXXX receiversCorrespondent;
    @Status("O")
    @TagName("72Z")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex("6*35z")
    //72Z
    private String sendertoReceiverInformation;
    @Status("O")
    @TagName("79Z")
    @FieldDescription("Narrative")
    @TagRegex("35*50z")
    //79Z
    private String narrative;

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

    public MT756Creator() {
        super("756");
    }


    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 Tag32BCreator(this));
            tagCreateList.add(new Tag33ACreator(this));
            tagCreateList.add(new Tag53aCreator(this));
            tagCreateList.add(new Tag54aCreator(this));
            tagCreateList.add(new Tag72ZCreator(this));
            tagCreateList.add(new Tag79ZCreator(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;
    }
}
