Search in sources :

Example 26 with BankDetails

use of com.axelor.apps.base.db.BankDetails 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 27 with BankDetails

use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.

the class BatchDirectDebitPaymentSchedule method processPaymentScheduleLines.

protected void processPaymentScheduleLines(int paymentScheduleType) {
    AccountingBatch accountingBatch = batch.getAccountingBatch();
    if (generateBankOrderFlag) {
        Preconditions.checkNotNull(accountingBatch.getCompany(), I18n.get("Company is missing."));
        Preconditions.checkNotNull(accountingBatch.getPaymentMode(), I18n.get("Payment method is missing."));
        BankDetails companyBankDetails = getCompanyBankDetails(accountingBatch);
        AccountManagement accountManagement = Beans.get(PaymentModeService.class).getAccountManagement(accountingBatch.getPaymentMode(), accountingBatch.getCompany(), companyBankDetails);
        Preconditions.checkNotNull(accountManagement, I18n.get("Account management is missing."));
        Preconditions.checkNotNull(accountManagement.getBankDetails(), I18n.get("Bank details in account management is missing."));
        Preconditions.checkNotNull(companyBankDetails.getCurrency(), I18n.get("Currency in company bank details is missing."));
        String bankOrderExportPath = accountingBatch.getPaymentMode().getBankOrderExportFolderPath();
        String dataExpotDir;
        try {
            dataExpotDir = appBaseService.getDataExportDir();
            BankPaymentConfigService bankPaymentConfigService = Beans.get(BankPaymentConfigService.class);
            BankPaymentConfig bankPaymentConfig = bankPaymentConfigService.getBankPaymentConfig(accountingBatch.getCompany());
            bankPaymentConfigService.getIcsNumber(bankPaymentConfig);
        } catch (AxelorException e) {
            throw new RuntimeException(e);
        }
        Preconditions.checkArgument(bankOrderExportPath != null && new File(dataExpotDir + bankOrderExportPath).exists(), String.format(I18n.get("Bank order export folder does not exist: %s"), dataExpotDir + bankOrderExportPath));
    }
    QueryBuilder<PaymentScheduleLine> queryBuilder = QueryBuilder.of(PaymentScheduleLine.class);
    queryBuilder.add("self.paymentSchedule.statusSelect = :paymentScheduleStatusSelect");
    queryBuilder.bind("paymentScheduleStatusSelect", PaymentScheduleRepository.STATUS_CONFIRMED);
    queryBuilder.add("self.paymentSchedule.typeSelect = :paymentScheduleTypeSelect");
    queryBuilder.bind("paymentScheduleTypeSelect", paymentScheduleType);
    queryBuilder.add("self.statusSelect = :statusSelect");
    queryBuilder.bind("statusSelect", PaymentScheduleLineRepository.STATUS_IN_PROGRESS);
    LocalDate dueDate = accountingBatch.getDueDate() != null ? accountingBatch.getDueDate() : Beans.get(AppBaseService.class).getTodayDate(accountingBatch.getCompany());
    queryBuilder.add("self.scheduleDate <= :dueDate");
    queryBuilder.bind("dueDate", dueDate);
    if (accountingBatch.getCompany() != null) {
        queryBuilder.add("self.paymentSchedule.company IS NULL OR self.paymentSchedule.company = :company");
        queryBuilder.bind("company", accountingBatch.getCompany());
    }
    queryBuilder.add("self.paymentSchedule.partner.id NOT IN (SELECT DISTINCT partner.id FROM Partner partner LEFT JOIN partner.blockingList blocking WHERE blocking.blockingSelect = :blockingSelect AND blocking.blockingToDate >= :blockingToDate)");
    queryBuilder.bind("blockingSelect", BlockingRepository.DEBIT_BLOCKING);
    queryBuilder.bind("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());
        }
        queryBuilder.add("self.paymentSchedule.companyBankDetails IS NULL OR self.paymentSchedule.companyBankDetails IN (:bankDetailsSet)");
        queryBuilder.bind("bankDetailsSet", bankDetailsSet);
    }
    if (accountingBatch.getPaymentMode() != null) {
        queryBuilder.add("self.paymentSchedule.paymentMode IS NULL OR self.paymentSchedule.paymentMode = :paymentMode");
        queryBuilder.bind("paymentMode", accountingBatch.getPaymentMode());
    }
    queryBuilder.add(":batch NOT MEMBER OF self.batchSet");
    queryBuilder.bind("batch", batch);
    processQuery(queryBuilder);
}
Also used : AxelorException(com.axelor.exception.AxelorException) PaymentModeService(com.axelor.apps.account.service.payment.PaymentModeService) PaymentScheduleLine(com.axelor.apps.account.db.PaymentScheduleLine) BankDetails(com.axelor.apps.base.db.BankDetails) LocalDate(java.time.LocalDate) BankPaymentConfig(com.axelor.apps.bankpayment.db.BankPaymentConfig) AccountingBatch(com.axelor.apps.account.db.AccountingBatch) BankPaymentConfigService(com.axelor.apps.bankpayment.service.config.BankPaymentConfigService) File(java.io.File) AccountManagement(com.axelor.apps.account.db.AccountManagement)

