Merge pull request #51 from internetee/110145900-pricelists-bug

110145900-date_conflict_fixed
This commit is contained in:
Timo Võhmar 2015-12-24 04:25:30 +02:00
commit 010d6e45b3

View file

@ -31,7 +31,7 @@ class Pricelist < ActiveRecord::Base
def pricelist_for(zone, operation, period)
lists = valid.where(category: zone, operation_category: operation, duration: period)
return lists.first if lists.count == 1
lists.where('valid_to IS NOT NULL').order(valid_from: :desc).first
lists.order(valid_from: :desc).first
end
end
end