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.tag767.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import lombok.Getter;
import lombok.Setter;

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

@Getter
@Setter
public class MT767Creator extends AbsMTCreator {
    //A部分
    @Status("M")
    @TagName("15A")
    @FieldDescription("New Sequence")
    @TagRegex("Empty filed")
    //15A 不填写任何数据
    private String newSequenceOfA;
    @Status("O")
    @TagName("27")
    @FieldDescription("Sequence of Total")
    @TagRegex("1!n/1!n")
    //27
    private String sequenceOfTotalOfA;
    @Status("O")
    @TagName("21")
    @FieldDescription("Related Reference")
    @TagRegex("16x")
    //21
    private String relatedReferenceOfA;
    @Status("M")
    @TagName("22A")
    @FieldDescription("Purpose of Message")
    @TagRegex("4!c")
    //22A
    private String purposeOfMessageOfA;
    @Status("O")
    @TagName("23S")
    @FieldDescription("Cancellation Request")
    @TagRegex("6!a")
    //23S
    private String cancellationRequestOfA;
    @Status("O")
    @TagName("72Z")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex("6*35z")
    //72Z
    private ActnoBicAdrTagXXX sendertoReceiverInformationOfA;
    @Status("O")
    @TagName("23X")
    @FieldDescription("File Identification")
    @TagRegex("4!c/65x")
    //23X
    private String fileIdentificationOfA;
    //B部分
    @Status("M")
    @TagName("15B")
    @FieldDescription("New Sequence")
    @TagRegex("Empty filed")
    //15B 不填写任何数据
    private String newSequenceOfB;
    @Status("M")
    @TagName("20")
    @FieldDescription("Undertaking Number")
    @TagRegex("16x")
    //20
    private String undertakingNumberOfB;
    @Status("M")
    @TagName("26E")
    @FieldDescription("Number of Amendment")
    @TagRegex("3n")
    //26E
    private String numberOfAmendmentOfB;
    @Status("M")
    @TagName("30")
    @FieldDescription("Date of Amendment")
    @TagRegex("6!n")
    //30
    private String dateOfAmendmentOfB;
    @Status("M")
    @TagName({"52A", "52D"})
    @FieldDescription("Issuer")
    @TagRegex({"[/1!a][/34x]\r\n4!a2!a2!c[3!c]", "[/1!a][/34x]\r\n4*35x"})
    //52a
    private ActnoBicAdrTagXXX issuerOfB;

    @Status("O")
    @TagName("23")
    @FieldDescription("Advising Bank Reference")
    @TagRegex("16x")
    private String advisingBankReferenceOfB;

