package com.brilliance.isc.convert.mt2xx;

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.mt2xx.mt2XXAbsCreator.MT204AbsCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.MT204Creator;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import com.brilliance.isc.swift.objmtconvert.util.Constans;
import org.junit.Test;

import java.math.BigDecimal;
import java.util.LinkedList;
import java.util.List;

/**
 * @Description：
 * @Author：夏猛
 * @CreateTime：2023/2/27 11:26
 **/
public class MT204Test {
    @Test
    public void mt204_Test() {

        //57a
        ActnoBicAdrTagXXX actnoBicAdrTag57a=new ActnoBicAdrTagXXX("57");
        //actnoBicAdrTag57a.setInfo("A");
        //actnoBicAdrTag57a.setAddress("WHYHCNHBXXX");
        //actnoBicAdrTag57a.setCode("THISIS41A");
        actnoBicAdrTag57a.setBic("GCYXXXXXX57");
        //actnoBicAdrTag57a.setAcctno("01111001759234567890");
        actnoBicAdrTag57a.setPartyIdentifier("1234-5678");
        //actnoBicAdrTag57a.setLocation("WHYHCNHBXXX");
        //58a
        ActnoBicAdrTagXXX actnoBicAdrTag58a=new ActnoBicAdrTagXXX("58");
        //actnoBicAdrTag58a.setAddress("58001");
        actnoBicAdrTag58a.setPartyIdentifier("1234-5678");
        actnoBicAdrTag58a.setBic("GCYXXXXXX57");
        //循环
        List<MT204AbsCreator> list204 = new LinkedList<>();
        //循环1
        MT204AbsCreator MT204AbsCreator01 =new MT204AbsCreator();
        MT204AbsCreator01.setTransactionReferenceNumberB("xunhuan1111111");//20 16x
        MT204AbsCreator01.setRelatedReference("111111");//21 16x

        //32B 3!a15d
        DcDateCurAmtTagXXX dcDateCurAmtTag32B1 = new DcDateCurAmtTagXXX("32");
        dcDateCurAmtTag32B1.setCurrency("USD");//3!a
        dcDateCurAmtTag32B1.setAmount(new BigDecimal("100"));//15d
        MT204AbsCreator01.setCurrencyCodeAmount(dcDateCurAmtTag32B1);

        //53a
        ActnoBicAdrTagXXX actnoBicAdrTag53a01=new ActnoBicAdrTagXXX("53");
        //actnoBicAdrTag53a01.setInfo("/P");
        //actnoBicAdrTag53a01.setAddress("WHYHCNHBXXX");
        //actnoBicAdrTag53a01.setCode("THISIS41A");
        actnoBicAdrTag53a01.setBic("WERTYU12");
        //actnoBicAdrTag53a01.setAcctno("6226TEST0001");
        actnoBicAdrTag53a01.setPartyIdentifier("1234-5678");
        //actnoBicAdrTag53a01.setLocation("WHYHCNHBXXX");
        MT204AbsCreator01.setDebitInstitution(actnoBicAdrTag53a01);

        MT204AbsCreator01.setSendertoReceiverInformationB("inf1111"+ Constans.CRLF+"RemittanceInformation"); //72 6*35x

        list204.add(MT204AbsCreator01);

        //循环2
        MT204AbsCreator MT204AbsCreator02 =new MT204AbsCreator();
        MT204AbsCreator02.setTransactionReferenceNumberB("xunhuan2222222"); //20 16x
        MT204AbsCreator02.setRelatedReference("222222");    //21 16x

        //32B 3!a15d
        DcDateCurAmtTagXXX dcDateCurAmtTag32B2 = new DcDateCurAmtTagXXX("32");
        dcDateCurAmtTag32B2.setCurrency("CON");//3!a
        dcDateCurAmtTag32B2.setAmount(new BigDecimal("200.2"));//15d
        MT204AbsCreator02.setCurrencyCodeAmount(dcDateCurAmtTag32B2);

        //53a
        ActnoBicAdrTagXXX actnoBicAdrTag53a02=new ActnoBicAdrTagXXX("53");
        //actnoBicAdrTag53a02.setInfo("/P");
        //actnoBicAdrTag53a02.setAddress("WHYHCNHBXXX");
        //actnoBicAdrTag53a02.setCode("THISIS41A");
        actnoBicAdrTag53a02.setBic("WERTYU12");
        //actnoBicAdrTag53a02.setAcctno("6226TEST0001");
        actnoBicAdrTag53a02.setPartyIdentifier("1234-5678");
        //actnoBicAdrTag53a02.setLocation("WHYHCNHBXXX");
        MT204AbsCreator02.setDebitInstitution(actnoBicAdrTag53a02);       //53a

        MT204AbsCreator02.setSendertoReceiverInformationB("inf2222"+ Constans.CRLF+"RemittanceInformation");   //72 6*35x

        list204.add(MT204AbsCreator02);

        //构造参数传入MT报文类型
        MT204Creator mt204Creator=new MT204Creator("204");
        mt204Creator.setSendBic("PSBCCNBJXXX");  //接收
        mt204Creator.setRecvBic("CIPSCNSHXXX");  //发送

        mt204Creator.setTransactionReferenceNumberA("A000001");  //20 16x
        mt204Creator.setSumofAmounts(new BigDecimal("300.2"));       //19 17d
        mt204Creator.setValueDate("202302");      //30 6!n
        mt204Creator.setAccountWithInstitution(actnoBicAdrTag57a);  //57a
        mt204Creator.setBeneficiaryInstitution(actnoBicAdrTag58a);  //58a
        mt204Creator.setSendertoReceiverInformationA("infA"+ Constans.CRLF+"RemittanceInformation");  //72 6*35x
        mt204Creator.setCycleDomain(list204);  //循环

        MtResult mtResult= MtCreatorManager.packMT(mt204Creator);

    }


