Search in sources :

Example 1 with ILUTUProducerAllocationDestination

use of de.metas.handlingunits.allocation.ILUTUProducerAllocationDestination in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_ReceiptSchedule_ReceiveHUs_Base method doIt.

@Override
@RunOutOfTrx
protected final String doIt() throws Exception {
    final I_M_ReceiptSchedule receiptSchedule = getM_ReceiptSchedule();
    final ReceiptScheduleHUGenerator huGenerator = ReceiptScheduleHUGenerator.newInstance(this).addM_ReceiptSchedule(receiptSchedule).setUpdateReceiptScheduleDefaultConfiguration(isUpdateReceiptScheduleDefaultConfiguration());
    // 
    // Get/Create the initial LU/TU configuration
    final I_M_HU_LUTU_Configuration lutuConfigurationOrig = getCurrentLUTUConfiguration(receiptSchedule);
    // 
    // Create the effective LU/TU configuration
    final I_M_HU_LUTU_Configuration lutuConfiguration = createM_HU_LUTU_Configuration(lutuConfigurationOrig);
    Services.get(ILUTUConfigurationFactory.class).save(lutuConfiguration);
    huGenerator.setM_HU_LUTU_Configuration(lutuConfiguration);
    // 
    // Calculate the target CUs that we want to allocate
    final ILUTUProducerAllocationDestination lutuProducer = huGenerator.getLUTUProducerAllocationDestination();
    final Quantity qtyCUsTotal = lutuProducer.calculateTotalQtyCU();
    if (qtyCUsTotal.isInfinite()) {
        throw new TerminalException("LU/TU configuration is resulting to infinite quantity: " + lutuConfiguration);
    }
    huGenerator.setQtyToAllocateTarget(qtyCUsTotal);
    // 
    // Generate the HUs
    final List<I_M_HU> hus = huGenerator.generateWithinOwnTransaction();
    openHUsToReceive(hus);
    return MSG_OK;
}
Also used : I_M_HU_LUTU_Configuration(de.metas.handlingunits.model.I_M_HU_LUTU_Configuration) I_M_HU(de.metas.handlingunits.model.I_M_HU) TerminalException(de.metas.adempiere.form.terminal.TerminalException) I_M_ReceiptSchedule(de.metas.handlingunits.model.I_M_ReceiptSchedule) Quantity(de.metas.quantity.Quantity) ILUTUConfigurationFactory(de.metas.handlingunits.allocation.ILUTUConfigurationFactory) ILUTUProducerAllocationDestination(de.metas.handlingunits.allocation.ILUTUProducerAllocationDestination) ReceiptScheduleHUGenerator(de.metas.handlingunits.receiptschedule.impl.ReceiptScheduleHUGenerator) RunOutOfTrx(de.metas.process.RunOutOfTrx)

Aggregations

TerminalException (de.metas.adempiere.form.terminal.TerminalException)1 ILUTUConfigurationFactory (de.metas.handlingunits.allocation.ILUTUConfigurationFactory)1 ILUTUProducerAllocationDestination (de.metas.handlingunits.allocation.ILUTUProducerAllocationDestination)1 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 I_M_HU_LUTU_Configuration (de.metas.handlingunits.model.I_M_HU_LUTU_Configuration)1 I_M_ReceiptSchedule (de.metas.handlingunits.model.I_M_ReceiptSchedule)1 ReceiptScheduleHUGenerator (de.metas.handlingunits.receiptschedule.impl.ReceiptScheduleHUGenerator)1 RunOutOfTrx (de.metas.process.RunOutOfTrx)1 Quantity (de.metas.quantity.Quantity)1