use of com.axelor.apps.bankpayment.db.BankPaymentConfig 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);
}
use of com.axelor.apps.bankpayment.db.BankPaymentConfig in project axelor-open-suite by axelor.
the class AppBankPaymentServiceImpl method generateBankPaymentConfigurations.
@Override
@Transactional
public void generateBankPaymentConfigurations() {
List<Company> companies = companyRepo.all().filter("self.bankPaymentConfig IS NULL").fetch();
for (Company company : companies) {
BankPaymentConfig config = new BankPaymentConfig();
config.setCompany(company);
bankPaymentConfigRepo.save(config);
}
}
Aggregations