package com.brilliance.isc.json2mx.pacs01000103;
import com.brilliance.isc.swift.objmtconvert.ext.XmlDate;
import com.brilliance.isc.swift.objmtconvert.manager.CreatorManager;
import com.brilliance.isc.swift.objmtconvert.model.mx.common.*;
import com.brilliance.isc.swift.objmtconvert.model.mx.pacs01000103.MXPacs01000103Creator;
import com.brilliance.isc.swift.objmtconvert.result.MxResult;
import org.junit.Test;

import java.math.BigDecimal;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author : zxg
 * @data : Created in 2023/4/23
 * @description :
 */
public class Pacs01000103Test {


    @Test
    public void test_Pacs010() throws ParseException {

        MXPacs01000103Creator mXPacs01000103Creator = new MXPacs01000103Creator("pacs.010.001.03");
        mXPacs01000103Creator.setSenderBic("PSBCCNBJ");
        mXPacs01000103Creator.setSenderNm("zs");
        mXPacs01000103Creator.setReceiverBic("PSBCCNBJ");
        mXPacs01000103Creator.setReceiverNm("lisi");
        mXPacs01000103Creator.setMsgDefIdr("sadasdd");
        mXPacs01000103Creator.setBizSvc("dadad");
        mXPacs01000103Creator.setCreDt(new XmlDate());

        mXPacs01000103Creator.setMsgId("aaaaaa");
        mXPacs01000103Creator.setCreDtTm(new XmlDate());
        mXPacs01000103Creator.setCdtId("bbbbb");
        Agent agent = new Agent();
        FinInstnId finInstnId = new FinInstnId();
        PstlAdr pstlAdr = new PstlAdr();
        finInstnId.setBicfi("PSBCCNBJ");
        finInstnId.setNm("zhaoliu");
        finInstnId.setLei("AAA11111111111AAAA22");
        List<String> list = new ArrayList<>();
        list.add("BIODATA GMBH");
        list.add("HOCHSTRASSE, 27");
        pstlAdr.setCtry("CN");
        pstlAdr.setAdrLine(list);
        finInstnId.setPstlAdr(pstlAdr);
        agent.setFinInstnId(finInstnId);
        mXPacs01000103Creator.setCdtrAgt(agent);
        Account account = new Account();
        IdentificationAcc identificationAcc = new IdentificationAcc();
        identificationAcc.setIban("AA11aabb11");
        account.setId(identificationAcc);
        Tp tp = new Tp();
        tp.setCd("cd");
//        tp.setPrtry("012andAND");
        account.setTp(tp);
        account.setCcy("USD");
        account.setNm("nm");
        mXPacs01000103Creator.setCdtrAgtAcct(account);

        mXPacs01000103Creator.setCdtr(agent);
        mXPacs01000103Creator.setCdtrAcct(account);

        mXPacs01000103Creator.setInstrId("setInstrIdsetInstrId");
        mXPacs01000103Creator.setTxId("setTxIdsetTxId");
        mXPacs01000103Creator.setEndToEndId("setEndToEndId");
        mXPacs01000103Creator.setClrSysRef("eeeeeee");

        PmtTpInf pmtTpInf = new PmtTpInf();
        pmtTpInf.setInstrPrty("instrprty");
        mXPacs01000103Creator.setPmtTpInf(pmtTpInf);

        Amt amt = new Amt();
        amt.setCcy("USD");
        BigDecimal bigDecimal = new BigDecimal("123456789111111.111");
        amt.setValue(bigDecimal);
        mXPacs01000103Creator.setIntrBkSttlmAmt(amt);

        mXPacs01000103Creator.setIntrBkSttlmDt(new Date());

        SttlmTmReq sttlmTmReq = new SttlmTmReq();
        //.*(\+|-)((0[0-9])|(1[0-3])):[0-5][0-9]
        //2023-04-25T15:35:45.052+08:00
        //11:39:48.413+08:00
        sttlmTmReq.setRjctTm(new XmlDate());
        mXPacs01000103Creator.setSttlmTmReq(sttlmTmReq);

        mXPacs01000103Creator.setDbtr(agent);
        mXPacs01000103Creator.setDbtrAcct(account);
        mXPacs01000103Creator.setDbtrAgt(agent);
        mXPacs01000103Creator.setDbtrAgtAcct(account);
        mXPacs01000103Creator.setInstrForDbtrAgt("gggggg");

        Purp purp = new Purp();
        purp.setCd("Pure");
//        purp.setPrtry("PurpPrtry");
        mXPacs01000103Creator.setPurp(purp);

        RmtInf rmtInf = new RmtInf();
        ArrayList<String> list1 = new ArrayList<>();
        rmtInf.setUstrd(list1);
        mXPacs01000103Creator.setRmtInf(null);

        mXPacs01000103Creator.setNbOfTxs("1");
        mXPacs01000103Creator.setType("MX");
        MxResult result = (MxResult) CreatorManager.pack(mXPacs01000103Creator);
        if (result.isSuccess()){
            String message = result.getMessage();
            System.out.println("message = " + message);
        }else {
            String errorInf = result.getErrorInf();
            System.out.println("errorInf = " + errorInf);
        }
    }
}
