package com.brilliance.isc.convert.mt7xx;

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.mt7xx.MT765Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.MT787Creator;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import com.brilliance.isc.swift.objmtconvert.util.Constans;
import org.junit.Test;

import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;

public class MT765Test {
    @Test
    public void mt765_Test()throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {

        DcDateCurAmtTagXXX demandAmount32B=new DcDateCurAmtTagXXX("32");
        demandAmount32B.setDate("220313");
        demandAmount32B.setCurrency("USD");
        demandAmount32B.setAmount(new BigDecimal("1000.00"));


        ActnoBicAdrTagXXX issuer52a = new ActnoBicAdrTagXXX("52");
        //issuer52a.setInfo("A");
        issuer52a.setAddress("WHYHCNHBXXX");
        //issuer52a.setBic ("GCYXXXXXX52");
        //issuer52a.setAcctno("01111001759234567890");
        issuer52a.setPartyIdentifier("1234-5678");
        //issuer52a.setLocation("WHYHCNHBXXX");

        ActnoBicAdrTagXXX intermediary56a=new ActnoBicAdrTagXXX("56");
        //intermediary56a.setInfo("A");
        //intermediary56a.setAddress("WHYHCNHBXXX");
        //intermediary56a.setCode("THISIS41A");
        //intermediary56a.setBic("GCYXXXXXX56");
        //intermediary56a.setAcctno("01111001759234567890");
        intermediary56a.setPartyIdentifier("1234-5678");
        intermediary56a.setLocation("WHYHCNHBXXX");

        ActnoBicAdrTagXXX accountWithInstitution57a=new ActnoBicAdrTagXXX("57");
        //accountWithInstitution57a.setInfo("A");
        accountWithInstitution57a.setAddress("WHYHCNHBXXX");
        //accountWithInstitution57a.setCode("THISIS41A");
        //accountWithInstitution57a.setBic("GCYXXXXXX57");
        //accountWithInstitution57a.setAcctno("01111001759234567890");
        accountWithInstitution57a.setPartyIdentifier("1234-5678");
        //accountWithInstitution57a.setLocation("WHYHCNHBXXX");

        ActnoBicAdrTagXXX beneficiary59a=new ActnoBicAdrTagXXX("59","765");
        //beneficiary59a.setInfo("A");
        //beneficiary59a.setAddress("WHYHCNHBXXX");
        //beneficiary59a.setAddress("WHYHCNHBXXX");
        //beneficiary59a.setCode("THISIS411");
        beneficiary59a.setBic("GCYXXXXXX57");
        beneficiary59a.setAcctno("6226TEST0001");
        //beneficiary59a.setPartyIdentifier("1234-5678");
        //beneficiary59a.setLocation("WHYHCNHBXXX");

        //构造参数传入MT报文类型
        MT765Creator mt765Creator = new MT765Creator("765");//报文类型
        mt765Creator.setTransactionReferenceNumber("EH Eigert Gmb");//20 16x
        mt765Creator.setRelatedReference("EH Eigert");//12 3!n
        mt765Creator.setBeneficiaryReferenceNumber("Eigert");
        mt765Creator.setIssuer52a(issuer52a);
        mt765Creator.setBeneficiary59a(beneficiary59a);
        mt765Creator.setDateOfDemand("220327");
        mt765Creator.setDemandType("PAYM");
        mt765Creator.setDemandAmount32B(demandAmount32B);
        mt765Creator.setAdditionalAmountInformation("EMAL/Email transfer");
        mt765Creator.setDemandStatement("INCP"+ Constans.CRLF+"Complete demand, no other documentation to");
        mt765Creator.setPresentationCompletionDetails("EMAL/Email transfer");
        //mt765Creator.setRequestedNewDateofExpiry("220315");
        mt765Creator.setIntermediary56a(intermediary56a);
        mt765Creator.setAccountWithInstitution57a(accountWithInstitution57a);
        mt765Creator.setSendertoReceiverInformation("EH Eigert GmbH\n" + "Hauptstrasse 987\n" + "DE/12345 Mannheim");
        mt765Creator.setFileIdentification("EMAL/Email transfer");
//
        MtResult mtResult = MtCreatorManager.packMT(mt765Creator);
//        MtCreatorManager.packMT(mt769Creator);
    }

