Skip to content

Commit

Permalink
Make sync work when unit has no name (closes foodcoops#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
wvengen committed Jan 2, 2015
1 parent c6e0b44 commit 1a88f2b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ def convert_units
fc_unit = (::Unit.new(unit) rescue nil)
supplier_unit = (::Unit.new(shared_article.unit) rescue nil)
if fc_unit and supplier_unit and fc_unit =~ supplier_unit
conversion_factor = (fc_unit.convert_to(supplier_unit.units) / supplier_unit).scalar
new_price = (shared_article.price * conversion_factor).to_f.round(3)
new_unit_quantity = (shared_article.unit_quantity / conversion_factor).to_f.round(1)
conversion_factor = (supplier_unit / fc_unit).to_base
new_price = (shared_article.price / conversion_factor).to_f.round(3)
new_unit_quantity = (shared_article.unit_quantity * conversion_factor).to_f.round(1)
[new_price, new_unit_quantity]
else
false
Expand Down

0 comments on commit 1a88f2b

Please sign in to comment.