Skip to content

Commit

Permalink
Merge pull request #1704 from 18F/timecard-report-fields
Browse files Browse the repository at this point in the history
Timecard report fields
  • Loading branch information
edwintorres authored Dec 19, 2023
2 parents 8023687 + 2fac56c commit 2441a8d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tock/employees/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ def organization_name(self):

return ''

@property
def unit_name(self):
"""
Returns the unit name associated with the employee or an empty string
if no unit is set.
"""
if self.unit is not None:
return self.unit.name
return ''

@property
def is_late(self):
"""
Expand Down
5 changes: 5 additions & 0 deletions tock/hours/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ def test_bulk_timecards(self):
'employee',
'start_date',
'end_date',
'is_weekly_bill',
'hours_spent',
'project_allocation',
'billable_expectation',
'target_hours',
'agency',
'flat_rate',
'active',
Expand All @@ -118,6 +122,7 @@ def test_bulk_timecards(self):
'expense_profit_loss_account',
'expense_profit_loss_account_name',
'employee_organization',
'employee_unit',
'project_organization',
))
rows_read = 0
Expand Down
15 changes: 14 additions & 1 deletion tock/hours/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,20 @@ class BulkTimecardSerializer(serializers.Serializer):
end_date = serializers.DateField(
source='timecard.reporting_period.end_date'
)
hours_spent = serializers.DecimalField(max_digits=5, decimal_places=2)
is_weekly_bill = serializers.BooleanField(
source='project.is_weekly_bill'
)
hours_spent = serializers.DecimalField(decimal_places=2, max_digits=5)
project_allocation = serializers.DecimalField(decimal_places=3, max_digits=6)
billable = serializers.BooleanField(
source='project.accounting_code.billable'
)
billable_expectation = serializers.DecimalField(decimal_places=2,
max_digits=3,
source='timecard.billable_expectation')
target_hours = serializers.DecimalField(decimal_places=2,
max_digits=5,
source='timecard.target_hours')
agency = serializers.CharField(
source='project.accounting_code.agency.name'
)
Expand Down Expand Up @@ -76,6 +86,9 @@ class BulkTimecardSerializer(serializers.Serializer):
employee_organization = serializers.CharField(
source='timecard.user.user_data.organization_name'
)
employee_unit = serializers.CharField(
source='timecard.user.user_data.unit_name'
)
project_organization = serializers.CharField(
source='project.organization_name'
)
Expand Down
7 changes: 7 additions & 0 deletions tock/tock/templates/hours/reports_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ <h1>Tock Reports</h1>
<div class="grid-row grid-gap">
<div class="grid-col-6">
<h2>Regular Reports</h2>
<div class="usa-alert usa-alert--info usa-alert--slim">
<div class="usa-alert__body">
<p class="usa-alert__text">
Large reports may fail to download. Change the date range in the report URL to work around this limitation.
</p>
</div>
</div>
<ul>
<li>Complete timecard data:
<a href="{% url 'reports:BulkTimecardList' %}?after={{starting_report_date|date:'Y-m-d'}}">All</a>
Expand Down

0 comments on commit 2441a8d

Please sign in to comment.