Skip to content

Commit

Permalink
* Updated - refactoring and correct transaction amount
Browse files Browse the repository at this point in the history
  • Loading branch information
cbarber committed Jun 15, 2015
1 parent cb95c29 commit ec1d4a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 12 additions & 0 deletions app/helpers/timesheet_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,16 @@ def options_for_period_select(value)
[l(:label_this_year), 'current_year']],
value)
end

def amount_for(time_entry)
price_for(time_entry).value.to_i * quantity_for(time_entry)
end

def quantity_for(time_entry)
-time_entry_hours
end

def price_for(time_entry)
time_entry.project.custom_value_for(10)
end
end
10 changes: 5 additions & 5 deletions app/views/timesheet/report.iif.riif
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ iif.trns do
date Time.now.strftime("%m/%d/%Y")
accnt 'Accounts Receivable'
name 'Customer'
amount grand_total.to_s
docnum "#{date_from.year}--#{timesheet.projects.collect{|p| p.id.to_s.ljust(3, '0') }.join('-')}--#{date_from.strftime('%m-%d')}--#{date_to.strftime('%m-%d')}"
amount timesheet.time_entries.sum { |project, data| data[:logs].sum { |time_entry| amount_for(time_entry) }
docnum "#{date_from.year}-#{timesheet.projects.collect{|p| p.id.to_s.ljust(3, '0') }.join('')}-#{date_from.strftime('%m%d')}-#{date_to.strftime('%m%d')}"
memo "Time entered for #{timesheet.time_entries.map { |project, data| project }.join(', ') } between #{date_from.strftime('%Y-%m-%d')} and #{date_to.strftime('%Y-%m-%d')}"
clear 'N'
toprint 'Y'
Expand All @@ -43,12 +43,12 @@ iif.trns do
trnstype 'INVOICE'
date time_entry.spent_on.strftime("%m/%d/%Y")
accnt 'Service Income'
amount time_entry.project.custom_value_for(10).value.to_i * time_entry.hours
amount amount_for(time_entry)
memo "#{time_entry.user.name} [#{time_entry.spent_on.strftime("%Y-%m-%d")}] ##{time_entry.issue.id} - #{time_entry.issue.subject}"
clear 'N'
qnty time_entry.hours
qnty quantity_for(time_entry)
# TODO: Hardcoded the custom_field id for now since there isn't a nice getter from name
price time_entry.project.custom_value_for(10)
price price_for(time_entry)
invitem 'website'
taxable 'N'
# yeartodate '0' # doesn't exist in gem's dsl
Expand Down

0 comments on commit ec1d4a7

Please sign in to comment.