Search in sources :

Example 16 with BPartnerId

use of de.metas.bpartner.BPartnerId in project metasfresh-webui-api by metasfresh.

the class ProductsToPickRowsDataFactory method getBestBeforePolicy.

private ShipmentAllocationBestBeforePolicy getBestBeforePolicy(final AllocablePackageable packageable) {
    final Optional<ShipmentAllocationBestBeforePolicy> bestBeforePolicy = packageable.getBestBeforePolicy();
    if (bestBeforePolicy.isPresent()) {
        return bestBeforePolicy.get();
    }
    final BPartnerId bpartnerId = packageable.getCustomerId();
    return bpartnersService.getBestBeforePolicy(bpartnerId);
}
Also used : ShipmentAllocationBestBeforePolicy(de.metas.bpartner.ShipmentAllocationBestBeforePolicy) BPartnerId(de.metas.bpartner.BPartnerId)

Example 17 with BPartnerId

use of de.metas.bpartner.BPartnerId in project metasfresh-webui-api by metasfresh.

the class PickingSlotsClearingViewFactory method createPickingSlotQuery.

private static final PickingSlotQuery createPickingSlotQuery(@NonNull final DocumentFilterList filters) {
    final PickingSlotQueryBuilder queryBuilder = PickingSlotQuery.builder();
    final BPartnerId bpartnerId = PickingSlotsClearingViewFilters.getBPartnerId(filters);
    if (bpartnerId != null) {
        queryBuilder.assignedToBPartnerId(bpartnerId);
    }
    final String barcode = PickingSlotsClearingViewFilters.getPickingSlotBarcode(filters);
    if (!Check.isEmpty(barcode, true)) {
        queryBuilder.barcode(barcode);
    }
    return queryBuilder.build();
}
Also used : BPartnerId(de.metas.bpartner.BPartnerId) PickingSlotQueryBuilder(de.metas.picking.api.PickingSlotQuery.PickingSlotQueryBuilder)

Example 18 with BPartnerId

use of de.metas.bpartner.BPartnerId in project metasfresh-webui-api by metasfresh.

the class PickingSlotsClearingViewBasedProcess method createNewHUProducer.

protected final LUTUProducerDestination createNewHUProducer(@NonNull final PickingSlotRow pickingRow, @NonNull final I_M_HU_PI targetHUPI) {
    final BPartnerId bpartnerId = BPartnerId.ofRepoIdOrNull(pickingRow.getBPartnerId());
    final int bpartnerLocationId = pickingRow.getBPartnerLocationId();
    final LocatorId locatorId = pickingRow.getPickingSlotLocatorId();
    final I_M_Locator locator = Services.get(IWarehouseDAO.class).getLocatorById(locatorId, I_M_Locator.class);
    if (!locator.isAfterPickingLocator()) {
        throw new AdempiereException("Picking slot's locator is not an after picking locator: " + locator.getValue());
    }
    final LUTUProducerDestination lutuProducer = new LUTUProducerDestination();
    lutuProducer.setBPartnerId(bpartnerId).setC_BPartner_Location_ID(bpartnerLocationId).setLocatorId(locatorId).setHUStatus(X_M_HU.HUSTATUS_Picked);
    final String targetHuType = Services.get(IHandlingUnitsBL.class).getHU_UnitType(targetHUPI);
    if (X_M_HU_PI_Version.HU_UNITTYPE_LoadLogistiqueUnit.equals(targetHuType)) {
        lutuProducer.setLUPI(targetHUPI);
    } else if (X_M_HU_PI_Version.HU_UNITTYPE_TransportUnit.equals(targetHuType)) {
        lutuProducer.setNoLU();
        lutuProducer.setTUPI(targetHUPI);
    }
    return lutuProducer;
}
Also used : IHandlingUnitsBL(de.metas.handlingunits.IHandlingUnitsBL) AdempiereException(org.adempiere.exceptions.AdempiereException) LocatorId(org.adempiere.warehouse.LocatorId) IWarehouseDAO(org.adempiere.warehouse.api.IWarehouseDAO) BPartnerId(de.metas.bpartner.BPartnerId) LUTUProducerDestination(de.metas.handlingunits.allocation.transfer.impl.LUTUProducerDestination) I_M_Locator(de.metas.handlingunits.model.I_M_Locator)

Example 19 with BPartnerId

use of de.metas.bpartner.BPartnerId in project metasfresh-webui-api by metasfresh.

