diff --git a/app/documents/order_by_groups.rb b/app/documents/order_by_groups.rb index 16a92238..e71aa8fc 100644 --- a/app/documents/order_by_groups.rb +++ b/app/documents/order_by_groups.rb @@ -26,7 +26,7 @@ class OrderByGroups < OrderPdf dimrows = [] each_group_order_article_for(group_order) do |goa| - price = goa.order_article.price.fc_price + price = order_article_price(goa.order_article) sub_total = price * goa.result total += sub_total rows << [goa.order_article.article.name, @@ -73,6 +73,17 @@ class OrderByGroups < OrderPdf private + # Return price for order_article. + # + # This is a separate method so that plugins can override it. + # + # @param article [OrderArticle] + # @return [Number] Price to show + # @see https://github.com/foodcoops/foodsoft/issues/445 + def order_article_price(order_article) + order_article.price.fc_price + end + def group_orders order.group_orders.ordered. joins(:ordergroup).order('groups.name'). diff --git a/app/documents/order_matrix.rb b/app/documents/order_matrix.rb index bd9e35cc..b92940a2 100644 --- a/app/documents/order_matrix.rb +++ b/app/documents/order_matrix.rb @@ -26,7 +26,7 @@ class OrderMatrix < OrderPdf order_articles_data << [a.article.name, a.article.unit, a.price.unit_quantity, - number_with_precision(a.price.fc_price, precision: 2), + number_with_precision(article_price(a), precision: 2), a.units] end @@ -84,4 +84,17 @@ class OrderMatrix < OrderPdf end end + private + + # Return price for article. + # + # This is a separate method so that plugins can override it. + # + # @param article [Article] + # @return [Number] Price to show + # @see https://github.com/foodcoops/foodsoft/issues/445 + def article_price(article) + article.price.fc_price + end + end