mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-29 22:38:30 -04:00
Format phone numbers with spaces in download of received text messages
Some users have reported a problem with the received text message report: > I have tested the reply service but in the excel report the mobile > number is showing as 4.47900E+23. How can I change the format so that > it is show the mobile number that has replied? This is happening because Excel is interpreting a phone number in the format `447900900123` as a number in [scientific notation](https://en.wikipedia.org/wiki/Scientific_notation), in other words 4.479 × 10<sup>23</sup>. `447900900123` is the format that our provider is giving us the number in – there’s no guarantee it will always be in this format. We can prevent this behaviour by putting spaces in the numbers. Excel and Google Sheets won’t try to convert a string with spaces into a number. I think we used to do this for the sent text messages report but probably stopped because we decided it was better to keep the phone number in the same format as it had been supplied to us for reconcilliation purposes.
This commit is contained in:
@@ -15,6 +15,7 @@ from flask import (
|
||||
url_for,
|
||||
)
|
||||
from flask_login import current_user
|
||||
from notifications_utils.recipients import format_phone_number_human_readable
|
||||
from werkzeug.utils import redirect
|
||||
|
||||
from app import (
|
||||
@@ -202,7 +203,7 @@ def inbox_download(service_id):
|
||||
'Message',
|
||||
'Received',
|
||||
]] + [[
|
||||
message['user_number'],
|
||||
format_phone_number_human_readable(message['user_number']),
|
||||
message['content'].lstrip(('=+-@')),
|
||||
format_datetime_numeric(message['created_at']),
|
||||
] for message in service_api_client.get_inbound_sms(service_id)['data']]
|
||||
|
||||
Reference in New Issue
Block a user