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

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

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

/**
 * @author zh
 * @create 2023-02-27-9:26
 */
public class MT400Creator extends AbsMTCreator {

    @Status("M")
    @TagName("20")
    @FieldDescription("Sending Bank's TRN")
    @TagRegex("16x")
    private String sendingBankTRN;
    @Status("M")
    @TagName("21")
    @FieldDescription("Related Reference")
    @TagRegex("16x")
    private String relatedReference;
    @Status("M")
    @TagName({"32A","32B","32K"})
    @FieldDescription("Amount Collected")
    @TagRegex({"6!n3!a15d","3!a15d","1!a3!n2!a3!a15d"})
    private DcDateCurAmtTagXXX amountCollected;
    @Status("M")
    @TagName("33A")
    @FieldDescription("Proceeds Remitted")
    @TagRegex("6!n3!a15d")
    private DcDateCurAmtTagXXX proceedsRemitted;
    @Status("O")
    @TagName({"52A","52D"})
    @FieldDescription("Ordering Bank")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX orderingBank;
    @Status("O")
    @TagName({"53A","53B","53D"})
    @FieldDescription("Sender's Correspondent")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX senderCorrespondent;
    @Status("O")
    @TagName({"54A","54B","54D"})
    @FieldDescription("Receiver's Correspondent")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX receiverCorrespondent;
    @Status("O")
    @TagName({"57A","57D"})
    @FieldDescription("Account With Bank")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX accountWithBank;
    @Status("O")
    @TagName({"58A","58B","58D"})
    @FieldDescription("Beneficiary 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 beneficiaryBank;
    @Status("O")
    @TagName("71B")
    @FieldDescription("Details of Charges")
    @TagRegex("6*35x")
    private String detailsOfCharges;
    @Status("O")
    @TagName("72")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex("6*35x")
    private String senderToReceiverInformation;
    @Status("O")
    @TagName("73")
    @FieldDescription("Details of Amounts Added")
    @TagRegex("6*35x")
    private String detailsOfAmountsAdded;

    public String getSendingBankTRN() {
        return sendingBankTRN;
    }

    public void setSendingBankTRN(String sendingBankTRN) {
        this.sendingBankTRN = sendingBankTRN;
    }

    public String getRelatedReference() {
        return relatedReference;
    }

    public void setRelatedReference(String relatedReference) {
        this.relatedReference = relatedReference;
    }

    public DcDateCurAmtTagXXX getAmountCollected() {
        return amountCollected;
    }

    public void setAmountCollected(DcDateCurAmtTagXXX amountCollected) {
        this.amountCollected = amountCollected;
    }

    public DcDateCurAmtTagXXX getProceedsRemitted() {
        return proceedsRemitted;
    }

    public void setProceedsRemitted(DcDateCurAmtTagXXX proceedsRemitted) {
        this.proceedsRemitted = proceedsRemitted;
    }

    public ActnoBicAdrTagXXX getOrderingBank() {
        return orderingBank;
    }

    public void setOrderingBank(ActnoBicAdrTagXXX orderingBank) {
        this.orderingBank = orderingBank;
    }

    public ActnoBicAdrTagXXX getSenderCorrespondent() {
        return senderCorrespondent;
    }

    public void setSenderCorrespondent(ActnoBicAdrTagXXX senderCorrespondent) {
        this.senderCorrespondent = senderCorrespondent;
    }

    public ActnoBicAdrTagXXX getReceiverCorrespondent() {
        return receiverCorrespondent;
    }

    public void setReceiverCorrespondent(ActnoBicAdrTagXXX receiverCorrespondent) {
        this.receiverCorrespondent = receiverCorrespondent;
    }

    public ActnoBicAdrTagXXX getAccountWithBank() {
        return accountWithBank;
    }

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

    public ActnoBicAdrTagXXX getBeneficiaryBank() {
        return beneficiaryBank;
    }

    public void setBeneficiaryBank(ActnoBicAdrTagXXX beneficiaryBank) {
        this.beneficiaryBank = beneficiaryBank;
    }

    public String getDetailsOfCharges() {
        return detailsOfCharges;
    }

    public void setDetailsOfCharges(String detailsOfCharges) {
        this.detailsOfCharges = detailsOfCharges;
    }

    public String getSenderToReceiverInformation() {
        return senderToReceiverInformation;
    }

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

    public String getDetailsOfAmountsAdded() {
        return detailsOfAmountsAdded;
    }

    public void setDetailsOfAmountsAdded(String detailsOfAmountsAdded) {
        this.detailsOfAmountsAdded = detailsOfAmountsAdded;
    }
//    public MT400Creator(String jsonData) throws Exception {
//        super(jsonData);
//    }
    public MT400Creator(String msgType)  {
        super(msgType);
    }
    public MT400Creator()  {
        super("400");
    }

    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 Tag33ACreator(this));
            tagCreateList.add(new Tag52aCreator(this));
            tagCreateList.add(new Tag53aCreator(this));
            tagCreateList.add(new Tag54aCreator(this));
            tagCreateList.add(new Tag57aCreator(this));
            tagCreateList.add(new Tag58aCreator(this));
            tagCreateList.add(new Tag71BCreator(this));
            tagCreateList.add(new Tag72Creator(this));
            tagCreateList.add(new Tag73Creator(this));
            dealTags(tagCreateList);
            mtResult.setMessage(abstractMT.message());
        } catch (Exception e) {
            e.printStackTrace();
            mtResult.setSuccess(false);
            mtResult.addDescription(e.getLocalizedMessage());
        }
        //return mtResult;

    }
}
