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