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.tag769.*;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag769.Tag71DCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag769.Tag72ZCreator;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import lombok.Data;
import lombok.With;

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

/**
 * @author gaosheng
 * @date 2023/3/3
 */
@Data
public class MT769Creator extends AbsMTCreator {

    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    //20
    private String transactionReferenceNumber;

    @Status("M")
    @TagName("21")
    @FieldDescription("Related Reference")
    @TagRegex("16x")
    //21
    private String relatedReference;

    @Status("O")
    @TagName("25")
    @FieldDescription("Account Identification")
    @TagRegex("35x")
    //25
    private String accountIdentification;

    @Status("O")
    @TagName("30")
    @FieldDescription("Date of Reduction or Release")
    @TagRegex("6!n")
    //30
    private String dateOfReductionOrRelease;

    @Status("O")
    @TagName({"32B", "32D"})
    @FieldDescription("Amount of Charges")
    //32a
    @TagRegex({"3!a15d", "6!n3!a15d"})
    private DcDateCurAmtTagXXX amountOfCharges;

    @Status("O")
    @TagName("33B")
    @FieldDescription("Amount Reduced or Released")
    @TagRegex("3!a15d")
    //33B
    private DcDateCurAmtTagXXX amountReducedOrReleased;

    @Status("O")
    @TagName("34B")
    @FieldDescription("Amount Outstanding")
    @TagRegex("3!a15d")
    //34B
    private DcDateCurAmtTagXXX amountOutstanding;

    @Status("O")
    @TagName("39C")
    @FieldDescription("Amount Specification")
    @TagRegex("4*35x")
    //39C
    private String amountSpecification;


    @Status("O")
    @TagName({"57A","57B","57D"})
    @FieldDescription("Account With Bank")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    //57a
    private ActnoBicAdrTagXXX accountWithBank;

    @Status("O")
    @TagName("71D")
    @FieldDescription("Details of Charges")
    @TagRegex("6*35z")
    //71D
    private String detailsOfCharges;

    @Status("O")
    @TagName("72Z")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex("6*35z")
    //72Z
    private String senderToReceiverInformation;

    @Status("O")
    @TagName("23X")
    @FieldDescription("File Identification")
    @TagRegex("4!c/65x")
    //23X
    private String fileIdentification;

    public MT769Creator() {
        super("769");
    }

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



    /**
     * 需要编写组装报文逻辑，调用set方法即可
     *
     * @return
     */
    public void pack() {
        //  MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList = new ArrayList<>();
        try {
            tagCreateList.add(new com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag769.Tag20Creator(this));
            tagCreateList.add(new com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag769.Tag21Creator(this));
            tagCreateList.add(new Tag25Creator(this));
            tagCreateList.add(new com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag769.Tag30Creator(this));
            tagCreateList.add(new Tag32aCreator(this));
            tagCreateList.add(new Tag33BCreator(this));
            tagCreateList.add(new Tag34BCreator(this));
            tagCreateList.add(new Tag39CCreator(this));
            tagCreateList.add(new Tag57aCreator(this));
            tagCreateList.add(new Tag71DCreator(this));
            tagCreateList.add(new Tag72ZCreator(this));
            tagCreateList.add(new Tag23XCreator(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;
    }
}