    @Status("O")
    @TagName("32B")
    @FieldDescription("Increase of Undertaking Amount")
    @TagRegex("3!a15d")
    //32B
    private DcDateCurAmtTagXXX increaseofUndertakingAmountOfB;
    @Status("O")
    @TagName("33B")
    @FieldDescription("Decrease of Undertaking Amount")
    @TagRegex("3!a15d")
    //33B
    private DcDateCurAmtTagXXX decreaseofUndertakingAmountOfB;
    @Status("O")
    @TagName("23B")
    @FieldDescription("Expiry Type")
    @TagRegex("4!c")
    //23B
    private String expiryTypeOfB;
    @Status("O")
    @TagName("31E")
    @FieldDescription("Date of Expiry")
    @TagRegex("6!n")
    //31E
    private String dateOfExpiryOfB;
    @Status("O")
    @TagName("35G")
    @FieldDescription("Expiry Condition/Event")
    @TagRegex("12*65x")
    //35G
    private String expiryConditionEventOfB;
    @Status("O")
    @TagName({"59", "59A"})
    @FieldDescription("Beneficiary")
    @TagRegex({"[/34x]<crlf>4*35x", "[/34x]<crlf>4!a2!a2!c[3!c]"})
    //59a
    private ActnoBicAdrTagXXX beneficiaryOfB;
    @Status("O")
    @TagName("77U")
    @FieldDescription("Other Amendments to Undertaking")
    @TagRegex("150*65z")
    //77U
    private String otherAmendmentsToUndertakingOfB;
    @Status("O")
    @TagName("24E")
    @FieldDescription("Delivery of Amendment To Undertaking")
    @TagRegex("4!c[/35x]")
    //24E
    private String deliveryOfAmendmentToUndertakingOfB;
    @Status("O")
    @TagName("24G")
    @FieldDescription("Delivery To/Collection By")
    @TagRegex("4!c\r\n[12*65z]")
    //24G
    private ActnoBicAdrTagXXX deliveryToCollectionByOfB;
    //C部分 可以为空
    @Status("M")
    @TagName("15C")
    @FieldDescription("New Sequence")
    @TagRegex("Empty field")
    //15C 不填写任何数据
    private String newSequenceOfC;
    @Status("O")
    @TagName("32B")
    @FieldDescription("Increase of Local Undertaking Amount")
    @TagRegex("3!a15d")
    //32B
    private DcDateCurAmtTagXXX increaseofLocalUndertakingAmountOfC;
    @Status("O")
    @TagName("33B")
    @FieldDescription("Decrease of Local Undertaking Amount")
    @TagRegex("3!a15d")
    //33B
    private DcDateCurAmtTagXXX decreaseofLocalUndertakingAmountOfC;
    @Status("O")
    @TagName("23B")
    @FieldDescription("Expiry Type")
    @TagRegex("4!c")
    //23B
    private String expiryTypeOfC;
    @Status("O")
    @TagName("31E")
    @FieldDescription("Date of Expiry")
    @TagRegex("6!n")
    //31E
    private String dateOfExpiryOfC;
    @Status("O")
    @TagName("35G")
    @FieldDescription("Expiry Condition/Event")
    @TagRegex("12*65x")
    //35G
    private String expiryConditionEventOfC;
    @Status("O")
    @TagName("59")
    @FieldDescription("Beneficiary")
    @TagRegex("[/34x]\r\n4*35x")
    //59
    private ActnoBicAdrTagXXX beneficiaryOfC;
    @Status("O")
    @TagName("77L")
    @FieldDescription("Other Amendments to Local Undertaking")
    @TagRegex("1200*65z")
    //77L
    private String otherAmendmentsToLocalUndertakingOfC;
    @Status("O")
    @TagName("24E")
    @FieldDescription("Delivery of Amendment To Local Undertaking")
    @TagRegex("4!c[/35x]")
    //24E
    private String deliveryOfAmendmentToLocalUndertakingOfC;
    @Status("O")
    @TagName("24G")
    @FieldDescription("Delivery To/Collection By")
    @TagRegex("4!c\r\n[12*65z]")
    //24G
    private ActnoBicAdrTagXXX deliveryToCollectionByOfC;

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

    public MT767Creator() {
        super("767");
    }

    @Override
    public void pack() {
        // MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList = new ArrayList<>();
        try {
            tagCreateList.add(new Tag15ACreator(this));
            tagCreateList.add(new Tag27Creator(this));
            tagCreateList.add(new Tag21Creator(this));
            tagCreateList.add(new Tag22ACreator(this));
            tagCreateList.add(new Tag23SCreator(this));
            tagCreateList.add(new Tag72ZCreator(this));
            tagCreateList.add(new Tag23XCreator(this));
            tagCreateList.add(new Tag15BCreator(this));
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag26ECreator(this));
            tagCreateList.add(new Tag30Creator(this));
            tagCreateList.add(new Tag52aCreator(this));
            tagCreateList.add(new Tag23Creator(this));
            tagCreateList.add(new TagB32BCreator(this));
            tagCreateList.add(new TagB33BCreator(this));
            tagCreateList.add(new TagB23BCreator(this));
            tagCreateList.add(new TagB31ECreator(this));
            tagCreateList.add(new TagB35GCreator(this));
            tagCreateList.add(new TagB59aCreator(this));
            tagCreateList.add(new Tag77UCreator(this));
            tagCreateList.add(new TagB24ECreator(this));
            tagCreateList.add(new TagB24GCreator(this));
            tagCreateList.add(new Tag15CCreator(this));
            tagCreateList.add(new TagC32BCreator(this));
            tagCreateList.add(new TagC33BCreator(this));
            tagCreateList.add(new TagC23BCreator(this));
            tagCreateList.add(new TagC31ECreator(this));
            tagCreateList.add(new TagC35GCreator(this));
            tagCreateList.add(new TagC59Creator(this));
            tagCreateList.add(new Tag77LCreator(this));
            tagCreateList.add(new TagC24ECreator(this));
            tagCreateList.add(new TagC24GCreator(this));


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