Example 28 with BankDetails

use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.

the class BankOrderController method fillBankDetails.

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

Example 29 with BankDetails

use of com.axelor.apps.base.db.BankDetails 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 30 with BankDetails

use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.

the class BankStatementFileAFB120Service method createBankStatementLine.

@Transactional
public BankStatementLineAFB120 createBankStatementLine(Map<String, Object> structuredContentLine, int sequence) {
    String description = (String) structuredContentLine.get("description");
    if (structuredContentLine.containsKey("additionalInformation") && structuredContentLine.get("additionalInformation") != null) {
        description += "\n" + (String) structuredContentLine.get("additionalInformation");
    }
    BankDetails bankDetails = null;
    if (structuredContentLine.containsKey("bankDetails") && structuredContentLine.get("bankDetails") != null) {
        bankDetails = bankDetailsRepository.find(((BankDetails) structuredContentLine.get("bankDetails")).getId());
    }
    Currency currency = null;
    if (structuredContentLine.containsKey("currency") && structuredContentLine.get("currency") != null) {
        currency = currencyRepository.find(((Currency) structuredContentLine.get("currency")).getId());
    }
    InterbankCodeLine operationInterbankCodeLine = null;
    if (structuredContentLine.containsKey("operationInterbankCodeLine") && structuredContentLine.get("operationInterbankCodeLine") != null) {
        operationInterbankCodeLine = interbankCodeLineRepository.find(((InterbankCodeLine) structuredContentLine.get("operationInterbankCodeLine")).getId());
    }
    InterbankCodeLine rejectInterbankCodeLine = null;
    if (structuredContentLine.containsKey("rejectInterbankCodeLine") && structuredContentLine.get("rejectInterbankCodeLine") != null) {
        rejectInterbankCodeLine = interbankCodeLineRepository.find(((InterbankCodeLine) structuredContentLine.get("rejectInterbankCodeLine")).getId());
    }
    BankStatementLineAFB120 bankStatementLineAFB120 = bankStatementLineAFB120Service.createBankStatementLine(findBankStatement(), sequence, bankDetails, (BigDecimal) structuredContentLine.get("debit"), (BigDecimal) structuredContentLine.get("credit"), currency, description, (LocalDate) structuredContentLine.get("operationDate"), (LocalDate) structuredContentLine.get("valueDate"), operationInterbankCodeLine, rejectInterbankCodeLine, (String) structuredContentLine.get("origin"), (String) structuredContentLine.get("reference"), (int) structuredContentLine.get("lineType"), (String) structuredContentLine.get("unavailabilityIndexSelect"), (String) structuredContentLine.get("commissionExemptionIndexSelect"));
    return bankStatementLineAFB120Repository.save(bankStatementLineAFB120);
}
Also used : BankDetails(com.axelor.apps.base.db.BankDetails) InterbankCodeLine(com.axelor.apps.account.db.InterbankCodeLine) Currency(com.axelor.apps.base.db.Currency) BankStatementLineAFB120(com.axelor.apps.bankpayment.db.BankStatementLineAFB120) Transactional(com.google.inject.persist.Transactional)

Aggregations

BankDetails (com.axelor.apps.base.db.BankDetails)63 Partner (com.axelor.apps.base.db.Partner)26 AxelorException (com.axelor.exception.AxelorException)26 PaymentMode (com.axelor.apps.account.db.PaymentMode)22 Company (com.axelor.apps.base.db.Company)22 BigDecimal (java.math.BigDecimal)14 LocalDate (java.time.LocalDate)13 Transactional (com.google.inject.persist.Transactional)12 ArrayList (java.util.ArrayList)11 Invoice (com.axelor.apps.account.db.Invoice)10 Journal (com.axelor.apps.account.db.Journal)9 BankDetailsService (com.axelor.apps.base.service.BankDetailsService)8 PaymentModeService (com.axelor.apps.account.service.payment.PaymentModeService)7 BankOrderLine (com.axelor.apps.bankpayment.db.BankOrderLine)7 Currency (com.axelor.apps.base.db.Currency)7 Account (com.axelor.apps.account.db.Account)6 AccountConfig (com.axelor.apps.account.db.AccountConfig)6 InvoicePayment (com.axelor.apps.account.db.InvoicePayment)6 Move (com.axelor.apps.account.db.Move)6 MoveLine (com.axelor.apps.account.db.MoveLine)6