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