Search in sources :

Example 1 with ServiceLevel3Choice

use of com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.ServiceLevel3Choice in project axelor-open-suite by axelor.

the class BankOrderFile00800101Service method createPmtInf.

/**
 * Builds the PaymentInformation part ({@code <PmtInf>} tag) of the file, and adds it into the
 * provided {@link PaymentInstructionInformation2} list
 *
 * @param paymentInstructionInformationList the list to add the {@link
 *     PaymentInstructionInformation2} objects into
 * @param creditor the creditor of the SEPA Direct Debit file
 * @throws DatatypeConfigurationException
 */
protected void createPmtInf(List<PaymentInstructionInformation2> paymentInstructionInformationList, PartyIdentification8 creditor) throws AxelorException, DatatypeConfigurationException {
    DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
    /*
     * Payment Information (mandatory)
     * Set of characteristics that apply to the credit side of the payment transactions included in the direct debit transaction initiation.
     */
    PaymentInstructionInformation2 paymentInstructionInformation2 = factory.createPaymentInstructionInformation2();
    paymentInstructionInformationList.add(paymentInstructionInformation2);
    /*
     * Payment Information Identification (optional)
     * Reference assigned by a sending party to unambiguously identify the payment information block within the message.
     */
    paymentInstructionInformation2.setPmtInfId(bankOrderSeq);
    /*
     * Payment Method (mandatory, always 'DD')
     * Specifies the means of payment that will be used to move the amount of money.
     */
    paymentInstructionInformation2.setPmtMtd(PaymentMethod2Code.DD);
    /*
     * Payment Type Information (mandatory)
     * Set of elements that further specifies the type of transaction.
     */
    PaymentTypeInformation2 paymentTypeInformation2 = factory.createPaymentTypeInformation2();
    paymentInstructionInformation2.setPmtTpInf(paymentTypeInformation2);
    /*
     * ServiceLevel (mandatory)
     * Agreement under which or rules under which the transaction should be processed.
     */
    ServiceLevel3Choice serviceLevel3Choice = factory.createServiceLevel3Choice();
    paymentTypeInformation2.setSvcLvl(serviceLevel3Choice);
    /*
     * Code (mandatory, always 'SEPA')
     * Identification of a pre-agreed level of service between the parties in a coded form.
     */
    serviceLevel3Choice.setCd(ServiceLevel2Code.SEPA);
    /*
     * Local Instrument (mandatory)
     * User community specific instrument.
     */
    LocalInstrument1Choice localInstrument1Choice = factory.createLocalInstrument1Choice();
    /*
     * Code (mandatory)
     *
     * Format : either 'CORE' or 'B2B'
     * Rule : The mixing of Core Direct Debits and Business-to-Business Direct Debits is not
     *        allowed in the same message.
     */
    switch(sepaType) {
        case SEPA_TYPE_CORE:
            localInstrument1Choice.setCd(SEPA_TYPE_CORE);
            break;
        case SEPA_TYPE_SBB:
            localInstrument1Choice.setCd(SEPA_TYPE_SBB);
            break;
        default:
            throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.BANK_ORDER_FILE_UNKNOWN_SEPA_TYPE));
    }
    paymentTypeInformation2.setLclInstrm(localInstrument1Choice);
    /*
     * Sequence Type (mandatory) // TO CHECK
     * Identifies the direct debit sequence, e.g. first, recurrent, final or one-off.
     *
     * Either one of the following values.
     * CODE  Name       Definition
     * ------------------------------------------------------------------------------------
     * FRST  First      First collection of a series of direct debit instructions.
     * RCUR  Recurrent  Direct debit instruction where the debtor's authorisation is used for
     *                  regular direct debit transactions initiated by the creditor.
     * FNAL  Final      Final collection of a series of direct debit instructions.
     * OOFF  One Off    Direct debit instruction where the debtor's authorisation is used to
     *                  initiate one single direct debit transaction.
     */
    paymentTypeInformation2.setSeqTp(SequenceType1Code.FRST);
    /*
     * Category Purpose (optional)
     * Specifies the purpose of the payment based on a set of pre-defined categories.
     *
     * iso20022.org -> 'PaymentCategoryPurpose1Code' for all codes available and definitions.
     * Rule : The usage and impact of these codes is to be agreed with your bank.
     */
    // paymentTypeInformation2.setCtgyPurp(PaymentCategoryPurpose1Code.CASH);
    /*
     * Requested Collection Date (mandatory)
     * Date at which the creditor requests the amount of money to be collected from the debtor.
     *
     * Format : YYYY-MM-DD
     * Usage  : The minimum delay between sending date and requested collection date is depending
     *          on the type of direct debit (B2B or CORE) and on the sequence type (FRST, OOFF,
     *          RCUR, FNAL).
     */
    paymentInstructionInformation2.setReqdColltnDt(datatypeFactory.newXMLGregorianCalendar(bankOrderDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
    /*
     * Creditor (mandatory)
     * Party to which an amount of money is due.
     */
    paymentInstructionInformation2.setCdtr(creditor);
    /*
     * Creditor Account (mandatory)
     * Unambiguous identification of the account of the creditor to which a credit entry will be posted as a result of the payment transaction.
     */
    AccountIdentification3Choice accountIdentification3Choice = factory.createAccountIdentification3Choice();
    accountIdentification3Choice.setIBAN(senderBankDetails.getIban());
    CashAccount7 cashAccount7 = factory.createCashAccount7();
    cashAccount7.setId(accountIdentification3Choice);
    paymentInstructionInformation2.setCdtrAcct(cashAccount7);
    /*
     * Creditor Agent (mandatory)
     * Financial institution servicing an account for the creditor.
     *
     * Note : The Bank Identifier Code (BIC) is composed of 8 or 11 characters, of which only the
     *        first 8 characters are significant.
     */
    FinancialInstitutionIdentification5Choice financialInstitutionIdentification5Choice = factory.createFinancialInstitutionIdentification5Choice();
    // BIC
    financialInstitutionIdentification5Choice.setBIC(senderBankDetails.getBank().getCode());
    BranchAndFinancialInstitutionIdentification3 branchAndFinancialInstitutionIdentification3 = factory.createBranchAndFinancialInstitutionIdentification3();
    branchAndFinancialInstitutionIdentification3.setFinInstnId(financialInstitutionIdentification5Choice);
    paymentInstructionInformation2.setCdtrAgt(branchAndFinancialInstitutionIdentification3);
    /*
     * Ultimate Creditor (optional)
     * Ultimate party to which an amount of money is due. Ultimate Creditor is only to be used if different from Creditor.
     */
    // paymentInstructionInformation2.setUltmtCdtr();
    /*
     * Charge Bearer (mandatory) // TO CHECK : option dans la vue BankOrder
     * Specifies which party/parties will bear the charges associated with the processing of the payment transaction.
     *
     * CODE  Name                   Description
     * ----------------------------------------------------------------------------------------
     * DEBT  BorneByDebtor          All transaction charges are to be borne by the debtor
     * CRED  BorneByCreditor        All transaction charges are to be borne by the creditor
     * SHAR  Shared                 In a direct debit context, means that transaction charges on
     *                              the sender side are to be borne by the creditor, transaction
     *                              charges on the receiver side are to be borne by the debtor.
     * SLEV  FollowingServiceLevel  Charges are to be applied following the rules agreed in the
     *                              service level and/or scheme.
     */
    paymentInstructionInformation2.setChrgBr(ChargeBearerType1Code.SLEV);
    /*
     * Direct Debit Transaction Information, <DrctDbtTxInf> tag
     * Does not need to set the List<DirectDebitTransactionInformation1> to the paymentInstructionInformation2 object (see doc)
     */
    createDrctDbtTxInf(paymentInstructionInformation2.getDrctDbtTxInf(), creditor);
}
Also used : AxelorException(com.axelor.exception.AxelorException) DatatypeFactory(javax.xml.datatype.DatatypeFactory) CashAccount7(com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.CashAccount7) BranchAndFinancialInstitutionIdentification3(com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.BranchAndFinancialInstitutionIdentification3) ServiceLevel3Choice(com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.ServiceLevel3Choice) AccountIdentification3Choice(com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.AccountIdentification3Choice) PaymentTypeInformation2(com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.PaymentTypeInformation2) PaymentInstructionInformation2(com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.PaymentInstructionInformation2) LocalInstrument1Choice(com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.LocalInstrument1Choice) FinancialInstitutionIdentification5Choice(com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.FinancialInstitutionIdentification5Choice)

Aggregations

AccountIdentification3Choice (com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.AccountIdentification3Choice)1 BranchAndFinancialInstitutionIdentification3 (com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.BranchAndFinancialInstitutionIdentification3)1 CashAccount7 (com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.CashAccount7)1 FinancialInstitutionIdentification5Choice (com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.FinancialInstitutionIdentification5Choice)1 LocalInstrument1Choice (com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.LocalInstrument1Choice)1 PaymentInstructionInformation2 (com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.PaymentInstructionInformation2)1 PaymentTypeInformation2 (com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.PaymentTypeInformation2)1 ServiceLevel3Choice (com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01.ServiceLevel3Choice)1 AxelorException (com.axelor.exception.AxelorException)1 DatatypeFactory (javax.xml.datatype.DatatypeFactory)1