Allow plugins to override some document prices

This commit is contained in:
wvengen 2016-10-20 14:20:12 +02:00 committed by wvengen
parent c6731b4e4f
commit 2072fbb4d5
2 changed files with 26 additions and 2 deletions

View file

@ -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').

View file

@ -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