use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.
the class PurchaseOrderPrintServiceImpl method prepareReportSettings.
public ReportSettings prepareReportSettings(PurchaseOrder purchaseOrder, String formatPdf) throws AxelorException {
if (purchaseOrder.getPrintingSettings() == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, String.format(I18n.get(IExceptionMessage.PURCHASE_ORDER_MISSING_PRINTING_SETTINGS), purchaseOrder.getPurchaseOrderSeq()), purchaseOrder);
}
String locale = ReportSettings.getPrintingLocale(purchaseOrder.getSupplierPartner());
String title = getFileName(purchaseOrder);
AppBase appBase = appBaseService.getAppBase();
ReportSettings reportSetting = ReportFactory.createReport(IReport.PURCHASE_ORDER, title + " - ${date}");
return reportSetting.addParam("PurchaseOrderId", purchaseOrder.getId()).addParam("Timezone", purchaseOrder.getCompany() != null ? purchaseOrder.getCompany().getTimezone() : null).addParam("Locale", locale).addParam("GroupProducts", appBase.getIsRegroupProductsOnPrintings() && purchaseOrder.getGroupProductsOnPrintings()).addParam("GroupProductTypes", appBase.getRegroupProductsTypeSelect()).addParam("GroupProductLevel", appBase.getRegroupProductsLevelSelect()).addParam("GroupProductProductTitle", appBase.getRegroupProductsLabelProducts()).addParam("GroupProductServiceTitle", appBase.getRegroupProductsLabelServices()).addParam("HeaderHeight", purchaseOrder.getPrintingSettings().getPdfHeaderHeight()).addParam("FooterHeight", purchaseOrder.getPrintingSettings().getPdfFooterHeight()).addFormat(formatPdf);
}
use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.
the class UserServiceImpl method processChangedPassword.
@Override
@Transactional(rollbackOn = { Exception.class })
public void processChangedPassword(User user) throws ClassNotFoundException, InstantiationException, IllegalAccessException, MessagingException, IOException, AxelorException, JSONException {
Preconditions.checkNotNull(user, I18n.get("User cannot be null."));
try {
if (!user.getSendEmailUponPasswordChange()) {
return;
}
if (user.equals(AuthUtils.getUser())) {
logger.debug("User {} changed own password.", user.getCode());
return;
}
AppBase appBase = Beans.get(AppBaseService.class).getAppBase();
Template template = appBase.getPasswordChangedTemplate();
if (template == null) {
throw new AxelorException(appBase, TraceBackRepository.CATEGORY_NO_VALUE, I18n.get("Template for changed password is missing."));
}
TemplateMessageService templateMessageService = Beans.get(TemplateMessageService.class);
templateMessageService.generateAndSendMessage(user, template);
} finally {
user.setTransientPassword(null);
}
}
use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.
the class UserHrServiceImpl method createEmployee.
@Transactional
public void createEmployee(User user) {
if (user.getPartner() == null) {
Beans.get(UserService.class).createPartner(user);
}
AppBase appBase = appHumanResourceService.getAppBase();
AppLeave appLeave = appHumanResourceService.getAppLeave();
Employee employee = new Employee();
employee.setContactPartner(user.getPartner());
employee.setTimeLoggingPreferenceSelect(appBase.getTimeLoggingPreferenceSelect());
employee.setDailyWorkHours(appBase.getDailyWorkHours());
employee.setNegativeValueLeave(appLeave.getAllowNegativeLeaveEmployees());
EventsPlanning planning = null;
Company company = user.getActiveCompany();
if (company != null) {
HRConfig hrConfig = company.getHrConfig();
if (hrConfig != null) {
planning = hrConfig.getPublicHolidayEventsPlanning();
}
}
employee.setPublicHolidayEventsPlanning(planning);
employee.setUser(user);
Beans.get(EmployeeRepository.class).save(employee);
user.setEmployee(employee);
userRepo.save(user);
}
use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.
the class KilometricService method computeDistance.
/**
* Compute the distance between two cities.
*
* @param fromCity
* @param toCity
* @return
* @throws AxelorException
*/
protected BigDecimal computeDistance(String fromCity, String toCity) throws AxelorException {
BigDecimal distance = BigDecimal.ZERO;
if (StringUtils.isEmpty(fromCity) || StringUtils.isEmpty(toCity) || fromCity.equalsIgnoreCase(toCity))
return distance;
AppBase appBase = appBaseService.getAppBase();
try {
switch(appBase.getMapApiSelect()) {
case AppBaseRepository.MAP_API_GOOGLE:
distance = this.getDistanceUsingGoogle(fromCity, toCity);
break;
case AppBaseRepository.MAP_API_OPEN_STREET_MAP:
distance = this.getDistanceUsingOSM(fromCity, toCity);
break;
}
return distance;
} catch (URISyntaxException | IOException | JSONException e) {
throw new AxelorException(e, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR);
}
}
use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.
the class CompanyServiceImpl method checkMultiBanks.
/**
* {@inheritDoc}
*/
@Override
public void checkMultiBanks(Company company) {
if (countActiveBankDetails(company) > 1) {
AppBaseService appBaseService = Beans.get(AppBaseService.class);
AppBase appBase = appBaseService.getAppBase();
if (!appBase.getManageMultiBanks()) {
appBaseService.setManageMultiBanks(true);
}
}
}
Aggregations