From 4a0f5e8a41339009f941417a38937c4a08e77868 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 28 Apr 2022 10:48:44 +0100 Subject: [PATCH] Make text message price dependent on date MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So we don’t have to deploy a change on a Saturday. In the future this could pull from the rates in the database, but while that code is shifting around I didn’t want to touoch it. We’d also have to think about caching so as not to have a non-authenticated route hitting the database. --- app/main/views/index.py | 2 ++ app/main/views/pricing.py | 11 ++++++++- app/templates/views/pricing/index.html | 2 +- app/templates/views/signedout.html | 2 +- tests/app/main/views/test_index.py | 33 ++++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 3 deletions(-) diff --git a/app/main/views/index.py b/app/main/views/index.py index f95c96759..cda97e84f 100644 --- a/app/main/views/index.py +++ b/app/main/views/index.py @@ -13,6 +13,7 @@ from notifications_utils.template import HTMLEmailTemplate, LetterImageTemplate from app import email_branding_client, letter_branding_client, status_api_client from app.main import main from app.main.forms import FieldWithNoneOption +from app.main.views.pricing import get_current_sms_rate from app.main.views.sub_navigation_dictionaries import ( features_nav, using_notify_nav, @@ -28,6 +29,7 @@ def index(): return render_template( 'views/signedout.html', + sms_rate=get_current_sms_rate(), counts=status_api_client.get_count_of_live_services_and_organisations(), ) diff --git a/app/main/views/pricing.py b/app/main/views/pricing.py index 436c815bd..3b7af1d12 100644 --- a/app/main/views/pricing.py +++ b/app/main/views/pricing.py @@ -1,19 +1,28 @@ +from datetime import datetime + from flask import current_app, render_template from flask_login import current_user from notifications_utils.international_billing_rates import ( INTERNATIONAL_BILLING_RATES, ) +from notifications_utils.timezones import convert_utc_to_bst from app.main import main from app.main.forms import SearchByNameForm from app.main.views.sub_navigation_dictionaries import pricing_nav +def get_current_sms_rate(): + if convert_utc_to_bst(datetime.utcnow()) < convert_utc_to_bst(datetime(2022, 5, 1)): + return '1.61' + return '1.72' + + @main.route('/pricing') def pricing(): return render_template( 'views/pricing/index.html', - sms_rate=0.0158, + sms_rate=get_current_sms_rate(), international_sms_rates=sorted([ (cc, country['names'], country['billable_units']) for cc, country in INTERNATIONAL_BILLING_RATES.items() diff --git a/app/templates/views/pricing/index.html b/app/templates/views/pricing/index.html index 590034582..3ffb35e9d 100644 --- a/app/templates/views/pricing/index.html +++ b/app/templates/views/pricing/index.html @@ -42,7 +42,7 @@

Text messages

Each unique service you add has an annual allowance of free text messages.

-

When a service has used its annual allowance, it costs 1.72 pence (plus VAT) for each text message you send.

+

When a service has used its annual allowance, it costs {{ sms_rate }} pence (plus VAT) for each text message you send.

You’ll use more free messages, or pay more for each message, if you send text messages longer than 160 characters.

You may also use more free messages, or pay more for each message, if you: