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

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

/**
 * @author gaosheng
 * @date 2023/2/24
 */
public class MT705Creator extends AbsMTCreator {

    @Status("M")
    @TagName("40A")
    @FieldDescription("Form of Documentary Credit")
    @TagRegex("24x")
    //40A
    private String formofDocumentaryCredit;

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

    @Status("M")
    @TagName("31D")
    @FieldDescription("Dateand Place of Expiry")
    @TagRegex("6!n29x")
    //31D
    private String dateandPlaceofExpiry;

    @Status("M")
    @TagName("50")
    @FieldDescription("Applicant")
    @TagRegex("4*35x")
    //50
    private String applicant;

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

    @Status("M")
    @TagName("32B")
    @FieldDescription("Currency Code Amount")
    @TagRegex("3!a15d")
    //32B
    private DcDateCurAmtTagXXX currencyCodeAmount;

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

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

    @Status("O")
    @TagName("41a")
    @FieldDescription("Available WithBy")
    @TagRegex("A or D")
    //41a
    private ActnoBicAdrTagXXX availableWithBy;

    @Status("O")
    @TagName("44A")
    @FieldDescription("Place of Taking in Charge Dispatchfrom Placeof Receipt")
    @TagRegex("65x")
    //44A
    private String placeofTakinginChargeDispatchfromPlaceofReceipt;

    @Status("O")
    @TagName("44E")
    @FieldDescription("Port of Loading Airport of Departure")
    @TagRegex("65x")
    //44E
    private String portofLoadingAirportofDeparture;

    @Status("O")
    @TagName("44F")
    @FieldDescription("Portof Discharge Airportof Destination")
    @TagRegex("65x")
    //44F
    private String portofDischargeAirportofDestination;

    @Status("O")
    @TagName("44B")
    @FieldDescription("Placeof Final Destination For Transportationto PlaceofDelivery")
    @TagRegex("65x")
    //44B
    private String placeofFinalDestinationForTransportationtoPlaceofDelivery;

    @Status("O")
    @TagName("44C")
    @FieldDescription("Latest Dateof Shipment")
    @TagRegex("6!n")
    //44C
    private String latestDateofShipment;

    @Status("O")
    @TagName("44D")
    @FieldDescription("Shipment Period")
    @TagRegex("6*65x")
    //44D
    private String shipmentPeriod;

    @Status("O")
    @TagName("45A")
    @FieldDescription("Description of Goodsandor Services")
    @TagRegex("100*65z")
    //45A
    private String descriptionofGoodsandorServices;

    @Status("O")
    @TagName("57a")
    @FieldDescription("Advise Through Bank")
    @TagRegex("A, B, or D")
    //57a
    private ActnoBicAdrTagXXX adviseThroughBank;

    @Status("O")
    @TagName("79Z")
    @FieldDescription("Narrative")
    @TagRegex("35*50z")
    //79Z
    private String narrative;

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

    public String getFormofDocumentaryCredit() {
        return formofDocumentaryCredit;
    }

    public void setFormofDocumentaryCredit(String formofDocumentaryCredit) {
        this.formofDocumentaryCredit = formofDocumentaryCredit;
    }

    public String getDocumentaryCreditNumber() {
        return documentaryCreditNumber;
    }

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

    public String getDateandPlaceofExpiry() {
        return dateandPlaceofExpiry;
    }

    public void setDateandPlaceofExpiry(String dateandPlaceofExpiry) {
        this.dateandPlaceofExpiry = dateandPlaceofExpiry;
    }

    public String getApplicant() {
        return applicant;
    }

    public void setApplicant(String applicant) {
        this.applicant = applicant;
    }

    public String getBeneficiary() {
        return beneficiary;
    }

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



    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 String getPlaceofTakinginChargeDispatchfromPlaceofReceipt() {
        return placeofTakinginChargeDispatchfromPlaceofReceipt;
    }

    public void setPlaceofTakinginChargeDispatchfromPlaceofReceipt(String placeofTakinginChargeDispatchfromPlaceofReceipt) {
        this.placeofTakinginChargeDispatchfromPlaceofReceipt = placeofTakinginChargeDispatchfromPlaceofReceipt;
    }

