Search in sources :

Example 1 with CreditTransferTransactionInformation10

use of iso.std.iso._20022.tech.xsd.pain_001_001.CreditTransferTransactionInformation10 in project estatio by estatio.

the class PaymentBatch_Test method aggregates_transfers_ok.

@Test
public void aggregates_transfers_ok() throws Exception {
    // given
    final IncomingInvoice invoice1 = newInvoice(new LocalDate(2017, 7, 7), seller1, seller1BankAccount, "EUR", "361754.46", "AF3T2017");
    final IncomingInvoice invoice2 = newInvoice(new LocalDate(2017, 6, 30), seller2, seller2BankAccount, "EUR", "15251.76", "DGD 11420 - 170522");
    final IncomingInvoice invoice3 = newInvoice(new LocalDate(2017, 6, 5), seller1, seller1BankAccount, "EUR", "-172805.79", "REDD2016VT");
    // sequence = 1
    paymentBatch.addLineIfRequired(invoice1);
    // sequence = 2
    paymentBatch.addLineIfRequired(invoice2);
    // sequence = 3
    paymentBatch.addLineIfRequired(invoice3);
    // then
    List<CreditTransfer> transfers = paymentBatch.getTransfers();
    assertThat(transfers).hasSize(2);
    final CreditTransfer transfer1 = transfers.get(0);
    final CreditTransfer transfer2 = transfers.get(1);
    assertThat(transfer1.getBatch()).isEqualTo(paymentBatch);
    assertThat(transfer1.getSellerName()).isEqualTo(seller1.getName());
    assertThat(transfer1.getAmount()).isEqualTo(invoice1.getGrossAmount().add(invoice3.getGrossAmount()));
    // the "1-3" suffix indicates payment lines with sequence 1 and 3 together
    assertThat(transfer1.getEndToEndId()).isEqualTo("97834-1-3");
    assertThat(transfer1.getRemittanceInformation()).isEqualTo("AF3T2017;REDD2016VT");
    assertThat(transfer1.getSellerBankAccount()).isEqualTo(seller1BankAccount);
    assertThat(transfer1.getSellerBic()).isEqualTo(seller1BankAccount.getBic());
    assertThat(transfer1.getSellerIban()).isEqualTo(seller1BankAccount.getIban());
    assertThat(transfer1.getSellerPostalAddressCountry()).isEqualTo("FR");
    assertThat(transfer2.getBatch()).isEqualTo(paymentBatch);
    assertThat(transfer2.getSellerName()).isEqualTo(seller2.getName());
    assertThat(transfer2.getAmount()).isEqualTo(invoice2.getGrossAmount());
    assertThat(transfer2.getEndToEndId()).isEqualTo("97834-2");
    assertThat(transfer2.getRemittanceInformation()).isEqualTo("DGD 11420 - 170522");
    assertThat(transfer2.getSellerBankAccount()).isEqualTo(seller2BankAccount);
    assertThat(transfer2.getSellerBic()).isEqualTo(seller2BankAccount.getBic());
    assertThat(transfer2.getSellerIban()).isEqualTo(seller2BankAccount.getIban());
    assertThat(transfer2.getSellerPostalAddressCountry()).isEqualTo("FR");
    // and also
    final CreditTransferTransactionInformation10 cdtTrf1 = transfer1.asXml();
    assertThat(cdtTrf1.getCdtr().getNm()).isEqualTo(transfer1.getSellerName());
    assertThat(cdtTrf1.getAmt().getInstdAmt().getValue()).isEqualTo(transfer1.getAmount());
    assertThat(cdtTrf1.getAmt().getInstdAmt().getCcy()).isEqualTo("EUR");
    assertThat(cdtTrf1.getPmtId().getEndToEndId()).isEqualTo(transfer1.getEndToEndId());
    assertThat(cdtTrf1.getRmtInf().getUstrds().get(0)).isEqualTo(transfer1.getRemittanceInformation());
    assertThat(cdtTrf1.getCdtrAgt().getFinInstnId().getBIC()).isEqualTo(transfer1.getSellerBic());
    assertThat(cdtTrf1.getCdtrAcct().getId().getIBAN()).isEqualTo(transfer1.getSellerIban());
    assertThat(cdtTrf1.getCdtr().getPstlAdr().getCtry()).isEqualTo(transfer1.getSellerPostalAddressCountry());
}
Also used : CreditTransferTransactionInformation10(iso.std.iso._20022.tech.xsd.pain_001_001.CreditTransferTransactionInformation10) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 2 with CreditTransferTransactionInformation10

