Skip to content

Commit

Permalink
adds additional fields to full timecard (object) report csv
Browse files Browse the repository at this point in the history
adds is_weekly_bill, project_allocation, billable_expectation,
, target_hours, and employee unit. This allows for analysis such
as whether a person was FT or PT on a project, aggregation across
chapters (units), and more.

The property unit_name was added to the UserData model in order to
prevent errors if a user has no associated unit.
  • Loading branch information
jduss4 committed Dec 18, 2023
1 parent 8023687 commit 8116d0b
Show file tree
Hide file tree
Showing 3 changed files with 29 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

0 comments on commit 8116d0b

Please sign in to comment.