use of de.metas.handlingunits.allocation.impl.HUProducerDestination 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;
}
Aggregations