Ruport for beginner

Dear Ruby community,

I am looking for a “simple” PDF output for monthly salaries. Input is a
CSV file and output should be a PDF file.

I just get more or less these fields from the CSV
id, name, valid_time and date

While creating the tables and preparing the output, there have are
several calculations to be done before PDF generation.

However, I am not yet there :frowning:

Here is what I got so far:

#!/usr/bin/ruby

require ‘rubygems’
require ‘ruport’

#csv_input = File.open(‘testtest.csv’,‘r’)

csv_input = <<-EOF
id,name,valid_time,date
1,baiki,5:00,9/10/2009
1,baiki,1:45,9/14/2009
2,lee,6:00,9/8/2009
2,lee,6:00,9/7/2009
2,lee,6:55,9/6/2009
2,lee,6:00,9/8/2009
1,baiki,5:00,9/11/2009
1,baiki,4:00,9/12/2009
1,baiki,2:00,9/13/2009
EOF

table = Table(:string => csv_input)

table = table.sub_table(%w[id name valid_time date])

table.rename_columns(‘id’ => ‘ID’, ‘name’ => ‘Name’, ‘valid_time’ =>
‘Hours worked’, ‘date’ => ‘Date’)

grouped_by_id = Grouping(table, :by => ‘ID’, :order => :ID)

puts grouped_by_id

#csv_input.close

My question for now. How can I sort within the grouping according to the
date. Basic sorting is asc ID.

Thanks
Baiki

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs