Search in sources :

Example 6 with I_M_ShipmentSchedule

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;
}
Also used : IPackagingDAO(de.metas.inoutcandidate.api.IPackagingDAO) I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) I_M_ShipmentSchedule(de.metas.handlingunits.model.I_M_ShipmentSchedule) BigDecimal(java.math.BigDecimal)

Example 7 with I_M_ShipmentSchedule

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();
}
Also used : MatchingSourceHusQueryBuilder(de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery.MatchingSourceHusQueryBuilder) I_M_ShipmentSchedule(de.metas.handlingunits.model.I_M_ShipmentSchedule) IShipmentScheduleEffectiveBL(de.metas.inoutcandidate.api.IShipmentScheduleEffectiveBL) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

I_M_ShipmentSchedule (de.metas.handlingunits.model.I_M_ShipmentSchedule)7 Test (org.junit.Test)3 IPackagingDAO (de.metas.inoutcandidate.api.IPackagingDAO)2 I_M_PickingSlot (de.metas.picking.model.I_M_PickingSlot)2 BigDecimal (java.math.BigDecimal)2 Expectations (mockit.Expectations)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)1 ListMultimap (com.google.common.collect.ListMultimap)1 I_M_Product (de.metas.adempiere.model.I_M_Product)1 I_M_HU_PI_Item_Product (de.metas.handlingunits.model.I_M_HU_PI_Item_Product)1 I_M_Warehouse (de.metas.handlingunits.model.I_M_Warehouse)1 MatchingSourceHusQuery (de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery)1 MatchingSourceHusQueryBuilder (de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery.MatchingSourceHusQueryBuilder)1 IShipmentScheduleEffectiveBL (de.metas.inoutcandidate.api.IShipmentScheduleEffectiveBL)1 PickedHUEditorRow (de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow)1 ProcessParamLookupValuesProvider (de.metas.ui.web.process.descriptor.ProcessParamLookupValuesProvider)1 NullLookupDataSource (de.metas.ui.web.window.model.lookup.NullLookupDataSource)1 Properties (java.util.Properties)1