use of de.metas.handlingunits.model.I_M_ShipmentSchedule in project metasfresh-webui-api by metasfresh.
the class WEBUI_Picking_PickQtyToNewHU method getParameterDefaultValue.
/**
* Returns the {@code qtyToDeliver} value of the currently selected shipment schedule, or {@code null}.
*/
@Override
public Object getParameterDefaultValue(@NonNull final IProcessDefaultParameter parameter) {
if (Objects.equals(PARAM_QTY_CU, parameter.getColumnName())) {
// can't be null
final I_M_ShipmentSchedule shipmentSchedule = getView().getCurrentShipmentSchedule();
final BigDecimal qtyPickedPlanned = Services.get(IPackagingDAO.class).retrieveQtyPickedPlannedOrNull(shipmentSchedule);
if (qtyPickedPlanned == null) {
return BigDecimal.ZERO;
}
final BigDecimal qtyToPick = shipmentSchedule.getQtyToDeliver().subtract(qtyPickedPlanned);
return qtyToPick.signum() > 0 ? qtyToPick : BigDecimal.ZERO;
} else if (Objects.equals(PARAM_M_HU_PI_Item_Product_ID, parameter.getColumnName())) {
final I_M_ShipmentSchedule shipmentSchedule = getView().getCurrentShipmentSchedule();
final I_M_HU_PI_Item_Product huPIItemProduct = shipmentSchedule.getM_HU_PI_Item_Product();
if (huPIItemProduct == null) {
return IProcessDefaultParametersProvider.DEFAULT_VALUE_NOTAVAILABLE;
}
return IntegerLookupValue.of(huPIItemProduct.getM_HU_PI_Item_Product_ID(), huPIItemProduct.getName());
}
return DEFAULT_VALUE_NOTAVAILABLE;
}
use of de.metas.handlingunits.model.I_M_ShipmentSchedule in project metasfresh-webui-api by metasfresh.
the class PickingHURowsRepository method createMatchingSourceHusQuery.
@VisibleForTesting
static MatchingSourceHusQuery createMatchingSourceHusQuery(@NonNull final PickingSlotRepoQuery query) {
final I_M_ShipmentSchedule currentShipmentSchedule = query.getCurrentShipmentScheduleId() > 0 ? load(query.getCurrentShipmentScheduleId(), I_M_ShipmentSchedule.class) : null;
final List<Integer> productIds;
final Set<Integer> allShipmentScheduleIds = query.getShipmentScheduleIds();
if (allShipmentScheduleIds.isEmpty()) {
productIds = ImmutableList.of();
} else if (allShipmentScheduleIds.size() == 1) {
productIds = ImmutableList.of(currentShipmentSchedule.getM_Product_ID());
} else {
productIds = Services.get(IQueryBL.class).createQueryBuilder(I_M_ShipmentSchedule.class).addInArrayFilter(I_M_ShipmentSchedule.COLUMNNAME_M_ShipmentSchedule_ID, allShipmentScheduleIds).create().listDistinct(I_M_ShipmentSchedule.COLUMNNAME_M_Product_ID, Integer.class);
}
final MatchingSourceHusQueryBuilder builder = MatchingSourceHusQuery.builder().productIds(productIds);
final IShipmentScheduleEffectiveBL shipmentScheduleEffectiveBL = Services.get(IShipmentScheduleEffectiveBL.class);
final int effectiveWarehouseId = currentShipmentSchedule != null ? shipmentScheduleEffectiveBL.getWarehouseId(currentShipmentSchedule) : -1;
builder.warehouseId(effectiveWarehouseId);
return builder.build();
}
Aggregations