use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoiceController method massPaymentOnSupplierInvoices.
public void massPaymentOnSupplierInvoices(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
if (!ObjectUtils.isEmpty(context.get("_ids"))) {
List<Long> invoiceIdList = (List) (((List) context.get("_ids")).stream().filter(ObjectUtils::notEmpty).map(input -> Long.parseLong(input.toString())).collect(Collectors.toList()));
List<Long> invoiceToPay = Beans.get(InvoicePaymentCreateService.class).getInvoiceIdsToPay(invoiceIdList);
if (invoiceToPay.isEmpty()) {
response.setError(I18n.get(IExceptionMessage.INVOICE_NO_INVOICE_TO_PAY));
}
response.setView(ActionView.define(I18n.get("Register a mass payment")).model(InvoicePayment.class.getName()).add("form", "invoice-payment-mass-form").param("popup", "reload").param("show-toolbar", "false").param("show-confirm", "false").param("popup-save", "false").param("forceEdit", "true").context("_invoices", invoiceToPay).map());
}
} catch (Exception e) {
TraceBackService.trace(response, e, ResponseMessageType.ERROR);
}
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoiceController method filterPrintingSettings.
/**
* Called on printing settings select. Set the domain for {@link Invoice#printingSettings}
*
* @param request
* @param response
*/
public void filterPrintingSettings(ActionRequest request, ActionResponse response) {
Invoice invoice = request.getContext().asType(Invoice.class);
List<PrintingSettings> printingSettingsList = Beans.get(TradingNameService.class).getPrintingSettingsList(invoice.getTradingName(), invoice.getCompany());
String domain = String.format("self.id IN (%s)", !printingSettingsList.isEmpty() ? StringTool.getIdListString(printingSettingsList) : "0");
response.setAttr("printingSettings", "domain", domain);
}
use of com.axelor.apps.account.db.Invoice 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.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoiceController method usherProcess.
public void usherProcess(ActionRequest request, ActionResponse response) {
Invoice invoice = request.getContext().asType(Invoice.class);
invoice = Beans.get(InvoiceRepository.class).find(invoice.getId());
try {
Beans.get(InvoiceService.class).usherProcess(invoice);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoiceController method fillDefaultPrintingSettings.
/**
* Called on trading name change. Set the default value for {@link Invoice#printingSettings}
*
* @param request
* @param response
*/
public void fillDefaultPrintingSettings(ActionRequest request, ActionResponse response) {
try {
Invoice invoice = request.getContext().asType(Invoice.class);
response.setValue("printingSettings", Beans.get(TradingNameService.class).getDefaultPrintingSettings(invoice.getTradingName(), invoice.getCompany()));
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations