-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from PSNAppz/develop
Mt940 Generator
- Loading branch information
Showing
29 changed files
with
686 additions
and
235 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
EXAMPLE_BANK_HOST=0.0.0.0 | ||
EXAMPLE_BANK_PORT=8003 |
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
9 changes: 9 additions & 0 deletions
9
openg2p-g2p-bridge-example-bank-api/src/openg2p_g2p_bridge_example_bank_api/celery_app.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,9 @@ | ||
from celery import Celery | ||
|
||
celery_app = Celery( | ||
"example_bank", | ||
broker="redis://localhost:6379/0", | ||
backend="redis://localhost:6379/0", | ||
) | ||
|
||
celery_app.conf.timezone = "UTC" |
13 changes: 10 additions & 3 deletions
13
...p-bridge-example-bank-api/src/openg2p_g2p_bridge_example_bank_api/controllers/__init__.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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
from openg2p_g2p_bridge_example_bank_api.controllers.block_funds import BlockFundsController | ||
from openg2p_g2p_bridge_example_bank_api.controllers.check_available_funds import FundAvailabilityController | ||
from openg2p_g2p_bridge_example_bank_api.controllers.initiate_payment import PaymentController | ||
from .account_statement import AccountStatementController | ||
from .block_funds import ( | ||
BlockFundsController, | ||
) | ||
from .check_available_funds import ( | ||
FundAvailabilityController, | ||
) | ||
from .initiate_payment import ( | ||
PaymentController, | ||
) |
69 changes: 69 additions & 0 deletions
69
...example-bank-api/src/openg2p_g2p_bridge_example_bank_api/controllers/account_statement.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,69 @@ | ||
import logging | ||
|
||
from openg2p_fastapi_common.context import dbengine | ||
from openg2p_fastapi_common.controller import BaseController | ||
from openg2p_g2p_bridge_example_bank_models.models import Account, AccountStatement | ||
from openg2p_g2p_bridge_example_bank_models.schemas import ( | ||
AccountStatementRequest, | ||
AccountStatementResponse, | ||
) | ||
from sqlalchemy.ext.asyncio import async_sessionmaker | ||
from sqlalchemy.future import select | ||
|
||
from ..celery_app import celery_app | ||
from ..config import Settings | ||
|
||
_config = Settings.get_config() | ||
_logger = logging.getLogger(_config.logging_default_logger_name) | ||
|
||
|
||
class AccountStatementController(BaseController): | ||
def __init__(self, **kwargs): | ||
super().__init__(**kwargs) | ||
|
||
self.router.tags += ["Account Statement"] | ||
|
||
self.router.add_api_route( | ||
"/generate_account_statement", | ||
self.generate_account_statement, | ||
response_model=AccountStatementResponse, | ||
methods=["POST"], | ||
) | ||
|
||
async def generate_account_statement( | ||
self, account_statement_request: AccountStatementRequest | ||
) -> AccountStatementResponse: | ||
_logger.info("Generating account statement") | ||
session_maker = async_sessionmaker(dbengine.get(), expire_on_commit=False) | ||
async with session_maker() as session: | ||
stmt = select(Account).where( | ||
Account.account_number | ||
== account_statement_request.program_account_number | ||
) | ||
result = await session.execute(stmt) | ||
account = result.scalars().first() | ||
|
||
if not account: | ||
_logger.error("Account not found") | ||
return AccountStatementResponse( | ||
status="failed", | ||
error_message="Account not found", | ||
) | ||
|
||
account_statement = AccountStatement( | ||
account_number=account_statement_request.program_account_number, | ||
active=True, | ||
) | ||
session.add(account_statement) | ||
await session.commit() | ||
|
||
# Create a new task to generate the account statement | ||
_logger.info("Account statement generation task created") | ||
celery_app.send_task( | ||
"account_statement_generator", | ||
args=(account_statement.id,), | ||
) | ||
|
||
return AccountStatementResponse( | ||
status="success", account_statement_id=str(account_statement.id) | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
EXAMPLE_BANK_HOST=0.0.0.0 | ||
EXAMPLE_BANK_PORT=8003 | ||
EXAMPLE_BANK_PROCESS_PAYMENT_FREQUENCY=3600 | ||
EXAMPLE_BANK_PAYMENT_INITIATE_ATTEMPTS=3 |
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 |
---|---|---|
|
@@ -78,4 +78,5 @@ docs/_build/ | |
|
||
# Ignore secret files and env | ||
.secrets.* | ||
../.env | ||
.env | ||
/db |
Binary file not shown.
Oops, something went wrong.