Search in sources :

Example 1 with Quantity

use of de.metas.quantity.Quantity in project metasfresh-webui-api by metasfresh.

the class ProductLookupDescriptor method createDisplayName.

private ITranslatableString createDisplayName(@NonNull final ITranslatableString productDisplayName, @NonNull final Group availableStockGroup) {
    final Quantity qtyOnHand = availableStockGroup.getQty();
    final ITranslatableString qtyValueStr = NumberTranslatableString.of(qtyOnHand.getQty(), DisplayType.Quantity);
    final ITranslatableString uomSymbolStr = availableStockGroup.getUomSymbolStr();
    final ITranslatableString storageAttributeString = availableStockGroup.getStorageAttributesString();
    final ITranslatableString displayName = ITranslatableString.compose("", productDisplayName, ": ", qtyValueStr, " ", uomSymbolStr, " (", storageAttributeString, ")");
    return displayName;
}
Also used : ITranslatableString(de.metas.i18n.ITranslatableString) Quantity(de.metas.quantity.Quantity)

Example 2 with Quantity

use of de.metas.quantity.Quantity in project metasfresh-webui-api by metasfresh.

the class AvailableToPromiseAdapter method createClientResultGroup0.

private Group createClientResultGroup0(final ResultGroup commonsResultGroup) {
    final GroupBuilder groupBuilder = Group.builder().productId(commonsResultGroup.getProductId());
    final Quantity quantity = Quantity.of(commonsResultGroup.getQty(), retrieveStockingUOM(commonsResultGroup.getProductId()));
    groupBuilder.qty(quantity);
    final AttributesKey attributesKey = commonsResultGroup.getStorageAttributesKey();
    final Type type = extractType(attributesKey);
    groupBuilder.type(type);
    if (type == Type.ATTRIBUTE_SET) {
        final List<I_M_AttributeValue> attributevalues = extractAttributeSetFromStorageAttributesKey(attributesKey);
        groupBuilder.attributeValues(attributevalues);
    }
    return groupBuilder.build();
}
Also used : Type(de.metas.ui.web.material.adapter.AvailableToPromiseResultForWebui.Group.Type) AttributesKey(de.metas.material.event.commons.AttributesKey) GroupBuilder(de.metas.ui.web.material.adapter.AvailableToPromiseResultForWebui.Group.GroupBuilder) Quantity(de.metas.quantity.Quantity) I_M_AttributeValue(org.compiere.model.I_M_AttributeValue)

Example 3 with Quantity

use of de.metas.quantity.Quantity in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_ReceiptSchedule_ReceiveCUs method createAllocationRequest.

private final IAllocationRequest createAllocationRequest(final I_M_ReceiptSchedule rs) {
    // Get Qty
    final BigDecimal qty = getEffectiveQtyToReceive(rs);
    if (qty.signum() <= 0) {
        // nothing to do
        return null;
    }
    final IMutableHUContext huContextInitial = Services.get(IHUContextFactory.class).createMutableHUContextForProcessing(getCtx());
    final IAllocationRequest allocationRequest = AllocationUtils.createAllocationRequestBuilder().setHUContext(huContextInitial).setDateAsToday().setProduct(rs.getM_Product()).setQuantity(new Quantity(qty, rs.getC_UOM())).setFromReferencedModel(rs).setForceQtyAllocation(true).create();
    return allocationRequest;
}
Also used : IMutableHUContext(de.metas.handlingunits.IMutableHUContext) IAllocationRequest(de.metas.handlingunits.allocation.IAllocationRequest) Quantity(de.metas.quantity.Quantity) IHUContextFactory(de.metas.handlingunits.IHUContextFactory) BigDecimal(java.math.BigDecimal)

Example 4 with Quantity

use of de.metas.quantity.Quantity in project metasfresh-webui-api by metasfresh.

the class PPOrderLineRowTest method canBuildForIssuedOrReceivedHU.

@Test
public void canBuildForIssuedOrReceivedHU() {
    final I_C_UOM uom = newInstance(I_C_UOM.class);
    uom.setUOMSymbol("UOMSymbol");
    final I_PP_Order_Qty ppOrderQty = newInstance(I_PP_Order_Qty.class);
    ppOrderQty.setM_HU_ID(10);
    final PPOrderLineRow result = PPOrderLineRow.builderForIssuedOrReceivedHU().attributesSupplier(() -> null).code("code").includedRows(ImmutableList.of()).packingInfo("packingInfo").ppOrderQty(ppOrderQty).processed(true).product(JSONLookupValue.of(35, "product")).quantity(new Quantity(BigDecimal.TEN, uom)).rowId(DocumentId.of(40)).type(PPOrderLineType.HU_TU).topLevelHU(true).huStatus(JSONLookupValue.of(X_M_HU.HUSTATUS_Active, "Active")).build();
    assertThat(result.getPackingInfo()).isEqualTo("packingInfo");
    assertThat(result.isTopLevelHU()).isTrue();
    assertThat(result.isHUStatusActive()).isTrue();
}
Also used : I_PP_Order_Qty(de.metas.handlingunits.model.I_PP_Order_Qty) Quantity(de.metas.quantity.Quantity) I_C_UOM(org.compiere.model.I_C_UOM) Test(org.junit.Test)

Example 5 with Quantity

use of de.metas.quantity.Quantity 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

Quantity (de.metas.quantity.Quantity)6 I_M_HU_LUTU_Configuration (de.metas.handlingunits.model.I_M_HU_LUTU_Configuration)2 I_PP_Order_Qty (de.metas.handlingunits.model.I_PP_Order_Qty)2 ITranslatableString (de.metas.i18n.ITranslatableString)2 BigDecimal (java.math.BigDecimal)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ListMultimap (com.google.common.collect.ListMultimap)1 TerminalException (de.metas.adempiere.form.terminal.TerminalException)1 IHUContextFactory (de.metas.handlingunits.IHUContextFactory)1 IMutableHUContext (de.metas.handlingunits.IMutableHUContext)1 IAllocationRequest (de.metas.handlingunits.allocation.IAllocationRequest)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_ReceiptSchedule (de.metas.handlingunits.model.I_M_ReceiptSchedule)1 I_PP_Order (de.metas.handlingunits.model.I_PP_Order)1 I_PP_Order_BOMLine (de.metas.handlingunits.model.I_PP_Order_BOMLine)1 IHUPPOrderBL (de.metas.handlingunits.pporder.api.IHUPPOrderBL)1 IHUPPOrderQtyDAO (de.metas.handlingunits.pporder.api.IHUPPOrderQtyDAO)1