use of de.metas.adempiere.form.terminal.TerminalException 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;
}
Aggregations