From 0bd12642ede5ff12c7d631f459e8efb5ff38b375 Mon Sep 17 00:00:00 2001 From: Jeremy Nelson Date: Wed, 13 Nov 2024 14:36:28 -0800 Subject: [PATCH] feat: Adjusts expense codes and adds tests for changed spreadsheet --- .../plugins/folio/helpers/constants.py | 38 ++++++++++++------- libsys_airflow/plugins/orafin/models.py | 5 +++ tests/orafin/test_models.py | 32 ++++++++++++++++ 3 files changed, 62 insertions(+), 13 deletions(-) diff --git a/libsys_airflow/plugins/folio/helpers/constants.py b/libsys_airflow/plugins/folio/helpers/constants.py index b11445c1..149e4fa6 100644 --- a/libsys_airflow/plugins/folio/helpers/constants.py +++ b/libsys_airflow/plugins/folio/helpers/constants.py @@ -82,6 +82,12 @@ 'material type': 'periodical', 'Expense code': '53262', }, + { + 'acquisition method': 'Package', + 'order format': 'Electronic Resource', + 'material type': 'periodical', + 'Expense code': '53262', + }, { 'acquisition method': 'Maintenance fee', 'order format': 'Electronic Resource', @@ -90,39 +96,45 @@ }, { 'acquisition method': nan, - 'order format': 'Physical Resource', - 'material type': 'sound recording', - 'Expense code': '53270', + 'order format': nan, + 'material type': 'archival', + 'Expense code': '53265', }, { 'acquisition method': nan, - 'order format': 'Physical Resource', + 'order format': nan, 'material type': 'map', 'Expense code': '53270', }, { 'acquisition method': nan, - 'order format': 'Physical Resource', - 'material type': 'microform', - 'Expense code': '53250', + 'order format': nan, + 'material type': 'score', + 'Expense code': '53270', }, { 'acquisition method': nan, - 'order format': 'Physical Resource', - 'material type': 'score', + 'order format': nan, + 'material type': 'sound recording', + 'Expense code': '53270', + }, + { + 'acquisition method': nan, + 'order format': nan, + 'material type': 'video recording', 'Expense code': '53270', }, { 'acquisition method': nan, 'order format': 'Physical Resource', - 'material type': 'software', - 'Expense code': '55410', + 'material type': 'microform', + 'Expense code': '53250', }, { 'acquisition method': nan, 'order format': 'Physical Resource', - 'material type': 'video recording', - 'Expense code': '53270', + 'material type': 'software', + 'Expense code': '55410', }, { 'acquisition method': 'Shipping', diff --git a/libsys_airflow/plugins/orafin/models.py b/libsys_airflow/plugins/orafin/models.py index 1caa558b..85e654ab 100644 --- a/libsys_airflow/plugins/orafin/models.py +++ b/libsys_airflow/plugins/orafin/models.py @@ -383,6 +383,11 @@ def _invoice_line_expense_line(self, invoice_line: InvoiceLine) -> None: == invoice_line.poLine.orderFormat ) ), + # Attempts match on material type + ( + self.expense_codes_df["material type uuid"] # type: ignore + == invoice_line.poLine.materialType + ), # Attempts match for Shipping ( ( diff --git a/tests/orafin/test_models.py b/tests/orafin/test_models.py index d9d75719..064bb714 100644 --- a/tests/orafin/test_models.py +++ b/tests/orafin/test_models.py @@ -215,6 +215,20 @@ def test_expense_codes(mock_folio_client): orderFormat=None, ) + periodical_package = PurchaseOrderLine( + id=str(uuid.uuid4()), + acquisitionMethod="a8737ea5-c500-41a0-8d17-0390ada22727", + materialType="d934e614-215d-4667-b231-aed97887f289", + orderFormat="Electronic Resource", + ) + + archival = PurchaseOrderLine( + id=str(uuid.uuid4()), + acquisitionMethod=None, + materialType='69edaa1b-e40b-4f1c-8cb5-4b615ac6a664', + orderFormat=None, + ) + match_default = PurchaseOrderLine( id=str(uuid.uuid4()), acquisitionMethod="e2ce5ac8-2d48-45e8-b39c-c2d02e17a366", @@ -314,6 +328,22 @@ def test_expense_codes(mock_folio_client): total=0.00, poLine=match_default, ), + InvoiceLine( + id=str(uuid.uuid4()), + adjustmentsTotal=0.00, + invoiceLineNumber="11", + subTotal=0.00, + total=0.00, + poLine=periodical_package, + ), + InvoiceLine( + id=str(uuid.uuid4()), + adjustmentsTotal=0.00, + invoiceLineNumber="12", + subTotal=0.00, + total=0.00, + poLine=archival, + ), ], ) @@ -330,6 +360,8 @@ def test_expense_codes(mock_folio_client): assert feeder_file.invoices[0].lines[7].expense_code == "55410" assert feeder_file.invoices[0].lines[8].expense_code == "55320" assert feeder_file.invoices[0].lines[9].expense_code == "53245" + assert feeder_file.invoices[0].lines[10].expense_code == "53262" + assert feeder_file.invoices[0].lines[11].expense_code == "53265" feeder_file.invoices[0].lines[0].poLine = None feeder_file.add_expense_lines(mock_folio_client)