Search in sources :

Example 1 with IAttributeDAO

use of org.adempiere.mm.attributes.api.IAttributeDAO in project metasfresh-webui-api by metasfresh.

the class OrderLinePricingConditionsViewFactory method createPricingConditionsBreakQuery.

private final PricingConditionsBreakQuery createPricingConditionsBreakQuery(final I_C_OrderLine salesOrderLine) {
    final IProductDAO productsRepo = Services.get(IProductDAO.class);
    final IAttributeDAO attributesRepo = Services.get(IAttributeDAO.class);
    final ProductId productId = ProductId.ofRepoId(salesOrderLine.getM_Product_ID());
    final ProductAndCategoryAndManufacturerId product = productsRepo.retrieveProductAndCategoryAndManufacturerByProductId(productId);
    final AttributeSetInstanceId asiId = AttributeSetInstanceId.ofRepoIdOrNone(salesOrderLine.getM_AttributeSetInstance_ID());
    final ImmutableAttributeSet attributes = attributesRepo.getImmutableAttributeSetById(asiId);
    final BigDecimal qty = salesOrderLine.getQtyOrdered();
    final BigDecimal price = salesOrderLine.getPriceActual();
    return PricingConditionsBreakQuery.builder().product(product).attributes(attributes).qty(qty).price(price).build();
}
Also used : ProductAndCategoryAndManufacturerId(de.metas.product.ProductAndCategoryAndManufacturerId) AttributeSetInstanceId(org.adempiere.mm.attributes.AttributeSetInstanceId) ImmutableAttributeSet(org.adempiere.mm.attributes.api.ImmutableAttributeSet) IProductDAO(de.metas.product.IProductDAO) ProductId(de.metas.product.ProductId) BigDecimal(java.math.BigDecimal) IAttributeDAO(org.adempiere.mm.attributes.api.IAttributeDAO)

Example 2 with IAttributeDAO

use of org.adempiere.mm.attributes.api.IAttributeDAO in project metasfresh-webui-api by metasfresh.

the class ViewColumnHelper method extractCaption.

private static ITranslatableString extractCaption(@NonNull final Field field) {
    final ViewColumn viewColumnAnn = field.getAnnotation(ViewColumn.class);
    final String captionKey = !Check.isEmpty(viewColumnAnn.captionKey()) ? viewColumnAnn.captionKey() : extractFieldName(field);
    final TranslationSource captionTranslationSource = viewColumnAnn.captionTranslationSource();
    if (captionTranslationSource == TranslationSource.DEFAULT) {
        final IMsgBL msgBL = Services.get(IMsgBL.class);
        return msgBL.translatable(captionKey);
    } else if (captionTranslationSource == TranslationSource.ATTRIBUTE_NAME) {
        final IAttributeDAO attributesRepo = Services.get(IAttributeDAO.class);
        return attributesRepo.getAttributeDisplayNameByValue(captionKey).orElseGet(() -> TranslatableStrings.anyLanguage(captionKey));
    } else {
        logger.warn("Unknown TranslationSource={} for {}. Returning the captionKey={}", captionTranslationSource, field, captionKey);
        return TranslatableStrings.anyLanguage(captionKey);
    }
}
Also used : IMsgBL(de.metas.i18n.IMsgBL) TranslationSource(de.metas.ui.web.view.descriptor.annotation.ViewColumn.TranslationSource) ToString(lombok.ToString) ITranslatableString(de.metas.i18n.ITranslatableString) IAttributeDAO(org.adempiere.mm.attributes.api.IAttributeDAO)

Aggregations

IAttributeDAO (org.adempiere.mm.attributes.api.IAttributeDAO)2 IMsgBL (de.metas.i18n.IMsgBL)1 ITranslatableString (de.metas.i18n.ITranslatableString)1 IProductDAO (de.metas.product.IProductDAO)1 ProductAndCategoryAndManufacturerId (de.metas.product.ProductAndCategoryAndManufacturerId)1 ProductId (de.metas.product.ProductId)1 TranslationSource (de.metas.ui.web.view.descriptor.annotation.ViewColumn.TranslationSource)1 BigDecimal (java.math.BigDecimal)1 ToString (lombok.ToString)1 AttributeSetInstanceId (org.adempiere.mm.attributes.AttributeSetInstanceId)1 ImmutableAttributeSet (org.adempiere.mm.attributes.api.ImmutableAttributeSet)1