diff --git a/koku/masu/database/aws_report_db_accessor.py b/koku/masu/database/aws_report_db_accessor.py index 4c4a9a8905..730705d3fd 100644 --- a/koku/masu/database/aws_report_db_accessor.py +++ b/koku/masu/database/aws_report_db_accessor.py @@ -329,11 +329,18 @@ def populate_markup_cost(self, provider_uuid, markup, start_date, end_date, bill OCPAWSCostLineItemProjectDailySummaryP.objects.filter( cost_entry_bill_id=bill_id, **date_filters ).update( - markup_cost=(F("unblended_cost") * markup), project_markup_cost=(F("unblended_cost") * markup) + markup_cost=(F("unblended_cost") * markup), + markup_cost_blended=(F("blended_cost") * markup), + markup_cost_savingsplan=(F("savingsplan_effective_cost") * markup), + markup_cost_amortized=(F("calculated_amortized_cost") * markup), + project_markup_cost=(F("calculated_amortized_cost") * markup), ) for ocpaws_model in OCP_ON_AWS_PERSPECTIVES: ocpaws_model.objects.filter(source_uuid=provider_uuid, **date_filters).update( - markup_cost=(F("unblended_cost") * markup) + markup_cost=(F("unblended_cost") * markup), + markup_cost_blended=(F("blended_cost") * markup), + markup_cost_savingsplan=(F("savingsplan_effective_cost") * markup), + markup_cost_amortized=(F("calculated_amortized_cost") * markup), ) OCPAllCostLineItemProjectDailySummaryP.objects.filter( diff --git a/koku/masu/database/sql/openshift/all/reporting_ocpallcostlineitem_daily_summary_aws.sql b/koku/masu/database/sql/openshift/all/reporting_ocpallcostlineitem_daily_summary_aws.sql index 6c6426a5b0..f53d2f3fe6 100644 --- a/koku/masu/database/sql/openshift/all/reporting_ocpallcostlineitem_daily_summary_aws.sql +++ b/koku/masu/database/sql/openshift/all/reporting_ocpallcostlineitem_daily_summary_aws.sql @@ -56,7 +56,7 @@ SELECT 'AWS'::text AS source_type, max(aws.unit), -- OCP on ALL tables should use calculated_amortized_cost sum(calculated_amortized_cost) as unblended_cost, - sum(aws.markup_cost), + sum(aws.markup_cost_amortized), max(aws.currency_code), max(cost_category_id) as cost_category_id, cast(1 as decimal) as shared_projects, diff --git a/koku/masu/database/sql/openshift/all/reporting_ocpallcostlineitem_project_daily_summary_aws.sql b/koku/masu/database/sql/openshift/all/reporting_ocpallcostlineitem_project_daily_summary_aws.sql index fb0190904f..4a425dbc54 100644 --- a/koku/masu/database/sql/openshift/all/reporting_ocpallcostlineitem_project_daily_summary_aws.sql +++ b/koku/masu/database/sql/openshift/all/reporting_ocpallcostlineitem_project_daily_summary_aws.sql @@ -58,7 +58,7 @@ SELECT 'AWS' as source_type, max(unit) as unit, -- OCP on ALL tables should use calculated_amortized_cost sum(calculated_amortized_cost) as unblended_cost, - sum(project_markup_cost) as project_markup_cost, + sum(markup_cost_amortized) as project_markup_cost, sum(pod_cost) as pod_cost, max(currency_code) as currency_code, max(cost_category_id) as cost_category_id, diff --git a/koku/masu/database/trino_sql/reporting_ocpawscostlineitem_daily_summary.sql b/koku/masu/database/trino_sql/reporting_ocpawscostlineitem_daily_summary.sql index 5146f4fda6..30b37611ad 100644 --- a/koku/masu/database/trino_sql/reporting_ocpawscostlineitem_daily_summary.sql +++ b/koku/masu/database/trino_sql/reporting_ocpawscostlineitem_daily_summary.sql @@ -1184,12 +1184,12 @@ SELECT pds.aws_uuid, ELSE calculated_amortized_cost / aws_uuid_count * cast({{markup}} as decimal(33,9)) END as markup_cost_amortized, CASE WHEN resource_id_matched = TRUE AND data_source = 'Pod' - THEN ({{pod_column | sqlsafe}} / {{node_column | sqlsafe}}) * unblended_cost - ELSE unblended_cost / aws_uuid_count + THEN ({{pod_column | sqlsafe}} / {{node_column | sqlsafe}}) * calculated_amortized_cost + ELSE calculated_amortized_cost / aws_uuid_count END as pod_cost, CASE WHEN resource_id_matched = TRUE AND data_source = 'Pod' - THEN ({{pod_column | sqlsafe}} / {{node_column | sqlsafe}}) * unblended_cost * cast({{markup}} as decimal(24,9)) - ELSE unblended_cost / aws_uuid_count * cast({{markup}} as decimal(24,9)) + THEN ({{pod_column | sqlsafe}} / {{node_column | sqlsafe}}) * calculated_amortized_cost * cast({{markup}} as decimal(24,9)) + ELSE calculated_amortized_cost / aws_uuid_count * cast({{markup}} as decimal(24,9)) END as project_markup_cost, pds.pod_labels, CASE WHEN pds.pod_labels IS NOT NULL @@ -1295,8 +1295,8 @@ SELECT max(savingsplan_effective_cost) * cast({{markup}} AS decimal(24,9)), max(calculated_amortized_cost), max(calculated_amortized_cost) * cast({{markup}} AS decimal(33,9)), - max(unblended_cost) AS pod_cost, - max(unblended_cost) * cast({{markup}} AS decimal(24,9)) AS project_markup_cost, + max(calculated_amortized_cost) AS pod_cost, + max(calculated_amortized_cost) * cast({{markup}} AS decimal(24,9)) AS project_markup_cost, max(ocp.pod_labels), cast(NULL AS varchar) AS tags, cast(NULL AS varchar) AS aws_cost_category,