Skip to content

Commit

Permalink
feat: Adjusts expense codes and adds tests for changed spreadsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
jermnelson committed Nov 13, 2024
1 parent e59b7a4 commit 0bd1264
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 13 deletions.
38 changes: 25 additions & 13 deletions libsys_airflow/plugins/folio/helpers/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
5 changes: 5 additions & 0 deletions libsys_airflow/plugins/orafin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
(
(
Expand Down
32 changes: 32 additions & 0 deletions tests/orafin/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
),
],
)

Expand All @@ -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)
Expand Down

0 comments on commit 0bd1264

Please sign in to comment.