Skip to content

Commit

Permalink
fix nil cost_price + operator bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Massimiliano Tavanti authored and Massimiliano Tavanti committed Nov 10, 2013
1 parent aa00ceb commit 698ae27
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/spree/line_item_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def options_text
end

def cost_price
variant.cost_price + ad_hoc_option_values.map(&:cost_price).inject(0, :+)
#due to the fact that cost_price can be nil we must convert it into bigdecimal (to_f will make nil->0 without losing precision in case of value)
variant.cost_price.to_f.to_d + ad_hoc_option_values.map(&:cost_price).inject(0, :+)
end

def cost_money
Expand Down

0 comments on commit 698ae27

Please sign in to comment.