use of de.metas.handlingunits.model.I_M_HU in project metasfresh-webui-api by metasfresh.
the class WEBUIHUCreationWithSerialNumberService method assignSerialNumberToCU.
private void assignSerialNumberToCU(final int huId, final String serialNo) {
final I_M_HU hu = create(Env.getCtx(), huId, I_M_HU.class, ITrx.TRXNAME_ThreadInherited);
final IContextAware ctxAware = getContextAware(hu);
final IHUContext huContext = handlingUnitsBL.createMutableHUContext(ctxAware);
final IAttributeStorage attributeStorage = getAttributeStorage(huContext, hu);
final I_M_Attribute serialNoAttribute = serialNoDAO.getSerialNoAttribute(ctxAware.getCtx());
Check.errorUnless(attributeStorage.hasAttribute(serialNoAttribute), "There is no SerialNo attribute {} defined for the handling unit {}", serialNoAttribute, hu);
attributeStorage.setValue(serialNoAttribute, serialNo.trim());
attributeStorage.saveChangesIfNeeded();
}
use of de.metas.handlingunits.model.I_M_HU in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_HU_MoveTUsToDirectWarehouse method doIt.
@Override
protected // @RunOutOfTrx // run in transaction!
String doIt() {
if (p_QtyTU <= 0) {
throw new FillMandatoryException("QtyTU");
}
final I_M_HU topLevelHU = getRecord(I_M_HU.class);
final HUsToNewTUsRequest request = HUsToNewTUsRequest.forSourceHuAndQty(topLevelHU, p_QtyTU);
final List<I_M_HU> tus = HUTransformService.newInstance().husToNewTUs(request);
if (tus.size() != p_QtyTU) {
throw new AdempiereException(WEBUI_HU_Constants.MSG_NotEnoughTUsFound, new Object[] { p_QtyTU, tus.size() });
}
HUMoveToDirectWarehouseService.newInstance().setDocumentsCollection(documentsCollection).setHUView(getView()).setFailOnFirstError(true).setLoggable(this).move(tus.iterator());
return MSG_OK;
}
use of de.metas.handlingunits.model.I_M_HU 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;
}
use of de.metas.handlingunits.model.I_M_HU in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_ReceiptSchedule_SelectHUsToReverse method doIt.
@Override
protected String doIt() throws Exception {
final I_M_ReceiptSchedule receiptSchedule = getRecord(I_M_ReceiptSchedule.class);
final List<I_M_HU> hus = ReceiptCorrectHUsProcessor.builder().setM_ReceiptSchedule(receiptSchedule).build().getAvailableHUsToReverse();
if (hus.isEmpty()) {
throw new AdempiereException("@NotFound@ @M_HU_ID@");
}
getResult().setRecordsToOpen(TableRecordReference.ofCollection(hus));
return MSG_OK;
}
use of de.metas.handlingunits.model.I_M_HU in project metasfresh-webui-api by metasfresh.
the class WebuiHUTransformCommand method action_updatePlanningReceiptOwnerPM.
/**
* @param row
* @param huPlanningReceiptOwnerPM
* @return
* @task https://github.com/metasfresh/metasfresh/issues/1130
*/
private WebuiHUTransformCommandResult action_updatePlanningReceiptOwnerPM(final HUEditorRow row, final boolean huPlanningReceiptOwnerPM) {
final I_M_HU hu = row.getM_HU();
hu.setHUPlanningReceiptOwnerPM(huPlanningReceiptOwnerPM);
InterfaceWrapperHelper.save(hu);
return WebuiHUTransformCommandResult.builder().huIdChanged(hu.getM_HU_ID()).build();
}
Aggregations