mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-02 08:30:10 -04:00
Add billing details property
This property lets service settings know if there are any billing details to preview.
This commit is contained in:
@@ -30,8 +30,16 @@ class Service(JSONModel):
|
||||
|
||||
ALLOWED_PROPERTIES = {
|
||||
'active',
|
||||
'allowed_broadcast_provider',
|
||||
'billing_contact_email_address',
|
||||
'billing_contact_name',
|
||||
'billing_reference',
|
||||
'consent_to_research',
|
||||
'contact_link',
|
||||
'count_as_live',
|
||||
'email_from',
|
||||
'go_live_at',
|
||||
'go_live_user',
|
||||
'id',
|
||||
'inbound_api',
|
||||
'message_limit',
|
||||
@@ -39,16 +47,12 @@ class Service(JSONModel):
|
||||
'name',
|
||||
'notes',
|
||||
'prefix_sms',
|
||||
'purchase_order_number',
|
||||
'research_mode',
|
||||
'service_callback_api',
|
||||
'volume_email',
|
||||
'volume_sms',
|
||||
'volume_letter',
|
||||
'consent_to_research',
|
||||
'count_as_live',
|
||||
'go_live_user',
|
||||
'go_live_at',
|
||||
'allowed_broadcast_provider',
|
||||
}
|
||||
|
||||
TEMPLATE_TYPES = (
|
||||
@@ -76,6 +80,19 @@ class Service(JSONModel):
|
||||
def permissions(self):
|
||||
return self._dict.get('permissions', self.TEMPLATE_TYPES)
|
||||
|
||||
@property
|
||||
def billing_details(self):
|
||||
billing_details = [
|
||||
self.billing_contact_email_address,
|
||||
self.billing_contact_name,
|
||||
self.billing_reference,
|
||||
self.purchase_order_number
|
||||
]
|
||||
if any(billing_details):
|
||||
return billing_details
|
||||
else:
|
||||
return None
|
||||
|
||||
def update(self, **kwargs):
|
||||
return service_api_client.update_service(self.id, **kwargs)
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@
|
||||
|
||||
{% call row() %}
|
||||
{{ text_field('Billing details')}}
|
||||
{{ optional_text_field(None, default="No billing details yet", wrap=True) }}
|
||||
{{ optional_text_field(current_service.billing_details, default="No billing details yet", wrap=True) }}
|
||||
{{ edit_field('Change', url_for('.service_settings', service_id=current_service.id), suffix='billing details for service') }}
|
||||
{% endcall %}
|
||||
|
||||
|
||||
@@ -151,6 +151,10 @@ def service_json(
|
||||
organisation_id=None,
|
||||
rate_limit=3000,
|
||||
notes=None,
|
||||
billing_contact_email_address=None,
|
||||
billing_contact_name=None,
|
||||
billing_reference=None,
|
||||
purchase_order_number=None
|
||||
):
|
||||
if users is None:
|
||||
users = []
|
||||
@@ -189,7 +193,11 @@ def service_json(
|
||||
'consent_to_research': True,
|
||||
'count_as_live': True,
|
||||
'organisation': organisation_id,
|
||||
'notes': notes
|
||||
'notes': notes,
|
||||
'billing_contact_email_address': billing_contact_email_address,
|
||||
'billing_contact_name': billing_contact_name,
|
||||
'billing_reference': billing_reference,
|
||||
'purchase_order_number': purchase_order_number,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import pytest
|
||||
from app.models.organisation import Organisation
|
||||
from app.models.service import Service
|
||||
from app.models.user import User
|
||||
from tests import organisation_json
|
||||
from tests import organisation_json, service_json
|
||||
from tests.conftest import ORGANISATION_ID
|
||||
|
||||
INV_PARENT_FOLDER_ID = '7e979e79-d970-43a5-ac69-b625a8d147b0'
|
||||
@@ -255,3 +255,13 @@ def test_bad_permission_raises(service_one):
|
||||
with pytest.raises(KeyError) as e:
|
||||
Service(service_one).has_permission('foo')
|
||||
assert str(e.value) == "'foo is not a service permission'"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("purchase_order_number,expected_result", [
|
||||
[None, None],
|
||||
["PO1234", [None, None, None, "PO1234"]]
|
||||
])
|
||||
def test_service_billing_details(purchase_order_number, expected_result):
|
||||
service = Service(service_json(purchase_order_number=purchase_order_number))
|
||||
service._dict['purchase_order_number'] = purchase_order_number
|
||||
assert service.billing_details == expected_result
|
||||
|
||||
Reference in New Issue
Block a user