    @Test
    public void mt20402_Test() {

        //57a
        ActnoBicAdrTagXXX actnoBicAdrTag57a=new ActnoBicAdrTagXXX("57");
        //actnoBicAdrTag57a.setInfo("A");
        //actnoBicAdrTag57a.setAddress("WHYHCNHBXXX");
        //actnoBicAdrTag57a.setCode("THISIS41A");
        //actnoBicAdrTag57a.setBic("GCYXXXXXX57");
        //actnoBicAdrTag57a.setAcctno("01111001759234567890");
        actnoBicAdrTag57a.setPartyIdentifier("1234-5678");
        actnoBicAdrTag57a.setLocation("WHYHCNHBXXX");
        //58a
        ActnoBicAdrTagXXX actnoBicAdrTag58a=new ActnoBicAdrTagXXX("58");
        actnoBicAdrTag58a.setAddress("58001");
        actnoBicAdrTag58a.setPartyIdentifier("1234-5678");
        //actnoBicAdrTag58a.setBic("GCYXXXXXX57");
        //循环
        List<MT204AbsCreator> list204 = new LinkedList<>();
        //循环1
        MT204AbsCreator MT204AbsCreator01 =new MT204AbsCreator();
        MT204AbsCreator01.setTransactionReferenceNumberB("xunhuan1111111");//20 16x
        MT204AbsCreator01.setRelatedReference("111111");//21 16x

        //32B 3!a15d
        DcDateCurAmtTagXXX dcDateCurAmtTag32B1 = new DcDateCurAmtTagXXX("32");
        dcDateCurAmtTag32B1.setCurrency("USD");//3!a
        dcDateCurAmtTag32B1.setAmount(new BigDecimal("100"));//15d
        MT204AbsCreator01.setCurrencyCodeAmount(dcDateCurAmtTag32B1);

        //53a
        ActnoBicAdrTagXXX actnoBicAdrTag53a01=new ActnoBicAdrTagXXX("53");
        //actnoBicAdrTag53a01.setInfo("/P");
        //actnoBicAdrTag53a01.setAddress("WHYHCNHBXXX");
        //actnoBicAdrTag53a01.setCode("THISIS41A");
        //actnoBicAdrTag53a01.setBic("WERTYU12");
        //actnoBicAdrTag53a01.setAcctno("6226TEST0001");
        actnoBicAdrTag53a01.setPartyIdentifier("1234-5678");
        actnoBicAdrTag53a01.setLocation("WHYHCNHBXXX");
        MT204AbsCreator01.setDebitInstitution(actnoBicAdrTag53a01);

        MT204AbsCreator01.setSendertoReceiverInformationB("inf1111"+ Constans.CRLF+"RemittanceInformation"); //72 6*35x

        list204.add(MT204AbsCreator01);

        //循环2
        MT204AbsCreator MT204AbsCreator02 =new MT204AbsCreator();
        MT204AbsCreator02.setTransactionReferenceNumberB("xunhuan2222222"); //20 16x
        MT204AbsCreator02.setRelatedReference("222222");    //21 16x

        //32B 3!a15d
        DcDateCurAmtTagXXX dcDateCurAmtTag32B2 = new DcDateCurAmtTagXXX("32");
        dcDateCurAmtTag32B2.setCurrency("CON");//3!a
        dcDateCurAmtTag32B2.setAmount(new BigDecimal("200.2"));//15d
        MT204AbsCreator02.setCurrencyCodeAmount(dcDateCurAmtTag32B2);

        //53a
        ActnoBicAdrTagXXX actnoBicAdrTag53a02=new ActnoBicAdrTagXXX("53");
        //actnoBicAdrTag53a02.setInfo("/P");
        actnoBicAdrTag53a02.setAddress("WHYHCNHBXXX");
        //actnoBicAdrTag53a02.setCode("THISIS41A");
        //actnoBicAdrTag53a02.setBic("WERTYU12");
        //actnoBicAdrTag53a02.setAcctno("6226TEST0001");
        actnoBicAdrTag53a02.setPartyIdentifier("1234-5678");
        //actnoBicAdrTag53a02.setLocation("WHYHCNHBXXX");
        MT204AbsCreator02.setDebitInstitution(actnoBicAdrTag53a02);       //53a

        MT204AbsCreator02.setSendertoReceiverInformationB("inf2222"+ Constans.CRLF+"RemittanceInformation");   //72 6*35x

        list204.add(MT204AbsCreator02);

        //构造参数传入MT报文类型
        MT204Creator mt204Creator=new MT204Creator("204");
        mt204Creator.setSendBic("PSBCCNBJXXX");  //接收
        mt204Creator.setRecvBic("CIPSCNSHXXX");  //发送

        mt204Creator.setTransactionReferenceNumberA("A000001");  //20 16x
        mt204Creator.setSumofAmounts(new BigDecimal("300.2"));       //19 17d
        mt204Creator.setValueDate("202302");      //30 6!n
        mt204Creator.setAccountWithInstitution(actnoBicAdrTag57a);  //57a
        mt204Creator.setBeneficiaryInstitution(actnoBicAdrTag58a);  //58a
        mt204Creator.setSendertoReceiverInformationA("infA"+ Constans.CRLF+"RemittanceInformation");  //72 6*35x
        mt204Creator.setCycleDomain(list204);  //循环

        MtResult mtResult= MtCreatorManager.packMT(mt204Creator);

    }

}