diff --git a/timed/reports/serializers.py b/timed/reports/serializers.py index 3088d30c..578f708a 100644 --- a/timed/reports/serializers.py +++ b/timed/reports/serializers.py @@ -2,6 +2,7 @@ from rest_framework_json_api import relations from rest_framework_json_api.serializers import ( CharField, + DecimalField, DurationField, IntegerField, Serializer, @@ -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" diff --git a/timed/reports/tests/test_project_statistic.py b/timed/reports/tests/test_project_statistic.py index 5f4616c0..2a815274 100644 --- a/timed/reports/tests/test_project_statistic.py +++ b/timed/reports/tests/test_project_statistic.py @@ -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) @@ -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, }, }, { @@ -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, }, }, ] diff --git a/timed/reports/views.py b/timed/reports/views.py index 1a555acd..68878154 100644 --- a/timed/reports/views.py +++ b/timed/reports/views.py @@ -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