package com.brilliance.isc.json2mx.pain00100109;

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.pain00100109.MXPain00100109Creator;
import com.brilliance.isc.swift.objmtconvert.result.MxResult;
import org.junit.Test;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;

/**
 * @author : zxg
 * @data : Created in 2023/4/24
 * @description :
 */
public class Pain00100109Test {

    @Test
    public void test_Pain001(){
        MXPain00100109Creator mxPain00100109Creator = new MXPain00100109Creator("pain.001.001.09");
        mxPain00100109Creator.setSenderBic("PSBCCNBJ");
        mxPain00100109Creator.setSenderNm("zs");
        mxPain00100109Creator.setReceiverBic("PSBCCNBJ");
        mxPain00100109Creator.setReceiverNm("lisi");
        mxPain00100109Creator.setBizMsgIdr("xxxxxx");
        mxPain00100109Creator.setMsgDefIdr("sadasdd");
        mxPain00100109Creator.setBizSvc("dadad");
        mxPain00100109Creator.setCreDt(new XmlDate());

        ArrayList<Authstn> authstns = new ArrayList<>();
        Authstn authstn = new Authstn();
        authstn.setCd("xx");
        authstn.setPrtry("prtry");
        authstns.add(authstn);
        mxPain00100109Creator.setAuthstn(authstns);

        Party party = new Party();
        party.setNm("InitgPtyParty");
        PstlAdr pstlAdr = new PstlAdr();
        pstlAdr.setPstBx("pstlAdrPstbx");
        pstlAdr.setFlr("pstlAdrFlr");
        pstlAdr.setRoom("pstlAdrroom");
        pstlAdr.setPstCd("pstlAdrcd");
        pstlAdr.setTwnNm("pstlAdrTwnNm");
        pstlAdr.setDstrctNm("pstlAdrDstrctNm");
        pstlAdr.setCtrySubDvsn("pstlAdrCtrySubDvsn");
        pstlAdr.setCtry("AA");
        party.setPstlAdr(pstlAdr);
        mxPain00100109Creator.setInitgPty(party);

        Agent agent = new Agent();
//        BrnchId brnchId = new BrnchId();
//        agent.setBrnchId(brnchId);
        FinInstnId finInstnId = new FinInstnId();
        finInstnId.setBicfi("AAAAAAAA000");
        agent.setFinInstnId(finInstnId);
        mxPain00100109Creator.setFwdgAgt(agent);

        mxPain00100109Creator.setPmtInfId("aaaa");
        mxPain00100109Creator.setPmtMtd("CHK");

        PmtTpInf pmtTpInf = new PmtTpInf();
        LclInstrm lclInstrm = new LclInstrm();
        lclInstrm.setCd("cd");
        pmtTpInf.setLclInstrm(lclInstrm);
        CtgyPurp ctgyPurp = new CtgyPurp();
        ctgyPurp.setCd("cd");
//        ctgyPurp.setPrtry("prtry");
        pmtTpInf.setCtgyPurp(ctgyPurp);
        mxPain00100109Creator.setPmtTpInf(pmtTpInf);

        ReqdExctnDt reqdExctnDt = new ReqdExctnDt();
        reqdExctnDt.setDt(new Date());
//        reqdExctnDt.setDtTm(new XmlDate());
        mxPain00100109Creator.setReqdExctnDt(reqdExctnDt);

        mxPain00100109Creator.setPoolgAdjstmntDt(new Date());
        mxPain00100109Creator.setDbtr(agent);
        Account account = new Account();
        IdentificationAcc acc = new IdentificationAcc();
        acc.setIban("AA99B");
        account.setId(acc);
        mxPain00100109Creator.setDbtrAcct(account);

        mxPain00100109Creator.setDbtrAgt(agent);
        mxPain00100109Creator.setDbtrAgtAcct(account);
        mxPain00100109Creator.setInstrForDbtrAgt("cccc");
        mxPain00100109Creator.setUltmtDbtr(party);
        mxPain00100109Creator.setChrgBr("dddd");
        mxPain00100109Creator.setChrgsAcct(account);
        mxPain00100109Creator.setChrgsAcctAgt(agent);

        PmtId pmtId = new PmtId();
        pmtId.setEndToEndId("eeee");
        pmtId.setUetr("eb4e7f8d-a762-4428-bd41-0c6ae44e7e25");
        mxPain00100109Creator.setPmtId(pmtId);

        Amt2 amt2 = new Amt2();
        EqvtAmt eqvtAmt = new EqvtAmt();
        Amt amt = new Amt();
        BigDecimal bigDecimal = new BigDecimal("123456789111111.111");
        amt.setValue(bigDecimal);
        amt.setCcy("USD");
        eqvtAmt.setAmt(amt);
        eqvtAmt.setCcyOfTrf("USD");
        amt2.setEqvtAmt(eqvtAmt);
        mxPain00100109Creator.setAmt(amt2);

        XchgRateInf xchgRateInf = new XchgRateInf();
        mxPain00100109Creator.setXchgRateInf(xchgRateInf);

        mxPain00100109Creator.setIntrmyAgt1(agent);
        mxPain00100109Creator.setIntrmyAgt1Acct(account);
        mxPain00100109Creator.setIntrmyAgt2(agent);
        mxPain00100109Creator.setIntrmyAgt2Acct(account);
        mxPain00100109Creator.setIntrmyAgt3(agent);
        mxPain00100109Creator.setIntrmyAgt3Acct(account);
        mxPain00100109Creator.setCdtrAgt(agent);
        mxPain00100109Creator.setCdtrAgtAcct(account);
        mxPain00100109Creator.setCdtr(party);
        mxPain00100109Creator.setCdtrAcct(account);
        mxPain00100109Creator.setUltmtCdtr(party);

        ArrayList<InstrForCdtrAgt> instrForCdtrAgtList = new ArrayList<>();
        InstrForCdtrAgt instrForCdtrAgt = new InstrForCdtrAgt();
        instrForCdtrAgt.setCd("cd");
        instrForCdtrAgt.setInstrInf("InstrForCdtrAgt");
        instrForCdtrAgtList.add(instrForCdtrAgt);
        mxPain00100109Creator.setInstrForCdtrAgt(instrForCdtrAgtList);

        mxPain00100109Creator.setInstrForDbtrAgt2("eeee");

        Purp purp = new Purp();
        purp.setCd("cd");
//        purp.setPrtry("prtrty");
        mxPain00100109Creator.setPurp(purp);

        ArrayList<Object> inf = new ArrayList<>();
        mxPain00100109Creator.setInf(inf);

        ArrayList<RltdRmtInf> rltdRmtInfs = new ArrayList<>();
        RltdRmtInf rltdRmtInf = new RltdRmtInf();
        rltdRmtInf.setRmtId("rmtid");
        mxPain00100109Creator.setRltdRmtInf(rltdRmtInfs);

        mxPain00100109Creator.setNbOfTxs("1");
        mxPain00100109Creator.setType("MX");

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

    }
}
