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

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

/**
 * @author gaosheng
 * @date 2023/3/1
 */
public class MT734Creator 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;

    //32A
    @Status("M")
    @TagName("32A")
    @FieldDescription("Date and Amount of Utilisation")
    @TagRegex("6!n3!a15d")
    private DcDateCurAmtTagXXX dateAndAmountOfUtilisation;

    //73A
    @Status("O")
    @TagName("73A")
    @FieldDescription("Charges Claimed")
    @TagRegex("6*35z")
    private String chargesClaimed;

    //33a
    @Status("O")
    @TagName({"33A","33B"})
    @FieldDescription("Total Amount Claimed")
    @TagRegex({"6!n3!a15d","3!a15d"})
    private DcDateCurAmtTagXXX totalAmountClaimed;

    //57a
    @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"})
    private ActnoBicAdrTagXXX accountWithBank;

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

    //77J
    @Status("M")
    @TagName("77J")
    @FieldDescription("Discrepancies")
    @TagRegex("70*50z")
    private String discrepancies;

    //77B
    @Status("M")
    @TagName("77B")
    @FieldDescription("Disposal of Documents")
    @TagRegex("3*35x")
    private String DisposalofDocuments;

    public String getDisposalofDocuments() {
        return DisposalofDocuments;
    }

    public void setDisposalofDocuments(String disposalofDocuments) {
        DisposalofDocuments = disposalofDocuments;
    }

    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 getChargesClaimed() {
        return chargesClaimed;
    }

    public void setChargesClaimed(String chargesClaimed) {
        this.chargesClaimed = chargesClaimed;
    }

    public DcDateCurAmtTagXXX getDateAndAmountOfUtilisation() {
        return dateAndAmountOfUtilisation;
    }

    public void setDateAndAmountOfUtilisation(DcDateCurAmtTagXXX dateAndAmountOfUtilisation) {
        this.dateAndAmountOfUtilisation = dateAndAmountOfUtilisation;
    }

    public DcDateCurAmtTagXXX getTotalAmountClaimed() {
        return totalAmountClaimed;
    }

    public void setTotalAmountClaimed(DcDateCurAmtTagXXX totalAmountClaimed) {
        this.totalAmountClaimed = totalAmountClaimed;
    }

    public ActnoBicAdrTagXXX getAccountWithBank() {
        return accountWithBank;
    }

    public void setAccountWithBank(ActnoBicAdrTagXXX accountWithBank) {
        this.accountWithBank = accountWithBank;
    }

    public String getSenderToReceiverInformation() {
        return senderToReceiverInformation;
    }

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

    public String getDiscrepancies() {
        return discrepancies;
    }

    public void setDiscrepancies(String discrepancies) {
        this.discrepancies = discrepancies;
    }

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

    public MT734Creator() {
    }

    /**
     * 需要编写组装报文逻辑，调用set方法即可
     *
     * @return
     */
    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 Tag32ACreator(this));
            tagCreateList.add(new Tag73ACreator(this));
            tagCreateList.add(new Tag33aCreator(this));
            tagCreateList.add(new Tag57aCreator(this));
            tagCreateList.add(new Tag72ZCreator(this));
            tagCreateList.add(new Tag77JCreator(this));
            tagCreateList.add(new Tag77BCreator(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;
    }
}