the class ViewGeoLocationsRestController method retrieveGeoLocationsForBPartnerId.

private List<JsonViewRowGeoLocation> retrieveGeoLocationsForBPartnerId(final ImmutableSetMultimap<BPartnerId, DocumentId> rowIdsByBPartnerId) {
    if (rowIdsByBPartnerId.isEmpty()) {
        return ImmutableList.of();
    }
    final List<JsonViewRowGeoLocation> result = new ArrayList<>();
    final ImmutableSet<BPartnerId> bpartnerIds = rowIdsByBPartnerId.keySet();
    for (final GeographicalCoordinatesWithBPartnerLocationId bplCoordinates : bpartnersRepo.getGeoCoordinatesByBPartnerIds(bpartnerIds)) {
        final BPartnerId bpartnerId = bplCoordinates.getBPartnerId();
        final ImmutableSet<DocumentId> rowIds = rowIdsByBPartnerId.get(bpartnerId);
        if (rowIds.isEmpty()) {
            // shall not happen
            logger.warn("Ignored unexpected bpartnerId={}. We have no rows for it.", bpartnerId);
            continue;
        }
        final GeographicalCoordinates coordinate = bplCoordinates.getCoordinate();
        for (final DocumentId rowId : rowIds) {
            result.add(JsonViewRowGeoLocation.builder().rowId(rowId).latitude(coordinate.getLatitude()).longitude(coordinate.getLongitude()).build());
        }
    }
    return result;
}
Also used : GeographicalCoordinatesWithBPartnerLocationId(de.metas.bpartner.GeographicalCoordinatesWithBPartnerLocationId) ArrayList(java.util.ArrayList) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) BPartnerId(de.metas.bpartner.BPartnerId) JsonViewRowGeoLocation(de.metas.ui.web.document.geo_location.json.JsonViewRowGeoLocation) GeographicalCoordinates(de.metas.location.geocoding.GeographicalCoordinates)

Example 20 with BPartnerId

use of de.metas.bpartner.BPartnerId in project metasfresh-webui-api by metasfresh.

the class ViewGeoLocationsRestController method extractBPartnerIds.

private static final ImmutableSetMultimap<BPartnerId, DocumentId> extractBPartnerIds(final ViewResult rows, final GeoLocationDocumentDescriptor descriptor) {
    final String locationColumnName = descriptor.getLocationColumnName();
    final ImmutableSetMultimap.Builder<BPartnerId, DocumentId> rowIdsByBPartnerRepoId = ImmutableSetMultimap.builder();
    for (final IViewRow row : rows.getPage()) {
        final BPartnerId bpartnerId = BPartnerId.ofRepoIdOrNull(row.getFieldValueAsInt(locationColumnName, -1));
        if (bpartnerId == null) {
            continue;
        }
        final DocumentId rowId = row.getId();
        rowIdsByBPartnerRepoId.put(bpartnerId, rowId);
    }
    return rowIdsByBPartnerRepoId.build();
}
Also used : ImmutableSetMultimap(com.google.common.collect.ImmutableSetMultimap) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) BPartnerId(de.metas.bpartner.BPartnerId) IViewRow(de.metas.ui.web.view.IViewRow)

Aggregations

BPartnerId (de.metas.bpartner.BPartnerId)25 ProductId (de.metas.product.ProductId)6 ITranslatableString (de.metas.i18n.ITranslatableString)5 AdempiereException (org.adempiere.exceptions.AdempiereException)5 HUPIItemProductId (de.metas.handlingunits.HUPIItemProductId)4 ZonedDateTime (java.time.ZonedDateTime)4 SOTrx (de.metas.lang.SOTrx)3 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)3 LookupValuesList (de.metas.ui.web.window.datatypes.LookupValuesList)3 I_C_Order (de.metas.adempiere.model.I_C_Order)2 ShipmentAllocationBestBeforePolicy (de.metas.bpartner.ShipmentAllocationBestBeforePolicy)2 IBPartnerDAO (de.metas.bpartner.service.IBPartnerDAO)2 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)2 I_M_HU_PI_Item (de.metas.handlingunits.model.I_M_HU_PI_Item)2 I_M_HU_PI_Item_Product (de.metas.handlingunits.model.I_M_HU_PI_Item_Product)2 OrderId (de.metas.order.OrderId)2 PriceListVersionId (de.metas.pricing.PriceListVersionId)2 IntegerLookupValue (de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue)2 UserId (de.metas.user.UserId)2 Services (de.metas.util.Services)2