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.MT201AbsCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.MT201Creator;
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：mt201test
 * @Author：夏猛
 * @CreateTime：2023/2/24 17:48
 **/
public class MT201Test {
    @Test
    public void mt201_Test(){
        //53B
        ActnoBicAdrTagXXX actnoBicAdrTag53B=new ActnoBicAdrTagXXX("53");
        actnoBicAdrTag53B.setLocation("WUHAN-HUBEI");  //53B
        actnoBicAdrTag53B.setPartyIdentifier("1234-5678");
        //循环
        List<MT201AbsCreator> list201 = new LinkedList<>();
        //循环1
        MT201AbsCreator MT201AbsCreator =new MT201AbsCreator();
        MT201AbsCreator.setTransactionReferenceNumber("xunhuan1111111"); //20 16x

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

        ActnoBicAdrTagXXX actnoBicAdrTag56a01=new ActnoBicAdrTagXXX("56");
        actnoBicAdrTag56a01.setBic("ASDFQW11");
        actnoBicAdrTag56a01.setPartyIdentifier("1234-5678");
        MT201AbsCreator.setIntermediary(actnoBicAdrTag56a01);  //56a

        ActnoBicAdrTagXXX actnoBicAdrTag57a01=new ActnoBicAdrTagXXX("57");
        //actnoBicAdrTag57a01.setBic("info");
        actnoBicAdrTag57a01.setPartyIdentifier("1234-5678");
        actnoBicAdrTag57a01.setLocation("WHYHCNHBXXX");
        //actnoBicAdrTag57a01.setAddress("6226TEST0001");
        MT201AbsCreator.setAccountWithInstitution(actnoBicAdrTag57a01);  //57a

        MT201AbsCreator.setSendertoReceiverInformationB("1234567890"+ Constans.CRLF+"ChequeNumberAnswers");  //72  6*35x

        list201.add(MT201AbsCreator);

        //循环2
        MT201AbsCreator MT201AbsCreator2 =new MT201AbsCreator();
        MT201AbsCreator2.setTransactionReferenceNumber("xunhuan2222222");  //20 16x

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


        ActnoBicAdrTagXXX actnoBicAdrTag56a02=new ActnoBicAdrTagXXX("56");
        actnoBicAdrTag56a02.setBic("ASDFQW11");
        actnoBicAdrTag56a02.setPartyIdentifier("1234-5678");
        MT201AbsCreator2.setIntermediary(actnoBicAdrTag56a02);  //56a

        ActnoBicAdrTagXXX actnoBicAdrTag57a02=new ActnoBicAdrTagXXX("57");
        //actnoBicAdrTag57a02.setBic("info");
        actnoBicAdrTag57a02.setPartyIdentifier("1234-5678");
        actnoBicAdrTag57a02.setLocation("WHYHCNHBXXX");
        //actnoBicAdrTag57a02.setAddress("6226TEST0001");
        MT201AbsCreator2.setAccountWithInstitution(actnoBicAdrTag57a02);    //57a

        MT201AbsCreator2.setSendertoReceiverInformationB("9876543210");  //72  6*35x

        list201.add(MT201AbsCreator2);

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

        mt201Creator.setSumofAmounts(new BigDecimal("300.00"));  //19 17d
        mt201Creator.setValueDate("202302");  //30  6!n
        mt201Creator.setSendersCorrespondent(actnoBicAdrTag53B);   //53B
        mt201Creator.setSendertoReceiverInformationA("infoA"+ Constans.CRLF+"CIPSCNSHXXX");  //72  6*35x
        mt201Creator.setCycleDomain(list201);   //循环

        MtResult mtResult= MtCreatorManager.packMT(mt201Creator);

    }


