Skip to content

Instantly share code, notes, and snippets.

@svs
Created October 11, 2012 06:41
Show Gist options
  • Save svs/3870621 to your computer and use it in GitHub Desktop.
Save svs/3870621 to your computer and use it in GitHub Desktop.
loan snippet
def scheduled_dates_must_be_center_meeting_days #this function is only for repayment dates
return [false, "Not client defined"] unless client
center = client.center
failed = []
correct_weekday = nil
["scheduled_first_payment_date"].each do |d|
# if the loan disbursal date is set and it is not being set right now, no need to check as the loan has been already disbursed
# hence we need not check it again
if self.disbursal_date and not self.dirty_attributes.keys.find{|da| da.name == :disbursal_date}
return true
end
if date = instance_eval(d) and not date.weekday == center.meeting_day_for(date).to_sym
failed << d.humanize
correct_weekday = center.meeting_day_for(date)
end
end
return [false, "#{failed.join(",")} must be #{correct_weekday}"] unless failed.blank?
return true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment