Search in sources :

Example 16 with BankOrderLine

use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.

the class BankOrderFileAFB160Service method generateFile.

/**
 * Method to create an XML file for SEPA transfer pain.001.001.02
 *
 * @throws AxelorException
 * @throws DatatypeConfigurationException
 * @throws JAXBException
 * @throws IOException
 */
@Override
public File generateFile() throws JAXBException, IOException, AxelorException, DatatypeConfigurationException {
    List<String> records = Lists.newArrayList();
    records.add(this.createSenderRecord());
    for (BankOrderLine bankOrderLine : bankOrderLineList) {
        records.add(this.createDetailRecord(bankOrderLine));
        if (this.useOptionalFurtherInformationRecord(bankOrderLine)) {
            records.add(this.createOptionalFurtherInformationRecord(bankOrderLine));
        }
    }
    records.add(this.createTotalRecord());
    fileToCreate = records;
    return super.generateFile();
}
Also used : BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine)

Example 17 with BankOrderLine

use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.

the class BankOrderFileAFB320XCTService method generateFile.

/**
 * Method to create an XML file for SEPA transfer pain.001.001.02
 *
 * @throws AxelorException
 * @throws DatatypeConfigurationException
 * @throws JAXBException
 * @throws IOException
 */
@Override
public File generateFile() throws JAXBException, IOException, AxelorException, DatatypeConfigurationException {
    List<String> records = Lists.newArrayList();
    records.add(this.createSenderRecord());
    for (BankOrderLine bankOrderLine : bankOrderLineList) {
        records.add(this.createDetailRecord(bankOrderLine));
        if (bankOrderLine.getPaymentModeSelect() == BankOrderLineRepository.PAYMENT_MODE_TRANSFER_OR_OTHER) {
            records.add(this.createDependentReceiverBankRecord(bankOrderLine));
        }
        if (this.useOptionnalFurtherInformationRecord(bankOrderLine)) {
            records.add(this.createOptionnalFurtherInformationRecord(bankOrderLine));
        }
    }
    records.add(this.createTotalRecord());
    fileToCreate = records;
    return super.generateFile();
}
Also used : BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine)

Example 18 with BankOrderLine

use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.

the class BankOrderCreateService method createBankOrder.

/**
 * Method to create a bank order for an invoice Payment
 *
 * @param invoicePayment An invoice payment
 * @throws AxelorException
 */
public BankOrder createBankOrder(InvoicePayment invoicePayment) throws AxelorException {
    Invoice invoice = invoicePayment.getInvoice();
    Company company = invoice.getCompany();
    PaymentMode paymentMode = invoicePayment.getPaymentMode();
    Partner partner = invoice.getPartner();
    BigDecimal amount = invoicePayment.getAmount();
    Currency currency = invoicePayment.getCurrency();
    LocalDate paymentDate = invoicePayment.getPaymentDate();
    BankDetails companyBankDetails = invoicePayment.getCompanyBankDetails() != null ? invoicePayment.getCompanyBankDetails() : this.getSenderBankDetails(invoice);
    String reference = InvoiceToolService.isPurchase(invoice) ? invoice.getSupplierInvoiceNb() : invoice.getInvoiceId();
    BankOrder bankOrder = this.createBankOrder(paymentMode, this.getBankOrderPartnerType(invoice), paymentDate, company, companyBankDetails, currency, reference, null, BankOrderRepository.TECHNICAL_ORIGIN_AUTOMATIC);
    BankDetails receiverBankDetails = invoiceService.getBankDetails(invoice);
    BankOrderLine bankOrderLine = bankOrderLineService.createBankOrderLine(paymentMode.getBankOrderFileFormat(), null, partner, receiverBankDetails, amount, currency, paymentDate, reference, null, invoice);
    bankOrder.addBankOrderLineListItem(bankOrderLine);
    bankOrder = bankOrderRepo.save(bankOrder);
    return bankOrder;
}
Also used : Company(com.axelor.apps.base.db.Company) Invoice(com.axelor.apps.account.db.Invoice) BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) BankDetails(com.axelor.apps.base.db.BankDetails) Currency(com.axelor.apps.base.db.Currency) BankOrder(com.axelor.apps.bankpayment.db.BankOrder) Partner(com.axelor.apps.base.db.Partner) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Example 19 with BankOrderLine

use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.

the class BankOrderCreateService method createBankOrder.

/**
 * Créer un ordre bancaire avec tous les paramètres
 *
 * @param
 * @return
 * @throws AxelorException
 */
