Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitleaksignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ cd9c0efec38c5d63053dd865e5d4e207c0760d91:docs/guides/Perform_static_analysis.md:
e2fd9d99d561c274cfd11b85a99a0cb1ae00f97d:infrastructure/terraform/components/reporting/templates/cloudinit_config.ps1:ipv4:28
8cd75c04961cd6ce8477b7dad9c6daa67f03cd19:infrastructure/terraform/components/reporting/templates/cloudinit_config.tmpl:ipv4:32
9b7b5b4539e13109e15c474684911b5a349c1b6d:infrastructure/terraform/components/reporting/scripts/sql/views/request_item_status_summary_all_emailfilter.sql:generic-api-key:12
d38af4e4f6c36ca9c3d843193b434386a9bad5ee:infrastructure/terraform/etc/env_eu-west-2_int.tfvars:generic-api-key:29
d38af4e4f6c36ca9c3d843193b434386a9bad5ee:infrastructure/terraform/etc/env_eu-west-2_prod.tfvars:generic-api-key:43
ca243cb73d3804a14f3eeefa8073c96802420c52:infrastructure/terraform/etc/env_eu-west-2_int.tfvars:generic-api-key:29
ca243cb73d3804a14f3eeefa8073c96802420c52:infrastructure/terraform/etc/env_eu-west-2_prod.tfvars:generic-api-key:43
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ data "aws_iam_policy_document" "sso_read_only_table_access" {
"arn:aws:glue:${var.region}:${var.aws_account_id}:table/${var.project}-*-reporting-database/monthly_recipient_with_more_than_five_messages",
"arn:aws:glue:${var.region}:${var.aws_account_id}:table/${var.project}-*-reporting-database/monthly_recipients_distribution",
"arn:aws:glue:${var.region}:${var.aws_account_id}:table/${var.project}-*-reporting-database/monthly_recipients_distribution_by_integrator",
"arn:aws:glue:${var.region}:${var.aws_account_id}:table/${var.project}-*-reporting-database/billing_transactions",
],
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ data "aws_iam_policy_document" "powerbi_gateway_permissions_policy" {
"arn:aws:glue:${var.region}:${local.this_account}:table/${aws_glue_catalog_database.reporting.name}/monthly_recipient_with_more_than_five_messages",
"arn:aws:glue:${var.region}:${local.this_account}:table/${aws_glue_catalog_database.reporting.name}/monthly_recipients_distribution",
"arn:aws:glue:${var.region}:${local.this_account}:table/${aws_glue_catalog_database.reporting.name}/monthly_recipients_distribution_by_integrator",
"arn:aws:glue:${var.region}:${local.this_account}:table/${aws_glue_catalog_database.reporting.name}/billing_transactions",
]
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "null_resource" "billing_transactions_view" {
triggers = {
sql = filesha256("${path.module}/scripts/sql/views/billing_transactions.sql")
}

provisioner "local-exec" {
command = <<EOT
${path.module}/scripts/create_replace_view.sh \
${aws_athena_workgroup.setup.name} \
${aws_glue_catalog_database.reporting.name} \
billing_transactions
EOT
}

depends_on = [
null_resource.request_item_plan_status_table,
null_resource.request_item_status_table
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
CREATE OR REPLACE VIEW ${view_name} AS
SELECT
DATE(rip.completedtime) AS billingdate,
rip.clientid,
rip.campaignid,
ri.billingref,
rip.senderodscode,
rip.communicationtype,
rip.specificationid,
rip.specificationbillingid,
rip.messagelength,
rip.messagelengthunits,
COUNT(*) AS messagecount
FROM request_item_plan_status rip
INNER JOIN request_item_status ri
ON
rip.clientid = ri.clientid AND
rip.requestitemid = ri.requestitemid
WHERE
rip.completedtime IS NOT NULL AND
(
(
--Bill for all text messages forwarded to the supplier
(rip.communicationtype ='SMS') AND (rip.status IN ('DELIVERED', 'FAILED')) AND (sendtime IS NOT NULL)
) OR (
--Bill for all letters accepted by the supplier
(rip.communicationtype ='LETTER') AND (rip.status='DELIVERED')
)
)
GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Loading