Search in sources :

Example 11 with BankOrderLine

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

the class BankOrderServiceImpl method setSequenceOnBankOrderLines.

@Override
public void setSequenceOnBankOrderLines(BankOrder bankOrder) {
    if (bankOrder.getBankOrderLineList() == null) {
        return;
    }
    String bankOrderSeq = bankOrder.getBankOrderSeq();
    int counter = 1;
    for (BankOrderLine bankOrderLine : bankOrder.getBankOrderLineList()) {
        bankOrderLine.setCounter(counter);
        bankOrderLine.setSequence(bankOrderSeq + "-" + Integer.toString(counter++));
    }
}
Also used : BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine)

Example 12 with BankOrderLine

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

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

the class BankOrderLineController method computeCompanyCurrencyAmount.

public void computeCompanyCurrencyAmount(ActionRequest request, ActionResponse response) {
    BankOrderLine bankOrderLine = request.getContext().asType(BankOrderLine.class);
    BankOrder bankOrder = request.getContext().getParent().asType(BankOrder.class);
    try {
        response.setValue("companyCurrencyAmount", Beans.get(BankOrderLineService.class).computeCompanyCurrencyAmount(bankOrder, bankOrderLine));
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) BankOrder(com.axelor.apps.bankpayment.db.BankOrder)

Example 14 with BankOrderLine

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

the class BankOrderLineController method fillBankDetail.

public void fillBankDetail(ActionRequest request, ActionResponse response) {
    BankOrderLine bankOrderLine = request.getContext().asType(BankOrderLine.class);
    BankOrder bankOrder = request.getContext().getParent().asType(BankOrder.class);
    BankDetails bankDetails = Beans.get(BankOrderLineService.class).getDefaultBankDetails(bankOrderLine, bankOrder);
    response.setValue("receiverBankDetails", bankDetails);
}
Also used : BankOrderLineService(com.axelor.apps.bankpayment.service.bankorder.BankOrderLineService) BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) BankDetails(com.axelor.apps.base.db.BankDetails) BankOrder(com.axelor.apps.bankpayment.db.BankOrder)

Example 15 with BankOrderLine

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

the class BankOrderMergeServiceImpl method consolidatePerPartner.

public void consolidatePerPartner(BankOrder bankOrder) {
    Map<List<Object>, BankOrderLine> bankOrderLineMap = new HashMap<List<Object>, BankOrderLine>();
    int counter = 1;
    for (BankOrderLine bankOrderLine : bankOrder.getBankOrderLineList()) {
        List<Object> keys = new ArrayList<Object>();
        keys.add(bankOrderLine.getPartner());
        keys.add(bankOrderLine.getBankOrderCurrency());
        keys.add(bankOrderLine.getBankOrderDate());
        keys.add(bankOrderLine.getBankOrderEconomicReason());
        keys.add(bankOrderLine.getFeesImputationModeSelect());
        keys.add(bankOrderLine.getPaymentModeSelect());
        keys.add(bankOrderLine.getReceiverBankDetails());
        keys.add(bankOrderLine.getReceiverCompany());
        if (bankOrderLineMap.containsKey(keys)) {
            BankOrderLine consolidateBankOrderLine = bankOrderLineMap.get(keys);
            if (consolidateBankOrderLine.getBankOrderLineOriginList() == null) {
                consolidateBankOrderLine.setBankOrderLineOriginList(new ArrayList<>());
            }
            if (bankOrderLine.getBankOrderLineOriginList() != null) {
                bankOrderLine.getBankOrderLineOriginList().stream().forEach(consolidateBankOrderLine::addBankOrderLineOriginListItem);
            }
            consolidateBankOrderLine.setBankOrderAmount(consolidateBankOrderLine.getBankOrderAmount().add(bankOrderLine.getBankOrderAmount()));
            consolidateBankOrderLine.setCompanyCurrencyAmount(consolidateBankOrderLine.getCompanyCurrencyAmount().add(bankOrderLine.getCompanyCurrencyAmount()));
        } else {
            bankOrderLine.setCounter(counter++);
            bankOrderLineMap.put(keys, bankOrderLine);
        }
    }
    bankOrder.getBankOrderLineList().clear();
    for (BankOrderLine bankOrderLine : bankOrderLineMap.values()) {
        Pair<String, LocalDate> lastReferences = getLastReferences(bankOrderLine);
        bankOrderLine.setReceiverReference(lastReferences.getLeft());
        bankOrderLine.setBankOrderDate(lastReferences.getRight());
        bankOrder.addBankOrderLineListItem(bankOrderLine);
    }
}
Also used : BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LocalDate(java.time.LocalDate) ArrayList(java.util.ArrayList) List(java.util.List)

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