Skip to content

Instantly share code, notes, and snippets.

@suryart
Created October 29, 2012 18:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suryart/3975619 to your computer and use it in GitHub Desktop.
Save suryart/3975619 to your computer and use it in GitHub Desktop.
Travel Allowance Statement generation Script
t1 = (Time.now-6.months).beginning_of_month # Start Date Time
t2 = (Time.now).end_of_month # End Date and Time
t = t1
amounts = [155, 140, 160]
from = "Banashankari 3rd Satge, Vyalikaval"
to = "Vyalikaval, Banashankari 3rd Satge"
month = t.month
year = t.year
leaves = {"26/01/2012" => "Republic Day", "23/03/2012" => "Chandramana Ugadi", "01/05/2012" => "May Day", "15/08/2012" => "Independence Day", "19/09/2012" => "Ganesha Chaturthi", "02/10/2012" => "Gandhi Jayanti", "23/10/2012" => "Audha Pooja", "01/11/2012" => "Kannada Rajyotsava", "12/11/2012" => "Naraka Chaturdashi", "14/11/2012" => "Balipadyami" }
puts "#{t.strftime("%B")} (#{t.strftime("%Y")}), From Location, To Location, Fare in INR"
while t <= t2
if month != t.month || year != t.year
puts "#{t.strftime("%B")} (#{t.strftime("%Y")}), From Location, To Location, Fare in INR"
month = t.month
year = t.year
end
if t.sunday?
puts "#{t.strftime("%d/%m/%Y")}, Sunday"
elsif !leaves["#{t.strftime("%d/%m/%Y")}"].blank?
puts "#{t.strftime("%d/%m/%Y")}, Leave (#{leaves[t.strftime("%d/%m/%Y").to_s]})"
else
puts "#{t.strftime("%d/%m/%Y")}, #{from}, #{amounts[rand(0..2)]}"
puts "#{t.strftime("%d/%m/%Y")}, #{to}, #{amounts[rand(0..2)]}"
end
t = t+1.day
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment