Search in sources :

Example 96 with Invoice

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);
    }
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) InvoiceService(com.axelor.apps.account.service.invoice.InvoiceService) Partner(com.axelor.apps.base.db.Partner) AxelorException(com.axelor.exception.AxelorException)

Example 97 with Invoice

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);
    }
}
Also used : Context(com.axelor.rpc.Context) Invoice(com.axelor.apps.account.db.Invoice) InvoiceRepository(com.axelor.apps.account.db.repo.InvoiceRepository) AxelorException(com.axelor.exception.AxelorException)

Example 98 with Invoice

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);
    }
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) PartnerPriceListService(com.axelor.apps.base.service.PartnerPriceListService) InvoiceService(com.axelor.apps.account.service.invoice.InvoiceService) AxelorException(com.axelor.exception.AxelorException)

Example 99 with Invoice

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);
    }
}
Also used : TraceBackService(com.axelor.exception.service.TraceBackService) Invoice(com.axelor.apps.account.db.Invoice) InvoiceService(com.axelor.apps.account.service.invoice.InvoiceService) AxelorException(com.axelor.exception.AxelorException)

Example 100 with Invoice

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));
}
Also used : Invoice(com.axelor.apps.account.db.Invoice)

Aggregations

Invoice (com.axelor.apps.account.db.Invoice)195 AxelorException (com.axelor.exception.AxelorException)69 ArrayList (java.util.ArrayList)48 Transactional (com.google.inject.persist.Transactional)46 BigDecimal (java.math.BigDecimal)32 Company (com.axelor.apps.base.db.Company)31 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)29 Partner (com.axelor.apps.base.db.Partner)27 InvoiceRepository (com.axelor.apps.account.db.repo.InvoiceRepository)22 InvoiceService (com.axelor.apps.account.service.invoice.InvoiceService)22 PaymentMode (com.axelor.apps.account.db.PaymentMode)21 Map (java.util.Map)21 List (java.util.List)20 StockMove (com.axelor.apps.stock.db.StockMove)19 RefundInvoice (com.axelor.apps.account.service.invoice.generator.invoice.RefundInvoice)18 MoveLine (com.axelor.apps.account.db.MoveLine)17 LocalDate (java.time.LocalDate)17 InvoiceGenerator (com.axelor.apps.account.service.invoice.generator.InvoiceGenerator)16 Context (com.axelor.rpc.Context)15 InvoicePayment (com.axelor.apps.account.db.InvoicePayment)14