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