use of iso.std.iso._20022.tech.xsd.pain_001_001.CreditTransferTransactionInformation10 in project estatio by estatio.

the class PaymentBatch method convertToXmlDocument.

// region > convertToXmlDocument
Document convertToXmlDocument() {
    final List<CreditTransfer> transfers = getTransfers();
    Document document = new Document();
    CustomerCreditTransferInitiationV03 cstmrCdtTrfInitn = new CustomerCreditTransferInitiationV03();
    document.setCstmrCdtTrfInitn(cstmrCdtTrfInitn);
    GroupHeader32 grpHdr = new GroupHeader32();
    cstmrCdtTrfInitn.setGrpHdr(grpHdr);
    grpHdr.setMsgId(msgId());
    grpHdr.setCreDtTm(newDateTime(getCreatedOn()));
    grpHdr.setNbOfTxs("" + transfers.size());
    grpHdr.setCtrlSum(ctrlSum());
    grpHdr.setInitgPty(newPartyIdentification32ForDebtorOwner());
    List<PaymentInstructionInformation3> pmtInfList = cstmrCdtTrfInitn.getPmtInves();
    PaymentInstructionInformation3 pmtInf = new PaymentInstructionInformation3();
    pmtInfList.add(pmtInf);
    pmtInf.setPmtInfId(getId());
    pmtInf.setPmtMtd(PaymentMethod3Code.TRF);
    pmtInf.setBtchBookg(false);
    pmtInf.setReqdExctnDt(newDateTime(getRequestedExecutionDate()));
    pmtInf.setDbtr(newPartyIdentification32ForDebtorOwner());
    pmtInf.setDbtrAcct(cashAccountFor(getDebtorBankAccount()));
    pmtInf.setDbtrAgt(agentFor(getDebtorBankAccount()));
    final List<CreditTransferTransactionInformation10> cdtTrfTxInfList = pmtInf.getCdtTrfTxInves();
    cdtTrfTxInfList.addAll(transfers.stream().map(CreditTransfer::asXml).collect(Collectors.toList()));
    return document;
}
Also used : GroupHeader32(iso.std.iso._20022.tech.xsd.pain_001_001.GroupHeader32) CreditTransferTransactionInformation10(iso.std.iso._20022.tech.xsd.pain_001_001.CreditTransferTransactionInformation10) PaymentInstructionInformation3(iso.std.iso._20022.tech.xsd.pain_001_001.PaymentInstructionInformation3) Document(iso.std.iso._20022.tech.xsd.pain_001_001.Document) CustomerCreditTransferInitiationV03(iso.std.iso._20022.tech.xsd.pain_001_001.CustomerCreditTransferInitiationV03)

Example 3 with CreditTransferTransactionInformation10

use of iso.std.iso._20022.tech.xsd.pain_001_001.CreditTransferTransactionInformation10 in project estatio by estatio.

the class CreditTransfer method asXml.

