Skip to content

Commit

Permalink
Merge pull request #30 from QuanMPhm/29/remove_HU_BU
Browse files Browse the repository at this point in the history
Removed HU invoice processing and added S3 export function for HU-BU invoice
  • Loading branch information
knikolla authored Apr 25, 2024
2 parents d61d2ba + 3ee0837 commit b1f1af1
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions process_report/process_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,6 @@ def main():
default="pi_invoices",
help="Name of output folder containing pi-specific invoice csvs",
)
parser.add_argument(
"--HU-invoice-file",
required=False,
default="HU_only.csv",
help="Name of output csv for HU invoice",
)
parser.add_argument(
"--HU-BU-invoice-file",
required=False,
Expand Down Expand Up @@ -200,23 +194,21 @@ def main():

export_billables(credited_projects, args.output_file)
export_pi_billables(credited_projects, args.output_folder, invoice_month)
export_HU_only(credited_projects, args.HU_invoice_file)
export_HU_BU(credited_projects, args.HU_BU_invoice_file)
export_lenovo(credited_projects, args.Lenovo_file)

if args.upload_to_s3:
invoice_list = [
args.nonbillable_file,
args.output_file,
args.HU_invoice_file,
args.HU_BU_invoice_file,
args.Lenovo_file,
]

for pi_invoice in os.listdir(args.output_folder):
invoice_list.append(os.path.join(args.output_folder, pi_invoice))

upload_to_s3(invoice_list, invoice_month)
upload_to_s3_HU_BU(args.HU_BU_invoice_file, invoice_month)


def fetch_S3_invoices(invoice_month):
Expand Down Expand Up @@ -381,11 +373,6 @@ def export_pi_billables(dataframe: pandas.DataFrame, output_folder, invoice_mont
)


def export_HU_only(dataframe, output_file):
HU_projects = dataframe[dataframe[INSTITUTION_FIELD] == "Harvard University"]
HU_projects.to_csv(output_file)


def export_HU_BU(dataframe, output_file):
HU_BU_projects = dataframe[
(dataframe[INSTITUTION_FIELD] == "Harvard University")
Expand Down Expand Up @@ -426,5 +413,17 @@ def upload_to_s3(invoice_list: list, invoice_month):
invoice_bucket.upload_file(invoice_filename, invoice_s3_path_archive)


def upload_to_s3_HU_BU(invoice_filename, invoice_month):
invoice_bucket = get_invoice_bucket()
invoice_bucket.upload_file(
invoice_filename,
f"Invoices/{invoice_month}/NERC-{invoice_month}-Total-Invoice.csv",
)
invoice_bucket.upload_file(
invoice_filename,
f"Invoices/{invoice_month}/Archive/NERC-{invoice_month}-Total-Invoice {get_iso8601_time()}.csv",
)


if __name__ == "__main__":
main()

0 comments on commit b1f1af1

Please sign in to comment.