package com.brilliance.isc.json2mx;

import com.brilliance.isc.swift.objmtconvert.ext.XmlDate;
import com.brilliance.isc.swift.objmtconvert.manager.CreatorManager;
import com.brilliance.isc.swift.objmtconvert.model.mx.camt05700106.MXCamt05700106Creator;
import com.brilliance.isc.swift.objmtconvert.model.mx.common.Amt;
import com.brilliance.isc.swift.objmtconvert.model.mx.common.Itm;
import com.brilliance.isc.swift.objmtconvert.result.MxResult;
import org.junit.Test;

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

/**
 * @Description
 * @Author s_guodong
 * @Date 2023/4/23
 */
public class Camt05700106Test {
    @Test
    public void testCamt05700106() {
        MXCamt05700106Creator mxCamt05700106Creator = new MXCamt05700106Creator("camt.057.001.06");
        // 头部信息
        mxCamt05700106Creator.setSenderBic("PSBCCNBJ");
        mxCamt05700106Creator.setSenderNm("zs");
        mxCamt05700106Creator.setReceiverBic("PSBCCNBJ");
        mxCamt05700106Creator.setReceiverNm("lisi");
        mxCamt05700106Creator.setBizMsgIdr("1111111");
        mxCamt05700106Creator.setMsgDefIdr("sadasdd");
        mxCamt05700106Creator.setBizSvc("swift.cbprplus.02");
        mxCamt05700106Creator.setCreDt(new XmlDate());

        // 通知信息唯一标识
        mxCamt05700106Creator.setId("12345678");

        // 账户预期金额详情
        List<Itm> list = new ArrayList<>();
        Itm itm = new Itm();
        // 账户所有者的唯一标识
        itm.setId("345543");
        // 金额明细
        Amt amt = new Amt();
        amt.setValue(new BigDecimal("888.9"));
        amt.setCcy("USD");
        itm.setAmt(amt);
        // 端到端标识号
        itm.setEndToEndId("12345678");
        list.add(itm);
        mxCamt05700106Creator.setItm(list);

        MxResult result = (MxResult) CreatorManager.pack(mxCamt05700106Creator);
        if (!result.isSuccess()) {
            System.out.println(result.getErrorInf());
        } else {
            System.out.println(result.getMessage());
        }
    }
}