    @Test
    public void mt20102_Test(){
        //53B
        ActnoBicAdrTagXXX actnoBicAdrTag53B=new ActnoBicAdrTagXXX("53");
        actnoBicAdrTag53B.setLocation("WUHAN-HUBEI");  //53B
        actnoBicAdrTag53B.setPartyIdentifier("1234-5678");
        //循环
        List<MT201AbsCreator> list201 = new LinkedList<>();
        //循环1
        MT201AbsCreator MT201AbsCreator =new MT201AbsCreator();
        MT201AbsCreator.setTransactionReferenceNumber("xunhuan1111111"); //20 16x
        //32B 3!a15d
        DcDateCurAmtTagXXX dcDateCurAmtTag32B1 = new DcDateCurAmtTagXXX("32");
        dcDateCurAmtTag32B1.setCurrency("CON");//3!a
        dcDateCurAmtTag32B1.setAmount(new BigDecimal("100"));//15d
        MT201AbsCreator.setCurrencyCodeAmount(dcDateCurAmtTag32B1);

        ActnoBicAdrTagXXX actnoBicAdrTag56a01=new ActnoBicAdrTagXXX("56");
        actnoBicAdrTag56a01.setBic("ASDFQW11");
        actnoBicAdrTag56a01.setPartyIdentifier("1234-5678");
        MT201AbsCreator.setIntermediary(actnoBicAdrTag56a01);  //56a

        ActnoBicAdrTagXXX actnoBicAdrTag57a01=new ActnoBicAdrTagXXX("57");
        //actnoBicAdrTag57a01.setBic("info");
        actnoBicAdrTag57a01.setPartyIdentifier("1234-5678");
        actnoBicAdrTag57a01.setLocation("WHYHCNHBXXX");
        //actnoBicAdrTag57a01.setAddress("6226TEST0001");
        MT201AbsCreator.setAccountWithInstitution(actnoBicAdrTag57a01);  //57a

        MT201AbsCreator.setSendertoReceiverInformationB("info");  //72  6*35x

        list201.add(MT201AbsCreator);

        //循环2
        MT201AbsCreator MT201AbsCreator2 =new MT201AbsCreator();
        MT201AbsCreator2.setTransactionReferenceNumber("xunhuan2222222");  //20 16x
        //32B 3!a15d
        DcDateCurAmtTagXXX dcDateCurAmtTag32B2 = new DcDateCurAmtTagXXX("32");
        dcDateCurAmtTag32B2.setCurrency("CON");//3!a
        dcDateCurAmtTag32B2.setAmount(new BigDecimal("200"));//15d
        MT201AbsCreator2.setCurrencyCodeAmount(dcDateCurAmtTag32B2);

        ActnoBicAdrTagXXX actnoBicAdrTag56a02=new ActnoBicAdrTagXXX("56");
        actnoBicAdrTag56a02.setBic("ASDFQW11");
        actnoBicAdrTag56a02.setPartyIdentifier("1234-5678");
        MT201AbsCreator2.setIntermediary(actnoBicAdrTag56a02);  //56a

        ActnoBicAdrTagXXX actnoBicAdrTag57a02=new ActnoBicAdrTagXXX("57");
        //actnoBicAdrTag57a02.setBic("info");
        actnoBicAdrTag57a02.setPartyIdentifier("1234-5678");
        actnoBicAdrTag57a02.setLocation("WHYHCNHBXXX");
        //actnoBicAdrTag57a02.setAddress("6226TEST0001");
        MT201AbsCreator2.setAccountWithInstitution(actnoBicAdrTag57a02);    //57a

        MT201AbsCreator2.setSendertoReceiverInformationB("info");  //72  6*35x

        list201.add(MT201AbsCreator2);

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

        mt201Creator.setSumofAmounts(new BigDecimal("300"));  //19 17d
        mt201Creator.setValueDate("202302");  //30  6!n
        mt201Creator.setSendersCorrespondent(actnoBicAdrTag53B);   //53B
        mt201Creator.setSendertoReceiverInformationA("infoA");  //72  6*35x
        mt201Creator.setCycleDomain(list201);   //循环

        MtResult mtResult= MtCreatorManager.packMT(mt201Creator);

    }

}
