Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed HU invoice processing and added S3 export function for HU-BU invoice #30

Merged
merged 2 commits into from
Apr 25, 2024
Merged
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
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()
Loading