use of com.axelor.apps.base.db.ProductMultipleQty in project axelor-open-suite by axelor.
the class MrpServiceImpl method computeMultipleProductsPurchaseReorderQty.
protected BigDecimal computeMultipleProductsPurchaseReorderQty(Product product, BigDecimal reorderQty) {
List<ProductMultipleQty> productMultipleQtyList = product.getPurchaseProductMultipleQtyList();
if (productMultipleQtyList == null || reorderQty == null || reorderQty.signum() == 0) {
return reorderQty;
}
BigDecimal diff = productMultipleQtyList.stream().map(ProductMultipleQty::getMultipleQty).filter(bigDecimal -> bigDecimal.signum() != 0).map(bigDecimal -> {
BigDecimal remainder = reorderQty.remainder(bigDecimal);
return remainder.signum() == 0 ? BigDecimal.ZERO : bigDecimal.subtract(remainder);
}).min(Comparator.naturalOrder()).orElse(BigDecimal.ZERO);
return reorderQty.add(diff);
}
Aggregations