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