use of de.metas.ui.web.material.adapter.AvailableToPromiseResultForWebui.Group in project metasfresh-webui-api by metasfresh.
the class ProductLookupDescriptor method explodeRecordsWithStockQuantities.
private final LookupValuesList explodeRecordsWithStockQuantities(@NonNull final LookupValuesList productLookupValues, @NonNull final Date dateOrNull) {
if (productLookupValues.isEmpty() || !isAvailableStockQueryActivatedInSysConfig()) {
return productLookupValues;
}
final AvailableToPromiseQueryBuilder atpQueryBuilder = AvailableToPromiseQuery.builder();
addStorageAttributeKeysToQueryBuilder(atpQueryBuilder);
atpQueryBuilder.productIds(productLookupValues.getKeysAsInt());
atpQueryBuilder.date(dateOrNull);
// invoke the query
final //
AvailableToPromiseResultForWebui availableStock = availableToPromiseAdapter.retrieveAvailableStock(atpQueryBuilder.build());
final List<Group> availableStockGroups = availableStock.getGroups();
// process the query's result into those explodedProductValues
return createLookupValuesFromAvailableStockGroups(productLookupValues, availableStockGroups);
}
use of de.metas.ui.web.material.adapter.AvailableToPromiseResultForWebui.Group in project metasfresh-webui-api by metasfresh.
the class ProductLookupDescriptor method createLookupValuesFromAvailableStockGroups.
private LookupValuesList createLookupValuesFromAvailableStockGroups(@NonNull final LookupValuesList initialLookupValues, @NonNull final List<Group> availableStockGroups) {
final boolean addOnlyPositiveATP = addOnlyPositiveATP();
final List<LookupValue> explodedProductValues = new ArrayList<>();
for (final Group availableStockGroup : availableStockGroups) {
if (addOnlyPositiveATP && availableStockGroup.getQty().signum() <= 0) {
continue;
}
final int productId = availableStockGroup.getProductId();
final LookupValue productLookupValue = initialLookupValues.getById(productId);
final ITranslatableString displayName = createDisplayName(productLookupValue.getDisplayNameTrl(), availableStockGroup);
final ImmutableMap<String, Object> attributeMap = availableStockGroup.getLookupAttributesMap();
final IntegerLookupValue integerLookupValue = IntegerLookupValue.builder().id(productId).displayName(displayName).attribute(ATTRIBUTE_ASI, attributeMap).build();
explodedProductValues.add(integerLookupValue);
}
if (explodedProductValues.isEmpty()) {
// fallback
return initialLookupValues;
}
return LookupValuesList.fromCollection(explodedProductValues);
}
use of de.metas.ui.web.material.adapter.AvailableToPromiseResultForWebui.Group in project metasfresh-webui-api by metasfresh.
the class AvailableToPromiseAdapter method retrieveAvailableStock.
@NonNull
public AvailableToPromiseResultForWebui retrieveAvailableStock(@NonNull final AvailableToPromiseQuery query) {
final //
de.metas.material.dispo.commons.repository.AvailableToPromiseResult commonsAvailableStock = stockRepository.retrieveAvailableStock(query);
final AvailableToPromiseResultForWebuiBuilder clientResultBuilder = AvailableToPromiseResultForWebui.builder();
final List<ResultGroup> commonsResultGroups = commonsAvailableStock.getResultGroups();
for (final ResultGroup commonsResultGroup : commonsResultGroups) {
final Group clientResultGroup = createClientResultGroup(commonsResultGroup);
clientResultBuilder.group(clientResultGroup);
}
return clientResultBuilder.build();
}
Aggregations