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

19760 - initial partial refunds model persistence #1415

Merged
merged 5 commits into from
Feb 16, 2024

Conversation

ochiu
Copy link
Collaborator

@ochiu ochiu commented Feb 15, 2024

Issue #:
bcgov/entity#19760
Description of changes:

  • update refund schema - add optional refundRevenue
  • persist refund partial records
  • extend converter to support camel to snake case conversion of properties
  • extend converter to handle enum values vs enum objects

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the sbc-pay license (Apache 2.0).

Copy link

codecov bot commented Feb 15, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (79924ce) 91.45% compared to head (2dec863) 91.93%.
Report is 111 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1415      +/-   ##
==========================================
+ Coverage   91.45%   91.93%   +0.48%     
==========================================
  Files         186      193       +7     
  Lines       11319    12975    +1656     
==========================================
+ Hits        10352    11929    +1577     
- Misses        967     1046      +79     
Flag Coverage Δ
bcolapi ?
eventlistenerqueue 82.00% <ø> (+0.18%) ⬆️
payadmin ∅ <ø> (?)
paymentjobs 84.45% <ø> (+4.23%) ⬆️
paymentreconciliationsqueue 92.39% <ø> (+0.95%) ⬆️
reportapi ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
pay-api/src/pay_api/models/refunds_partial.py 95.65% <ø> (ø)
pay-api/src/pay_api/services/refund.py 94.41% <100.00%> (+0.56%) ⬆️
pay-api/src/pay_api/utils/converter.py 94.11% <88.00%> (-5.89%) ⬇️

... and 28 files with indirect coverage changes

@ochiu ochiu force-pushed the 19760-Partial-Refunds branch from aaa597a to e8179bf Compare February 16, 2024 16:39
# Conflicts:
#	pay-api/src/pay_api/models/refunds_partial.py
#	pay-api/src/pay_api/services/refund.py
#	pay-api/src/pay_api/utils/converter.py
- test update
- fix converter structure enum issue


class Converter(cattrs.Converter):
"""Addon to cattr converter."""

def __init__(self):
def __init__(self, camel_to_snake_case: bool = False, enum_to_value: bool = False):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably convert this into a data class for ConverterOptions if we start adding more configurations in the future

@ochiu ochiu marked this pull request as ready for review February 16, 2024 19:34
@ochiu ochiu requested review from seeker25 and Jxio as code owners February 16, 2024 19:34
Comment on lines 56 to 60
def find_by_invoice_id(cls, invoice_id: int):
"""Return refund partials by invoice id."""
return db.session.query(RefundsPartial)\
.join(PaymentLineItem, PaymentLineItem.id == RefundsPartial.payment_line_item_id)\
.filter(PaymentLineItem.invoice_id == invoice_id).all()
Copy link
Collaborator

@seeker25 seeker25 Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to put this in the service and keep the models barebones?

You reference to payment_line_item in the model, which could cause some pain of circular dependencies in the future

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, good call

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@seeker25 seeker25 merged commit 796cedd into bcgov:main Feb 16, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants