Search in sources :

Example 31 with Product

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

the class CostSheetServiceImpl method _computeToConsumeProduct.

protected void _computeToConsumeProduct(Company company, BillOfMaterial billOfMaterial, int bomLevel, CostSheetLine parentCostSheetLine, int origin, UnitCostCalculation unitCostCalculation) throws AxelorException {
    if (billOfMaterial.getBillOfMaterialSet() != null) {
        for (BillOfMaterial billOfMaterialLine : billOfMaterial.getBillOfMaterialSet()) {
            Product product = billOfMaterialLine.getProduct();
            if (product != null) {
                CostSheetLine costSheetLine = costSheetLineService.createConsumedProductCostSheetLine(company, product, billOfMaterialLine.getUnit(), bomLevel, parentCostSheetLine, billOfMaterialLine.getQty(), origin, unitCostCalculation);
                BigDecimal wasteRate = billOfMaterialLine.getWasteRate();
                if (wasteRate != null && wasteRate.compareTo(BigDecimal.ZERO) > 0) {
                    costSheetLineService.createConsumedProductWasteCostSheetLine(company, product, billOfMaterialLine.getUnit(), bomLevel, parentCostSheetLine, billOfMaterialLine.getQty(), wasteRate, origin, unitCostCalculation);
                }
                if (billOfMaterialLine.getDefineSubBillOfMaterial()) {
                    this._computeCostPrice(company, billOfMaterialLine, bomLevel, costSheetLine, origin, unitCostCalculation);
                }
            }
        }
    }
}
Also used : BillOfMaterial(com.axelor.apps.production.db.BillOfMaterial) CostSheetLine(com.axelor.apps.production.db.CostSheetLine) ProdProduct(com.axelor.apps.production.db.ProdProduct) Product(com.axelor.apps.base.db.Product) ProdResidualProduct(com.axelor.apps.production.db.ProdResidualProduct) BigDecimal(java.math.BigDecimal)

Example 32 with Product

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

the class UnitCostCalculationServiceImpl method calculationProcess.

protected void calculationProcess(UnitCostCalculation unitCostCalculation) throws AxelorException {
    for (int level = this.getMaxLevel(); level >= 0; level--) {
        for (Product product : this.getProductList(level)) {
            this.calculationProductProcess(unitCostCalculationRepository.find(unitCostCalculation.getId()), productRepository.find(product.getId()));
            JPA.clear();
        }
    }
}
Also used : Product(com.axelor.apps.base.db.Product)

Example 33 with Product

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

the class ProductController method openProductTree.

public void openProductTree(ActionRequest request, ActionResponse response) {
    Product product = request.getContext().asType(Product.class);
    product = Beans.get(ProductRepository.class).find(product.getId());
    TempBomTree tempBomTree = Beans.get(BillOfMaterialService.class).generateTree(product.getDefaultBillOfMaterial(), true);
    response.setView(ActionView.define(I18n.get("Bill of materials")).model(TempBomTree.class.getName()).add("tree", "bill-of-material-tree").context("_tempBomTreeId", tempBomTree.getId()).map());
}
Also used : TempBomTree(com.axelor.apps.production.db.TempBomTree) BillOfMaterialService(com.axelor.apps.production.service.BillOfMaterialService) Product(com.axelor.apps.base.db.Product)

Example 34 with Product

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

the class ProductionProjectedStockController method showMissingQuantityOfProduct.

public void showMissingQuantityOfProduct(ActionRequest request, ActionResponse response) {
    Map<String, Long> mapId = Beans.get(ProjectedStockService.class).getProductIdCompanyIdStockLocationIdFromContext(request.getContext());
    if (mapId == null || mapId.get("productId") == 0L) {
        return;
    }
    Long productId = mapId.get("productId");
    Long companyId = mapId.get("companyId");
    Long stockLocationId = mapId.get("stockLocationId");
    String domain = Beans.get(ManufOrderService.class).getConsumeAndMissingQtyForAProduct(productId, companyId, stockLocationId);
    Product product = Beans.get(ProductRepository.class).find(mapId.get("productId"));
    String title = I18n.get(VIEW_MISSING_QTY_TITLE);
    title = String.format(title, product.getName());
    response.setView(ActionView.define(title).model(StockMoveLine.class.getName()).add("grid", "stock-move-line-consumed-manuf-order-grid").add("form", "stock-move-line-form").domain(domain).param("popup", "true").param("popup-save", "false").map());
}
Also used : ManufOrderService(com.axelor.apps.production.service.manuforder.ManufOrderService) ProjectedStockService(com.axelor.apps.supplychain.service.ProjectedStockService) ProductRepository(com.axelor.apps.base.db.repo.ProductRepository) Product(com.axelor.apps.base.db.Product)

Example 35 with Product

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

the class ProductionProjectedStockController method showBuildingQuantityOfProduct.

public void showBuildingQuantityOfProduct(ActionRequest request, ActionResponse response) {
    Map<String, Long> mapId = Beans.get(ProjectedStockService.class).getProductIdCompanyIdStockLocationIdFromContext(request.getContext());
    if (mapId == null || mapId.get("productId") == 0L) {
        return;
    }
    Long productId = mapId.get("productId");
    Long companyId = mapId.get("companyId");
    Long stockLocationId = mapId.get("stockLocationId");
    String domain = Beans.get(ManufOrderService.class).getBuildingQtyForAProduct(productId, companyId, stockLocationId);
    Product product = Beans.get(ProductRepository.class).find(mapId.get("productId"));
    String title = I18n.get(VIEW_BUILDING_QTY_TITLE);
    title = String.format(title, product.getName());
    response.setView(ActionView.define(title).model(StockMoveLine.class.getName()).add("grid", "stock-move-line-produced-manuf-order-grid").add("form", "stock-move-line-form").domain(domain).param("popup", "true").param("popup-save", "false").map());
}
Also used : ManufOrderService(com.axelor.apps.production.service.manuforder.ManufOrderService) ProjectedStockService(com.axelor.apps.supplychain.service.ProjectedStockService) ProductRepository(com.axelor.apps.base.db.repo.ProductRepository) Product(com.axelor.apps.base.db.Product)

Aggregations

Product (com.axelor.apps.base.db.Product)189 BigDecimal (java.math.BigDecimal)91 AxelorException (com.axelor.exception.AxelorException)70 Transactional (com.google.inject.persist.Transactional)45 ArrayList (java.util.ArrayList)38 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)33 Company (com.axelor.apps.base.db.Company)24 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)24 Unit (com.axelor.apps.base.db.Unit)23 ProductRepository (com.axelor.apps.base.db.repo.ProductRepository)23 HashMap (java.util.HashMap)20 BillOfMaterial (com.axelor.apps.production.db.BillOfMaterial)19 StockLocation (com.axelor.apps.stock.db.StockLocation)19 List (java.util.List)19 ProdProduct (com.axelor.apps.production.db.ProdProduct)18 StockLocationLine (com.axelor.apps.stock.db.StockLocationLine)18 LocalDate (java.time.LocalDate)18 PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)16 StockMove (com.axelor.apps.stock.db.StockMove)16 Map (java.util.Map)16