Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix nil cost_price + operator bug #1

Merged
merged 2 commits into from
Nov 10, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion app/models/spree/order_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def contains?(variant, ad_hoc_option_value_ids, product_customizations)
end
end

def merge!(order)
def merge!(order, user)
order.line_items.each do |line_item|
self.add_variant(line_item.variant, line_item.quantity, line_item.ad_hoc_option_value_ids, line_item.product_customizations)
end
Expand Down
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
en:
add: "Add"
required: "Required?"
price_modifier: "Price Adjustment"
price_modifier_type: "What price modifier strategy does this option type use?"
Expand Down Expand Up @@ -46,4 +47,4 @@ en:
customize: 'Customize'
reset: 'Reset'
position_within_product: 'Display order relative to other Ad Hoc Options (low numbers are displayed first)'
selected_by_default: 'Selected by default?'
selected_by_default: 'Selected by default?'