- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
def check_dates
if !start_on.nil? && !end_on.nil? && start_on > end_on
errors.add(:base, 'The first month cannot be after the last month.')
return false
end
is_admin_user = User.has_level?('admin')
if confirmed_at.nil? && !start_on.nil? && !is_admin_edit? && !is_admin_edit_revision?
d = Date.current_date
if is_newsletter?
if !is_admin_user && (d.year > start_on.year || (d.year == start_on.year && d.month > start_on.month))
errors.add(:base, 'The first month has already passed.')
return false
end
if !office_id.nil?
office = Office.find_by_id(office_id)
deadline = office.deadline(start_on.year, start_on.month)
if !is_admin_user && d > (deadline + Order::PastDeadlineLimit)
errors.add(:base, "The #{office.name} office deadline for this month has already passed.")
return false
end
if is_design_only?
original = get_original_order
if start_on < original.start_on
errors.add(:base, 'The first month cannot be before the first month of the original order.')
return false
end
if start_on > original.end_on
errors.add(:base, 'The first month cannot be after the last month of the original order.')
return false
end
end
validate_adjusted_order
end
else
if new_record? && !is_admin_user
if d.year > start_on.year
errors.add(:base, 'The year has already passed.')
return false
end
end
if !is_admin_user && !ads.empty? && 1 == ads.map(&:neighborhood_id).uniq.size
if directory && directory.finalized? && d > (directory.finalized_on + Order::PastDeadlineLimit)
errors.add(:base, 'The directory has already been finalized.')
return false
end
end
end
end
if is_admin_edit?
original = get_original_order
if months < original.publication_month_with_receipt_span
errors.add(:base, 'The order already has more paid months than the new contract length.')
end
end
end
spivti 16.09.2013 19:15 # 0
kegdan 16.09.2013 20:27 # 0
kegdan 16.09.2013 20:43 # 0
guest 04.10.2013 12:54 # 0
anonimb84a2f6fd141 16.09.2013 22:19 # 0