Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #909 from trowik/project-statistics-add-expenditures
Browse files Browse the repository at this point in the history
Project statistics add expenditures
  • Loading branch information
trowik authored Dec 5, 2022
2 parents 01ad1f2 + 144444b commit 5150eb0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions timed/reports/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from rest_framework_json_api import relations
from rest_framework_json_api.serializers import (
CharField,
DecimalField,
DurationField,
IntegerField,
Serializer,
Expand Down Expand Up @@ -41,6 +42,10 @@ class Meta:
class ProjectStatisticSerializer(TotalTimeRootMetaMixin, Serializer):
duration = DurationField()
name = CharField()
amount_offered = DecimalField(max_digits=None, decimal_places=2)
amount_offered_currency = CharField()
amount_invoiced = DecimalField(max_digits=None, decimal_places=2)
amount_invoiced_currency = CharField()

class Meta:
resource_name = "project-statistics"
Expand Down
10 changes: 10 additions & 0 deletions timed/reports/tests/test_project_statistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ def test_project_statistic_list(
is_external=False,
)
report = ReportFactory.create(duration=timedelta(hours=1))
project = report.task.project
ReportFactory.create(duration=timedelta(hours=2), task=report.task)
report2 = ReportFactory.create(duration=timedelta(hours=4))
project_2 = report2.task.project
task = TaskFactory(project=report.task.project)
ReportFactory.create(duration=timedelta(hours=2), task=task)

Expand All @@ -56,6 +58,10 @@ def test_project_statistic_list(
"attributes": {
"duration": "04:00:00",
"name": report2.task.project.name,
"amount-offered": str(project_2.amount_offered.amount),
"amount-offered-currency": project_2.amount_offered_currency,
"amount-invoiced": str(project_2.amount_invoiced.amount),
"amount-invoiced-currency": project_2.amount_invoiced_currency,
},
},
{
Expand All @@ -64,6 +70,10 @@ def test_project_statistic_list(
"attributes": {
"duration": "05:00:00",
"name": report.task.project.name,
"amount-offered": str(project.amount_offered.amount),
"amount-offered-currency": project.amount_offered_currency,
"amount-invoiced": str(project.amount_invoiced.amount),
"amount-invoiced-currency": project.amount_invoiced_currency,
},
},
]
Expand Down
4 changes: 4 additions & 0 deletions timed/reports/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ def get_queryset(self):
start=Project,
annotations={
"name": F("name"),
"amount_offered": F("amount_offered"),
"amount_offered_currency": F("amount_offered_currency"),
"amount_invoiced": F("amount_invoiced"),
"amount_invoiced_currency": F("amount_invoiced_currency"),
},
)
return queryset
Expand Down

0 comments on commit 5150eb0

Please sign in to comment.