    public String getPortofLoadingAirportofDeparture() {
        return portofLoadingAirportofDeparture;
    }

    public void setPortofLoadingAirportofDeparture(String portofLoadingAirportofDeparture) {
        this.portofLoadingAirportofDeparture = portofLoadingAirportofDeparture;
    }

    public String getPortofDischargeAirportofDestination() {
        return portofDischargeAirportofDestination;
    }

    public void setPortofDischargeAirportofDestination(String portofDischargeAirportofDestination) {
        this.portofDischargeAirportofDestination = portofDischargeAirportofDestination;
    }

    public String getPlaceofFinalDestinationForTransportationtoPlaceofDelivery() {
        return placeofFinalDestinationForTransportationtoPlaceofDelivery;
    }

    public void setPlaceofFinalDestinationForTransportationtoPlaceofDelivery(String placeofFinalDestinationForTransportationtoPlaceofDelivery) {
        this.placeofFinalDestinationForTransportationtoPlaceofDelivery = placeofFinalDestinationForTransportationtoPlaceofDelivery;
    }

    public String getLatestDateofShipment() {
        return latestDateofShipment;
    }

    public void setLatestDateofShipment(String latestDateofShipment) {
        this.latestDateofShipment = latestDateofShipment;
    }

    public String getShipmentPeriod() {
        return shipmentPeriod;
    }

    public void setShipmentPeriod(String shipmentPeriod) {
        this.shipmentPeriod = shipmentPeriod;
    }

    public String getDescriptionofGoodsandorServices() {
        return descriptionofGoodsandorServices;
    }

    public void setDescriptionofGoodsandorServices(String descriptionofGoodsandorServices) {
        this.descriptionofGoodsandorServices = descriptionofGoodsandorServices;
    }

    public DcDateCurAmtTagXXX getCurrencyCodeAmount() {
        return currencyCodeAmount;
    }

    public void setCurrencyCodeAmount(DcDateCurAmtTagXXX currencyCodeAmount) {
        this.currencyCodeAmount = currencyCodeAmount;
    }

    public ActnoBicAdrTagXXX getAvailableWithBy() {
        return availableWithBy;
    }

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

    public ActnoBicAdrTagXXX getAdviseThroughBank() {
        return adviseThroughBank;
    }

    public void setAdviseThroughBank(ActnoBicAdrTagXXX adviseThroughBank) {
        this.adviseThroughBank = adviseThroughBank;
    }

    public String getNarrative() {
        return narrative;
    }

    public void setNarrative(String narrative) {
        this.narrative = narrative;
    }

    public String getSendertoReceiverInformation() {
        return sendertoReceiverInformation;
    }

    public void setSendertoReceiverInformation(String sendertoReceiverInformation) {
        this.sendertoReceiverInformation = sendertoReceiverInformation;
    }

    // 无参构造  （json）
    public MT705Creator(String jsonData) throws ClassNotFoundException {
        super(jsonData);
    }

    /**
     * 需要编写组装报文逻辑，调用set方法即可
     *
     * @return
     */
    public void pack() {
       // MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList = new ArrayList<>();
        try {
            tagCreateList.add(new Tag40ACreator(this));
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag31DCreator(this));
            tagCreateList.add(new Tag50Creator(this));
            tagCreateList.add(new Tag59Creator(this));
            tagCreateList.add(new Tag32BCreator(this));
            tagCreateList.add(new Tag39ACreator(this));
            tagCreateList.add(new Tag39CCreator(this));
            tagCreateList.add(new Tag41aCreator(this));
            tagCreateList.add(new Tag44ACreator(this));
            tagCreateList.add(new Tag44ECreator(this));
            tagCreateList.add(new Tag44FCreator(this));
            tagCreateList.add(new Tag44BCreator(this));
            tagCreateList.add(new Tag44CCreator(this));
            tagCreateList.add(new Tag44DCreator(this));
            tagCreateList.add(new Tag45ACreator(this));
            tagCreateList.add(new Tag57aCreator(this));
            tagCreateList.add(new Tag79ZCreator(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;
    }
}