public BankOrder createBankOrder(PaymentMode paymentMode, Integer partnerType, LocalDate bankOrderDate, Company senderCompany, BankDetails senderBankDetails, Currency currency, String senderReference, String senderLabel, int technicalOriginSelect) throws AxelorException {
    BankOrderFileFormat bankOrderFileFormat = paymentMode.getBankOrderFileFormat();
    BankOrder bankOrder = new BankOrder();
    bankOrder.setOrderTypeSelect(paymentMode.getOrderTypeSelect());
    bankOrder.setPaymentMode(paymentMode);
    bankOrder.setPartnerTypeSelect(partnerType);
    if (!bankOrderFileFormat.getIsMultiDate()) {
        bankOrder.setBankOrderDate(bankOrderDate);
    }
    bankOrder.setStatusSelect(BankOrderRepository.STATUS_DRAFT);
    bankOrder.setRejectStatusSelect(BankOrderRepository.REJECT_STATUS_NOT_REJECTED);
    bankOrder.setSenderCompany(senderCompany);
    bankOrder.setSenderBankDetails(senderBankDetails);
    EbicsUser signatoryEbicsUser = bankOrderService.getDefaultEbicsUserFromBankDetails(senderBankDetails);
    User signatoryUser = null;
    if (signatoryEbicsUser != null) {
        signatoryUser = signatoryEbicsUser.getAssociatedUser();
        bankOrder.setSignatoryEbicsUser(signatoryEbicsUser);
    }
    if (signatoryUser != null) {
        bankOrder.setSignatoryUser(signatoryUser);
    }
    if (!bankOrderFileFormat.getIsMultiCurrency()) {
        bankOrder.setBankOrderCurrency(currency);
    }
    bankOrder.setCompanyCurrency(senderCompany.getCurrency());
    bankOrder.setSenderReference(senderReference);
    bankOrder.setSenderLabel(senderLabel);
    bankOrder.setBankOrderLineList(new ArrayList<BankOrderLine>());
    bankOrder.setBankOrderFileFormat(bankOrderFileFormat);
    bankOrder.setTechnicalOriginSelect(technicalOriginSelect);
    return bankOrder;
}
Also used : EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) User(com.axelor.auth.db.User) BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) BankOrderFileFormat(com.axelor.apps.bankpayment.db.BankOrderFileFormat) BankOrder(com.axelor.apps.bankpayment.db.BankOrder)

Example 20 with BankOrderLine

use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.

the class BankOrderLineService method createBankOrderLine.

/**
 * Generic method to create a BankOrderLine
 *
 * @param receiverCompany
 * @param partner
 * @param bankDetails
 * @param amount
 * @param receiverReference
 * @param receiverLabel
 * @return
 * @throws AxelorException
 */
public BankOrderLine createBankOrderLine(BankOrderFileFormat bankOrderFileFormat, Company receiverCompany, Partner partner, BankDetails bankDetails, BigDecimal amount, Currency currency, LocalDate bankOrderDate, String receiverReference, String receiverLabel, Model origin) throws AxelorException {
    BankOrderLine bankOrderLine = new BankOrderLine();
    bankOrderLine.setReceiverCompany(receiverCompany);
    bankOrderLine.setPartner(partner);
    bankOrderLine.setReceiverBankDetails(bankDetails);
    bankOrderLine.setBankOrderAmount(amount);
    if (bankOrderFileFormat.getIsMultiCurrency()) {
        bankOrderLine.setBankOrderCurrency(currency);
    }
    if (bankOrderFileFormat.getIsMultiDate()) {
        bankOrderLine.setBankOrderDate(bankOrderDate);
    }
    bankOrderLine.setReceiverReference(receiverReference);
    bankOrderLine.setReceiverLabel(receiverLabel);
    if (origin != null) {
        bankOrderLine.addBankOrderLineOriginListItem(bankOrderLineOriginService.createBankOrderLineOrigin(origin));
    }
    if (bankOrderFileFormat.getOrderFileFormatSelect().equals(BankOrderFileFormatRepository.FILE_FORMAT_PAIN_XXX_CFONB320_XCT)) {
        bankOrderLine.setBankOrderEconomicReason(bankOrderFileFormat.getBankOrderEconomicReason());
        bankOrderLine.setReceiverCountry(bankOrderFileFormat.getReceiverCountry());
        if (bankDetails != null) {
            Bank bank = bankDetails.getBank();
            if (bank != null && bank.getCountry() != null) {
                bankOrderLine.setReceiverCountry(bank.getCountry());
            }
        } else {
            throw new AxelorException(bankOrderLine, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.BANK_ORDER_LINE_BANK_DETAILS_MISSING));
        }
        bankOrderLine.setPaymentModeSelect(bankOrderFileFormat.getPaymentModeSelect());
        bankOrderLine.setFeesImputationModeSelect(bankOrderFileFormat.getFeesImputationModeSelect());
        bankOrderLine.setReceiverAddressStr(getReceiverAddress(partner));
    }
    return bankOrderLine;
}
Also used : AxelorException(com.axelor.exception.AxelorException) BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) Bank(com.axelor.apps.base.db.Bank)

Aggregations

BankOrderLine (com.axelor.apps.bankpayment.db.BankOrderLine)23 BankOrder (com.axelor.apps.bankpayment.db.BankOrder)8 BankDetails (com.axelor.apps.base.db.BankDetails)7 AxelorException (com.axelor.exception.AxelorException)6 BigDecimal (java.math.BigDecimal)5 LocalDate (java.time.LocalDate)4 DatatypeFactory (javax.xml.datatype.DatatypeFactory)4 PaymentMode (com.axelor.apps.account.db.PaymentMode)3 Transactional (com.google.inject.persist.Transactional)3 Umr (com.axelor.apps.account.db.Umr)2 BankOrderLineService (com.axelor.apps.bankpayment.service.bankorder.BankOrderLineService)2 Company (com.axelor.apps.base.db.Company)2 Currency (com.axelor.apps.base.db.Currency)2 Partner (com.axelor.apps.base.db.Partner)2 AccountingBatch (com.axelor.apps.account.db.AccountingBatch)1 Invoice (com.axelor.apps.account.db.Invoice)1 InvoicePayment (com.axelor.apps.account.db.InvoicePayment)1 PaymentSchedule (com.axelor.apps.account.db.PaymentSchedule)1 PaymentScheduleLine (com.axelor.apps.account.db.PaymentScheduleLine)1 Reimbursement (com.axelor.apps.account.db.Reimbursement)1