Skip to content

Commit

Permalink
Add amount to order_service CSV-Export
Browse files Browse the repository at this point in the history
  • Loading branch information
Kagemaru committed Sep 17, 2024
1 parent 1c5c088 commit ec61ab2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/controllers/concerns/worktimes_csv.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) 2006-2017, Puzzle ITC GmbH. This file is part of
# Copyright (c) 2006-2024, Puzzle ITC GmbH. This file is part of
# PuzzleTime and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/puzzle/puzzletime.
Expand All @@ -19,13 +19,14 @@ def send_worktimes_csv(worktimes, filename)

def worktimes_csv(worktimes)
CSV.generate do |csv|
csv << ['Datum', 'Stunden', 'Von Zeit', 'Bis Zeit', 'Reporttyp',
csv << ['Datum', 'Stunden', 'Von Zeit', 'Bis Zeit', 'Stundenansatz CHF', 'Reporttyp',
'Verrechenbar', 'Member', 'Position', 'Ticket', 'Bemerkungen']
worktimes.each do |time|
csv << [I18n.l(time.work_date),
time.hours,
(time.start_stop? ? I18n.l(time.from_start_time, format: :time) : ''),
(time.start_stop? && time.to_end_time? ? I18n.l(time.to_end_time, format: :time) : ''),
currency(time.amount),
time.report_type,
time.billable,
time.employee.label,
Expand All @@ -35,4 +36,11 @@ def worktimes_csv(worktimes)
end
end
end

def currency(value)
format(
'%<amount>0.02f',
amount: value,
)
end
end

0 comments on commit ec61ab2

Please sign in to comment.