Search in sources :

Example 16 with Company

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

the class PrintTemplateServiceImpl method initMaker.

@SuppressWarnings("unchecked")
protected TemplateMaker initMaker(Long objectId, String model, String simpleModel, Locale locale) throws ClassNotFoundException {
    String timezone = null;
    Company activeCompany = Optional.ofNullable(AuthUtils.getUser()).map(User::getActiveCompany).orElse(null);
    if (activeCompany != null) {
        timezone = activeCompany.getTimezone();
    }
    TemplateMaker maker = new TemplateMaker(timezone, locale, TEMPLATE_DELIMITER, TEMPLATE_DELIMITER);
    Class<? extends Model> myClass = (Class<? extends Model>) Class.forName(model);
    maker.setContext(JPA.find(myClass, objectId), simpleModel);
    return maker;
}
Also used : Company(com.axelor.apps.base.db.Company) TemplateMaker(com.axelor.tool.template.TemplateMaker) Model(com.axelor.db.Model) MetaModel(com.axelor.meta.db.MetaModel)

Example 17 with Company

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

the class BatchCalendarSynchronization method process.

@Override
protected void process() {
    final Company company = batch.getBaseBatch().getCompany();
    ;
    final List<ICalendar> calendars = repo.all().filter("self.user.activeCompany = :company AND self.isValid = TRUE").bind("company", company).fetch();
    for (ICalendar calendar : calendars) {
        try {
            iCalendarService.sync(calendar, batch.getBaseBatch().getAllEvents(), batch.getBaseBatch().getSynchronizationDuration());
            incrementDone();
        } catch (Exception e) {
            e.printStackTrace();
            incrementAnomaly();
        }
    }
}
Also used : Company(com.axelor.apps.base.db.Company) ICalendar(com.axelor.apps.base.db.ICalendar)

Example 18 with Company

use of com.axelor.apps.base.db.Company 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 19 with Company

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

the class OpportunityServiceImpl method setSequence.

@Override
public void setSequence(Opportunity opportunity) throws AxelorException {
    Company company = opportunity.getCompany();
    String seq = Beans.get(SequenceService.class).getSequenceNumber(SequenceRepository.OPPORTUNITY, company);
    if (seq == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.OPPORTUNITY_1), company != null ? company.getName() : null);
    }
    opportunity.setOpportunitySeq(seq);
}
Also used : AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) SequenceService(com.axelor.apps.base.service.administration.SequenceService)

Example 20 with Company

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

the class StockCorrectionServiceImpl method generateStockMove.

public StockMove generateStockMove(StockCorrection stockCorrection) throws AxelorException {
    StockLocation toStockLocation = stockCorrection.getStockLocation();
    Company company = toStockLocation.getCompany();
    StockLocation fromStockLocation = stockConfigService.getInventoryVirtualStockLocation(stockConfigService.getStockConfig(company));
    StockMoveService stockMoveService = Beans.get(StockMoveService.class);
    StockMoveLineService stockMoveLineService = Beans.get(StockMoveLineService.class);
    StockLocationLine stockLocationLine = null;
    StockLocationLineService stockLocationLineService = Beans.get(StockLocationLineService.class);
    if (stockCorrection.getTrackingNumber() == null) {
        stockLocationLine = stockLocationLineService.getStockLocationLine(stockCorrection.getStockLocation(), stockCorrection.getProduct());
    } else {
        stockLocationLine = stockLocationLineService.getDetailLocationLine(stockCorrection.getStockLocation(), stockCorrection.getProduct(), stockCorrection.getTrackingNumber());
    }
    BigDecimal realQty = stockCorrection.getRealQty();
    Product product = stockCorrection.getProduct();
    TrackingNumber trackingNumber = stockCorrection.getTrackingNumber();
    BigDecimal diff = realQty.subtract(stockLocationLine.getCurrentQty());
    StockMove stockMove = null;
    if (diff.compareTo(BigDecimal.ZERO) == 0) {
        return null;
    } else if (diff.compareTo(BigDecimal.ZERO) > 0) {
        stockMove = this.createStockMoveHeader(company, fromStockLocation, toStockLocation);
    } else {
        stockMove = this.createStockMoveHeader(company, toStockLocation, fromStockLocation);
    }
    stockMove.setOriginTypeSelect(StockMoveRepository.ORIGIN_STOCK_CORRECTION);
    stockMove.setOriginId(stockCorrection.getId());
    stockMove.setStockCorrectionReason(stockCorrection.getStockCorrectionReason());
    BigDecimal productCostPrice = (BigDecimal) productCompanyService.get(product, "costPrice", company);
    StockMoveLine stockMoveLine = stockMoveLineService.createStockMoveLine(product, product.getName(), product.getDescription(), diff.abs(), productCostPrice, productCostPrice, product.getUnit(), stockMove, StockMoveLineService.TYPE_NULL, false, BigDecimal.ZERO);
    if (stockMoveLine == null) {
        throw new AxelorException(stockCorrection, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.STOCK_CORRECTION_1));
    }
    if (trackingNumber != null && stockMoveLine.getTrackingNumber() == null) {
        stockMoveLine.setTrackingNumber(trackingNumber);
    }
    stockMoveService.plan(stockMove);
    stockMoveService.copyQtyToRealQty(stockMove);
    stockMoveService.realize(stockMove, false);
    return stockMove;
}
Also used : AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) StockMove(com.axelor.apps.stock.db.StockMove) TrackingNumber(com.axelor.apps.stock.db.TrackingNumber) StockLocation(com.axelor.apps.stock.db.StockLocation) Product(com.axelor.apps.base.db.Product) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) StockLocationLine(com.axelor.apps.stock.db.StockLocationLine) BigDecimal(java.math.BigDecimal)

Aggregations

Company (com.axelor.apps.base.db.Company)213 Transactional (com.google.inject.persist.Transactional)72 Partner (com.axelor.apps.base.db.Partner)68 AxelorException (com.axelor.exception.AxelorException)65 BigDecimal (java.math.BigDecimal)54 Move (com.axelor.apps.account.db.Move)35 MoveLine (com.axelor.apps.account.db.MoveLine)35 LocalDate (java.time.LocalDate)35 ArrayList (java.util.ArrayList)31 PaymentMode (com.axelor.apps.account.db.PaymentMode)28 AccountConfig (com.axelor.apps.account.db.AccountConfig)27 Journal (com.axelor.apps.account.db.Journal)26 Account (com.axelor.apps.account.db.Account)25 Invoice (com.axelor.apps.account.db.Invoice)25 BankDetails (com.axelor.apps.base.db.BankDetails)22 Currency (com.axelor.apps.base.db.Currency)19 Product (com.axelor.apps.base.db.Product)17 StockLocation (com.axelor.apps.stock.db.StockLocation)17 StockMove (com.axelor.apps.stock.db.StockMove)15 List (java.util.List)15