-
Notifications
You must be signed in to change notification settings - Fork 39
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
21537 - Shortname Refunds - PUT and GET methods #1758
Open
seeker25
wants to merge
2
commits into
bcgov:main
Choose a base branch
from
seeker25:21537
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Fix audit columns for eft_refunds. | ||
|
||
Revision ID: 75a39e02c746 | ||
Revises: 29f59e6f147b | ||
Create Date: 2024-09-20 13:45:35.132557 | ||
|
||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
# revision identifiers, used by Alembic. | ||
# Note you may see foreign keys with distribution_codes_history | ||
# For disbursement_distribution_code_id, service_fee_distribution_code_id | ||
# Please ignore those lines and don't include in migration. | ||
|
||
revision = '75a39e02c746' | ||
down_revision = '29f59e6f147b' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('eft_refunds', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('created_name', sa.String(length=100), nullable=True)) | ||
batch_op.add_column(sa.Column('updated_name', sa.String(length=50), nullable=True)) | ||
batch_op.alter_column('updated_by', | ||
existing_type=sa.VARCHAR(length=100), | ||
type_=sa.String(length=50), | ||
existing_nullable=True) | ||
batch_op.drop_column('updated_by_name') | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('eft_refunds', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('updated_by_name', sa.VARCHAR(length=100), autoincrement=False, nullable=True)) | ||
batch_op.alter_column('updated_by', | ||
existing_type=sa.String(length=50), | ||
type_=sa.VARCHAR(length=100), | ||
existing_nullable=True) | ||
batch_op.drop_column('updated_name') | ||
batch_op.drop_column('created_name') | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Init.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
"""Rationale behind creating these DTOS below. | ||
|
||
1. To ensure that the request and response payloads are validated before they are passed to the service layer. | ||
2. To ensure that the request and response payloads are consistent across the application. | ||
3. To ensure that the request and response payloads are consistent with the API documentation. | ||
|
||
In the near future, will find a library that generates our API spec based off of these DTOs. | ||
""" | ||
from decimal import Decimal | ||
from typing import List | ||
from attrs import define | ||
|
||
from pay_api.utils.converter import Converter | ||
|
||
|
||
@define | ||
class EFTShortNameGetRequest: | ||
"""EFT Short name search.""" | ||
|
||
short_name: str = None | ||
short_name_id: int = None | ||
short_name_type: str = None | ||
amount_owing: Decimal = None | ||
statement_id: int = None | ||
state: str = None | ||
page: int = 1 | ||
limit: int = 10 | ||
account_id: int = None | ||
account_name: str = None | ||
account_branch: str = None | ||
account_id_list: str = None | ||
|
||
@classmethod | ||
def from_dict(cls, data: dict): | ||
"""Convert from request args to EFTShortNameSearchDTO.""" | ||
dto = Converter(camel_to_snake_case=True).structure(data, EFTShortNameGetRequest) | ||
# In the future, we'll need a cleaner way to handle this. | ||
dto.state = dto.state.split(',') if dto.state else None | ||
dto.account_id_list = dto.account_id_list.split(',') if dto.account_id_list else None | ||
return dto | ||
|
||
|
||
@define | ||
class EFTShortNameSummaryGetRequest: | ||
"""EFT Short name summary search.""" | ||
|
||
short_name: str = None | ||
short_name_id: int = None | ||
short_name_type: str = None | ||
credits_remaining: Decimal = None | ||
linked_accounts_count: int = None | ||
payment_received_start_date: str = None | ||
payment_received_end_date: str = None | ||
page: int = 1 | ||
limit: int = 10 | ||
|
||
@classmethod | ||
def from_dict(cls, data: dict): | ||
"""Convert from request args to EFTShortNameSummarySearchDTO.""" | ||
dto = Converter(camel_to_snake_case=True).structure(data, EFTShortNameSummaryGetRequest) | ||
return dto | ||
|
||
|
||
@define | ||
class EFTShortNameRefundPatchRequest: | ||
"""EFT Short name refund DTO.""" | ||
|
||
comment: str | ||
decline_reason: str | ||
status: str | ||
|
||
@classmethod | ||
def from_dict(cls, data: dict): | ||
"""Convert from request json to EFTShortNameRefundDTO.""" | ||
return Converter(camel_to_snake_case=True).structure(data, EFTShortNameRefundPatchRequest) | ||
|
||
def to_dict(self): | ||
"""Convert from EFTShortNameRefundDTO to request json.""" | ||
return Converter(snake_case_to_camel=True).unstructure(self) | ||
|
||
|
||
@define | ||
class EFTShortNameRefundGetRequest: | ||
"""EFT Short name refund DTO.""" | ||
|
||
statuses: List[str] | ||
|
||
@classmethod | ||
def from_dict(cls, data: dict): | ||
"""Convert from request json to EFTShortNameRefundDTO.""" | ||
input_string = data.get('status', '') | ||
statuses = input_string.split(',') if input_string else [] | ||
return EFTShortNameRefundGetRequest(statuses=statuses) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 7 was a bit too low, 15 is reasonable.. for some of our larger search dataclasses