Search in sources :

Example 71 with AxelorException

use of com.axelor.exception.AxelorException in project axelor-open-suite by axelor.

the class ExpenseController method valid.

// validating expense and sending mail to applicant
public void valid(ActionRequest request, ActionResponse response) throws AxelorException {
    try {
        Expense expense = request.getContext().asType(Expense.class);
        expense = Beans.get(ExpenseRepository.class).find(expense.getId());
        ExpenseService expenseService = Beans.get(ExpenseService.class);
        expenseService.validate(expense);
        Message message = expenseService.sendValidationEmail(expense);
        if (message != null && message.getStatusSelect() == MessageRepository.STATUS_SENT) {
            response.setFlash(String.format(I18n.get("Email sent to %s"), Beans.get(MessageServiceBaseImpl.class).getToRecipients(message)));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    } finally {
        response.setReload(true);
    }
}
Also used : IExceptionMessage(com.axelor.apps.hr.exception.IExceptionMessage) Message(com.axelor.apps.message.db.Message) Expense(com.axelor.apps.hr.db.Expense) MessageServiceBaseImpl(com.axelor.apps.base.service.message.MessageServiceBaseImpl) ExpenseService(com.axelor.apps.hr.service.expense.ExpenseService) AxelorException(com.axelor.exception.AxelorException)

Example 72 with AxelorException

use of com.axelor.exception.AxelorException in project axelor-open-suite by axelor.

the class ExtraHoursController method cancel.

// canceling request and sending mail to applicant
public void cancel(ActionRequest request, ActionResponse response) throws AxelorException {
    try {
        ExtraHours extraHours = request.getContext().asType(ExtraHours.class);
        extraHours = Beans.get(ExtraHoursRepository.class).find(extraHours.getId());
        Beans.get(ExtraHoursService.class).cancel(extraHours);
        Message message = Beans.get(ExtraHoursService.class).sendCancellationEmail(extraHours);
        if (message != null && message.getStatusSelect() == MessageRepository.STATUS_SENT) {
            response.setFlash(String.format(I18n.get("Email sent to %s"), Beans.get(MessageServiceBaseImpl.class).getToRecipients(message)));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    } finally {
        response.setReload(true);
    }
}
Also used : ExtraHours(com.axelor.apps.hr.db.ExtraHours) Message(com.axelor.apps.message.db.Message) MessageServiceBaseImpl(com.axelor.apps.base.service.message.MessageServiceBaseImpl) ExtraHoursService(com.axelor.apps.hr.service.extra.hours.ExtraHoursService) AxelorException(com.axelor.exception.AxelorException)

Example 73 with AxelorException

use of com.axelor.exception.AxelorException in project axelor-open-suite by axelor.

the class ExtraHoursController method refuse.

// refusing request and sending mail to applicant
public void refuse(ActionRequest request, ActionResponse response) throws AxelorException {
    try {
        ExtraHours extraHours = request.getContext().asType(ExtraHours.class);
        extraHours = Beans.get(ExtraHoursRepository.class).find(extraHours.getId());
        Beans.get(ExtraHoursService.class).refuse(extraHours);
        Message message = Beans.get(ExtraHoursService.class).sendRefusalEmail(extraHours);
        if (message != null && message.getStatusSelect() == MessageRepository.STATUS_SENT) {
            response.setFlash(String.format(I18n.get("Email sent to %s"), Beans.get(MessageServiceBaseImpl.class).getToRecipients(message)));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    } finally {
        response.setReload(true);
    }
}
Also used : ExtraHours(com.axelor.apps.hr.db.ExtraHours) Message(com.axelor.apps.message.db.Message) MessageServiceBaseImpl(com.axelor.apps.base.service.message.MessageServiceBaseImpl) ExtraHoursService(com.axelor.apps.hr.service.extra.hours.ExtraHoursService) AxelorException(com.axelor.exception.AxelorException)

Example 74 with AxelorException

use of com.axelor.exception.AxelorException in project axelor-open-suite by axelor.

the class LeaveController method refuse.

/**
 * Refuses leave request and sends an email to the applicant.
 *
 * @param request
 * @param response
 * @throws AxelorException
 */
public void refuse(ActionRequest request, ActionResponse response) throws AxelorException {
    try {
        LeaveService leaveService = Beans.get(LeaveService.class);
        LeaveRequest leaveRequest = request.getContext().asType(LeaveRequest.class);
        leaveRequest = Beans.get(LeaveRequestRepository.class).find(leaveRequest.getId());
        leaveService.refuse(leaveRequest);
        Message message = leaveService.sendRefusalEmail(leaveRequest);
        if (message != null && message.getStatusSelect() == MessageRepository.STATUS_SENT) {
            response.setFlash(String.format(I18n.get("Email sent to %s"), Beans.get(MessageServiceBaseImpl.class).getToRecipients(message)));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    } finally {
        response.setReload(true);
    }
}
Also used : IExceptionMessage(com.axelor.apps.hr.exception.IExceptionMessage) Message(com.axelor.apps.message.db.Message) LeaveService(com.axelor.apps.hr.service.leave.LeaveService) MessageServiceBaseImpl(com.axelor.apps.base.service.message.MessageServiceBaseImpl) LeaveRequest(com.axelor.apps.hr.db.LeaveRequest) AxelorException(com.axelor.exception.AxelorException)

Example 75 with AxelorException

use of com.axelor.exception.AxelorException in project axelor-open-suite by axelor.

the class PickingStockMovePrintServiceimpl method prepareReportSettings.

@Override
public ReportSettings prepareReportSettings(StockMove stockMove, String format) throws AxelorException {
    if (stockMove.getPrintingSettings() == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, String.format(I18n.get(IExceptionMessage.STOCK_MOVES_MISSING_PRINTING_SETTINGS), stockMove.getStockMoveSeq()), stockMove);
    }
    String locale = ReportSettings.getPrintingLocale(stockMove.getPartner());
    String title = getFileName(stockMove);
    ReportSettings reportSetting = ReportFactory.createReport(IReport.PICKING_STOCK_MOVE, title + " - ${date}");
    return reportSetting.addParam("StockMoveId", stockMove.getId()).addParam("Timezone", stockMove.getCompany() != null ? stockMove.getCompany().getTimezone() : null).addParam("Locale", locale).addParam("HeaderHeight", stockMove.getPrintingSettings().getPdfHeaderHeight()).addParam("FooterHeight", stockMove.getPrintingSettings().getPdfFooterHeight()).addFormat(format);
}
Also used : AxelorException(com.axelor.exception.AxelorException) ReportSettings(com.axelor.apps.report.engine.ReportSettings)

Aggregations

AxelorException (com.axelor.exception.AxelorException)546 Transactional (com.google.inject.persist.Transactional)126 BigDecimal (java.math.BigDecimal)118 ArrayList (java.util.ArrayList)84 IOException (java.io.IOException)73 Product (com.axelor.apps.base.db.Product)64 Company (com.axelor.apps.base.db.Company)63 LocalDate (java.time.LocalDate)58 Partner (com.axelor.apps.base.db.Partner)48 List (java.util.List)45 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)40 HashMap (java.util.HashMap)38 Invoice (com.axelor.apps.account.db.Invoice)33 StockMove (com.axelor.apps.stock.db.StockMove)32 Map (java.util.Map)31 Beans (com.axelor.inject.Beans)30 I18n (com.axelor.i18n.I18n)28 Inject (com.google.inject.Inject)28 MoveLine (com.axelor.apps.account.db.MoveLine)27 Context (com.axelor.rpc.Context)27