Search in sources :

Example 21 with I_M_HU

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();
}
Also used : IAttributeStorage(de.metas.handlingunits.attribute.storage.IAttributeStorage) I_M_HU(de.metas.handlingunits.model.I_M_HU) I_M_Attribute(org.compiere.model.I_M_Attribute) IContextAware(org.adempiere.model.IContextAware) IHUContext(de.metas.handlingunits.IHUContext)

Example 22 with I_M_HU

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;
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) AdempiereException(org.adempiere.exceptions.AdempiereException) FillMandatoryException(org.adempiere.exceptions.FillMandatoryException) HUsToNewTUsRequest(de.metas.handlingunits.allocation.transfer.HUTransformService.HUsToNewTUsRequest)

Example 23 with I_M_HU

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

Example 24 with I_M_HU

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;
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) AdempiereException(org.adempiere.exceptions.AdempiereException) I_M_ReceiptSchedule(de.metas.handlingunits.model.I_M_ReceiptSchedule)

Example 25 with I_M_HU

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();
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU)

Aggregations

I_M_HU (de.metas.handlingunits.model.I_M_HU)43 AdempiereException (org.adempiere.exceptions.AdempiereException)12 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)11 PickingSlotRow (de.metas.ui.web.picking.pickingslot.PickingSlotRow)7 List (java.util.List)7 Services (org.adempiere.util.Services)6 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)5 IProcessPrecondition (de.metas.process.IProcessPrecondition)5 ProcessPreconditionsResolution (de.metas.process.ProcessPreconditionsResolution)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 ImmutableList (com.google.common.collect.ImmutableList)4 IAllocationSource (de.metas.handlingunits.allocation.IAllocationSource)4 IProcessDefaultParametersProvider (de.metas.process.IProcessDefaultParametersProvider)4 Param (de.metas.process.Param)4 HUEditorView (de.metas.ui.web.handlingunits.HUEditorView)4 BigDecimal (java.math.BigDecimal)4 Collection (java.util.Collection)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)3 I_M_HU_PI_Item (de.metas.handlingunits.model.I_M_HU_PI_Item)3