Search in sources :

Example 11 with I_M_HU

use of de.metas.handlingunits.model.I_M_HU in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_HU_CreateMaterialReceipt method retrieveHUsToReceive.

private Set<I_M_HU> retrieveHUsToReceive() {
    final IQuery<I_M_HU> query = Services.get(IQueryBL.class).createQueryBuilder(I_M_HU.class, this).filter(getProcessInfo().getQueryFilterOrElse(ConstantQueryFilter.of(false))).addOnlyActiveRecordsFilter().create();
    final List<I_M_HU> hus = query.list(I_M_HU.class);
    if (hus.isEmpty()) {
        throw new AdempiereException("@NoSelection@ @M_HU_ID@").setParameter("query", query);
    }
    return ImmutableSet.copyOf(hus);
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) AdempiereException(org.adempiere.exceptions.AdempiereException)

Example 12 with I_M_HU

use of de.metas.handlingunits.model.I_M_HU in project metasfresh-webui-api by metasfresh.

the class HUEditorRowAttributesProvider method createRowAttributes.

private HUEditorRowAttributes createRowAttributes(final ViewRowAttributesKey key) {
    final int huId = key.getHuId().toInt();
    final I_M_HU hu = InterfaceWrapperHelper.create(Env.getCtx(), huId, I_M_HU.class, ITrx.TRXNAME_None);
    if (hu == null) {
        throw new IllegalArgumentException("No HU found for M_HU_ID=" + huId);
    }
    final IAttributeStorage attributesStorage = getAttributeStorageFactory().getAttributeStorage(hu);
    attributesStorage.setSaveOnChange(true);
    final DocumentId documentTypeId = DocumentId.of(huId);
    final DocumentId huEditorRowId = key.getHuEditorRowId();
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(DocumentType.ViewRecordAttributes, documentTypeId, huEditorRowId);
    final boolean rowAttributesReadonly = // readonly if the provider shall provide readonly attributes
    isReadonly() || // or, readonly if not Planning, see https://github.com/metasfresh/metasfresh-webui-api/issues/314
    !X_M_HU.HUSTATUS_Planning.equals(hu.getHUStatus());
    return new HUEditorRowAttributes(documentPath, attributesStorage, rowAttributesReadonly);
}
Also used : IAttributeStorage(de.metas.handlingunits.attribute.storage.IAttributeStorage) I_M_HU(de.metas.handlingunits.model.I_M_HU) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath)

Example 13 with I_M_HU

use of de.metas.handlingunits.model.I_M_HU in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_InOut_Shipment_SelectHUs method doIt.

@Override
protected String doIt() throws Exception {
    final I_M_InOut shipment = getRecord(I_M_InOut.class);
    final List<I_M_HU> shipmentHandlingUnits = Services.get(IHUInOutDAO.class).retrieveShippedHandlingUnits(shipment);
    getResult().setRecordsToOpen(TableRecordReference.ofCollection(shipmentHandlingUnits));
    return MSG_OK;
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) I_M_InOut(de.metas.handlingunits.model.I_M_InOut) IHUInOutDAO(de.metas.handlingunits.inout.IHUInOutDAO)

Example 14 with I_M_HU

use of de.metas.handlingunits.model.I_M_HU in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_ReceiptSchedule_ReceiveCUs method createPlanningVHU.

