Product category improvements

This commit is contained in:
2013-02-26 09:40:29 +01:00
parent 0c3bec5c4a
commit 08333cb1bb
6 changed files with 42 additions and 9 deletions
+3 -3
View File
@@ -5,8 +5,8 @@ class ProductCategory
property :position, type: Fixnum, default: 0
property :week_days, type: Array, default: Array.new(7, 1)
property :full_day, type: :boolean, default: true
property :start_from, type: Fixnum, default: 0
property :end_on, type: Fixnum, default: 2880 # Two days in minutes
property :start_from, type: Fixnum, default: 1320 # 22:00
property :end_on, type: Fixnum, default: 1380 # 23:00
belongs_to :supplier
has_and_belongs_to_many :products, storing_keys: true
@@ -72,7 +72,7 @@ class ProductCategory
# time is not by default Time.now.utc since it can be specified as nil
def self.for_supplier_in_time(supplier, time = nil)
time ||= Time.now.utc
time ||= Time.now.in_time_zone(supplier.time_zone)
minute = (time.seconds_since_midnight/60).round
week_day = time.wday
if minute < supplier.night_offset