diff --git a/atst/models/request.py b/atst/models/request.py index bd14b5db..44474ca3 100644 --- a/atst/models/request.py +++ b/atst/models/request.py @@ -27,3 +27,8 @@ class Request(Base): @property def status_displayname(self): return self.status_events[-1].displayname + + @property + def annual_spend(self): + monthly = self.body.get("details_of_use", {}).get("estimated_monthly_spend", 0) + return monthly * 12 diff --git a/tests/models/test_requests.py b/tests/models/test_requests.py index 987723af..2572c7c3 100644 --- a/tests/models/test_requests.py +++ b/tests/models/test_requests.py @@ -68,3 +68,8 @@ def test_request_status_pending_deleted_displayname(): request = Requests.set_status(request, RequestStatus.CANCELED) assert request.status_displayname == "Canceled" + +def test_annual_spend(): + request = RequestFactory.create() + monthly = request.body.get("details_of_use").get("estimated_monthly_spend") + assert request.annual_spend == monthly * 12