Search in sources :

Example 1 with Product

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

the class ProductServiceImpl method generateProductVariants.

@Override
@Transactional
public void generateProductVariants(Product productModel) throws AxelorException {
    List<ProductVariant> productVariantList = this.getProductVariantList(productModel.getProductVariantConfig());
    int seq = 1;
    List<Product> productVariantsList = productRepo.all().filter("self.parentProduct = ?1", productModel).fetch();
    if (productVariantsList != null && !productVariantsList.isEmpty()) {
        Integer lastSeq = 0;
        for (Product product : productVariantsList) {
            Integer productSeq = Integer.parseInt(StringUtils.substringAfterLast(product.getCode(), "-"));
            if (productSeq.compareTo(lastSeq) > 0) {
                lastSeq = productSeq;
            }
        }
        seq = lastSeq + 1;
    }
    for (ProductVariant productVariant : productVariantList) {
        productVariantRepo.save(productVariant);
        productRepo.save(this.createProduct(productModel, productVariant, seq++));
    }
}
Also used : Product(com.axelor.apps.base.db.Product) ProductVariant(com.axelor.apps.base.db.ProductVariant) Transactional(com.google.inject.persist.Transactional)

Example 2 with Product

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

the class ContractController method changeProduct.

public void changeProduct(ActionRequest request, ActionResponse response) {
    ContractLineService contractLineService = Beans.get(ContractLineService.class);
    ContractLine contractLine = new ContractLine();
    try {
        contractLine = request.getContext().asType(ContractLine.class);
        Contract contract = request.getContext().getParent().asType(Contract.class);
        Product product = contractLine.getProduct();
        contractLine = contractLineService.fillAndCompute(contractLine, contract, product);
        response.setValues(contractLine);
    } catch (Exception e) {
        response.setValues(contractLineService.reset(contractLine));
    }
}
Also used : ContractLine(com.axelor.apps.contract.db.ContractLine) ContractLineService(com.axelor.apps.contract.service.ContractLineService) Product(com.axelor.apps.base.db.Product) Contract(com.axelor.apps.contract.db.Contract)

Example 3 with Product

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

the class ContractVersionController method changeProduct.

public void changeProduct(ActionRequest request, ActionResponse response) {
    ContractLineService contractLineService = Beans.get(ContractLineService.class);
    ContractLine contractLine = new ContractLine();
    try {
        contractLine = request.getContext().asType(ContractLine.class);
        ContractVersion contractVersion = request.getContext().getParent().asType(ContractVersion.class);
        Contract contract = contractVersion.getNextContract() == null ? contractVersion.getContract() : contractVersion.getNextContract();
        Product product = contractLine.getProduct();
        contractLine = contractLineService.fillAndCompute(contractLine, contract, product);
        response.setValues(contractLine);
    } catch (Exception e) {
        response.setValues(contractLineService.reset(contractLine));
    }
}
Also used : ContractLine(com.axelor.apps.contract.db.ContractLine) ContractLineService(com.axelor.apps.contract.service.ContractLineService) Product(com.axelor.apps.base.db.Product) ContractVersion(com.axelor.apps.contract.db.ContractVersion) Contract(com.axelor.apps.contract.db.Contract)

Example 4 with Product

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

the class LogisticalFormServiceImpl method updateProductNetMass.

public void updateProductNetMass(LogisticalForm logisticalForm) {
    BigDecimal totalNetMass = BigDecimal.ZERO;
    if (logisticalForm.getLogisticalFormLineList() != null) {
        for (LogisticalFormLine logisticalFormLine : logisticalForm.getLogisticalFormLineList()) {
            if (logisticalFormLine.getStockMoveLine() != null && logisticalFormLine.getStockMoveLine().getProduct() != null && logisticalFormLine.getTypeSelect().equals(LogisticalFormLineRepository.TYPE_DETAIL)) {
                Product product = productRepository.find(logisticalFormLine.getStockMoveLine().getProduct().getId());
                logisticalFormLine.setUnitNetMass(product.getNetMass());
                totalNetMass = totalNetMass.add(logisticalFormLine.getQty().multiply(product.getNetMass()));
            }
        }
        logisticalForm.setTotalNetMass(totalNetMass);
    }
}
Also used : Product(com.axelor.apps.base.db.Product) LogisticalFormLine(com.axelor.apps.stock.db.LogisticalFormLine) BigDecimal(java.math.BigDecimal)

Example 5 with Product

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

the class PartnerProductQualityRatingServiceImpl method undoCalculation.

@Override
@Transactional(rollbackOn = { Exception.class })
public void undoCalculation(StockMove stockMove) throws AxelorException {
    Partner partner = stockMove.getPartner();
    if (partner == null || !partner.getIsSupplier()) {
        return;
    }
    List<StockMoveLine> stockMoveLines = stockMove.getStockMoveLineList();
    if (stockMoveLines != null) {
        for (StockMoveLine stockMoveLine : stockMoveLines) {
            Product product = stockMoveLine.getProduct();
            Optional<PartnerProductQualityRating> optional = searchPartnerProductQualityRating(partner, product);
            if (optional.isPresent()) {
                PartnerProductQualityRating partnerProductQualityRating = optional.get();
                updatePartnerProductQualityRating(partnerProductQualityRating, stockMoveLine, true);
            }
        }
    }
    updateSupplier(partner);
}
Also used : PartnerProductQualityRating(com.axelor.apps.stock.db.PartnerProductQualityRating) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Product(com.axelor.apps.base.db.Product) Partner(com.axelor.apps.base.db.Partner) Transactional(com.google.inject.persist.Transactional)

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