Search in sources :

Example 51 with ProductId

use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.

the class OrderLinePricingConditionsViewFactory method createSourceDocumentLine.

private final SourceDocumentLine createSourceDocumentLine(@NonNull final I_C_OrderLine orderLineRecord, @NonNull final SOTrx soTrx) {
    final IProductDAO productsRepo = Services.get(IProductDAO.class);
    final ProductId productId = ProductId.ofRepoId(orderLineRecord.getM_Product_ID());
    final ProductCategoryId productCategoryId = productsRepo.retrieveProductCategoryByProductId(productId);
    final Money priceEntered = Money.of(orderLineRecord.getPriceEntered(), CurrencyId.ofRepoId(orderLineRecord.getC_Currency_ID()));
    return SourceDocumentLine.builder().orderLineId(OrderLineId.ofRepoIdOrNull(orderLineRecord.getC_OrderLine_ID())).soTrx(soTrx).bpartnerId(BPartnerId.ofRepoId(orderLineRecord.getC_BPartner_ID())).productId(productId).productCategoryId(productCategoryId).priceEntered(priceEntered).discount(Percent.of(orderLineRecord.getDiscount())).paymentTermId(PaymentTermId.ofRepoIdOrNull(orderLineRecord.getC_PaymentTerm_Override_ID())).pricingConditionsBreakId(PricingConditionsBreakId.ofOrNull(orderLineRecord.getM_DiscountSchema_ID(), orderLineRecord.getM_DiscountSchemaBreak_ID())).build();
}
Also used : Money(de.metas.money.Money) ProductCategoryId(de.metas.product.ProductCategoryId) IProductDAO(de.metas.product.IProductDAO) ProductId(de.metas.product.ProductId)

Example 52 with ProductId

use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.

the class ProductPricingConditionsViewFactory method createPricingConditionsRowData.

@Override
protected PricingConditionsRowData createPricingConditionsRowData(final CreateViewRequest request) {
    final Set<ProductId> productIds = ProductId.ofRepoIds(request.getFilterOnlyIds());
    Check.assumeNotEmpty(productIds, "productIds is not empty");
    final IProductDAO productsRepo = Services.get(IProductDAO.class);
    final Set<ProductAndCategoryAndManufacturerId> products = productsRepo.retrieveProductAndCategoryAndManufacturersByProductIds(productIds);
    return preparePricingConditionsRowData().pricingConditionsBreaksExtractor(pricingConditions -> pricingConditions.streamBreaksMatchingAnyOfProducts(products)).basePricingSystemPriceCalculator(this::calculateBasePricingSystemPrice).load();
}
Also used : ProductAndCategoryAndManufacturerId(de.metas.product.ProductAndCategoryAndManufacturerId) IProductDAO(de.metas.product.IProductDAO) ProductId(de.metas.product.ProductId)

Example 53 with ProductId

use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.

the class ProductPricingConditionsViewFactory method createPricingContext.

private IPricingContext createPricingContext(final BasePricingSystemPriceCalculatorRequest request) {
    final IPricingBL pricingBL = Services.get(IPricingBL.class);
    final PricingConditionsBreak pricingConditionsBreak = request.getPricingConditionsBreak();
    final IEditablePricingContext pricingCtx = pricingBL.createPricingContext();
    final ProductId productId = pricingConditionsBreak.getMatchCriteria().getProductId();
    pricingCtx.setProductId(productId);
    pricingCtx.setQty(BigDecimal.ONE);
    pricingCtx.setBPartnerId(request.getBpartnerId());
    pricingCtx.setSOTrx(SOTrx.ofBoolean(request.isSOTrx()));
    return pricingCtx;
}
Also used : PricingConditionsBreak(de.metas.pricing.conditions.PricingConditionsBreak) IPricingBL(de.metas.pricing.service.IPricingBL) IEditablePricingContext(de.metas.pricing.IEditablePricingContext) ProductId(de.metas.product.ProductId)

Example 54 with ProductId

use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.

the class ASIRestController method createWebuiASIEditingInfoForSingleDocument.

private static WebuiASIEditingInfo createWebuiASIEditingInfoForSingleDocument(final Document contextDocument, final AttributeSetInstanceId attributeSetInstanceId) {
    final ProductId productId = ProductId.ofRepoIdOrNull(contextDocument.asEvaluatee().get_ValueAsInt("M_Product_ID", -1));
    final SOTrx soTrx = SOTrx.ofBoolean(contextDocument.asEvaluatee().get_ValueAsBoolean("IsSOTrx", true));
    final String callerTableName = contextDocument.getEntityDescriptor().getTableNameOrNull();
    // FIXME implement
    final int callerColumnId = -1;
    final ASIEditingInfo info = ASIEditingInfo.of(productId, attributeSetInstanceId, callerTableName, callerColumnId, soTrx);
    return WebuiASIEditingInfo.builder(info).contextDocumentPath(contextDocument.getDocumentPath()).build();
}
Also used : SOTrx(de.metas.lang.SOTrx) ProductId(de.metas.product.ProductId) ASIEditingInfo(org.adempiere.mm.attributes.util.ASIEditingInfo)

Example 55 with ProductId

use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.

the class PurchaseRowFactory method getQtyAvailableToPromise.

private Quantity getQtyAvailableToPromise(final PurchaseDemand demand) {
    final ProductId productId = demand.getProductId();
    final AttributesKey attributesKey = AttributesKeys.createAttributesKeyFromASIStorageAttributes(demand.getAttributeSetInstanceId()).orElse(AttributesKey.ALL);
    final AvailableToPromiseQuery query = AvailableToPromiseQuery.builder().productId(productId.getRepoId()).date(demand.getSalesPreparationDate()).storageAttributesKeyPattern(AttributesKeyPatterns.ofAttributeKey(attributesKey)).build();
    final BigDecimal qtyAvailableToPromise = availableToPromiseRepository.retrieveAvailableStockQtySum(query);
    final I_C_UOM uom = productsBL.getStockUOM(productId);
    return Quantity.of(qtyAvailableToPromise, uom);
}
Also used : AvailableToPromiseQuery(de.metas.material.dispo.commons.repository.atp.AvailableToPromiseQuery) AttributesKey(de.metas.material.event.commons.AttributesKey) ProductId(de.metas.product.ProductId) BigDecimal(java.math.BigDecimal) I_C_UOM(org.compiere.model.I_C_UOM)

Aggregations

ProductId (de.metas.product.ProductId)56 HUPIItemProductId (de.metas.handlingunits.HUPIItemProductId)8 BPartnerId (de.metas.bpartner.BPartnerId)7 HuId (de.metas.handlingunits.HuId)7 Quantity (de.metas.quantity.Quantity)7 AdempiereException (org.adempiere.exceptions.AdempiereException)7 I_M_HU (de.metas.handlingunits.model.I_M_HU)6 IHUProductStorage (de.metas.handlingunits.storage.IHUProductStorage)5 IHUStorage (de.metas.handlingunits.storage.IHUStorage)5 ITranslatableString (de.metas.i18n.ITranslatableString)5 BigDecimal (java.math.BigDecimal)5 I_C_UOM (org.compiere.model.I_C_UOM)5 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)4 ArrayList (java.util.ArrayList)4 ImmutableAttributeSet (org.adempiere.mm.attributes.api.ImmutableAttributeSet)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 ImmutableList (com.google.common.collect.ImmutableList)3 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)3 I_M_HU_PI_Item_Product (de.metas.handlingunits.model.I_M_HU_PI_Item_Product)3 IProductBL (de.metas.product.IProductBL)3