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

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

/**
 * @author gaosheng
 * @date 2023/2/23
 */
public class MT701Creator extends AbsMTCreator {

    @Status("M")
    @TagName("27")
    @FieldDescription("Sequence of Total")
    @TagRegex("1!n/1!n")
    //27
    private String sequenceofTotal;

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

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

    @Status("O")
    @TagName("46A")
    @FieldDescription("Documents Required")
    @TagRegex("100*65z")
    //46A
    private String documentsRequired;

    @Status("O")
    @TagName("47A")
    @FieldDescription("Additional Conditions")
    @TagRegex("100*65z")
    //47A
    private String additionalConditions;

    @Status("O")
    @TagName("49G")
    @FieldDescription("Special Payment Conditions for Beneficiary")
    @TagRegex("100*65z")
    //49G
    private String specialPaymentConditionsforBeneficiary;

    @Status("O")
    @TagName("49H")
    @FieldDescription("Special Payment Conditions for BankOnly")
    @TagRegex("100*65z")
    //49H
    public String specialPaymentConditionsforBankOnly;

    public String getSequenceofTotal() {
        return sequenceofTotal;
    }

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

    public String getDocumentaryCreditNumber() {
        return documentaryCreditNumber;
    }

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

    public String getDescriptionofGoodsandorServices() {
        return descriptionofGoodsandorServices;
    }

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

    public String getDocumentsRequired() {
        return documentsRequired;
    }

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

    public String getAdditionalConditions() {
        return additionalConditions;
    }

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

    public String getSpecialPaymentConditionsforBeneficiary() {
        return specialPaymentConditionsforBeneficiary;
    }

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

    public String getSpecialPaymentConditionsforBankOnly() {
        return specialPaymentConditionsforBankOnly;
    }

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

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

    public MT701Creator() {
        super("701");
    }

    /**
     * 需要编写组装报文逻辑，调用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 Tag45ACreator(this));
            tagCreateList.add(new Tag46ACreator(this));
            tagCreateList.add(new Tag47ACreator(this));
            tagCreateList.add(new Tag49GCreator(this));
            tagCreateList.add(new Tag49HCreator(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;
    }
}