    @Test
    public void mt765_2_Test()throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {

        DcDateCurAmtTagXXX demandAmount32B=new DcDateCurAmtTagXXX("32");
        demandAmount32B.setDate("220313");
        demandAmount32B.setCurrency("USD");
        demandAmount32B.setAmount(new BigDecimal("1000.00"));


        ActnoBicAdrTagXXX issuer52a = new ActnoBicAdrTagXXX("52");
        //issuer52a.setInfo("A");
        issuer52a.setAddress("WHYHCNHBXXX");
        //issuer52a.setBic ("GCYXXXXXX52");
        //issuer52a.setAcctno("01111001759234567890");
        issuer52a.setPartyIdentifier("1234-5678");
        //issuer52a.setLocation("WHYHCNHBXXX");

        ActnoBicAdrTagXXX intermediary56a=new ActnoBicAdrTagXXX("56");
        //intermediary56a.setInfo("A");
        //intermediary56a.setAddress("WHYHCNHBXXX");
        //intermediary56a.setCode("THISIS41A");
        //intermediary56a.setBic("GCYXXXXXX56");
        //intermediary56a.setAcctno("01111001759234567890");
        intermediary56a.setPartyIdentifier("1234-5678");
        intermediary56a.setLocation("WHYHCNHBXXX");

        ActnoBicAdrTagXXX accountWithInstitution57a=new ActnoBicAdrTagXXX("57");
        //accountWithInstitution57a.setInfo("A");
        accountWithInstitution57a.setAddress("WHYHCNHBXXX");
        //accountWithInstitution57a.setCode("THISIS41A");
        //accountWithInstitution57a.setBic("GCYXXXXXX57");
        //accountWithInstitution57a.setAcctno("01111001759234567890");
        accountWithInstitution57a.setPartyIdentifier("1234-5678");
        //accountWithInstitution57a.setLocation("WHYHCNHBXXX");

        ActnoBicAdrTagXXX beneficiary59a=new ActnoBicAdrTagXXX("59","765");
        //beneficiary59a.setInfo("A");
        //beneficiary59a.setAddress("WHYHCNHBXXX");
        //beneficiary59a.setAddress("WHYHCNHBXXX");
        //beneficiary59a.setCode("THISIS411");
        beneficiary59a.setBic("GCYXXXXXX57");
        beneficiary59a.setAcctno("6226TEST0001");
        //beneficiary59a.setPartyIdentifier("1234-5678");
        //beneficiary59a.setLocation("WHYHCNHBXXX");

        //构造参数传入MT报文类型
        MT765Creator mt765Creator = new MT765Creator("765");//报文类型
        mt765Creator.setTransactionReferenceNumber("EH Eigert Gmb");//20 16x
        mt765Creator.setRelatedReference("EH Eigert");//12 3!n
        mt765Creator.setBeneficiaryReferenceNumber("Eigert");
        mt765Creator.setIssuer52a(issuer52a);
        mt765Creator.setBeneficiary59a(beneficiary59a);
        mt765Creator.setDateOfDemand("220327");
        mt765Creator.setDemandType("PAYM");
        mt765Creator.setDemandAmount32B(demandAmount32B);
        mt765Creator.setAdditionalAmountInformation("EMAL/Email transfer");
        mt765Creator.setDemandStatement("INCP"+ Constans.CRLF+"Complete demand, no other documentation to");
        //mt765Creator.setPresentationCompletionDetails("EMAL/Email transfer");
        mt765Creator.setRequestedNewDateofExpiry("220315");
        mt765Creator.setIntermediary56a(intermediary56a);
        mt765Creator.setAccountWithInstitution57a(accountWithInstitution57a);
        mt765Creator.setSendertoReceiverInformation("EH Eigert GmbH\n" + "Hauptstrasse 987\n" + "DE/12345 Mannheim");
        mt765Creator.setFileIdentification("EMAL/Email transfer");
//
        MtResult mtResult = MtCreatorManager.packMT(mt765Creator);
//        MtCreatorManager.packMT(mt769Creator);
    }
}
