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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations