use of com.axelor.apps.account.service.PaymentScheduleLineService 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();
}
}
Aggregations