package com.brilliance.isc.convert.mt7xx;

import com.brilliance.isc.swift.objmtconvert.manager.MtCreatorManager;
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.MT707Creator;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import org.junit.Test;

import java.math.BigDecimal;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * @author gechengyang
 * @date 2023/2/14
 */

public class MT707Test {

    @Test
    public void mt707_Test() {
        MT707Creator mt707Creator = new MT707Creator("707");//报文类型
        //27
        mt707Creator.setSequenceOfTotal("1/1");//1!n/1!n
        //20
        mt707Creator.setSendersReference("OST12588");//16x
        //21
        mt707Creator.setReceiversReference("sffff");//16x
        //23
        mt707Creator.setIssuingBanksReference("123456");//16x
        //31C
        mt707Creator.setDateOfIssue("150202");//6!n
        //26E
        mt707Creator.setNumberOfAmendment("001");//3n
        //30
        mt707Creator.setDateOfAmendment("150205");//6!n
        //22A
        mt707Creator.setPurposeOfMessage("ISSU");//4!c
        //52a
        ActnoBicAdrTagXXX issuingBank = new ActnoBicAdrTagXXX("52");
        issuingBank.setPartyIdentifier("ppo888p");
        issuingBank.setCode("aaaa");
        issuingBank.setBic("TESTTE23");
        mt707Creator.setIssuingBank(issuingBank);//A or D
        //23S
        mt707Creator.setCancellationRequest("QOIJNH");//6!a

        //50B
        mt707Creator.setNonBankIssuer("jjgggh");//4*35x

        //40A
        mt707Creator.setFormOfDocumentaryCredit("safaf");//24x
        //40E
        mt707Creator.setApplicableRules("ffafasf");//30x[/35x]
        //31D
        mt707Creator.setApplicableRules("150529AMSTERDAM");//6!n29x
        //50
        mt707Creator.setChangedApplicantDetails("fdsddd");//4*35x
        //59
        ActnoBicAdrTagXXX beneficiary = new ActnoBicAdrTagXXX("59");
        beneficiary.setAddress("frrfg");
        mt707Creator.setBeneficiary(beneficiary);//[/34x]<crlf>4*35x
        //32B
        DcDateCurAmtTagXXX increaseOfDocumentaryCreditAmount = new DcDateCurAmtTagXXX("32");
        increaseOfDocumentaryCreditAmount.setAmount(new BigDecimal("1000.00"));
        increaseOfDocumentaryCreditAmount.setCurrency("USD");
        mt707Creator.setIncreaseOfDocumentaryCreditAmount(increaseOfDocumentaryCreditAmount);//3!a15d

        //mt707Creator.setIncreaseOfDocumentaryCreditAmount("ERR,");//3!a15d
        /*//33B
        DcDateCurAmtTagXXX decreaseOfDocumentaryCreditAmount=new DcDateCurAmtTagXXX("33");
        decreaseOfDocumentaryCreditAmount.setAmount(new BigDecimal("1000.00"));
        decreaseOfDocumentaryCreditAmount.setCurrency("USD");
        mt707Creator.setDecreaseOfDocumentaryCreditAmount(decreaseOfDocumentaryCreditAmount);//3!a15d*/
        //39A
        mt707Creator.setPercentageCreditAmountTolerance("22/66");//2n/2n
        //39C
        mt707Creator.setAdditionalAmountsCovered("DFGGGG");//4*35x
        //41a
        ActnoBicAdrTagXXX availableWithBy = new ActnoBicAdrTagXXX("41");
        availableWithBy.setCode("QQQQ");
        availableWithBy.setBic("TESTTE23");
        mt707Creator.setAvailableWithBy(availableWithBy);//A or D
        //42C
        mt707Creator.setDraftsAt("NKJFHJK");//3*35x
        //42a
        ActnoBicAdrTagXXX drawee = new ActnoBicAdrTagXXX("42");
        drawee.setPartyIdentifier("ppo888p");
        drawee.setCode("aaaa");
        drawee.setBic("TESTTE23");
        mt707Creator.setDrawee(drawee);//A or D
        //42M
        mt707Creator.setMixedPaymentDetails("KLLKLJ");//4*35x
        //42P
        mt707Creator.setNegotiationDeferredPaymentDetails("OUOIRUIO");//4*35x
        //43P
        mt707Creator.setPartialShipments("HKSF");//11x
        //43T
        mt707Creator.setTranshipment("SFFF");//11x
        //44A
        mt707Creator.setPlaceOfTakingInChargeDFPOR("SFFF");//65x
        //44E
        mt707Creator.setPortOfLoadingAOD("RRVVV");//65x
        //44F
        mt707Creator.setPortOfDischargeAOD("ASFF");//65x
        //44B
        mt707Creator.setPlaceOfFinalDestinationFTTPOD("DADFFD");//65x
        //44C
        mt707Creator.setLatestDateOfShipment("150515");//6!n
        //44D
        //mt707Creator.setShipmentPeriod("DFVCCXXC");//6*65x
        //45B
        mt707Creator.setDescriptionOfGoodsAndOS("FVBBNN");//100*65z
        //46B
        mt707Creator.setDocumentsRequired("/ADD/+COPY OF CERTIFICATE OF ORIGIN\n" +
                " SHOWING GOODS ARE OF BELGIAN ORIGIN\n" +
                " /ADD/+COPY OF CONSULAR INVOICE MENTIONING\n" +
                " IMPORT REGISTRATION NUMBER 123");//100*65z
        //47B
        mt707Creator.setAdditionalConditions("WSMDLKSAJ");//100*65z
        //49M
        mt707Creator.setSpecialPaymentConditionsForBeneficiary("NJKVN");//100*65z
        //49N
        mt707Creator.setSpecialPaymentConditionsForBankOnly("WUZHESHIZHU");//100*65z
        //71D
        mt707Creator.setCharges("BNCXZLM");//6*35z
        //71N
        ActnoBicAdrTagXXX amendmentChargePayableBy = new ActnoBicAdrTagXXX("71");
        amendmentChargePayableBy.setCode("QQQQ");
        mt707Creator.setAmendmentChargePayableBy(amendmentChargePayableBy);//4!c<crlf>[6*35z]
        //48
        mt707Creator.setPeriodForPresentationInDays("365");//3n[/35x]
        //49
        mt707Creator.setConfirmationInstructions("KDFJNJK");//7!x
        //58a
        ActnoBicAdrTagXXX requestedConfirmationParty = new ActnoBicAdrTagXXX("58");
        requestedConfirmationParty.setPartyIdentifier("ppo888p");
        requestedConfirmationParty.setCode("aaaa");
        requestedConfirmationParty.setBic("TESTTE23");
        mt707Creator.setRequestedConfirmationParty(requestedConfirmationParty);//A or D
        //53a
        ActnoBicAdrTagXXX reimbursingBank = new ActnoBicAdrTagXXX("53");
        reimbursingBank.setPartyIdentifier("ppo888p");
        reimbursingBank.setCode("aaaa");
        reimbursingBank.setBic("TESTTE23");
        mt707Creator.setReimbursingBank(reimbursingBank);//A or D
        //78
        mt707Creator.setInstructionsToThePayingANB("DVGGF");//12*65x
        //57a
        ActnoBicAdrTagXXX adviseThroughBank = new ActnoBicAdrTagXXX("57");
        adviseThroughBank.setPartyIdentifier("ppo888p");
        adviseThroughBank.setCode("aaaa");
        adviseThroughBank.setBic("TESTTE23");
        mt707Creator.setAdviseThroughBank(adviseThroughBank);//A, B, or D
        //72Z
        mt707Creator.setSenderToReceiverInformation("KUFHS");//6*35z
        MtResult mtResult = MtCreatorManager.packMT(mt707Creator);

    }


    @Test
    public void test() {
        String str = "love234csdnjava";
        String regEx = "[^0-9]";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(str);
        String result = m.replaceAll("").trim();
        System.out.println(result);
        System.out.println(str);
    }
}

