diff --git a/app/api/services/eligibility_check.py b/app/api/services/eligibility_check.py index 5343a3a..a4bffcb 100644 --- a/app/api/services/eligibility_check.py +++ b/app/api/services/eligibility_check.py @@ -60,7 +60,7 @@ class EligibilityCheckService(BaseService): } return response_data - except ValidationError as err: + except (ValidationError, ValueError) as err: logger.error(f"Validation Error: {err.messages}") return jsonify({ "message": "Validation exception" diff --git a/app/models/transaction.py b/app/models/transaction.py index 010b31e..5343e80 100644 --- a/app/models/transaction.py +++ b/app/models/transaction.py @@ -17,6 +17,9 @@ class Transaction(db.Model): @classmethod def create_transaction(cls, id, account_id, customer_id, type, channel, msisdn, country_code,): + if cls.query.filter_by(id=id).first(): + raise ValueError("Transaction with this id already exists") + transaction = cls( id=id, customer_id=customer_id, diff --git a/docker-compose.yml b/docker-compose.yml index aca41e0..ef41164 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,8 @@ services: digifi-bank-to-product-core: build: . + env_file: + - .env ports: - "${APP_PORT:-4500}:5000" environment: diff --git a/requirements.txt b/requirements.txt index 3c9ceeb..b807973 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,12 @@ # Flask and Extensions Flask==2.3.3 +# Database +flask-sqlalchemy +flask-migrate +psycopg2-binary +alembic + # Schema for validations Flask-Marshmallow==0.15.0 marshmallow==3.19.0 @@ -14,19 +20,6 @@ gunicorn # Swagger flask-swagger-ui -# Database -flask-sqlalchemy -flask-migrate -psycopg2-binary -alembic - # Env python-dotenv - - - - -# Logging (Python Standard Library, for reference) - -