use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.CreditTransferTransactionInformation10 in project axelor-open-suite by axelor.
the class BankOrderFile00100103Service method generateFile.
/**
* Method to create an XML file for SEPA transfer pain.001.001.03
*
* @throws AxelorException
* @throws DatatypeConfigurationException
* @throws JAXBException
* @throws IOException
*/
@Override
public File generateFile() throws JAXBException, IOException, AxelorException, DatatypeConfigurationException {
DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
ObjectFactory factory = new ObjectFactory();
ServiceLevel8Choice svcLvl = factory.createServiceLevel8Choice();
svcLvl.setCd("SEPA");
PaymentTypeInformation19 pmtTpInf = factory.createPaymentTypeInformation19();
pmtTpInf.setSvcLvl(svcLvl);
// Payer
PartyIdentification32 dbtr = factory.createPartyIdentification32();
dbtr.setNm(senderBankDetails.getOwnerName());
// IBAN
AccountIdentification4Choice iban = factory.createAccountIdentification4Choice();
iban.setIBAN(senderBankDetails.getIban());
CashAccount16 dbtrAcct = factory.createCashAccount16();
dbtrAcct.setId(iban);
// BIC
FinancialInstitutionIdentification7 finInstnId = factory.createFinancialInstitutionIdentification7();
fillBic(finInstnId, senderBankDetails.getBank());
BranchAndFinancialInstitutionIdentification4 dbtrAgt = factory.createBranchAndFinancialInstitutionIdentification4();
dbtrAgt.setFinInstnId(finInstnId);
PaymentInstructionInformation3 pmtInf = factory.createPaymentInstructionInformation3();
pmtInf.setPmtInfId(bankOrderSeq);
pmtInf.setPmtMtd(PaymentMethod3Code.TRF);
pmtInf.setPmtTpInf(pmtTpInf);
/**
* RequestedExecutionDate Definition : Date at which the initiating party asks the Debtor's Bank
* to process the payment. This is the date on which the debtor's account(s) is (are) to be
* debited. XML Tag : <ReqdExctnDt> Occurrences : [1..1] Format : YYYY-MM-DD Rules : date is
* limited to maximum one year in the future.
*/
pmtInf.setReqdExctnDt(datatypeFactory.newXMLGregorianCalendar(bankOrderDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
pmtInf.setDbtr(dbtr);
pmtInf.setDbtrAcct(dbtrAcct);
pmtInf.setDbtrAgt(dbtrAgt);
CreditTransferTransactionInformation10 cdtTrfTxInf = null;
PaymentIdentification1 pmtId = null;
AmountType3Choice amt = null;
ActiveOrHistoricCurrencyAndAmount instdAmt = null;
PartyIdentification32 cbtr = null;
CashAccount16 cbtrAcct = null;
BranchAndFinancialInstitutionIdentification4 cbtrAgt = null;
RemittanceInformation5 rmtInf = null;
for (BankOrderLine bankOrderLine : bankOrderLineList) {
BankDetails receiverBankDetails = bankOrderLine.getReceiverBankDetails();
// Reference
pmtId = factory.createPaymentIdentification1();
// pmtId.setInstrId(bankOrderLine.getSequence());
pmtId.setEndToEndId(bankOrderLine.getSequence());
// Amount
instdAmt = factory.createActiveOrHistoricCurrencyAndAmount();
instdAmt.setCcy(bankOrderCurrency.getCode());
instdAmt.setValue(bankOrderLine.getBankOrderAmount());
amt = factory.createAmountType3Choice();
amt.setInstdAmt(instdAmt);
// Receiver
cbtr = factory.createPartyIdentification32();
cbtr.setNm(receiverBankDetails.getOwnerName());
// IBAN
iban = factory.createAccountIdentification4Choice();
iban.setIBAN(receiverBankDetails.getIban());
cbtrAcct = factory.createCashAccount16();
cbtrAcct.setId(iban);
// BIC
finInstnId = factory.createFinancialInstitutionIdentification7();
fillBic(finInstnId, receiverBankDetails.getBank());
cbtrAgt = factory.createBranchAndFinancialInstitutionIdentification4();
cbtrAgt.setFinInstnId(finInstnId);
rmtInf = factory.createRemittanceInformation5();
String ustrd = "";
if (!Strings.isNullOrEmpty(bankOrderLine.getReceiverReference())) {
ustrd += bankOrderLine.getReceiverReference();
}
if (!Strings.isNullOrEmpty(bankOrderLine.getReceiverLabel())) {
if (!Strings.isNullOrEmpty(ustrd)) {
ustrd += " - ";
}
ustrd += bankOrderLine.getReceiverLabel();
}
if (!Strings.isNullOrEmpty(ustrd)) {
rmtInf.getUstrd().add(ustrd);
}
// StructuredRemittanceInformation7 strd = factory.createStructuredRemittanceInformation7();
//
// CreditorReferenceInformation2 cdtrRefInf = factory.createCreditorReferenceInformation2();
// cdtrRefInf.setRef(bankOrderLine.getReceiverReference());
//
// strd.setCdtrRefInf(cdtrRefInf);
//
// rmtInf.getStrd().add(strd);
// Transaction
cdtTrfTxInf = factory.createCreditTransferTransactionInformation10();
cdtTrfTxInf.setPmtId(pmtId);
cdtTrfTxInf.setAmt(amt);
cdtTrfTxInf.setCdtr(cbtr);
cdtTrfTxInf.setCdtrAcct(cbtrAcct);
cdtTrfTxInf.setCdtrAgt(cbtrAgt);
cdtTrfTxInf.setRmtInf(rmtInf);
pmtInf.getCdtTrfTxInf().add(cdtTrfTxInf);
}
// Header
GroupHeader32 grpHdr = factory.createGroupHeader32();
/**
* Référence du message qui n'est pas utilisée comme référence fonctionnelle.
*/
grpHdr.setMsgId(bankOrderSeq);
/**
* CreationDateTime Definition : Date and Time at which a (group of) payment instruction(s) was
* created by the instructing party. XML Tag : <CreDtTm> Occurrences : [1..1] Format :
* YYYY-MM-DDThh:mm:ss
*/
grpHdr.setCreDtTm(datatypeFactory.newXMLGregorianCalendar(generationDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))));
grpHdr.setNbOfTxs(Integer.toString(nbOfLines));
grpHdr.setCtrlSum(arithmeticTotal);
grpHdr.setInitgPty(dbtr);
// Parent
CustomerCreditTransferInitiationV03 customerCreditTransferInitiationV03 = factory.createCustomerCreditTransferInitiationV03();
customerCreditTransferInitiationV03.setGrpHdr(grpHdr);
customerCreditTransferInitiationV03.getPmtInf().add(pmtInf);
// Document
Document xml = factory.createDocument();
xml.setCstmrCdtTrfInitn(customerCreditTransferInitiationV03);
fileToCreate = factory.createDocument(xml);
return super.generateFile();
}
use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.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(truncateFieldToMaxLength(getEndToEndId(), 35));
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;
}
use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.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(truncateFieldToMaxLength(msgId(), 35));
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;
}
use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.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", "/FRA");
invoice1.setCommunicationNumber("+++111/222/333+++");
final IncomingInvoice invoice2 = newInvoice(new LocalDate(2017, 6, 30), seller2, seller2BankAccount, "EUR", "15251.76", "DGD 11420 - 170522", "/FRA");
final IncomingInvoice invoice3 = newInvoice(new LocalDate(2017, 6, 5), seller1, seller1BankAccount, "EUR", "-172805.79", "REDD2016VT", "/FRA");
// 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 (+++111/222/333+++);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());
}
Aggregations