Search in sources :

Example 11 with Inventory

use of com.axelor.apps.stock.db.Inventory in project axelor-open-suite by axelor.

the class InventoryService method createInventory.

public Inventory createInventory(LocalDate plannedStartDate, LocalDate plannedEndDate, String description, StockLocation stockLocation, boolean excludeOutOfStock, boolean includeObsolete, ProductFamily productFamily, ProductCategory productCategory) throws AxelorException {
    if (stockLocation == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.INVENTORY_1));
    }
    Inventory inventory = new Inventory();
    inventory.setInventorySeq(this.getInventorySequence(stockLocation.getCompany()));
    inventory.setPlannedStartDateT(plannedStartDate.atStartOfDay(ZoneOffset.UTC));
    inventory.setPlannedEndDateT(plannedEndDate.atStartOfDay(ZoneOffset.UTC));
    inventory.setDescription(description);
    inventory.setFormatSelect(InventoryRepository.FORMAT_PDF);
    inventory.setStockLocation(stockLocation);
    inventory.setExcludeOutOfStock(excludeOutOfStock);
    inventory.setIncludeObsolete(includeObsolete);
    inventory.setProductCategory(productCategory);
    inventory.setProductFamily(productFamily);
    inventory.setStatusSelect(InventoryRepository.STATUS_DRAFT);
    return inventory;
}
Also used : AxelorException(com.axelor.exception.AxelorException) Inventory(com.axelor.apps.stock.db.Inventory)

Example 12 with Inventory

use of com.axelor.apps.stock.db.Inventory in project axelor-open-suite by axelor.

the class ImportInventory method importInventory.

public Object importInventory(Object bean, Map<String, Object> values) throws AxelorException {
    assert bean instanceof Inventory;
    Inventory inventory = (Inventory) bean;
    inventory.setInventoryTitle(inventoryService.computeTitle(inventory));
    return inventory;
}
Also used : Inventory(com.axelor.apps.stock.db.Inventory)

Example 13 with Inventory

use of com.axelor.apps.stock.db.Inventory in project axelor-open-suite by axelor.

the class InventoryController method cancel.

public void cancel(ActionRequest request, ActionResponse response) {
    try {
        Inventory inventory = request.getContext().asType(Inventory.class);
        inventory = Beans.get(InventoryRepository.class).find(inventory.getId());
        Beans.get(InventoryService.class).cancel(inventory);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : InventoryService(com.axelor.apps.stock.service.InventoryService) Inventory(com.axelor.apps.stock.db.Inventory) BirtException(org.eclipse.birt.core.exception.BirtException) NoResultException(javax.persistence.NoResultException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException)

Example 14 with Inventory

use of com.axelor.apps.stock.db.Inventory in project axelor-open-suite by axelor.

the class InventoryController method fillInventoryLineList.

public void fillInventoryLineList(ActionRequest request, ActionResponse response) {
    try {
        Long inventoryId = (Long) request.getContext().get("id");
        if (inventoryId != null) {
            Inventory inventory = Beans.get(InventoryRepository.class).find(inventoryId);
            Boolean succeed = Beans.get(InventoryService.class).fillInventoryLineList(inventory);
            if (succeed == null) {
                response.setFlash(I18n.get(IExceptionMessage.INVENTORY_9));
            } else {
                if (succeed) {
                    response.setNotify(I18n.get(IExceptionMessage.INVENTORY_10));
                } else {
                    response.setNotify(I18n.get(IExceptionMessage.INVENTORY_11));
                }
            }
        }
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : InventoryRepository(com.axelor.apps.stock.db.repo.InventoryRepository) InventoryService(com.axelor.apps.stock.service.InventoryService) Inventory(com.axelor.apps.stock.db.Inventory) BirtException(org.eclipse.birt.core.exception.BirtException) NoResultException(javax.persistence.NoResultException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException)

Example 15 with Inventory

use of com.axelor.apps.stock.db.Inventory in project axelor-open-suite by axelor.

the class InventoryController method validateInventory.

public void validateInventory(ActionRequest request, ActionResponse response) {
    try {
        Long id = request.getContext().asType(Inventory.class).getId();
        Inventory inventory = Beans.get(InventoryRepository.class).find(id);
        Beans.get(InventoryService.class).validateInventory(inventory);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : InventoryRepository(com.axelor.apps.stock.db.repo.InventoryRepository) InventoryService(com.axelor.apps.stock.service.InventoryService) Inventory(com.axelor.apps.stock.db.Inventory) BirtException(org.eclipse.birt.core.exception.BirtException) NoResultException(javax.persistence.NoResultException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException)

Aggregations

Inventory (com.axelor.apps.stock.db.Inventory)18 AxelorException (com.axelor.exception.AxelorException)12 IOException (java.io.IOException)9 NoResultException (javax.persistence.NoResultException)9 BirtException (org.eclipse.birt.core.exception.BirtException)8 InventoryService (com.axelor.apps.stock.service.InventoryService)7 InventoryLine (com.axelor.apps.stock.db.InventoryLine)5 InventoryRepository (com.axelor.apps.stock.db.repo.InventoryRepository)4 SequenceService (com.axelor.apps.base.service.administration.SequenceService)3 StockLocation (com.axelor.apps.stock.db.StockLocation)3 Product (com.axelor.apps.base.db.Product)2 StockLocationLine (com.axelor.apps.stock.db.StockLocationLine)2 StockMove (com.axelor.apps.stock.db.StockMove)2 TrackingNumber (com.axelor.apps.stock.db.TrackingNumber)2 StockLocationLineRepository (com.axelor.apps.stock.db.repo.StockLocationLineRepository)2 Beans (com.axelor.inject.Beans)2 MetaFile (com.axelor.meta.db.MetaFile)2 Transactional (com.google.inject.persist.Transactional)2 Company (com.axelor.apps.base.db.Company)1 ProductCategory (com.axelor.apps.base.db.ProductCategory)1