use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class StockMoveLineStockRepository method copy.
@Override
public StockMoveLine copy(StockMoveLine entity, boolean deep) {
StockMoveLine copy = super.copy(entity, deep);
copy.setStockMove(null);
copy.setPlannedStockMove(null);
return copy;
}
use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class StockMoveLineStockRepository method populate.
@Override
public Map<String, Object> populate(Map<String, Object> json, Map<String, Object> context) {
Long stockMoveLineId = (Long) json.get("id");
StockMoveLine stockMoveLine = find(stockMoveLineId);
StockMove stockMove = stockMoveLine.getStockMove();
if (stockMove == null || (stockMove.getFromStockLocation() != null && stockMove.getFromStockLocation().getTypeSelect() == StockLocationRepository.TYPE_VIRTUAL)) {
return super.populate(json, context);
}
if (stockMove.getStatusSelect() < StockMoveRepository.STATUS_REALIZED) {
Beans.get(StockMoveLineService.class).setAvailableStatus(stockMoveLine);
json.put("availableStatus", stockMoveLine.getProduct() != null && stockMoveLine.getProduct().getStockManaged() ? stockMoveLine.getAvailableStatus() : null);
json.put("availableStatusSelect", stockMoveLine.getAvailableStatusSelect());
}
return super.populate(json, context);
}
use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class StockMoveManagementRepository method populate.
@Override
public Map<String, Object> populate(Map<String, Object> json, Map<String, Object> context) {
Long stockMoveId = (Long) json.get("id");
StockMove stockMove = find(stockMoveId);
if (stockMove.getStatusSelect() > STATUS_PLANNED || stockMove.getStockMoveLineList() == null || (stockMove.getFromStockLocation() != null && stockMove.getFromStockLocation().getTypeSelect() == StockLocationRepository.TYPE_VIRTUAL)) {
return super.populate(json, context);
}
int available = 0, availableForProduct = 0, missing = 0;
for (StockMoveLine stockMoveLine : stockMove.getStockMoveLineList()) {
if (stockMoveLine != null && stockMoveLine.getProduct() != null && stockMoveLine.getProduct().getProductTypeSelect() != null && stockMoveLine.getProduct().getProductTypeSelect().equals(ProductRepository.PRODUCT_TYPE_SERVICE)) {
continue;
}
Beans.get(StockMoveLineService.class).updateAvailableQty(stockMoveLine, stockMove.getFromStockLocation());
Product product = stockMoveLine.getProduct();
if (stockMoveLine.getAvailableQty().compareTo(stockMoveLine.getRealQty()) >= 0 || product != null && !product.getStockManaged()) {
available++;
} else if (stockMoveLine.getAvailableQtyForProduct().compareTo(stockMoveLine.getRealQty()) >= 0) {
availableForProduct++;
} else if (stockMoveLine.getAvailableQty().compareTo(stockMoveLine.getRealQty()) < 0 && stockMoveLine.getAvailableQtyForProduct().compareTo(stockMoveLine.getRealQty()) < 0) {
missing++;
}
}
if ((available > 0 || availableForProduct > 0) && missing == 0) {
json.put("availableStatusSelect", StockMoveRepository.STATUS_AVAILABLE);
} else if ((available > 0 || availableForProduct > 0) && missing > 0) {
json.put("availableStatusSelect", StockMoveRepository.STATUS_PARTIALLY_AVAILABLE);
} else if (available == 0 && availableForProduct == 0 && missing > 0) {
json.put("availableStatusSelect", StockMoveRepository.STATUS_UNAVAILABLE);
}
return super.populate(json, context);
}
use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class PartnerProductQualityRatingServiceImpl method calculate.
@Override
@Transactional(rollbackOn = { Exception.class })
public void calculate(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();
PartnerProductQualityRating partnerProductQualityRating = searchPartnerProductQualityRating(partner, product).orElseGet(() -> createPartnerProductQualityRating(partner, product));
updatePartnerProductQualityRating(partnerProductQualityRating, stockMoveLine);
}
}
updateSupplier(partner);
}
use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class StockMoveLineController method updateRealQty.
public List<StockMoveLine> updateRealQty(List<StockMoveLine> moveLines, BigDecimal oldKitQty, BigDecimal newKitQty, boolean isRealQty) {
BigDecimal qty = BigDecimal.ZERO;
int scale = appBaseService.getNbDecimalDigitForQty();
if (moveLines != null) {
if (newKitQty.compareTo(BigDecimal.ZERO) != 0) {
for (StockMoveLine line : moveLines) {
qty = (line.getRealQty().divide(oldKitQty, scale, RoundingMode.HALF_UP)).multiply(newKitQty);
line.setRealQty(qty.setScale(scale, RoundingMode.HALF_UP));
}
} else {
for (StockMoveLine line : moveLines) {
line.setRealQty(qty.setScale(scale, RoundingMode.HALF_UP));
}
}
}
return moveLines;
}
Aggregations