private I_M_HU createPlanningVHU(final I_M_ReceiptSchedule receiptSchedule) {
    // 
    // Create allocation request for the quantity user entered
    final IAllocationRequest allocationRequest = createAllocationRequest(receiptSchedule);
    if (allocationRequest == null || allocationRequest.isZeroQty()) {
        return null;
    }
    // task 09717
    // make sure the attributes are initialized in case of multiple row selection, also
    huReceiptScheduleBL.setInitialAttributeValueDefaults(allocationRequest, ImmutableList.of(receiptSchedule));
    // 
    // Allocation Source: our receipt schedule
    final IAllocationSource allocationSource = huReceiptScheduleBL.createAllocationSource(receiptSchedule);
    // 
    // Allocation Destination: HU producer which will create 1 VHU
    final HUProducerDestination huProducer = HUProducerDestination.of(handlingUnitsDAO.retrieveVirtualPI(getCtx())).setMaxHUsToCreate(// we want one VHU
    1);
    // 
    // Transfer Qty
    HULoader.of(allocationSource, huProducer).setAllowPartialUnloads(false).setAllowPartialLoads(false).load(allocationRequest);
    // 
    // Get created VHU and return it
    final List<I_M_HU> hus = huProducer.getCreatedHUs();
    if (hus == null || hus.size() != 1) {
        throw new HUException("One and only one VHU was expected but we got: " + hus);
    }
    final I_M_HU vhu = hus.get(0);
    InterfaceWrapperHelper.setTrxName(vhu, ITrx.TRXNAME_None);
    return vhu;
}
Also used : IAllocationSource(de.metas.handlingunits.allocation.IAllocationSource) HUException(de.metas.handlingunits.exceptions.HUException) I_M_HU(de.metas.handlingunits.model.I_M_HU) IAllocationRequest(de.metas.handlingunits.allocation.IAllocationRequest) HUProducerDestination(de.metas.handlingunits.allocation.impl.HUProducerDestination)

Example 15 with I_M_HU

use of de.metas.handlingunits.model.I_M_HU in project metasfresh-webui-api by metasfresh.

the class SqlHUEditorViewRepository method createHUEditorRow.

private HUEditorRow createHUEditorRow(final int parent_HU_ID, final int topLevelHUId, @NonNull final IHUProductStorage huStorage, final boolean processed) {
    // final Stopwatch stopwatch = Stopwatch.createStarted();
    final I_M_HU hu = huStorage.getM_HU();
    final int huId = hu.getM_HU_ID();
    final I_M_Product product = huStorage.getM_Product();
    final HUEditorRowAttributesProvider attributesProviderEffective = huId != parent_HU_ID ? attributesProvider : null;
    final HUEditorRow huEditorRow = HUEditorRow.builder(windowId).setRowId(HUEditorRowId.ofHUStorage(huId, topLevelHUId, product.getM_Product_ID())).setType(HUEditorRowType.HUStorage).setTopLevel(false).setProcessed(processed).setAttributesProvider(attributesProviderEffective).setHUUnitType(JSONLookupValue.of(X_M_HU_PI_Version.HU_UNITTYPE_VirtualPI, "CU")).setHUStatus(createHUStatusLookupValue(hu)).setProduct(createProductLookupValue(product)).setUOM(createUOMLookupValue(huStorage.getC_UOM())).setQtyCU(huStorage.getQty()).build();
    // System.out.println("createHUEditorRow: created " + huEditorRow + " (storage) in " + stopwatch);
    return huEditorRow;
}
Also used : I_M_Product(org.compiere.model.I_M_Product) I_M_HU(de.metas.handlingunits.model.I_M_HU)

Aggregations

I_M_HU (de.metas.handlingunits.model.I_M_HU)43 AdempiereException (org.adempiere.exceptions.AdempiereException)12 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)11 PickingSlotRow (de.metas.ui.web.picking.pickingslot.PickingSlotRow)7 List (java.util.List)7 Services (org.adempiere.util.Services)6 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)5 IProcessPrecondition (de.metas.process.IProcessPrecondition)5 ProcessPreconditionsResolution (de.metas.process.ProcessPreconditionsResolution)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 ImmutableList (com.google.common.collect.ImmutableList)4 IAllocationSource (de.metas.handlingunits.allocation.IAllocationSource)4 IProcessDefaultParametersProvider (de.metas.process.IProcessDefaultParametersProvider)4 Param (de.metas.process.Param)4 HUEditorView (de.metas.ui.web.handlingunits.HUEditorView)4 BigDecimal (java.math.BigDecimal)4 Collection (java.util.Collection)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)3 I_M_HU_PI_Item (de.metas.handlingunits.model.I_M_HU_PI_Item)3