Search in sources :

Example 1 with BankOrder

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

the class BankOrderManagementRepository method copy.

@Override
public BankOrder copy(BankOrder entity, boolean deep) {
    BankOrder copy = super.copy(entity, deep);
    copy.setStatusSelect(STATUS_DRAFT);
    copy.setGeneratedMetaFile(null);
    copy.setSignedMetaFile(null);
    copy.setConfirmationDateTime(null);
    copy.setFileGenerationDateTime(null);
    copy.setValidationDateTime(null);
    copy.setSendingDateTime(null);
    copy.setBankOrderSeq(null);
    return copy;
}
Also used : BankOrder(com.axelor.apps.bankpayment.db.BankOrder)

Example 2 with BankOrder

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

the class BatchCreditTransferExpensePaymentHR method mergeBankOrders.

/**
 * Merge bank orders.
 *
 * @param doneList
 * @throws AxelorException
 */
@Transactional(rollbackOn = { Exception.class })
protected void mergeBankOrders(List<Expense> doneList) throws AxelorException {
    List<Expense> expenseList = new ArrayList<>();
    List<BankOrder> bankOrderList = new ArrayList<>();
    for (Expense expense : doneList) {
        BankOrder bankOrder = expense.getBankOrder();
        if (bankOrder != null) {
            expenseList.add(expense);
            bankOrderList.add(bankOrder);
        }
    }
    if (bankOrderList.size() > 1) {
        BankOrder mergedBankOrder = bankOrderMergeService.mergeBankOrders(bankOrderList);
        for (Expense expense : expenseList) {
            expense.setBankOrder(mergedBankOrder);
        }
    }
}
Also used : Expense(com.axelor.apps.hr.db.Expense) ArrayList(java.util.ArrayList) BankOrder(com.axelor.apps.bankpayment.db.BankOrder) Transactional(com.google.inject.persist.Transactional)

Example 3 with BankOrder

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

the class ExpenseServiceImpl method addPayment.

@Override
@Transactional(rollbackOn = { Exception.class })
public void addPayment(Expense expense, BankDetails bankDetails) throws AxelorException {
    expense.setPaymentDate(appAccountService.getTodayDate(expense.getCompany()));
    PaymentMode paymentMode = expense.getPaymentMode();
    if (paymentMode == null) {
        paymentMode = expense.getUser().getPartner().getOutPaymentMode();
        if (paymentMode == null) {
            throw new AxelorException(expense, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.EXPENSE_MISSING_PAYMENT_MODE));
        }
        expense.setPaymentMode(paymentMode);
    }
    if (paymentMode.getGenerateBankOrder()) {
        BankOrder bankOrder = Beans.get(BankOrderCreateServiceHr.class).createBankOrder(expense, bankDetails);
        expense.setBankOrder(bankOrder);
        Beans.get(BankOrderRepository.class).save(bankOrder);
        expense.setPaymentStatusSelect(InvoicePaymentRepository.STATUS_PENDING);
    } else {
        if (accountConfigService.getAccountConfig(expense.getCompany()).getGenerateMoveForInvoicePayment()) {
            this.createMoveForExpensePayment(expense);
        }
        if (paymentMode.getAutomaticTransmission()) {
            expense.setPaymentStatusSelect(InvoicePaymentRepository.STATUS_PENDING);
        } else {
            expense.setPaymentStatusSelect(InvoicePaymentRepository.STATUS_VALIDATED);
            expense.setStatusSelect(ExpenseRepository.STATUS_REIMBURSED);
        }
    }
    expense.setPaymentAmount(expense.getInTaxTotal().subtract(expense.getAdvanceAmount()).subtract(expense.getWithdrawnCash()).subtract(expense.getPersonalExpenseAmount()));
}
Also used : AxelorException(com.axelor.exception.AxelorException) BankOrderCreateServiceHr(com.axelor.apps.hr.service.bankorder.BankOrderCreateServiceHr) BankOrder(com.axelor.apps.bankpayment.db.BankOrder) BankOrderRepository(com.axelor.apps.bankpayment.db.repo.BankOrderRepository) PaymentMode(com.axelor.apps.account.db.PaymentMode) Transactional(com.google.inject.persist.Transactional)

Example 4 with BankOrder

use of com.axelor.apps.bankpayment.db.BankOrder 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 5 with BankOrder

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

the class BatchBankPaymentServiceImpl method createBankOrderFromPaymentScheduleLines.

@Override
@Transactional(rollbackOn = { Exception.class })
public BankOrder createBankOrderFromPaymentScheduleLines(Batch batch) throws AxelorException, JAXBException, IOException, DatatypeConfigurationException {
    List<PaymentScheduleLine> paymentScheduleLineList;
    int offset = 0;
    while (!(paymentScheduleLineList = fetchPaymentScheduleLineDoneList(batch, offset)).isEmpty()) {
        createBankOrders(batch, paymentScheduleLineList);
        offset += paymentScheduleLineList.size();
        JPA.clear();
        batch = batchRepo.find(batch.getId());
    }
    List<BankOrder> bankOrderList;
    while ((bankOrderList = fetchLimitedBankOrderList(batch)).size() > 1) {
        bankOrderMergeService.mergeBankOrders(bankOrderList);
        JPA.clear();
        batch = batchRepo.find(batch.getId());
    }
    if (bankOrderList.isEmpty()) {
        throw new AxelorException(batch, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.BANK_ORDER_MERGE_NO_BANK_ORDERS));
    }
    BankOrder bankOrder = bankOrderRepo.find(bankOrderList.iterator().next().getId());
    batch.setBankOrder(bankOrder);
    return bankOrder;
}
Also used : AxelorException(com.axelor.exception.AxelorException) PaymentScheduleLine(com.axelor.apps.account.db.PaymentScheduleLine) BankOrder(com.axelor.apps.bankpayment.db.BankOrder) Transactional(com.google.inject.persist.Transactional)

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