use of com.axelor.apps.bankpayment.db.BankOrder 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;
}
use of com.axelor.apps.bankpayment.db.BankOrder 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());
}
}
}
use of com.axelor.apps.bankpayment.db.BankOrder in project axelor-open-suite by axelor.
the class BankOrderController method realize.
public void realize(ActionRequest request, ActionResponse response) {
try {
BankOrder bankOrder = request.getContext().asType(BankOrder.class);
bankOrder = Beans.get(BankOrderRepository.class).find(bankOrder.getId());
if (bankOrder != null) {
Beans.get(BankOrderService.class).realize(bankOrder);
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
response.setReload(true);
}
use of com.axelor.apps.bankpayment.db.BankOrder in project axelor-open-suite by axelor.
the class BankOrderController method merge.
@SuppressWarnings("unchecked")
public void merge(ActionRequest request, ActionResponse response) {
try {
List<Integer> listSelectedBankOrder = (List<Integer>) request.getContext().get("_ids");
BankOrderRepository bankOrderRepository = Beans.get(BankOrderRepository.class);
List<BankOrder> bankOrderList = Lists.newArrayList();
if (listSelectedBankOrder != null) {
for (Integer bankOrderId : listSelectedBankOrder) {
BankOrder bankOrder = bankOrderRepository.find(bankOrderId.longValue());
if (bankOrder != null) {
bankOrderList.add(bankOrder);
}
}
BankOrder bankOrder = Beans.get(BankOrderMergeService.class).mergeBankOrders(bankOrderList);
response.setView(ActionView.define(I18n.get("Bank Order")).model(BankOrder.class.getName()).add("form", "bank-order-form").param("forceEdit", "true").context("_showRecord", String.valueOf(bankOrder.getId())).map());
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.bankpayment.db.BankOrder in project axelor-open-suite by axelor.
the class BankOrderController method sign.
public void sign(ActionRequest request, ActionResponse response) throws AxelorException {
BankOrder bankOrder = request.getContext().asType(BankOrder.class);
bankOrder = Beans.get(BankOrderRepository.class).find(bankOrder.getId());
try {
ActionViewBuilder confirmView = ActionView.define("Sign bank order").model(BankOrder.class.getName()).add("form", "bank-order-sign-wizard-form").param("popup", "reload").param("show-toolbar", "false").param("show-confirm", "false").param("popup-save", "false").param("forceEdit", "true").context("_showRecord", bankOrder.getId());
response.setView(confirmView.map());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations