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.MT202Creator;
import org.junit.Test;

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

/**
 * @author gechengyang
 * @date 2023/2/27
 */
public class MT202Test {
    @Test
    public void mt202_Test() {

        //52A 52D
        ActnoBicAdrTagXXX actnoBicAdr52a = new ActnoBicAdrTagXXX("52");
        actnoBicAdr52a.setBic("WHYHCNHBX01");
        actnoBicAdr52a.setPartyIdentifier("2222-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");
        //53A 53B 53D
        ActnoBicAdrTagXXX actnoBicAdr53a = new ActnoBicAdrTagXXX("53");
        actnoBicAdr53a.setAddress("WJHGJGJ");
        actnoBicAdr53a.setPartyIdentifier("1234-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        //54A 54B 54D
        ActnoBicAdrTagXXX actnoBicAdr54a = new ActnoBicAdrTagXXX("54");
        actnoBicAdr54a.setAcctno("HVJHJHJH");
        actnoBicAdr54a.setPartyIdentifier("3333-4321");
        actnoBicAdr54a.setLocation("JHGJGJJHNBMN");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        //56A 56D
        ActnoBicAdrTagXXX actnoBicAdr56a = new ActnoBicAdrTagXXX("56");
        actnoBicAdr56a.setAddress("WJHGJGJ");
        actnoBicAdr56a.setPartyIdentifier("4444-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        //57A 57B 57D
        ActnoBicAdrTagXXX actnoBicAdr57a = new ActnoBicAdrTagXXX("57");
        actnoBicAdr57a.setAddress("WJHGJGJ");
        actnoBicAdr57a.setPartyIdentifier("7777-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        //58A 58D
        ActnoBicAdrTagXXX actnoBicAdr58a = new ActnoBicAdrTagXXX("58");
        actnoBicAdr58a.setAddress("WJHGJGJ");
        actnoBicAdr58a.setPartyIdentifier("8888-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        MT202Creator mt202Creator = new MT202Creator("202");
        //20
        mt202Creator.setTransactionReferenceNumber("111");//16x
        //21
        mt202Creator.setRelatedReference("2222");//16x
        LinkedList<Object> list13C = new LinkedList<>();
        list13C.add("/BEN/1234-9632");
//        list13C.add("/1234C9632");
        mt202Creator.setTimeIndication(list13C);// /8c/4!n1!x4!n
        //32A
        DcDateCurAmtTagXXX dcDateCurAmt32A = new DcDateCurAmtTagXXX("32");
        dcDateCurAmt32A.setDate("200306");
        dcDateCurAmt32A.setCurrency("USD");
        dcDateCurAmt32A.setAmount(new BigDecimal("2000.00"));
        mt202Creator.setValueDateCurrencyAmount(dcDateCurAmt32A);//6!n3!a15d
        //52A 52D
        mt202Creator.setOrderingInstitution(actnoBicAdr52a);//A,D
        //53A 53B 53D
        mt202Creator.setSendersCorrespondent(actnoBicAdr53a);//A,B,D
        //54A 54B 54D
        mt202Creator.setReceiversCorrespondent(actnoBicAdr54a);//A,B,D
        //56A 56D
        mt202Creator.setIntermediary(actnoBicAdr56a);//A,D
        //57A 57B 57D
//        mt202Creator.setAccountWithInstitution(actnoBicAdr57a);//A,B,D
        //58A 58D
        mt202Creator.setBeneficiaryInstitution(actnoBicAdr58a);//A,D
        //72
        mt202Creator.setSenderToReceiverInformation("/002TEST/12345\r\n/002TEST/5555");//6*35x

        MtCreatorManager.packMT(mt202Creator);

    }
    @Test
    public void mt202_Test2() {

        //52A 52D
        ActnoBicAdrTagXXX actnoBicAdr52a = new ActnoBicAdrTagXXX("52");
        actnoBicAdr52a.setBic("WHYHCNHBX01");
        actnoBicAdr52a.setPartyIdentifier("2222-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");
        //53A 53B 53D
        ActnoBicAdrTagXXX actnoBicAdr53a = new ActnoBicAdrTagXXX("53");
        actnoBicAdr53a.setAddress("WJHGJGJ");
        actnoBicAdr53a.setPartyIdentifier("1234-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        //54A 54B 54D
        ActnoBicAdrTagXXX actnoBicAdr54a = new ActnoBicAdrTagXXX("54");
        actnoBicAdr54a.setAcctno("HVJHJHJH");
        actnoBicAdr54a.setPartyIdentifier("3333-4321");
        actnoBicAdr54a.setLocation("JHGJGJJHNBMN");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        //56A 56D
        ActnoBicAdrTagXXX actnoBicAdr56a = new ActnoBicAdrTagXXX("56");
        actnoBicAdr56a.setAddress("WJHGJGJ");
        actnoBicAdr56a.setPartyIdentifier("4444-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        //57A 57B 57D
        ActnoBicAdrTagXXX actnoBicAdr57a = new ActnoBicAdrTagXXX("57");
        actnoBicAdr57a.setAddress("WJHGJGJ");
        actnoBicAdr57a.setPartyIdentifier("7777-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        //58A 58D
        ActnoBicAdrTagXXX actnoBicAdr58a = new ActnoBicAdrTagXXX("58");
        actnoBicAdr58a.setBic("PSBCCNBJ");
        actnoBicAdr58a.setPartyIdentifier("8888-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        MT202Creator mt202Creator = new MT202Creator("202");
        //20
        mt202Creator.setTransactionReferenceNumber("111");//16x
        //21
        mt202Creator.setRelatedReference("2222");//16x
        LinkedList<Object> list13C = new LinkedList<>();
        list13C.add("/BEN/1234-9632");
//        list13C.add("/1234C9632");
        mt202Creator.setTimeIndication(list13C);// /8c/4!n1!x4!n
        //32A
        DcDateCurAmtTagXXX dcDateCurAmt32A = new DcDateCurAmtTagXXX("32");
        dcDateCurAmt32A.setDate("030608");
        dcDateCurAmt32A.setCurrency("USD");
        dcDateCurAmt32A.setAmount(new BigDecimal("2000.00"));
        mt202Creator.setValueDateCurrencyAmount(dcDateCurAmt32A);//6!n3!a15d
        //52A 52D
//        mt202Creator.setOrderingInstitution(actnoBicAdr52a);//A,D
        //53A 53B 53D
        mt202Creator.setSendersCorrespondent(actnoBicAdr53a);//A,B,D
        //54A 54B 54D
        mt202Creator.setReceiversCorrespondent(actnoBicAdr54a);//A,B,D
        //56A 56D
        mt202Creator.setIntermediary(actnoBicAdr56a);//A,D
        //57A 57B 57D
        mt202Creator.setAccountWithInstitution(actnoBicAdr57a);//A,B,D
        //58A 58D
        mt202Creator.setBeneficiaryInstitution(actnoBicAdr58a);//A,D
        //72
        mt202Creator.setSenderToReceiverInformation("/002TEST/12345\r\n/002TEST/5555");//6*35x

        MtCreatorManager.packMT(mt202Creator);

    }

    @Test
    public void mt202_Test3() {
        //业务校验
        //52A 52D
        ActnoBicAdrTagXXX actnoBicAdr52a = new ActnoBicAdrTagXXX("52");
        actnoBicAdr52a.setBic("WHYHCNHBX01");
        actnoBicAdr52a.setPartyIdentifier("2222-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");
        //53A 53B 53D
        ActnoBicAdrTagXXX actnoBicAdr53a = new ActnoBicAdrTagXXX("53");
        actnoBicAdr53a.setAddress("WJHGJGJ\r\nOIUYT");
        actnoBicAdr53a.setPartyIdentifier("1234-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        //54A 54B 54D
        ActnoBicAdrTagXXX actnoBicAdr54a = new ActnoBicAdrTagXXX("54");
        actnoBicAdr54a.setAcctno("HVJHJHJH");
        actnoBicAdr54a.setPartyIdentifier("3333-4321");
        actnoBicAdr54a.setLocation("JHGJGJJHNBMN");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        //56A 56D
        ActnoBicAdrTagXXX actnoBicAdr56a = new ActnoBicAdrTagXXX("56");
        actnoBicAdr56a.setAddress("WJHGJGJ");
        actnoBicAdr56a.setPartyIdentifier("4444-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        //57A 57B 57D
        ActnoBicAdrTagXXX actnoBicAdr57a = new ActnoBicAdrTagXXX("57");
        actnoBicAdr57a.setAddress("WJHGJGJ");
        actnoBicAdr57a.setPartyIdentifier("7777-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        //58A 58D
        ActnoBicAdrTagXXX actnoBicAdr58a = new ActnoBicAdrTagXXX("58");
        actnoBicAdr58a.setAddress("WJHGJGJ\r\nPUTGFR");
        actnoBicAdr58a.setPartyIdentifier("8888-4321");
//        actnoBicAdrTagXXX.setBic("WHYHCNHBXXX");

        MT202Creator mt202Creator = new MT202Creator("202");
        //20
        mt202Creator.setTransactionReferenceNumber("111");//16x
        //21
        mt202Creator.setRelatedReference("2222");//16x
        LinkedList<Object> list13C = new LinkedList<>();
        list13C.add("/BEN/1234-9632");
//        list13C.add("/1234C9632");
        mt202Creator.setTimeIndication(list13C);// /8c/4!n1!x4!n
        //32A
        DcDateCurAmtTagXXX dcDateCurAmt32A = new DcDateCurAmtTagXXX("32");
        dcDateCurAmt32A.setDate("200306");
        dcDateCurAmt32A.setCurrency("USD");
        dcDateCurAmt32A.setAmount(new BigDecimal("2000.00"));
        mt202Creator.setValueDateCurrencyAmount(dcDateCurAmt32A);//6!n3!a15d
        //52A 52D
        mt202Creator.setOrderingInstitution(actnoBicAdr52a);//A,D
        //53A 53B 53D
        mt202Creator.setSendersCorrespondent(actnoBicAdr53a);//A,B,D
        //54A 54B 54D
        mt202Creator.setReceiversCorrespondent(actnoBicAdr54a);//A,B,D
        //56A 56D
        mt202Creator.setIntermediary(actnoBicAdr56a);//A,D
        //57A 57B 57D
//        mt202Creator.setAccountWithInstitution(actnoBicAdr57a);//A,B,D
        //58A 58D
        mt202Creator.setBeneficiaryInstitution(actnoBicAdr58a);//A,D
        //72
        mt202Creator.setSenderToReceiverInformation("/002TEST/12345\r\n/002TEST/5555");//6*35x

        MtCreatorManager.packMT(mt202Creator);

    }
}
