use of com.axelor.apps.stock.db.Inventory in project axelor-open-suite by axelor.
the class InventoryController method setInventorySequence.
public void setInventorySequence(ActionRequest request, ActionResponse response) {
try {
Inventory inventory = request.getContext().asType(Inventory.class);
SequenceService sequenceService = Beans.get(SequenceService.class);
if (sequenceService.isEmptyOrDraftSequenceNumber(inventory.getInventorySeq())) {
StockLocation stockLocation = inventory.getStockLocation();
response.setValue("inventorySeq", Beans.get(InventoryService.class).getInventorySequence(stockLocation.getCompany()));
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.stock.db.Inventory in project axelor-open-suite by axelor.
the class InventoryController method showStockMoves.
public void showStockMoves(ActionRequest request, ActionResponse response) {
try {
Inventory inventory = request.getContext().asType(Inventory.class);
List<StockMove> stockMoveList = Beans.get(InventoryService.class).findStockMoves(inventory);
ActionViewBuilder builder = ActionView.define(I18n.get("Internal Stock Moves")).model(StockMove.class.getName()).add("grid", "stock-move-grid").add("form", "stock-move-form").param("search-filters", "internal-stock-move-filters");
if (stockMoveList.isEmpty()) {
response.setFlash(I18n.get("No stock moves found for this inventory."));
} else {
builder.context("_showSingle", true).domain(String.format("self.originTypeSelect = '%s' AND self.originId = %s", StockMoveRepository.ORIGIN_INVENTORY, inventory.getId()));
response.setView(builder.map());
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.stock.db.Inventory in project axelor-open-suite by axelor.
the class InventoryController method importFile.
public void importFile(ActionRequest request, ActionResponse response) {
try {
Inventory inventory = Beans.get(InventoryRepository.class).find(request.getContext().asType(Inventory.class).getId());
Path filePath = Beans.get(InventoryService.class).importFile(inventory);
response.setFlash(String.format(I18n.get(IExceptionMessage.INVENTORY_8), filePath.toString()));
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.stock.db.Inventory in project axelor-open-suite by axelor.
the class ImportInventory method validateInventory.
@Transactional(rollbackOn = { Exception.class })
public Object validateInventory(Object bean, Map<String, Object> values) throws AxelorException {
assert bean instanceof InventoryLine;
Inventory inventory = (Inventory) bean;
inventoryService.validateInventory(inventory);
return inventory;
}
use of com.axelor.apps.stock.db.Inventory in project axelor-open-suite by axelor.
the class InventoryService method fillInventoryLineList.
@Transactional(rollbackOn = { Exception.class })
public Boolean fillInventoryLineList(Inventory inventory) throws AxelorException {
if (inventory.getStockLocation() == null) {
throw new AxelorException(inventory, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.INVENTORY_1));
}
this.initInventoryLines(inventory);
List<? extends StockLocationLine> stockLocationLineList = this.getStockLocationLines(inventory);
if (stockLocationLineList != null) {
Boolean succeed = false;
for (StockLocationLine stockLocationLine : stockLocationLineList) {
if (stockLocationLine.getTrackingNumber() == null) {
// if no tracking number on stockLocationLine, check if there is a tracking
// number on the product
long numberOfTrackingNumberOnAProduct = stockLocationLineList.stream().filter(sll -> stockLocationLine.getProduct() != null && stockLocationLine.getProduct().equals(sll.getProduct()) && sll.getTrackingNumber() != null && inventory.getStockLocation().equals(sll.getDetailsStockLocation())).count();
if (numberOfTrackingNumberOnAProduct != 0) {
// there is a tracking number on the product
continue;
}
}
inventory.addInventoryLineListItem(this.createInventoryLine(inventory, stockLocationLine));
succeed = true;
}
inventoryRepo.save(inventory);
return succeed;
}
return null;
}
Aggregations