Search in sources :

Example 6 with BankOrder

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

the class BatchCreditTransferPartnerReimbursementBankPayment method createBankOrder.

/**
 * Create a bank order for the specified list of reimbursements.
 *
 * @param accountingBatch
 * @param reimbursementList
 * @return
 * @throws AxelorException
 * @throws DatatypeConfigurationException
 * @throws IOException
 * @throws JAXBException
 */
@Transactional(rollbackOn = { Exception.class })
protected BankOrder createBankOrder(AccountingBatch accountingBatch, List<Reimbursement> reimbursementList) throws AxelorException, JAXBException, IOException, DatatypeConfigurationException {
    LocalDate bankOrderDate = accountingBatch.getDueDate() != null ? accountingBatch.getDueDate() : appBaseService.getTodayDate(accountingBatch.getCompany());
    BankOrder bankOrder = bankOrderCreateService.createBankOrder(accountingBatch.getPaymentMode(), BankOrderRepository.PARTNER_TYPE_CUSTOMER, bankOrderDate, accountingBatch.getCompany(), accountingBatch.getBankDetails(), accountingBatch.getCompany().getCurrency(), null, null, BankOrderRepository.TECHNICAL_ORIGIN_AUTOMATIC);
    for (Reimbursement reimbursement : reimbursementList) {
        BankOrderLine bankOrderLine = bankOrderLineService.createBankOrderLine(accountingBatch.getPaymentMode().getBankOrderFileFormat(), null, reimbursement.getPartner(), reimbursement.getBankDetails(), reimbursement.getAmountToReimburse(), accountingBatch.getCompany().getCurrency(), bankOrderDate, reimbursement.getRef(), reimbursement.getDescription(), reimbursement);
        bankOrder.addBankOrderLineListItem(bankOrderLine);
        Beans.get(ReimbursementExportService.class).reimburse(reimbursement, accountingBatch.getCompany());
    }
    bankOrder = bankOrderRepo.save(bankOrder);
    bankOrderService.confirm(bankOrder);
    return bankOrder;
}
Also used : BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) ReimbursementExportService(com.axelor.apps.account.service.ReimbursementExportService) Reimbursement(com.axelor.apps.account.db.Reimbursement) BatchCreditTransferPartnerReimbursement(com.axelor.apps.account.service.batch.BatchCreditTransferPartnerReimbursement) BankOrder(com.axelor.apps.bankpayment.db.BankOrder) LocalDate(java.time.LocalDate) Transactional(com.google.inject.persist.Transactional)

Example 7 with BankOrder

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

the class BatchDirectDebitCustomerInvoice method process.

@Override
protected void process() {
    AccountingBatch accountingBatch = batch.getAccountingBatch();
    List<String> filterList = new ArrayList<>();
    List<Pair<String, Object>> bindingList = new ArrayList<>();
    filterList.add("self.operationTypeSelect = :operationTypeSelect");
    bindingList.add(Pair.of("operationTypeSelect", (Object) InvoiceRepository.OPERATION_TYPE_CLIENT_SALE));
    filterList.add("self.statusSelect = :statusSelect");
    bindingList.add(Pair.of("statusSelect", (Object) InvoiceRepository.STATUS_VENTILATED));
    filterList.add("self.amountRemaining > 0");
    filterList.add("self.hasPendingPayments = FALSE");
    LocalDate dueDate = accountingBatch.getDueDate() != null ? accountingBatch.getDueDate() : Beans.get(AppBaseService.class).getTodayDate(accountingBatch.getCompany());
    filterList.add("self.dueDate <= :dueDate");
    bindingList.add(Pair.of("dueDate", (Object) dueDate));
    if (accountingBatch.getCompany() != null) {
        filterList.add("self.company = :company");
        bindingList.add(Pair.of("company", (Object) accountingBatch.getCompany()));
    }
    filterList.add("self.partner.id NOT IN (SELECT DISTINCT partner.id FROM Partner partner LEFT JOIN partner.blockingList blocking WHERE blocking.blockingSelect = :blockingSelect AND blocking.blockingToDate >= :blockingToDate)");
    bindingList.add(Pair.of("blockingSelect", BlockingRepository.DEBIT_BLOCKING));
    bindingList.add(Pair.of("blockingToDate", Beans.get(AppBaseService.class).getTodayDate(accountingBatch.getCompany())));
    if (accountingBatch.getBankDetails() != null) {
        Set<BankDetails> bankDetailsSet = Sets.newHashSet(accountingBatch.getBankDetails());
        if (accountingBatch.getIncludeOtherBankAccounts() && appBaseService.getAppBase().getManageMultiBanks()) {
            bankDetailsSet.addAll(accountingBatch.getCompany().getBankDetailsList());
        }
        filterList.add("self.companyBankDetails IN (:bankDetailsSet)");
        bindingList.add(Pair.of("bankDetailsSet", (Object) bankDetailsSet));
    }
    if (accountingBatch.getPaymentMode() != null) {
        filterList.add("self.paymentMode = :paymentMode");
        bindingList.add(Pair.of("paymentMode", (Object) accountingBatch.getPaymentMode()));
    }
    List<InvoicePayment> invoicePaymentList = processQuery(filterList, bindingList);
    if (!invoicePaymentList.isEmpty()) {
        try {
            final BankOrder bankOrder = Beans.get(BankOrderMergeService.class).mergeFromInvoicePayments(invoicePaymentList);
            findBatch().setBankOrder(bankOrder);
        } catch (AxelorException e) {
            TraceBackService.trace(e, ExceptionOriginRepository.DIRECT_DEBIT, batch.getId());
            LOG.error(e.getMessage());
        }
    }
}
Also used : InvoicePayment(com.axelor.apps.account.db.InvoicePayment) AxelorException(com.axelor.exception.AxelorException) BankDetails(com.axelor.apps.base.db.BankDetails) ArrayList(java.util.ArrayList) LocalDate(java.time.LocalDate) AppBaseService(com.axelor.apps.base.service.app.AppBaseService) BankOrderMergeService(com.axelor.apps.bankpayment.service.bankorder.BankOrderMergeService) AccountingBatch(com.axelor.apps.account.db.AccountingBatch) BankOrder(com.axelor.apps.bankpayment.db.BankOrder) Pair(org.apache.commons.lang3.tuple.Pair)

