package com.brilliance.isc.swift.objmtconvert.model.mt4xx.mt4XXAbsCreator;

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

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

/**
 * author: hw
 * @create 2024-07-05-11:10
 */
public class MT416AbsCreator extends AbsMTCreator {

    @Status("M")
    @TagName("21A")
    @FieldDescription("Related Sequence Reference")
    @TagRegex("16x")
    private String relatedSeqRef;

    @Status("O")
    @TagName("23E")
    @FieldDescription("Advice Type")
    @TagRegex("4!c[/30x]")
    private String adviceType;

    @Status("O")
    @TagName("21C")
    @FieldDescription("Principal's Reference")
    @TagRegex("35x")
    private String principalRef;

    @Status("M")
    @TagName("32a")
    @FieldDescription("Face Amount of Document(s)")
    @TagRegex({"6!n3!a15d", "3!a15d", "1!a3!n2!a3!a15d"})
    private DcDateCurAmtTagXXX faceAmt;

    @Status("O")
    @TagName("50D")
    @FieldDescription("Principal")
    @TagRegex({"[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX principal;

    @Status("O")
    @TagName("59")
    @FieldDescription("Drawee")
    @TagRegex({"[/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX drawee;

    @Status("O")
    @TagName("71F")
    @FieldDescription("Sender's Charges")
    @TagRegex("3!a15d")
    private String senderCharges;

    @Status("O")
    @TagName("77A")
    @FieldDescription("Reason for Non-Payment/Non-Acceptance")
    @TagRegex("20*35x")
    private String reason;

    public String getRelatedSeqRef() {
        return relatedSeqRef;
    }

    public void setRelatedSeqRef(String relatedSeqRef) {
        this.relatedSeqRef = relatedSeqRef;
    }

    public String getAdviceType() {
        return adviceType;
    }

    public void setAdviceType(String adviceType) {
        this.adviceType = adviceType;
    }

    public String getPrincipalRef() {
        return principalRef;
    }

    public void setPrincipalRef(String principalRef) {
        this.principalRef = principalRef;
    }

    public DcDateCurAmtTagXXX getFaceAmt() {
        return faceAmt;
    }

    public void setFaceAmt(DcDateCurAmtTagXXX faceAmt) {
        this.faceAmt = faceAmt;
    }

    public ActnoBicAdrTagXXX getPrincipal() {
        return principal;
    }

    public void setPrincipal(ActnoBicAdrTagXXX principal) {
        this.principal = principal;
    }

    public ActnoBicAdrTagXXX getDrawee() {
        return drawee;
    }

    public void setDrawee(ActnoBicAdrTagXXX drawee) {
        this.drawee = drawee;
    }

    public String getSenderCharges() {
        return senderCharges;
    }

    public void setSenderCharges(String senderCharges) {
        this.senderCharges = senderCharges;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

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

    public MT416AbsCreator() {
        super();
    }

    public void pack() {
        List<AbsTagCreate> tagCreateList = new ArrayList<>();
        try{
            tagCreateList.add(new Tag21ACreator(this));
            tagCreateList.add(new Tag23EBCreator(this));
            tagCreateList.add(new Tag21CCreator(this));
            tagCreateList.add(new Tag32aCreator(this));
            tagCreateList.add(new Tag50DCreator(this));
            tagCreateList.add(new Tag59Creator(this));
            tagCreateList.add(new Tag71FBCreator(this));
            tagCreateList.add(new Tag77ABCreator(this));

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

    public MtResult unpack() {
        return null;
    }
}
