From e703d1a1720238ae4220ad84a1237ef9adccc774 Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Wed, 20 Jan 2021 18:00:43 +0000 Subject: [PATCH 1/3] Add billing details fields to Service model and db table The fields are: Purchase order number - string field Billing contact name - text field to acommodate possible multiple contacts Billing contact email address - text field to acommodate possible multiple contacts Billing reference - string field All these fields are nullable. Notify platform admins will be able to check and edit those values in Service Settings section in Notify interface. This will help make billing tasks and reports simpler. Similar fields will also be added to Organisation model and db table. --- app/models.py | 4 ++ .../versions/0339_service_billing_details.py | 39 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 migrations/versions/0339_service_billing_details.py diff --git a/app/models.py b/app/models.py index 0710ca559..7ace4b0b7 100644 --- a/app/models.py +++ b/app/models.py @@ -488,6 +488,10 @@ class Service(db.Model, Versioned): organisation = db.relationship('Organisation', backref='services') notes = db.Column(db.Text, nullable=True) + purchase_order_number = db.Column(db.String(255), nullable=True) + billing_contact_name = db.Column(db.Text, nullable=True) + billing_contact_email_address = db.Column(db.Text, nullable=True) + billing_reference = db.Column(db.String(255), nullable=True) email_branding = db.relationship( 'EmailBranding', diff --git a/migrations/versions/0339_service_billing_details.py b/migrations/versions/0339_service_billing_details.py new file mode 100644 index 000000000..175fd6b47 --- /dev/null +++ b/migrations/versions/0339_service_billing_details.py @@ -0,0 +1,39 @@ +""" + +Revision ID: 0339_service_billing_details +Revises: 0338_add_notes_to_service +Create Date: 2021-01-20 17:55:46.555460 + +""" +from alembic import op +import sqlalchemy as sa + + +revision = '0339_service_billing_details' +down_revision = '0338_add_notes_to_service' + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('services', sa.Column('billing_contact_email_address', sa.Text(), nullable=True)) + op.add_column('services', sa.Column('billing_contact_name', sa.Text(), nullable=True)) + op.add_column('services', sa.Column('billing_reference', sa.String(length=255), nullable=True)) + op.add_column('services', sa.Column('purchase_order_number', sa.String(length=255), nullable=True)) + op.add_column('services_history', sa.Column('billing_contact_email_address', sa.Text(), nullable=True)) + op.add_column('services_history', sa.Column('billing_contact_name', sa.Text(), nullable=True)) + op.add_column('services_history', sa.Column('billing_reference', sa.String(length=255), nullable=True)) + op.add_column('services_history', sa.Column('purchase_order_number', sa.String(length=255), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('services_history', 'purchase_order_number') + op.drop_column('services_history', 'billing_reference') + op.drop_column('services_history', 'billing_contact_name') + op.drop_column('services_history', 'billing_contact_email_address') + op.drop_column('services', 'purchase_order_number') + op.drop_column('services', 'billing_reference') + op.drop_column('services', 'billing_contact_name') + op.drop_column('services', 'billing_contact_email_address') + # ### end Alembic commands ### From ffac16a2a0896f8c283b8227ab243459d0db7fc8 Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Mon, 25 Jan 2021 17:42:18 +0000 Subject: [PATCH 2/3] Add new billing details to test_get_service_by_id --- tests/app/service/test_rest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/app/service/test_rest.py b/tests/app/service/test_rest.py index 1f50b6cae..9b36d928e 100644 --- a/tests/app/service/test_rest.py +++ b/tests/app/service/test_rest.py @@ -248,6 +248,9 @@ def test_get_service_by_id(admin_request, sample_service): assert set(json_resp['data'].keys()) == { 'active', 'allowed_broadcast_provider', + 'billing_contact_email_address', + 'billing_contact_name', + 'billing_reference', 'consent_to_research', 'contact_link', 'count_as_live', @@ -266,6 +269,7 @@ def test_get_service_by_id(admin_request, sample_service): 'organisation_type', 'permissions', 'prefix_sms', + 'purchase_order_number', 'rate_limit', 'research_mode', 'restricted', From b3abdfb40103324f45b59158aae3132ba40c6a08 Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Mon, 25 Jan 2021 17:53:22 +0000 Subject: [PATCH 3/3] Rename billing contact email and name fields to plural So: 'billing_contact_email_address' becomes 'billing_contact_email_addresses' AND 'billing_contact_name' becomes 'billing_contact_names' This is to signify that each of those fields can contain numerous items --- app/models.py | 4 ++-- .../versions/0339_service_billing_details.py | 16 ++++++++-------- tests/app/service/test_rest.py | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/models.py b/app/models.py index 7ace4b0b7..7dac89327 100644 --- a/app/models.py +++ b/app/models.py @@ -489,8 +489,8 @@ class Service(db.Model, Versioned): notes = db.Column(db.Text, nullable=True) purchase_order_number = db.Column(db.String(255), nullable=True) - billing_contact_name = db.Column(db.Text, nullable=True) - billing_contact_email_address = db.Column(db.Text, nullable=True) + billing_contact_names = db.Column(db.Text, nullable=True) + billing_contact_email_addresses = db.Column(db.Text, nullable=True) billing_reference = db.Column(db.String(255), nullable=True) email_branding = db.relationship( diff --git a/migrations/versions/0339_service_billing_details.py b/migrations/versions/0339_service_billing_details.py index 175fd6b47..b1b854d43 100644 --- a/migrations/versions/0339_service_billing_details.py +++ b/migrations/versions/0339_service_billing_details.py @@ -15,12 +15,12 @@ down_revision = '0338_add_notes_to_service' def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.add_column('services', sa.Column('billing_contact_email_address', sa.Text(), nullable=True)) - op.add_column('services', sa.Column('billing_contact_name', sa.Text(), nullable=True)) + op.add_column('services', sa.Column('billing_contact_email_addresses', sa.Text(), nullable=True)) + op.add_column('services', sa.Column('billing_contact_names', sa.Text(), nullable=True)) op.add_column('services', sa.Column('billing_reference', sa.String(length=255), nullable=True)) op.add_column('services', sa.Column('purchase_order_number', sa.String(length=255), nullable=True)) - op.add_column('services_history', sa.Column('billing_contact_email_address', sa.Text(), nullable=True)) - op.add_column('services_history', sa.Column('billing_contact_name', sa.Text(), nullable=True)) + op.add_column('services_history', sa.Column('billing_contact_email_addresses', sa.Text(), nullable=True)) + op.add_column('services_history', sa.Column('billing_contact_names', sa.Text(), nullable=True)) op.add_column('services_history', sa.Column('billing_reference', sa.String(length=255), nullable=True)) op.add_column('services_history', sa.Column('purchase_order_number', sa.String(length=255), nullable=True)) # ### end Alembic commands ### @@ -30,10 +30,10 @@ def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_column('services_history', 'purchase_order_number') op.drop_column('services_history', 'billing_reference') - op.drop_column('services_history', 'billing_contact_name') - op.drop_column('services_history', 'billing_contact_email_address') + op.drop_column('services_history', 'billing_contact_names') + op.drop_column('services_history', 'billing_contact_email_addresses') op.drop_column('services', 'purchase_order_number') op.drop_column('services', 'billing_reference') - op.drop_column('services', 'billing_contact_name') - op.drop_column('services', 'billing_contact_email_address') + op.drop_column('services', 'billing_contact_names') + op.drop_column('services', 'billing_contact_email_addresses') # ### end Alembic commands ### diff --git a/tests/app/service/test_rest.py b/tests/app/service/test_rest.py index 9b36d928e..6aac914ea 100644 --- a/tests/app/service/test_rest.py +++ b/tests/app/service/test_rest.py @@ -248,8 +248,8 @@ def test_get_service_by_id(admin_request, sample_service): assert set(json_resp['data'].keys()) == { 'active', 'allowed_broadcast_provider', - 'billing_contact_email_address', - 'billing_contact_name', + 'billing_contact_email_addresses', + 'billing_contact_names', 'billing_reference', 'consent_to_research', 'contact_link',