Example 8 with BankOrder

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

the class BankOrderController method realize.

public void realize(ActionRequest request, ActionResponse response) {
    try {
        BankOrder bankOrder = request.getContext().asType(BankOrder.class);
        bankOrder = Beans.get(BankOrderRepository.class).find(bankOrder.getId());
        if (bankOrder != null) {
            Beans.get(BankOrderService.class).realize(bankOrder);
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
    response.setReload(true);
}
Also used : BankOrderService(com.axelor.apps.bankpayment.service.bankorder.BankOrderService) BankOrder(com.axelor.apps.bankpayment.db.BankOrder) AxelorException(com.axelor.exception.AxelorException)

Example 9 with BankOrder

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

the class BankOrderController method merge.

@SuppressWarnings("unchecked")
public void merge(ActionRequest request, ActionResponse response) {
    try {
        List<Integer> listSelectedBankOrder = (List<Integer>) request.getContext().get("_ids");
        BankOrderRepository bankOrderRepository = Beans.get(BankOrderRepository.class);
        List<BankOrder> bankOrderList = Lists.newArrayList();
        if (listSelectedBankOrder != null) {
            for (Integer bankOrderId : listSelectedBankOrder) {
                BankOrder bankOrder = bankOrderRepository.find(bankOrderId.longValue());
                if (bankOrder != null) {
                    bankOrderList.add(bankOrder);
                }
            }
            BankOrder bankOrder = Beans.get(BankOrderMergeService.class).mergeBankOrders(bankOrderList);
            response.setView(ActionView.define(I18n.get("Bank Order")).model(BankOrder.class.getName()).add("form", "bank-order-form").param("forceEdit", "true").context("_showRecord", String.valueOf(bankOrder.getId())).map());
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : BankOrderMergeService(com.axelor.apps.bankpayment.service.bankorder.BankOrderMergeService) List(java.util.List) BankOrderRepository(com.axelor.apps.bankpayment.db.repo.BankOrderRepository) BankOrder(com.axelor.apps.bankpayment.db.BankOrder) AxelorException(com.axelor.exception.AxelorException)

Example 10 with BankOrder

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

the class BankOrderController method sign.

public void sign(ActionRequest request, ActionResponse response) throws AxelorException {
    BankOrder bankOrder = request.getContext().asType(BankOrder.class);
    bankOrder = Beans.get(BankOrderRepository.class).find(bankOrder.getId());
    try {
        ActionViewBuilder confirmView = ActionView.define("Sign bank order").model(BankOrder.class.getName()).add("form", "bank-order-sign-wizard-form").param("popup", "reload").param("show-toolbar", "false").param("show-confirm", "false").param("popup-save", "false").param("forceEdit", "true").context("_showRecord", bankOrder.getId());
        response.setView(confirmView.map());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : BankOrder(com.axelor.apps.bankpayment.db.BankOrder) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder) AxelorException(com.axelor.exception.AxelorException)

Aggregations

BankOrder (com.axelor.apps.bankpayment.db.BankOrder)33 AxelorException (com.axelor.exception.AxelorException)16 Transactional (com.google.inject.persist.Transactional)11 BankOrderService (com.axelor.apps.bankpayment.service.bankorder.BankOrderService)10 BankOrderLine (com.axelor.apps.bankpayment.db.BankOrderLine)8 PaymentMode (com.axelor.apps.account.db.PaymentMode)6 BankDetails (com.axelor.apps.base.db.BankDetails)6 LocalDate (java.time.LocalDate)6 Company (com.axelor.apps.base.db.Company)4 Currency (com.axelor.apps.base.db.Currency)4 InvoicePayment (com.axelor.apps.account.db.InvoicePayment)3 EbicsUser (com.axelor.apps.bankpayment.db.EbicsUser)3 Partner (com.axelor.apps.base.db.Partner)3 BigDecimal (java.math.BigDecimal)3 ArrayList (java.util.ArrayList)3 AccountingBatch (com.axelor.apps.account.db.AccountingBatch)2 PaymentScheduleLine (com.axelor.apps.account.db.PaymentScheduleLine)2 BankOrderRepository (com.axelor.apps.bankpayment.db.repo.BankOrderRepository)2 BankOrderLineService (com.axelor.apps.bankpayment.service.bankorder.BankOrderLineService)2 BankOrderMergeService (com.axelor.apps.bankpayment.service.bankorder.BankOrderMergeService)2