use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoiceController method fillPriceList.
/**
* Called from invoice form view on partner change. Get the default price list for the invoice.
* Call {@link PartnerPriceListService#getDefaultPriceList(Partner, int)}.
*
* @param request
* @param response
*/
public void fillPriceList(ActionRequest request, ActionResponse response) {
try {
Invoice invoice = request.getContext().asType(Invoice.class);
Partner partner = invoice.getPartner();
if (partner == null) {
return;
}
int priceListTypeSelect = Beans.get(InvoiceService.class).getPurchaseTypeOrSaleType(invoice);
response.setValue("priceList", Beans.get(PartnerPriceListService.class).getDefaultPriceList(partner, priceListTypeSelect));
} 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 regenerateAndShowInvoice.
public void regenerateAndShowInvoice(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
Invoice invoice = Beans.get(InvoiceRepository.class).find(Long.parseLong(context.get("id").toString()));
Integer reportType = context.get("reportType") != null ? Integer.parseInt(context.get("reportType").toString()) : null;
try {
response.setCanClose(true);
response.setView(ActionView.define(I18n.get("Invoice")).add("html", Beans.get(InvoicePrintService.class).printInvoice(invoice, true, "pdf", reportType, null)).map());
} 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 changePriceListDomain.
/**
* Called from invoice view on price list select. Call {@link
* PartnerPriceListService#getPriceListDomain(Partner, int)}.
*
* @param request
* @param response
*/
public void changePriceListDomain(ActionRequest request, ActionResponse response) {
try {
Invoice invoice = request.getContext().asType(Invoice.class);
int priceListTypeSelect = Beans.get(InvoiceService.class).getPurchaseTypeOrSaleType(invoice);
String domain = Beans.get(PartnerPriceListService.class).getPriceListDomain(invoice.getPartner(), priceListTypeSelect);
response.setAttr("priceList", "domain", domain);
} 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 validate.
/**
* Fonction appeler par le bouton valider
*
* @param request
* @param response
* @return
*/
public void validate(ActionRequest request, ActionResponse response) throws AxelorException {
Invoice invoice = request.getContext().asType(Invoice.class);
invoice = Beans.get(InvoiceRepository.class).find(invoice.getId());
try {
// we have to inject TraceBackService to use non static methods
TraceBackService traceBackService = Beans.get(TraceBackService.class);
long tracebackCount = traceBackService.countMessageTraceBack(invoice);
Beans.get(InvoiceService.class).validate(invoice);
response.setReload(true);
if (traceBackService.countMessageTraceBack(invoice) > tracebackCount) {
traceBackService.findLastMessageTraceBack(invoice).ifPresent(traceback -> response.setNotify(String.format(I18n.get(com.axelor.apps.message.exception.IExceptionMessage.SEND_EMAIL_EXCEPTION), traceback.getMessage())));
}
} 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 checkPartnerBankDetailsList.
public void checkPartnerBankDetailsList(ActionRequest request, ActionResponse response) {
Invoice invoice = request.getContext().asType(Invoice.class);
response.setAttr("$partnerBankDetailsListWarning", "hidden", Beans.get(InvoiceService.class).checkPartnerBankDetailsList(invoice));
}
Aggregations