From 10a2ea1ec621974b2bb305c0afdb06c214ed4069 Mon Sep 17 00:00:00 2001 From: PSNAppZ Date: Mon, 7 Oct 2024 13:00:43 +0530 Subject: [PATCH] Add reported_in_mt940 to AccountingLog --- .../tasks/account_statement_generator.py | 6 +++++- .../models/account_statement.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/openg2p-g2p-bridge-example-bank-celery/src/openg2p_g2p_bridge_example_bank_celery/tasks/account_statement_generator.py b/openg2p-g2p-bridge-example-bank-celery/src/openg2p_g2p_bridge_example_bank_celery/tasks/account_statement_generator.py index cdd1a05..7b2abad 100644 --- a/openg2p-g2p-bridge-example-bank-celery/src/openg2p_g2p_bridge_example_bank_celery/tasks/account_statement_generator.py +++ b/openg2p-g2p-bridge-example-bank-celery/src/openg2p_g2p_bridge_example_bank_celery/tasks/account_statement_generator.py @@ -59,7 +59,8 @@ def account_statement_generator(account_statement_id: int): account_logs = ( session.execute( select(AccountingLog).where( - AccountingLog.account_number == account_statement.account_number + AccountingLog.account_number == account_statement.account_number, + AccountingLog.reported_in_mt940.is_(False), ) ) .scalars() @@ -115,6 +116,9 @@ def account_statement_generator(account_statement_id: int): f"\n{account_log.narrative_5}\n{account_log.narrative_6}", ) ) + # Update the log to indicate that it has been reported in the MT940 statement + account_log.reported_in_mt940 = True + statement = mt940_writer.create_statement( account_statement_id, diff --git a/openg2p-g2p-bridge-example-bank-models/src/openg2p_g2p_bridge_example_bank_models/models/account_statement.py b/openg2p-g2p-bridge-example-bank-models/src/openg2p_g2p_bridge_example_bank_models/models/account_statement.py index ffc8aa3..a8d0915 100644 --- a/openg2p-g2p-bridge-example-bank-models/src/openg2p_g2p_bridge_example_bank_models/models/account_statement.py +++ b/openg2p-g2p-bridge-example-bank-models/src/openg2p_g2p_bridge_example_bank_models/models/account_statement.py @@ -2,7 +2,7 @@ from enum import Enum from openg2p_fastapi_common.models import BaseORMModelWithTimes -from sqlalchemy import DateTime, Float, String, Text +from sqlalchemy import DateTime, Float, String, Text, Boolean from sqlalchemy import Enum as SqlEnum from sqlalchemy.orm import Mapped, mapped_column @@ -43,3 +43,4 @@ class AccountingLog(BaseORMModelWithTimes): narrative_6: Mapped[str] = mapped_column( String, nullable=True ) # beneficiary phone number + reported_in_mt940: Mapped[bool] = mapped_column(Boolean, default=False) \ No newline at end of file