Skip to content

Commit

Permalink
Added MOCA Prepaid Invoice
Browse files Browse the repository at this point in the history
This invoice has custom output filepaths for S3,
and only lists projects belonging to prepay groups not
managed by MGHPCC
  • Loading branch information
QuanMPhm committed Dec 12, 2024
1 parent e8ad7d8 commit d69cd85
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
41 changes: 41 additions & 0 deletions process_report/invoices/MOCA_prepaid_invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from process_report.invoices import invoice
import process_report.util as util


class MOCAPrepaidInvoice(invoice.Invoice):
export_columns_list = [
invoice.INVOICE_DATE_FIELD,
invoice.PROJECT_FIELD,
invoice.PROJECT_ID_FIELD,
invoice.PI_FIELD,
invoice.INVOICE_EMAIL_FIELD,
invoice.INVOICE_ADDRESS_FIELD,
invoice.INSTITUTION_FIELD,
invoice.INSTITUTION_ID_FIELD,
invoice.SU_HOURS_FIELD,
invoice.SU_TYPE_FIELD,
invoice.RATE_FIELD,
invoice.GROUP_NAME_FIELD,
invoice.GROUP_INSTITUTION_FIELD,
invoice.GROUP_BALANCE_FIELD,
invoice.COST_FIELD,
invoice.GROUP_BALANCE_USED_FIELD,
invoice.CREDIT_FIELD,
invoice.CREDIT_CODE_FIELD,
invoice.BALANCE_FIELD,
]

@property
def output_path(self) -> str:
return f"MOCA-A_Prepaid_Groups-{self.invoice_month}-Invoice.csv"

@property
def output_s3_key(self) -> str:
return f"Invoices/{self.invoice_month}/MOCA-A_Prepaid_Groups-{self.invoice_month}-Invoice.csv"

@property
def output_s3_archive_key(self):
return f"Invoices/{self.invoice_month}/Archive/MOCA-A_Prepaid_Groups-{self.invoice_month}-Invoice {util.get_iso8601_time()}.csv"

def _prepare_export(self):
self.data = self.data[self.data[invoice.GROUP_MANAGED_FIELD] == False] # noqa: E712
6 changes: 6 additions & 0 deletions process_report/process_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
NERC_total_invoice,
bu_internal_invoice,
pi_specific_invoice,
MOCA_prepaid_invoice,
)
from process_report.processors import (
validate_pi_alias_processor,
Expand Down Expand Up @@ -344,6 +345,10 @@ def main():
name=args.output_folder, invoice_month=invoice_month, data=processed_data.copy()
)

moca_prepaid_inv = MOCA_prepaid_invoice.MOCAPrepaidInvoice(
name="", invoice_month=invoice_month, data=processed_data.copy()
)

util.process_and_export_invoices(
[
lenovo_inv,
Expand All @@ -352,6 +357,7 @@ def main():
nerc_total_inv,
bu_internal_inv,
pi_inv,
moca_prepaid_inv,
],
args.upload_to_s3,
)
Expand Down

0 comments on commit d69cd85

Please sign in to comment.