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++));
}
}
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));
}
}
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));
}
}
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);
}
}
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);
}
Aggregations