Search in sources :

Example 1 with PaymentScheduleService

use of com.axelor.apps.account.service.PaymentScheduleService in project axelor-open-suite by axelor.

the class BatchDirectDebitPaymentSchedule method processQuery.

private void processQuery(QueryBuilder<PaymentScheduleLine> queryBuilder) {
    Query<PaymentScheduleLine> query = queryBuilder.build();
    List<PaymentScheduleLine> paymentScheduleLineList;
    PaymentScheduleService paymentScheduleService = Beans.get(PaymentScheduleService.class);
    PaymentScheduleLineService paymentScheduleLineService = Beans.get(PaymentScheduleLineService.class);
    BankDetailsRepository bankDetailsRepo = Beans.get(BankDetailsRepository.class);
    BankDetails companyBankDetails = getCompanyBankDetails(batch.getAccountingBatch());
    while (!(paymentScheduleLineList = query.fetch(FETCH_LIMIT)).isEmpty()) {
        findBatch();
        companyBankDetails = bankDetailsRepo.find(companyBankDetails.getId());
        PaymentMode directDebitPaymentMode = batch.getAccountingBatch().getPaymentMode();
        for (PaymentScheduleLine paymentScheduleLine : paymentScheduleLineList) {
            try {
                if (generateBankOrderFlag) {
                    PaymentSchedule paymentSchedule = paymentScheduleLine.getPaymentSchedule();
                    BankDetails bankDetails = paymentScheduleService.getBankDetails(paymentSchedule);
                    Preconditions.checkArgument(bankDetails.getActive(), bankDetails.getPartner() != null ? bankDetails.getPartner().getFullName() + " - " + I18n.get("Bank details are inactive.") : I18n.get("Bank details are inactive."));
                    if (directDebitPaymentMode.getOrderTypeSelect() == PaymentModeRepository.ORDER_TYPE_SEPA_DIRECT_DEBIT) {
                        Partner partner = paymentSchedule.getPartner();
                        Preconditions.checkNotNull(partner, I18n.get("Partner is missing."));
                        Preconditions.checkNotNull(partner.getActiveUmr(), I18n.get("Partner active UMR is missing."));
                    }
                }
                paymentScheduleLineService.createPaymentMove(paymentScheduleLine, companyBankDetails, directDebitPaymentMode);
                incrementDone(paymentScheduleLine);
            } catch (Exception e) {
                TraceBackService.trace(e, ExceptionOriginRepository.DIRECT_DEBIT, batch.getId());
                incrementAnomaly(paymentScheduleLine);
                break;
            }
        }
        JPA.clear();
    }
}
Also used : PaymentScheduleLine(com.axelor.apps.account.db.PaymentScheduleLine) PaymentSchedule(com.axelor.apps.account.db.PaymentSchedule) BankDetailsRepository(com.axelor.apps.base.db.repo.BankDetailsRepository) BankDetails(com.axelor.apps.base.db.BankDetails) PaymentScheduleService(com.axelor.apps.account.service.PaymentScheduleService) PaymentScheduleLineService(com.axelor.apps.account.service.PaymentScheduleLineService) Partner(com.axelor.apps.base.db.Partner) AxelorException(com.axelor.exception.AxelorException) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Aggregations

PaymentMode (com.axelor.apps.account.db.PaymentMode)1 PaymentSchedule (com.axelor.apps.account.db.PaymentSchedule)1 PaymentScheduleLine (com.axelor.apps.account.db.PaymentScheduleLine)1 PaymentScheduleLineService (com.axelor.apps.account.service.PaymentScheduleLineService)1 PaymentScheduleService (com.axelor.apps.account.service.PaymentScheduleService)1 BankDetails (com.axelor.apps.base.db.BankDetails)1 Partner (com.axelor.apps.base.db.Partner)1 BankDetailsRepository (com.axelor.apps.base.db.repo.BankDetailsRepository)1 AxelorException (com.axelor.exception.AxelorException)1