Search in sources :

Example 1 with AppBase

use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.

the class AppBaseServiceImpl method getCustomStyle.

@CallMethod
@Override
public String getCustomStyle() {
    AppBase appBase = Beans.get(AppBaseRepository.class).all().fetchOne();
    String style = appBase.getCustomAppStyle();
    if (StringUtils.isBlank(style)) {
        return null;
    }
    return style;
}
Also used : AppBase(com.axelor.apps.base.db.AppBase) CallMethod(com.axelor.meta.CallMethod)

Example 2 with AppBase

use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.

the class AppBaseServiceImpl method getTodayDateTime.

public ZonedDateTime getTodayDateTime(Company company) {
    ZonedDateTime todayDateTime = ZonedDateTime.now();
    if (company != null) {
        todayDateTime = DateTool.getTodayDateTime(company.getTimezone());
    }
    String applicationMode = AppSettings.get().get("application.mode", "prod");
    if ("dev".equals(applicationMode)) {
        User user = AuthUtils.getUser();
        if (user != null && user.getToday() != null) {
            todayDateTime = user.getToday();
        } else {
            AppBase appBase = getAppBase();
            if (appBase != null && appBase.getToday() != null) {
                return appBase.getToday();
            }
        }
    }
    return todayDateTime;
}
Also used : User(com.axelor.auth.db.User) ZonedDateTime(java.time.ZonedDateTime) AppBase(com.axelor.apps.base.db.AppBase)

Example 3 with AppBase

use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.

the class AppBaseServiceImpl method getGeneralDuration.

@Override
public BigDecimal getGeneralDuration(BigDecimal duration) {
    if (duration == null) {
        return null;
    }
    AppBase appBase = getAppBase();
    if (appBase != null) {
        String timePref = appBase.getTimeLoggingPreferenceSelect();
        BigDecimal dailyWorkHrs = appBase.getDailyWorkHours();
        if (timePref.equals("days") && dailyWorkHrs != null && dailyWorkHrs.compareTo(BigDecimal.ZERO) != 0) {
            duration = duration.divide(dailyWorkHrs, 2, RoundingMode.HALF_UP);
        } else if (timePref.equals("minutes")) {
            duration = duration.multiply(new BigDecimal(60));
        }
    }
    return duration;
}
Also used : BigDecimal(java.math.BigDecimal) AppBase(com.axelor.apps.base.db.AppBase)

Example 4 with AppBase

use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.

the class ConvertLeadWizardController method setConvertLeadIntoOpportunity.

public void setConvertLeadIntoOpportunity(ActionRequest request, ActionResponse response) throws AxelorException {
    Lead lead = findLead(request);
    AppBase appBase = Beans.get(AppBaseService.class).getAppBase();
    response.setAttr("lead", "value", lead);
    response.setAttr("amount", "value", lead.getEstimatedBudget());
    response.setAttr("customerDescription", "value", lead.getDescription());
    response.setAttr("source", "value", lead.getSource());
    response.setAttr("partner", "value", lead.getPartner());
    response.setAttr("user", "value", lead.getUser());
    response.setAttr("team", "value", lead.getTeam());
    response.setAttr("webSite", "value", lead.getWebSite());
    response.setAttr("source", "value", lead.getSource());
    response.setAttr("department", "value", lead.getDepartment());
    response.setAttr("isCustomer", "value", true);
    response.setAttr("partnerTypeSelect", "value", "1");
    response.setAttr("language", "value", appBase.getDefaultPartnerLanguage());
    Company company = null;
    CompanyRepository companyRepo = Beans.get(CompanyRepository.class);
    if (lead.getUser() != null && lead.getUser().getActiveCompany() != null) {
        company = lead.getUser().getActiveCompany();
    } else if (companyRepo.all().count() == 1) {
        company = companyRepo.all().fetchOne();
    }
    if (company != null) {
        response.setAttr("company", "value", company);
        response.setAttr("currency", "value", company.getCurrency());
    }
}
Also used : Company(com.axelor.apps.base.db.Company) CompanyRepository(com.axelor.apps.base.db.repo.CompanyRepository) AppBaseService(com.axelor.apps.base.service.app.AppBaseService) Lead(com.axelor.apps.crm.db.Lead) AppBase(com.axelor.apps.base.db.AppBase)

Example 5 with AppBase

use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.

the class ConvertLeadWizardController method setPartnerDefaults.

public void setPartnerDefaults(ActionRequest request, ActionResponse response) throws AxelorException {
    Lead lead = findLead(request);
    AppBase appBase = Beans.get(AppBaseService.class).getAppBase();
    response.setAttr("name", "value", lead.getEnterpriseName());
    response.setAttr("industrySector", "value", lead.getIndustrySector());
    response.setAttr("titleSelect", "value", lead.getTitleSelect());
    response.setAttr("emailAddress", "value", lead.getEmailAddress());
    response.setAttr("mobilePhone", "value", lead.getMobilePhone());
    response.setAttr("fixedPhone", "value", lead.getFixedPhone());
    response.setAttr("webSite", "value", lead.getWebSite());
    response.setAttr("source", "value", lead.getSource());
    response.setAttr("department", "value", lead.getDepartment());
    response.setAttr("team", "value", lead.getTeam());
    response.setAttr("user", "value", lead.getUser());
    if (lead.getUser() != null) {
        if (lead.getUser().getActiveCompany().getDefaultPartnerCategorySelect() == CompanyRepository.CATEGORY_CUSTOMER) {
            response.setAttr("isCustomer", "value", true);
        } else if (lead.getUser().getActiveCompany().getDefaultPartnerCategorySelect() == CompanyRepository.CATEGORY_SUPPLIER) {
            response.setAttr("isSupplier", "value", true);
        } else {
            response.setAttr("isProspect", "value", true);
        }
    } else {
        response.setAttr("isProspect", "value", true);
    }
    response.setAttr("partnerTypeSelect", "value", "1");
    response.setAttr("language", "value", appBase.getDefaultPartnerLanguage());
    response.setAttr("nbrEmployees", "value", 0);
}
Also used : AppBaseService(com.axelor.apps.base.service.app.AppBaseService) Lead(com.axelor.apps.crm.db.Lead) AppBase(com.axelor.apps.base.db.AppBase)

Aggregations

AppBase (com.axelor.apps.base.db.AppBase)18 AxelorException (com.axelor.exception.AxelorException)8 BigDecimal (java.math.BigDecimal)5 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)4 User (com.axelor.auth.db.User)3 JSONException (wslite.json.JSONException)3 Company (com.axelor.apps.base.db.Company)2 CurrencyConversionLine (com.axelor.apps.base.db.CurrencyConversionLine)2 Lead (com.axelor.apps.crm.db.Lead)2 ReportSettings (com.axelor.apps.report.engine.ReportSettings)2 Transactional (com.google.inject.persist.Transactional)2 MalformedURLException (java.net.MalformedURLException)2 LocalDate (java.time.LocalDate)2 AppLeave (com.axelor.apps.base.db.AppLeave)1 EventsPlanning (com.axelor.apps.base.db.EventsPlanning)1 CompanyRepository (com.axelor.apps.base.db.repo.CompanyRepository)1 MapService (com.axelor.apps.base.service.MapService)1 UserService (com.axelor.apps.base.service.user.UserService)1 Employee (com.axelor.apps.hr.db.Employee)1 HRConfig (com.axelor.apps.hr.db.HRConfig)1