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.mt7xx.tag.tag708.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import java.util.ArrayList;
import java.util.List;

/**
 * @author wuzhe
 * @date 2023/2/27
 */
public class MT708Creator extends AbsMTCreator {
    @Status("M")
    @TagName("27")
    @FieldDescription("Sequence of Total")
    @TagRegex("1!n/1!n")
    //27
    private String sequenceofTotal;
    @Status("M")
    @TagName("20")
    @FieldDescription("Sender's Reference")
    @TagRegex("16x")
    //20
    private String senderReference;
    @Status("M")
    @TagName("21")
    @FieldDescription("Receiver's Reference")
    @TagRegex("16x")
    //21
    private String receiverReference;
    @Status("M")
    @TagName("23")
    @FieldDescription("Issuing Bank's Reference")
    @TagRegex("16x")
    //23
    private String issuingBankReference;
    @Status("M")
    @TagName("26E")
    @FieldDescription("Number of Amendment")
    @TagRegex("3n")
    //26E
    private String numberofAmendment;
    @Status("M")
    @TagName("30")
    @FieldDescription("Date of Amendment")
    @TagRegex("6!n")
    //30
    private String dateofAmendment;
    @Status("O")
    @TagName("45B")
    @FieldDescription("Description of Goods and/or Services")
    @TagRegex("100*65z")
    //45B
    private String descriptionofGoodsServices;
    @Status("O")
    @TagName("46B")
    @FieldDescription("Documents Required")
    @TagRegex("100*65z")
    //46B
    private String documentsRequired;
    @Status("O")
    @TagName("47B")
    @FieldDescription("Additional Conditions")
    @TagRegex("100*65z")
    //47B
    private String additionalConditions;
    @Status("O")
    @TagName("49M")
    @FieldDescription("Special Payment Conditions for Beneficiary")
    @TagRegex("100*65z")
    //49M
    private String specialPaymentConditionsforBeneficiary;
    @Status("O")
    @TagName("49N")
    @FieldDescription("Special Payment Conditions for Bank Only")
    @TagRegex("100*65z")
    //49N
    private String specialPaymentConditionsforBankOnly;

    //27
    public String getSequenceofTotal() {
        return sequenceofTotal;
    }

    public void setSequenceofTotal(String sequenceofTotal) {
        this.sequenceofTotal = sequenceofTotal;
    }

    //20
    public String getSenderReference() {
        return senderReference;
    }

    public void setSenderReference(String senderReference) {
        this.senderReference = senderReference;
    }

    //21
    public String getReceiverReference() {
        return receiverReference;
    }

    public void setReceiverReference(String receiverReference) {
        this.receiverReference = receiverReference;
    }

    //23
    public String getIssuingBankReference() {
        return issuingBankReference;
    }

    public void setIssuingBankReference(String issuingBankReference) {
        this.issuingBankReference = issuingBankReference;
    }

    //26E
    public String getNumberofAmendment() {
        return numberofAmendment;
    }

    public void setNumberofAmendment(String numberofAmendment) {
        this.numberofAmendment = numberofAmendment;
    }

    //30
    public String getDateofAmendment() {
        return dateofAmendment;
    }

    public void setDateofAmendment(String dateofAmendment) {
        this.dateofAmendment = dateofAmendment;
    }

    //45B
    public String getDescriptionofGoodsServices() {
        return descriptionofGoodsServices;
    }

    public void setDescriptionofGoodsServices(String descriptionofGoodsServices) {
        this.descriptionofGoodsServices = descriptionofGoodsServices;
    }

    //46B
    public String getDocumentsRequired() {
        return documentsRequired;
    }

    public void setDocumentsRequired(String documentsRequired) {
        this.documentsRequired = documentsRequired;
    }

    //47B
    public String getAdditionalConditions() {
        return additionalConditions;
    }

    public void setAdditionalConditions(String additionalConditions) {
        this.additionalConditions = additionalConditions;
    }

    //49M
    public String getSpecialPaymentConditionsforBeneficiary() {
        return specialPaymentConditionsforBeneficiary;
    }

    public void setSpecialPaymentConditionsforBeneficiary(String specialPaymentConditionsforBeneficiary) {
        this.specialPaymentConditionsforBeneficiary = specialPaymentConditionsforBeneficiary;
    }

    //49N
    public String getSpecialPaymentConditionsforBankOnly() {
        return specialPaymentConditionsforBankOnly;
    }

    public void setSpecialPaymentConditionsforBankOnly(String specialPaymentConditionsforBankOnly) {
        this.specialPaymentConditionsforBankOnly = specialPaymentConditionsforBankOnly;
    }

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

    public MT708Creator() {
        super("708");
    }

    /**
     * 需要编写组装报文逻辑，调用set方法即可
     *
     * @return
     */
    public void pack() {
       // MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList = new ArrayList<>();
        try {
            tagCreateList.add(new Tag27Creator(this));
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag21Creator(this));
            tagCreateList.add(new Tag23Creator(this));
            tagCreateList.add(new Tag26ECreator(this));
            tagCreateList.add(new Tag30Creator(this));
            tagCreateList.add(new Tag45BCreator(this));
            tagCreateList.add(new Tag46BCreator(this));
            tagCreateList.add(new Tag47BCreator(this));
            tagCreateList.add(new Tag49MCreator(this));
            tagCreateList.add(new Tag49NCreator(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;
    }

}

