Skip to content

Commit

Permalink
Add vendor name (#223)
Browse files Browse the repository at this point in the history
* Add vendor name

Why these changes are being introduced:
* Stakeholders requested that the vendor name be added to the credit card slips email

How this addresses that need:
* Update extract_credit_card_slip_data function to include vendor name
* Add vendor name to XML template
* Update PR template
* Update fixtures and unit tests to account for code changes

Side effects of this change:
* None

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/INFRA-439

* Update Pipfile.lock

* Update moto call
  • Loading branch information
ehanson8 committed May 16, 2024
1 parent 603d196 commit bdf569e
Show file tree
Hide file tree
Showing 8 changed files with 585 additions and 380 deletions.
33 changes: 12 additions & 21 deletions .github/pull-request-template.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,29 @@
### What does this PR do?

Describe the overall purpose of the PR changes. Doesn't need to be as specific as the
individual commits.

### Helpful background context

Describe any additional context beyond what the PR accomplishes if it is likely to be
useful to a reviewer.

Delete this section if it isn't applicable to the PR.
### Purpose and background context
Describe the overall purpose of the PR changes and any useful background context.

### How can a reviewer manually see the effects of these changes?

Explain how to see the proposed changes in the application if possible.

Delete this section if it isn't applicable to the PR.

### Includes new or updated dependencies?
YES | NO

### Changes expectations for external applications?
YES | NO

### What are the relevant tickets?

Include links to Jira Software and/or Jira Service Management tickets here.
- Include links to Jira Software and/or Jira Service Management tickets here.

### Developer

- [ ] All new ENV is documented in README (or there is none)
- [ ] All new ENV is documented in README
- [ ] All new ENV has been added to staging and production environments
- [ ] All related Jira tickets are linked in commit message(s)
- [ ] Stakeholder approval has been confirmed (or is not needed)

### Code Reviewer

- [ ] The commit message is clear and follows our guidelines (not just this pull request message)
### Code Reviewer(s)
- [ ] The commit message is clear and follows our guidelines (not just this PR message)
- [ ] There are appropriate tests covering any new functionality
- [ ] The documentation has been updated or is unnecessary
- [ ] The changes have been verified
- [ ] The provided documentation is sufficient for understanding any new functionality introduced
- [ ] Any manual tests have been performed and verified
- [ ] New dependencies are appropriate or there were no changes
900 changes: 548 additions & 352 deletions Pipfile.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ccslips/polines.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def extract_credit_card_slip_data(client: AlmaClient, po_line_record: dict) -> d
f"${get_total_price_from_fund_distribution(fund_distribution, price):.2f}"
),
"vendor_code": po_line_record.get("vendor_account", "No vendor found"),
"vendor_name": po_line_record.get("vendor", {}).get("desc", "No vendor found"),
}
po_line_data.update(get_account_data(client, fund_distribution))

Expand Down
6 changes: 6 additions & 0 deletions config/credit_card_slip_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<td class="cardholder" align="left"></td>
<td></td>
</tr>
<tr>
<td align="left">Vendor name:
</td>
<td class="vendor_name" align="left"></td>
<td></td>
</tr>
<tr>
<td align="left">Vendor code:
</td>
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
import requests_mock
from click.testing import CliRunner
from moto import mock_ses
from moto import mock_aws

from ccslips.alma import AlmaClient

Expand Down Expand Up @@ -136,7 +136,7 @@ def mocked_alma(fund_records, po_line_records):
# AWS fixtures
@pytest.fixture(autouse=True)
def mocked_ses():
with mock_ses():
with mock_aws():
ses = boto3.client("ses", region_name="us-east-1")
ses.verify_email_identity(EmailAddress="from@example.com")
yield ses
3 changes: 2 additions & 1 deletion tests/fixtures/po_line_records.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"resource_metadata": {
"title": "Book title"
},
"vendor_account": "Corporation"
"vendor_account": "CORP",
"vendor": {"value": "CORP", "desc": "Corporation"}
},
"missing_fields": {
"acquisition_method": {
Expand Down
3 changes: 2 additions & 1 deletion tests/test_alma.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def test_get_full_po_line(alma_client):
"number": "POL-all-fields",
"price": {"sum": "12.0"},
"resource_metadata": {"title": "Book title"},
"vendor_account": "Corporation",
"vendor_account": "CORP",
"vendor": {"value": "CORP", "desc": "Corporation"},
}


Expand Down
15 changes: 12 additions & 3 deletions tests/test_polines.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def test_extract_credit_card_slip_data_all_fields_present(alma_client, po_line_r
"quantity": "3",
"item_title": "Book title",
"total_price": "$12.00",
"vendor_code": "Corporation",
"vendor_code": "CORP",
"vendor_name": "Corporation",
}


Expand All @@ -40,6 +41,7 @@ def test_extract_credit_card_slip_data_missing_fields(alma_client, po_line_recor
"item_title": "Unknown title",
"total_price": "$0.00",
"vendor_code": "No vendor found",
"vendor_name": "No vendor found",
}


Expand Down Expand Up @@ -184,7 +186,8 @@ def test_generate_credit_card_slips_html_populates_all_fields():
"quantity": "3",
"item_title": "Book title",
"total_price": "$12.00",
"vendor_code": "Corporation",
"vendor_code": "CORP",
"vendor_name": "Corporation",
}
]
assert (
Expand Down Expand Up @@ -212,10 +215,16 @@ def test_generate_credit_card_slips_html_populates_all_fields():
<td class="cardholder" align="left">cardholder name</td>
<td />
</tr>
<tr>
<td align="left">Vendor name:
</td>
<td class="vendor_name" align="left">Corporation</td>
<td />
</tr>
<tr>
<td align="left">Vendor code:
</td>
<td class="vendor_code" align="left">Corporation</td>
<td class="vendor_code" align="left">CORP</td>
<td />
</tr>
<tr>
Expand Down

0 comments on commit bdf569e

Please sign in to comment.