Allow plugins to override some document prices
This commit is contained in:
parent
c6731b4e4f
commit
2072fbb4d5
2 changed files with 26 additions and 2 deletions
|
@ -26,7 +26,7 @@ class OrderByGroups < OrderPdf
|
||||||
dimrows = []
|
dimrows = []
|
||||||
|
|
||||||
each_group_order_article_for(group_order) do |goa|
|
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
|
sub_total = price * goa.result
|
||||||
total += sub_total
|
total += sub_total
|
||||||
rows << [goa.order_article.article.name,
|
rows << [goa.order_article.article.name,
|
||||||
|
@ -73,6 +73,17 @@ class OrderByGroups < OrderPdf
|
||||||
|
|
||||||
private
|
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
|
def group_orders
|
||||||
order.group_orders.ordered.
|
order.group_orders.ordered.
|
||||||
joins(:ordergroup).order('groups.name').
|
joins(:ordergroup).order('groups.name').
|
||||||
|
|
|
@ -26,7 +26,7 @@ class OrderMatrix < OrderPdf
|
||||||
order_articles_data << [a.article.name,
|
order_articles_data << [a.article.name,
|
||||||
a.article.unit,
|
a.article.unit,
|
||||||
a.price.unit_quantity,
|
a.price.unit_quantity,
|
||||||
number_with_precision(a.price.fc_price, precision: 2),
|
number_with_precision(article_price(a), precision: 2),
|
||||||
a.units]
|
a.units]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -84,4 +84,17 @@ class OrderMatrix < OrderPdf
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue