Search in sources :

Example 16 with PaymentMode

use of com.axelor.apps.account.db.PaymentMode in project axelor-open-suite by axelor.

the class InvoicePaymentToolServiceImpl method findCompatibleBankDetails.

/**
 * @inheritDoc
 */
@Override
public List<BankDetails> findCompatibleBankDetails(Company company, InvoicePayment invoicePayment) {
    PaymentMode paymentMode = invoicePayment.getPaymentMode();
    if (company == null || paymentMode == null) {
        return new ArrayList<BankDetails>();
    }
    paymentMode = Beans.get(PaymentModeRepository.class).find(invoicePayment.getPaymentMode().getId());
    return Beans.get(PaymentModeService.class).getCompatibleBankDetailsList(paymentMode, company);
}
Also used : PaymentModeService(com.axelor.apps.account.service.payment.PaymentModeService) ArrayList(java.util.ArrayList) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Example 17 with PaymentMode

use of com.axelor.apps.account.db.PaymentMode in project axelor-open-suite by axelor.

the class StockMoveInvoiceController method generateInvoiceConcatInStockMove.

/**
 * Called from mass invoicing in stock move confirm view. Get parameters entered by the user, then
 * call {@link StockMoveMultiInvoiceService#createInvoiceFromMultiIncomingStockMove(List,
 * PaymentCondition, PaymentMode, Partner)} and show the generated invoice.
 *
 * @param request
 * @param response
 */
