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.model.mt7xx.tag.tag740.*;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag740.Tag20Creator;
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 MT740Creator extends AbsMTCreator {

    //20
    @Status("M")
    @TagName("20")
    @FieldDescription("Documentary Credit Number")
    @TagRegex("16x")
    private String documentaryCreditNumber;

    //25
    @Status("O")
    @TagName("25")
    @FieldDescription("Account Identification")
    @TagRegex("35x")
    private String accountIdentification;

    //40F
    @Status("M")
    @TagName("40F")
    @FieldDescription("Applicable Rules")
    @TagRegex("30x")
    private String applicableRules;

    //31D
    @Status("O")
    @TagName("31D")
    @FieldDescription("Date and Place of Expiry")
    @TagRegex("6!n29x")
    private String dateAndPlaceOfExpiry;

    //58a
    @Status("O")
    @TagName({"58A","58D"})
    @FieldDescription("Negotiating Bank")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX negotiatingBank;

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


    //32B
    @Status("M")
    @TagName("32B")
    @FieldDescription("Credit Amount")
    @TagRegex("3!a15d")
    private DcDateCurAmtTagXXX creditAmount;

    //39A
    @Status("O")
    @TagName("39A")
    @FieldDescription("Percentage Credit Amount Tolerance")
    @TagRegex("2n/2n")
    private String percentageCreditAmountTolerance;

    //39C
    @Status("O")
    @TagName("39C")
    @FieldDescription("Additional Amounts Covered")
    @TagRegex("4*35x")
    private String additionalAmountsCovered;

    //41a
    @Status("M")
    @TagName({"41A","41D"})
    @FieldDescription("Available With ... By ...")
    @TagRegex({"4!a2!a2!c[3!c]<crlf>14x","4*35x<crlf>14x"})
    private ActnoBicAdrTagXXX availableWithBy;

    //42C
    @Status("O")
    @TagName("42C")
    @FieldDescription("Drafts at ...")
    @TagRegex("3*35x")
    private String draftsAt;

    //42a
    @Status("M")
    @TagName({"42A","42D"})
    @FieldDescription("Drawee")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX drawee;

    //42M
    @Status("O")
    @TagName("42M")
    @FieldDescription("Mixed Payment Details")
    @TagRegex("4*35x")
    private String mixedPaymentDetails;

    //42P
    @Status("O")
    @TagName("42P")
    @FieldDescription("Negotiation/Deferred Payment Details")
    @TagRegex("4*35x")
    private String negotiationDPD;

    //71A
    @Status("O")
    @TagName("71A")
    @FieldDescription("Reimbursing Bank's Charges")
    @TagRegex("3!a")
    private String reimbursingBanksCharges;

    //71D
    @Status("O")
    @TagName("71D")
    @FieldDescription("Other Charges")
    @TagRegex("6*35z")
    private String otherCharges;

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

    public String getDocumentaryCreditNumber() {
        return documentaryCreditNumber;
    }

    public void setDocumentaryCreditNumber(String documentaryCreditNumber) {
        this.documentaryCreditNumber = documentaryCreditNumber;
    }

    public String getAccountIdentification() {
        return accountIdentification;
    }

    public void setAccountIdentification(String accountIdentification) {
        this.accountIdentification = accountIdentification;
    }

    public String getApplicableRules() {
        return applicableRules;
    }

    public void setApplicableRules(String applicableRules) {
        this.applicableRules = applicableRules;
    }

    public String getDateAndPlaceOfExpiry() {
        return dateAndPlaceOfExpiry;
    }

    public void setDateAndPlaceOfExpiry(String dateAndPlaceOfExpiry) {
        this.dateAndPlaceOfExpiry = dateAndPlaceOfExpiry;
    }


    public String getPercentageCreditAmountTolerance() {
        return percentageCreditAmountTolerance;
    }

    public void setPercentageCreditAmountTolerance(String percentageCreditAmountTolerance) {
        this.percentageCreditAmountTolerance = percentageCreditAmountTolerance;
    }

    public String getAdditionalAmountsCovered() {
        return additionalAmountsCovered;
    }

    public void setAdditionalAmountsCovered(String additionalAmountsCovered) {
        this.additionalAmountsCovered = additionalAmountsCovered;
    }

    public ActnoBicAdrTagXXX getNegotiatingBank() {
        return negotiatingBank;
    }

    public void setNegotiatingBank(ActnoBicAdrTagXXX negotiatingBank) {
        this.negotiatingBank = negotiatingBank;
    }

    public ActnoBicAdrTagXXX getBeneficiary() {
        return beneficiary;
    }

    public void setBeneficiary(ActnoBicAdrTagXXX beneficiary) {
        this.beneficiary = beneficiary;
    }

    public DcDateCurAmtTagXXX getCreditAmount() {
        return creditAmount;
    }

    public void setCreditAmount(DcDateCurAmtTagXXX creditAmount) {
        this.creditAmount = creditAmount;
    }

    public ActnoBicAdrTagXXX getAvailableWithBy() {
        return availableWithBy;
    }

    public void setAvailableWithBy(ActnoBicAdrTagXXX availableWithBy) {
        this.availableWithBy = availableWithBy;
    }

    public String getDraftsAt() {
        return draftsAt;
    }

    public void setDraftsAt(String draftsAt) {
        this.draftsAt = draftsAt;
    }

    public ActnoBicAdrTagXXX getDrawee() {
        return drawee;
    }

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

    public String getMixedPaymentDetails() {
        return mixedPaymentDetails;
    }

    public void setMixedPaymentDetails(String mixedPaymentDetails) {
        this.mixedPaymentDetails = mixedPaymentDetails;
    }

    public String getNegotiationDPD() {
        return negotiationDPD;
    }

    public void setNegotiationDPD(String negotiationDPD) {
        this.negotiationDPD = negotiationDPD;
    }

    public String getReimbursingBanksCharges() {
        return reimbursingBanksCharges;
    }

    public void setReimbursingBanksCharges(String reimbursingBanksCharges) {
        this.reimbursingBanksCharges = reimbursingBanksCharges;
    }

    public String getOtherCharges() {
        return otherCharges;
    }

    public void setOtherCharges(String otherCharges) {
        this.otherCharges = otherCharges;
    }

    public String getSenderToReceiverInformation() {
        return senderToReceiverInformation;
    }

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

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

    public MT740Creator() {
    }

    /**
     * 需要编写组装报文逻辑，调用set方法即可
     *
     * @return
     */
    public void pack() {
        //MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList = new ArrayList<>();
        try {
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag25Creator(this));
            tagCreateList.add(new Tag31DCreator(this));
            tagCreateList.add(new Tag32BCreator(this));
            tagCreateList.add(new Tag39ACreator(this));
            tagCreateList.add(new Tag39CCreator(this));
            tagCreateList.add(new Tag40FCreator(this));
            tagCreateList.add(new Tag41aCreator(this));
            tagCreateList.add(new Tag42aCreator(this));
            tagCreateList.add(new Tag42CCreator(this));
            tagCreateList.add(new Tag42MCreator(this));
            tagCreateList.add(new Tag42PCreator(this));
            tagCreateList.add(new Tag58aCreator(this));
            tagCreateList.add(new Tag59Creator(this));
            tagCreateList.add(new Tag71DCreator(this));
            tagCreateList.add(new Tag71ZCreator(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;
    }
}
