From 775afd2b772a6e7c01357e71fe3e74856634f3ec Mon Sep 17 00:00:00 2001 From: QuanMPhm Date: Wed, 15 May 2024 16:24:32 -0400 Subject: [PATCH] Added rounding to Cost and Rate for storage invoice Cost will now be rounded to 2 decimal points Rate will be rounded to 6 decimal points, since the Openshift Gb/hr rates at the time of this commit is $0.000009 --- .../management/commands/calculate_storage_gb_hours.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coldfront_plugin_cloud/management/commands/calculate_storage_gb_hours.py b/src/coldfront_plugin_cloud/management/commands/calculate_storage_gb_hours.py index b1bad40..33d0726 100644 --- a/src/coldfront_plugin_cloud/management/commands/calculate_storage_gb_hours.py +++ b/src/coldfront_plugin_cloud/management/commands/calculate_storage_gb_hours.py @@ -1,5 +1,5 @@ import csv -from decimal import Decimal +from decimal import Decimal, ROUND_HALF_UP import dataclasses from datetime import datetime, timedelta import logging @@ -161,7 +161,7 @@ def process_invoice_row(allocation, attrs, su_name, rate): Invoice_Type_Hours=time, Invoice_Type=su_name, Rate=rate, - Cost=time * rate + Cost=(time * rate).quantize(Decimal('.01'), rounding=ROUND_HALF_UP) ) csv_invoice_writer.writerow( row.get_values()