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.tag707.*;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag732.Tag21Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag732.Tag30Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag732.Tag32BCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag732.Tag72ZCreator;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

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

/**
 * @author gaosheng
 * @date 2023/3/1
 */
public class MT732Creator extends AbsMTCreator {

    //20
    @Status("M")
    @TagName("20")
    @FieldDescription("Sender's TRN")
    @TagRegex("16x")
    private String sendersTRN;

    //21
    @Status("M")
    @TagName("21")
    @FieldDescription("Presenting Bank's Reference")
    @TagRegex("16x")
    private String presentingBanksReference;

    //30
    @Status("M")
    @TagName("30")
    @FieldDescription("Date of Advice of Payment/Acceptance/Negotiation")
    @TagRegex("6!n")
    private String dateOfAdviceOfPaymentAN;

    //32B
    @Status("M")
    @TagName("32B")
    @FieldDescription("Amount of Utilisation")
    @TagRegex("3!a15d")
    private DcDateCurAmtTagXXX amountOfUtilisation;

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

    public String getSendersTRN() {
        return sendersTRN;
    }

    public void setSendersTRN(String sendersTRN) {
        this.sendersTRN = sendersTRN;
    }

    public String getPresentingBanksReference() {
        return presentingBanksReference;
    }

    public void setPresentingBanksReference(String presentingBanksReference) {
        this.presentingBanksReference = presentingBanksReference;
    }

    public String getDateOfAdviceOfPaymentAN() {
        return dateOfAdviceOfPaymentAN;
    }

    public void setDateOfAdviceOfPaymentAN(String dateOfAdviceOfPaymentAN) {
        this.dateOfAdviceOfPaymentAN = dateOfAdviceOfPaymentAN;
    }

    public DcDateCurAmtTagXXX getAmountOfUtilisation() {
        return amountOfUtilisation;
    }

    public void setAmountOfUtilisation(DcDateCurAmtTagXXX amountOfUtilisation) {
        this.amountOfUtilisation = amountOfUtilisation;
    }

    public String getSenderToReceiverInformation() {
        return senderToReceiverInformation;
    }

    public void setSenderToReceiverInformation(String senderToReceiverInformation) {
        this.senderToReceiverInformation = senderToReceiverInformation;
    }

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

    public MT732Creator() {
    }

    /**
     * 需要编写组装报文逻辑，调用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.tag732.Tag20Creator(this));
            tagCreateList.add(new Tag21Creator(this));
            tagCreateList.add(new Tag30Creator(this));
            tagCreateList.add(new Tag32BCreator(this));
            tagCreateList.add(new Tag72ZCreator(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;
    }
}
