-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
18468 - EFT Credits / Model updates (#1315)
* 17829 - EFT Credits / Model updates * Remove unused EFT/WIRE tests and methods * eft model updates for reconciliation handling * fix eft_transactions model column typo * fix eft_transaction model mapper * revert update invoice flow changes - does not apply to EFT * move deduct eft credits tests to payment account service * EFT Credit model updates * PR feedback, fix tests
- Loading branch information
Showing
14 changed files
with
337 additions
and
73 deletions.
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
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
56 changes: 56 additions & 0 deletions
56
...api/migrations/versions/2023_10_27_598bbfce4dad_17829_eft_credits_shortname_versioning.py
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,56 @@ | ||
"""17829-eft-credits-shortname-versioning | ||
Revision ID: 598bbfce4dad | ||
Revises: 194cdd7cf986 | ||
Create Date: 2023-10-27 12:11:36.931753 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '598bbfce4dad' | ||
down_revision = '2ef58b39cafc' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table('eft_credits', | ||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), | ||
sa.Column('amount', sa.Numeric(), nullable=False), | ||
sa.Column('remaining_amount', sa.Numeric(), nullable=False), | ||
sa.Column('payment_account_id', sa.Integer(), nullable=True), | ||
sa.Column('eft_file_id', sa.Integer(), nullable=False), | ||
sa.Column('short_name_id', sa.Integer(), nullable=False), | ||
sa.Column('created_on', sa.DateTime(), nullable=False), | ||
sa.ForeignKeyConstraint(['payment_account_id'], ['payment_accounts.id'], ), | ||
sa.ForeignKeyConstraint(['eft_file_id'], ['eft_files.id'], ), | ||
sa.ForeignKeyConstraint(['short_name_id'], ['eft_short_names.id'], ), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
|
||
op.create_table('eft_short_names_version', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('short_name', sa.String(), nullable=False), | ||
sa.Column('auth_account_id', sa.String(length=50), nullable=True), | ||
sa.Column('created_on', sa.DateTime(), nullable=False), | ||
sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False), | ||
sa.Column('end_transaction_id', sa.BigInteger(), nullable=True), | ||
sa.Column('operation_type', sa.SmallInteger(), nullable=False), | ||
sa.PrimaryKeyConstraint('id', 'transaction_id') | ||
) | ||
|
||
op.add_column('eft_transactions', sa.Column('short_name_id', sa.Integer(), nullable=True)) | ||
op.add_column('eft_transactions', sa.Column('deposit_amount_cents', sa.BigInteger(), nullable=True)), | ||
op.create_foreign_key('eft_transactions_short_name_fk', 'eft_transactions', | ||
'eft_short_names', ['short_name_id'], ['id']) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('eft_credits') | ||
op.drop_table('eft_short_names_version') | ||
op.drop_constraint('eft_transactions_short_name_fk', 'eft_transactions', type_='foreignkey') | ||
op.drop_column('eft_transactions', 'short_name_id') | ||
op.drop_column('eft_transactions', 'deposit_amount_cents') |
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,61 @@ | ||
# Copyright © 2023 Province of British Columbia | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Model to handle all operations related to EFT Credits data.""" | ||
from datetime import datetime | ||
from sqlalchemy import ForeignKey | ||
|
||
from .base_model import BaseModel | ||
from .db import db | ||
|
||
|
||
class EFTCredit(BaseModel): # pylint:disable=too-many-instance-attributes | ||
"""This class manages all of the base data for EFT credits.""" | ||
|
||
__tablename__ = 'eft_credits' | ||
# this mapper is used so that new and old versions of the service can be run simultaneously, | ||
# making rolling upgrades easier | ||
# This is used by SQLAlchemy to explicitly define which fields we're interested | ||
# so it doesn't freak out and say it can't map the structure if other fields are present. | ||
# This could occur from a failed deploy or during an upgrade. | ||
# The other option is to tell SQLAlchemy to ignore differences, but that is ambiguous | ||
# and can interfere with Alembic upgrades. | ||
# | ||
# NOTE: please keep mapper names in alpha-order, easier to track that way | ||
# Exception, id is always first, _fields first | ||
__mapper_args__ = { | ||
'include_properties': [ | ||
'id', | ||
'amount', | ||
'created_on', | ||
'eft_file_id', | ||
'short_name_id', | ||
'payment_account_id', | ||
'remaining_amount' | ||
] | ||
} | ||
|
||
id = db.Column(db.Integer, primary_key=True, autoincrement=True) | ||
|
||
amount = db.Column(db.Numeric(19, 2), nullable=False) | ||
remaining_amount = db.Column(db.Numeric(19, 2), nullable=False) | ||
created_on = db.Column('created_on', db.DateTime, nullable=True, default=datetime.now) | ||
|
||
eft_file_id = db.Column(db.Integer, ForeignKey('eft_files.id'), nullable=False) | ||
short_name_id = db.Column(db.Integer, ForeignKey('eft_short_names.id'), nullable=False) | ||
payment_account_id = db.Column(db.Integer, ForeignKey('payment_accounts.id'), nullable=True, index=True) | ||
|
||
@classmethod | ||
def find_by_payment_account_id(cls, payment_account_id: int): | ||
"""Find EFT Credit by payment account id.""" | ||
return cls.query.filter_by(payment_account_id=payment_account_id).all() |
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.