public void generateInvoiceConcatInStockMove(ActionRequest request, ActionResponse response) {
    try {
        List<StockMove> stockMoveList = new ArrayList<>();
        String stockMoveListStr = (String) request.getContext().get("supplierStockMoveToInvoice");
        for (String stockMoveId : stockMoveListStr.split(",")) {
            stockMoveList.add(JPA.em().find(StockMove.class, new Long(stockMoveId)));
        }
        PaymentCondition paymentCondition = null;
        PaymentMode paymentMode = null;
        Partner contactPartner = null;
        if (request.getContext().get("paymentCondition") != null) {
            paymentCondition = JPA.em().find(PaymentCondition.class, Long.valueOf((Integer) ((Map) request.getContext().get("paymentCondition")).get("id")));
        }
        if (request.getContext().get("paymentMode") != null) {
            paymentMode = JPA.em().find(PaymentMode.class, Long.valueOf((Integer) ((Map) request.getContext().get("paymentMode")).get("id")));
        }
        if (request.getContext().get("contactPartner") != null) {
            contactPartner = JPA.em().find(Partner.class, Long.valueOf((Integer) ((Map) request.getContext().get("contactPartner")).get("id")));
        }
        Optional<Invoice> invoice = Beans.get(StockMoveMultiInvoiceService.class).createInvoiceFromMultiIncomingStockMove(stockMoveList, paymentCondition, paymentMode, contactPartner);
        invoice.ifPresent(inv -> response.setView(ActionView.define("Invoice").model(Invoice.class.getName()).add("grid", "invoice-grid").add("form", "invoice-form").param("search-filters", "customer-invoices-filters").param("forceEdit", "true").context("_showRecord", String.valueOf(inv.getId())).context("_operationTypeSelect", inv.getOperationTypeSelect()).context("todayDate", Beans.get(AppSupplychainService.class).getTodayDate(inv.getCompany())).map()));
        response.setCanClose(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PaymentCondition(com.axelor.apps.account.db.PaymentCondition) StockMove(com.axelor.apps.stock.db.StockMove) Invoice(com.axelor.apps.account.db.Invoice) StockMoveMultiInvoiceService(com.axelor.apps.supplychain.service.StockMoveMultiInvoiceService) ArrayList(java.util.ArrayList) AppSupplychainService(com.axelor.apps.supplychain.service.app.AppSupplychainService) Partner(com.axelor.apps.base.db.Partner) Map(java.util.Map) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Example 18 with PaymentMode

use of com.axelor.apps.account.db.PaymentMode in project axelor-open-suite by axelor.

the class BankOrderMergeServiceImpl method mergeBankOrders.

@Transactional(rollbackOn = { Exception.class })
public BankOrder mergeBankOrders(Collection<BankOrder> bankOrders) throws AxelorException {
    if (bankOrders == null || bankOrders.size() <= 1) {
        throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, IExceptionMessage.BANK_ORDER_MERGE_AT_LEAST_TWO_BANK_ORDERS);
    }
    this.checkSameElements(bankOrders);
    BankOrder bankOrder = bankOrders.iterator().next();
    bankOrders.remove(bankOrder);
    bankOrder.setSenderLabel(null);
    bankOrder.setSenderReference(null);
    bankOrder.setBankOrderDate(Beans.get(AppBaseService.class).getTodayDate(bankOrder.getSenderCompany()));
    bankOrder.setSignatoryUser(null);
    bankOrder.setSignatoryEbicsUser(null);
    PaymentMode paymentMode = bankOrder.getPaymentMode();
    for (BankOrderLine bankOrderLine : this.getAllBankOrderLineList(bankOrders)) {
        bankOrder.addBankOrderLineListItem(bankOrderLine);
    }
    bankOrderRepo.save(bankOrder);
    for (BankOrder bankOrderToRemove : bankOrders) {
        bankOrderToRemove = bankOrderRepo.find(bankOrderToRemove.getId());
        List<InvoicePayment> invoicePaymentList = invoicePaymentRepo.findByBankOrder(bankOrderToRemove).fetch();
        for (InvoicePayment invoicePayment : invoicePaymentList) {
            invoicePayment.setBankOrder(bankOrder);
        }
        bankOrderRepo.remove(bankOrderToRemove);
    }
    if (paymentMode.getConsoBankOrderLinePerPartner()) {
        consolidatePerPartner(bankOrder);
    }
    bankOrderService.updateTotalAmounts(bankOrder);
    return bankOrderRepo.save(bankOrder);
}
Also used : AxelorException(com.axelor.exception.AxelorException) InvoicePayment(com.axelor.apps.account.db.InvoicePayment) BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) BankOrder(com.axelor.apps.bankpayment.db.BankOrder) PaymentMode(com.axelor.apps.account.db.PaymentMode) Transactional(com.google.inject.persist.Transactional)

Example 19 with PaymentMode

use of com.axelor.apps.account.db.PaymentMode in project axelor-open-suite by axelor.

the class BankOrderServiceImpl method confirm.

@Override
@Transactional(rollbackOn = { Exception.class })
public void confirm(BankOrder bankOrder) throws AxelorException, JAXBException, IOException, DatatypeConfigurationException {
    checkBankDetails(bankOrder.getSenderBankDetails(), bankOrder);
    if (bankOrder.getGeneratedMetaFile() == null) {
        checkLines(bankOrder);
    }
    setNbOfLines(bankOrder);
    setSequenceOnBankOrderLines(bankOrder);
    generateFile(bankOrder);
    PaymentMode paymentMode = bankOrder.getPaymentMode();
    if (Beans.get(AppBankPaymentService.class).getAppBankPayment().getEnableEbicsModule() && paymentMode != null && paymentMode.getAutomaticTransmission()) {
        bankOrder.setConfirmationDateTime(Beans.get(AppBaseService.class).getTodayDateTime().toLocalDateTime());
        bankOrder.setStatusSelect(BankOrderRepository.STATUS_AWAITING_SIGNATURE);
        makeEbicsUserFollow(bankOrder);
        bankOrderRepo.save(bankOrder);
    } else {
        validate(bankOrder);
    }
}
Also used : AppBaseService(com.axelor.apps.base.service.app.AppBaseService) PaymentMode(com.axelor.apps.account.db.PaymentMode) Transactional(com.google.inject.persist.Transactional)

Example 20 with PaymentMode

use of com.axelor.apps.account.db.PaymentMode in project axelor-open-suite by axelor.

the class BatchDirectDebit method start.

@Override
protected void start() throws IllegalAccessException {
    super.start();
    PaymentMode directDebitPaymentMode = batch.getAccountingBatch().getPaymentMode();
    generateBankOrderFlag = directDebitPaymentMode != null && directDebitPaymentMode.getGenerateBankOrder();
}
Also used : PaymentMode(com.axelor.apps.account.db.PaymentMode)

Aggregations

PaymentMode (com.axelor.apps.account.db.PaymentMode)45 Company (com.axelor.apps.base.db.Company)27 Partner (com.axelor.apps.base.db.Partner)26 BankDetails (com.axelor.apps.base.db.BankDetails)21 Invoice (com.axelor.apps.account.db.Invoice)18 AxelorException (com.axelor.exception.AxelorException)17 Transactional (com.google.inject.persist.Transactional)13 BigDecimal (java.math.BigDecimal)11 LocalDate (java.time.LocalDate)10 PaymentCondition (com.axelor.apps.account.db.PaymentCondition)9 Currency (com.axelor.apps.base.db.Currency)9 ArrayList (java.util.ArrayList)8 Journal (com.axelor.apps.account.db.Journal)7 PaymentModeService (com.axelor.apps.account.service.payment.PaymentModeService)7 Map (java.util.Map)7 BankOrder (com.axelor.apps.bankpayment.db.BankOrder)6 BankDetailsService (com.axelor.apps.base.service.BankDetailsService)6 Account (com.axelor.apps.account.db.Account)5 Move (com.axelor.apps.account.db.Move)5 PriceList (com.axelor.apps.base.db.PriceList)5