@Programmatic
public CreditTransferTransactionInformation10 asXml() {
    CreditTransferTransactionInformation10 cdtTrfTxInf = new CreditTransferTransactionInformation10();
    PaymentIdentification1 pmtId = new PaymentIdentification1();
    cdtTrfTxInf.setPmtId(pmtId);
    pmtId.setEndToEndId(getEndToEndId());
    AmountType3Choice amt = new AmountType3Choice();
    cdtTrfTxInf.setAmt(amt);
    ActiveOrHistoricCurrencyAndAmount instdAmt = new ActiveOrHistoricCurrencyAndAmount();
    amt.setInstdAmt(instdAmt);
    instdAmt.setCcy(getCurrency().getReference().trim());
    instdAmt.setValue(getAmount());
    BankAccount creditorBankAccount = this.getSellerBankAccount();
    cdtTrfTxInf.setCdtrAgt(PaymentBatch.agentFor(creditorBankAccount));
    cdtTrfTxInf.setCdtrAcct(PaymentBatch.cashAccountFor(creditorBankAccount));
    PartyIdentification32 cdtr = new PartyIdentification32();
    cdtTrfTxInf.setCdtr(cdtr);
    cdtr.setNm(getSeller().getName());
    PostalAddress6 pstlAdr = new PostalAddress6();
    cdtr.setPstlAdr(pstlAdr);
    pstlAdr.setCtry(PaymentBatch.ctryFor(getSeller()));
    RemittanceInformation5 rmtInf = new RemittanceInformation5();
    cdtTrfTxInf.setRmtInf(rmtInf);
    List<String> ustrdList = rmtInf.getUstrds();
    ustrdList.add(getRemittanceInformation());
    return cdtTrfTxInf;
}
Also used : AmountType3Choice(iso.std.iso._20022.tech.xsd.pain_001_001.AmountType3Choice) ActiveOrHistoricCurrencyAndAmount(iso.std.iso._20022.tech.xsd.pain_001_001.ActiveOrHistoricCurrencyAndAmount) RemittanceInformation5(iso.std.iso._20022.tech.xsd.pain_001_001.RemittanceInformation5) PaymentIdentification1(iso.std.iso._20022.tech.xsd.pain_001_001.PaymentIdentification1) CreditTransferTransactionInformation10(iso.std.iso._20022.tech.xsd.pain_001_001.CreditTransferTransactionInformation10) BankAccount(org.estatio.module.financial.dom.BankAccount) PostalAddress6(iso.std.iso._20022.tech.xsd.pain_001_001.PostalAddress6) PartyIdentification32(iso.std.iso._20022.tech.xsd.pain_001_001.PartyIdentification32) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

CreditTransferTransactionInformation10 (iso.std.iso._20022.tech.xsd.pain_001_001.CreditTransferTransactionInformation10)3 ActiveOrHistoricCurrencyAndAmount (iso.std.iso._20022.tech.xsd.pain_001_001.ActiveOrHistoricCurrencyAndAmount)1 AmountType3Choice (iso.std.iso._20022.tech.xsd.pain_001_001.AmountType3Choice)1 CustomerCreditTransferInitiationV03 (iso.std.iso._20022.tech.xsd.pain_001_001.CustomerCreditTransferInitiationV03)1 Document (iso.std.iso._20022.tech.xsd.pain_001_001.Document)1 GroupHeader32 (iso.std.iso._20022.tech.xsd.pain_001_001.GroupHeader32)1 PartyIdentification32 (iso.std.iso._20022.tech.xsd.pain_001_001.PartyIdentification32)1 PaymentIdentification1 (iso.std.iso._20022.tech.xsd.pain_001_001.PaymentIdentification1)1 PaymentInstructionInformation3 (iso.std.iso._20022.tech.xsd.pain_001_001.PaymentInstructionInformation3)1 PostalAddress6 (iso.std.iso._20022.tech.xsd.pain_001_001.PostalAddress6)1 RemittanceInformation5 (iso.std.iso._20022.tech.xsd.pain_001_001.RemittanceInformation5)1 Programmatic (org.apache.isis.applib.annotation.Programmatic)1 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)1 BankAccount (org.estatio.module.financial.dom.BankAccount)1 LocalDate (org.joda.time.LocalDate)1 Test (org.junit.Test)1