Search in sources :

Example 31 with Invoice

use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.

the class InvoiceController method fillAdvancePaymentInvoiceSet.

/**
 * Called on partner and currency change, fill the domain of the field {@link
 * Invoice#advancePaymentInvoiceSet} with default values. The default values are every invoices
 * found in the domain.
 *
 * @param request
 * @param response
 */
public void fillAdvancePaymentInvoiceSet(ActionRequest request, ActionResponse response) {
    Invoice invoice = request.getContext().asType(Invoice.class);
    try {
        Set<Invoice> invoices = Beans.get(InvoiceService.class).getDefaultAdvancePaymentInvoice(invoice);
        response.setValue("advancePaymentInvoiceSet", invoices);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) InvoiceService(com.axelor.apps.account.service.invoice.InvoiceService) AxelorException(com.axelor.exception.AxelorException)

Example 32 with Invoice

use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.

the class InvoiceController method fillAdvancePaymentInvoiceSetDomain.

/**
 * Called on load and on new, create the domain for the field {@link
 * Invoice#advancePaymentInvoiceSet}
 *
 * @param request
 * @param response
 */
public void fillAdvancePaymentInvoiceSetDomain(ActionRequest request, ActionResponse response) {
    Invoice invoice = request.getContext().asType(Invoice.class);
    try {
        String domain = Beans.get(InvoiceService.class).createAdvancePaymentInvoiceSetDomain(invoice);
        response.setAttr("advancePaymentInvoiceSet", "domain", domain);
    } catch (Exception e) {
        TraceBackService.trace(e);
        response.setError(e.getMessage());
    }
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) InvoiceService(com.axelor.apps.account.service.invoice.InvoiceService) AxelorException(com.axelor.exception.AxelorException)

Example 33 with Invoice

use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.

the class InvoiceController method checkNotImputedRefunds.

public void checkNotImputedRefunds(ActionRequest request, ActionResponse response) {
    Invoice invoice = request.getContext().asType(Invoice.class);
    invoice = Beans.get(InvoiceRepository.class).find(invoice.getId());
    try {
        String msg = Beans.get(InvoiceService.class).checkNotImputedRefunds(invoice);
        if (msg != null) {
            response.setFlash(msg);
        }
    } catch (AxelorException e) {
        TraceBackService.trace(response, e);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) Invoice(com.axelor.apps.account.db.Invoice) InvoiceService(com.axelor.apps.account.service.invoice.InvoiceService)

Example 34 with Invoice

use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.

the class InvoiceController method cancel.

/**
 * Passe l'état de la facture à "annulée"
 *
 * @param request
 * @param response
 * @throws AxelorException
 */
public void cancel(ActionRequest request, ActionResponse response) throws AxelorException {
    Invoice invoice = request.getContext().asType(Invoice.class);
    invoice = Beans.get(InvoiceRepository.class).find(invoice.getId());
    if (invoice.getStatusSelect() == InvoiceRepository.STATUS_VENTILATED && invoice.getCompany().getAccountConfig() != null && !invoice.getCompany().getAccountConfig().getAllowCancelVentilatedInvoice()) {
        response.setError(I18n.get(IExceptionMessage.INVOICE_CAN_NOT_GO_BACK_TO_VALIDATE_STATUS_OR_CANCEL_VENTILATED_INVOICE));
        return;
    }
    Beans.get(InvoiceService.class).cancel(invoice);
    response.setFlash(I18n.get(IExceptionMessage.INVOICE_1));
    response.setReload(true);
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) InvoiceService(com.axelor.apps.account.service.invoice.InvoiceService)

Example 35 with Invoice

use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.

the class InvoiceController method setPfpValidatorUser.

public void setPfpValidatorUser(ActionRequest request, ActionResponse response) {
    Invoice invoice = request.getContext().asType(Invoice.class);
    response.setValue("pfpValidatorUser", Beans.get(InvoiceService.class).getPfpValidatorUser(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