use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.
the class InvoiceController method fillCompanyBankDetails.
/**
* Called on load and in partner, company or payment mode change. Fill the bank details with a
* default value.
*
* @param request
* @param response
* @throws AxelorException
*/
public void fillCompanyBankDetails(ActionRequest request, ActionResponse response) throws AxelorException {
Invoice invoice = request.getContext().asType(Invoice.class);
PaymentMode paymentMode = invoice.getPaymentMode();
Company company = invoice.getCompany();
Partner partner = invoice.getPartner();
if (company == null) {
return;
}
if (partner != null) {
partner = Beans.get(PartnerRepository.class).find(partner.getId());
}
BankDetails defaultBankDetails = Beans.get(BankDetailsService.class).getDefaultCompanyBankDetails(company, paymentMode, partner, invoice.getOperationTypeSelect());
response.setValue("companyBankDetails", defaultBankDetails);
}
use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.
the class InvoicePaymentController method filterBankDetails.
/**
* Create the domain for companyBankDetails field.
*
* @param request
* @param response
*/
@SuppressWarnings("unchecked")
public void filterBankDetails(ActionRequest request, ActionResponse response) {
InvoicePayment invoicePayment = request.getContext().asType(InvoicePayment.class);
Map<String, Object> partialInvoice = (Map<String, Object>) request.getContext().get("_invoice");
Invoice invoice = Beans.get(InvoiceRepository.class).find(((Integer) partialInvoice.get("id")).longValue());
Company company = invoice.getCompany();
List<BankDetails> bankDetailsList = Beans.get(InvoicePaymentToolService.class).findCompatibleBankDetails(company, invoicePayment);
if (bankDetailsList.isEmpty()) {
response.setAttr("companyBankDetails", "domain", "self.id IN (0)");
} else {
String idList = StringTool.getIdListString(bankDetailsList);
response.setAttr("companyBankDetails", "domain", "self.id IN (" + idList + ")");
}
}
use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.
the class PaymentVoucherController method fillCompanyBankDetails.
/**
* Called on load and in partner, company or payment mode change. Fill the bank details with a
* default value.
*
* @param request
* @param response
* @throws AxelorException
*/
public void fillCompanyBankDetails(ActionRequest request, ActionResponse response) throws AxelorException {
PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
PaymentMode paymentMode = paymentVoucher.getPaymentMode();
Company company = paymentVoucher.getCompany();
Partner partner = paymentVoucher.getPartner();
if (company == null) {
return;
}
if (partner != null) {
partner = Beans.get(PartnerRepository.class).find(partner.getId());
}
BankDetails defaultBankDetails = Beans.get(BankDetailsService.class).getDefaultCompanyBankDetails(company, paymentMode, partner, null);
response.setValue("companyBankDetails", defaultBankDetails);
}
use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.
the class PaymentVoucherController method askPaymentVoucher.
public void askPaymentVoucher(ActionRequest request, ActionResponse response) {
PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
if (paymentVoucher.getHasAutoInput()) {
PaymentMode paymentMode = paymentVoucher.getPaymentMode();
Company company = paymentVoucher.getCompany();
BankDetails companyBankDetails = paymentVoucher.getCompanyBankDetails();
try {
Journal journal = Beans.get(PaymentModeService.class).getPaymentModeJournal(paymentMode, company, companyBankDetails);
if (journal.getExcessPaymentOk()) {
response.setAlert(I18n.get("No items have been selected. Do you want to continue?"));
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
}
use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.
the class BatchCreditTransferExpensePaymentHR method processExpenses.
/**
* Process expenses that need to be paid.
*
* @return
*/
protected List<Expense> processExpenses() {
List<Expense> doneList = new ArrayList<>();
// Can't pass an empty collection to the query
List<Long> anomalyList = Lists.newArrayList(0L);
AccountingBatch accountingBatch = batch.getAccountingBatch();
boolean manageMultiBanks = appAccountService.getAppBase().getManageMultiBanks();
String filter = "self.ventilated = true " + "AND self.paymentStatusSelect = :paymentStatusSelect " + "AND self.company = :company " + "AND self.user.partner.outPaymentMode = :paymentMode " + "AND self.id NOT IN (:anomalyList)";
if (manageMultiBanks) {
filter += " AND self.bankDetails IN (:bankDetailsSet)";
}
Query<Expense> query = expenseRepo.all().filter(filter).bind("paymentStatusSelect", InvoicePaymentRepository.STATUS_DRAFT).bind("company", accountingBatch.getCompany()).bind("paymentMode", accountingBatch.getPaymentMode()).bind("anomalyList", anomalyList);
if (manageMultiBanks) {
Set<BankDetails> bankDetailsSet = Sets.newHashSet(accountingBatch.getBankDetails());
if (accountingBatch.getIncludeOtherBankAccounts()) {
bankDetailsSet.addAll(accountingBatch.getCompany().getBankDetailsList());
}
query.bind("bankDetailsSet", bankDetailsSet);
}
for (List<Expense> expenseList; !(expenseList = query.fetch(FETCH_LIMIT)).isEmpty(); JPA.clear()) {
for (Expense expense : expenseList) {
try {
addPayment(expense, accountingBatch.getBankDetails());
doneList.add(expense);
incrementDone();
} catch (Exception ex) {
incrementAnomaly();
anomalyList.add(expense.getId());
query.bind("anomalyList", anomalyList);
TraceBackService.trace(ex, ExceptionOriginRepository.CREDIT_TRANSFER, batch.getId());
ex.printStackTrace();
log.error(String.format("Credit transfer batch for expense payment: anomaly for expense %s", expense.getExpenseSeq()));
break;
}
}
}
return doneList;
}
Aggregations