Move files to folders
This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,9 +1,8 @@
|
|||||||
|
# Bank Management System files
|
||||||
flask_session/
|
flask_session/
|
||||||
application/__pycache__/
|
session_data.json
|
||||||
application/session_data.json
|
bank.db
|
||||||
server/bank.db
|
log.txt
|
||||||
server/test_database.db
|
|
||||||
server/log.txt
|
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|||||||
43
database/class_account.py
Normal file
43
database/class_account.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# Lucas Mathews - Fontys Student ID: 5023572
|
||||||
|
# Banking System Account Class
|
||||||
|
|
||||||
|
from sqlalchemy import ForeignKey, Column, String, Integer, Boolean
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
|
from class_base import Base
|
||||||
|
|
||||||
|
class Account(Base):
|
||||||
|
__tablename__ = 'accounts'
|
||||||
|
account_id = Column("account_id", String, primary_key=True)
|
||||||
|
client_id = Column(String, ForeignKey('clients.client_id'))
|
||||||
|
description = Column("description", String)
|
||||||
|
open_timestamp = Column("open_timestamp", String)
|
||||||
|
account_type = Column("account_type", String)
|
||||||
|
balance = Column("balance", Integer)
|
||||||
|
enabled = Column("enabled", Boolean)
|
||||||
|
notes = Column("notes", String)
|
||||||
|
transactions = relationship("Transaction", foreign_keys='Transaction.account_id', backref="account")
|
||||||
|
|
||||||
|
def __init__(self, account_id, client_id, description, open_timestamp, account_type, balance, enabled, notes, transactions):
|
||||||
|
"""Initialises the account object."""
|
||||||
|
self.account_id = account_id
|
||||||
|
self.client_id = client_id
|
||||||
|
self.description = description
|
||||||
|
self.open_timestamp = open_timestamp
|
||||||
|
self.account_type = account_type
|
||||||
|
self.balance = balance
|
||||||
|
self.enabled = enabled
|
||||||
|
self.notes = notes
|
||||||
|
self.transactions = transactions if transactions is not None else []
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
"""Returns the account as a dictionary."""
|
||||||
|
return {
|
||||||
|
"account_id": self.account_id,
|
||||||
|
"client_id": self.client_id,
|
||||||
|
"description": self.description,
|
||||||
|
"open_timestamp": self.open_timestamp,
|
||||||
|
"account_type": self.account_type,
|
||||||
|
"balance": self.balance,
|
||||||
|
"notes": self.notes
|
||||||
|
}
|
||||||
6
database/class_base.py
Normal file
6
database/class_base.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Lucas Mathews - Fontys Student ID: 5023572
|
||||||
|
# Banking System Base Class
|
||||||
|
|
||||||
|
from sqlalchemy.orm import declarative_base
|
||||||
|
|
||||||
|
Base = declarative_base()
|
||||||
50
database/class_client.py
Normal file
50
database/class_client.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Lucas Mathews - Fontys Student ID: 5023572
|
||||||
|
# Banking System Client Class
|
||||||
|
|
||||||
|
from sqlalchemy import Column, String, Boolean
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
|
from class_base import Base
|
||||||
|
|
||||||
|
class Client(Base):
|
||||||
|
__tablename__ = 'clients'
|
||||||
|
client_id = Column("client_id", String, primary_key=True)
|
||||||
|
name = Column("name", String)
|
||||||
|
birthdate = Column("birthdate", String)
|
||||||
|
opening_timestamp = Column("opening_timestamp", String)
|
||||||
|
address = Column("address", String)
|
||||||
|
phone_number = Column("phone_number", String)
|
||||||
|
email = Column("email", String)
|
||||||
|
hash = Column("hash", String)
|
||||||
|
notes = Column("notes", String)
|
||||||
|
enabled = Column("enabled", Boolean)
|
||||||
|
administrator = Column("administrator", Boolean)
|
||||||
|
accounts = relationship("Account", backref="client")
|
||||||
|
|
||||||
|
def __init__(self, client_id, name, birthdate, opening_timestamp, address, phone_number, email, hash, notes, enabled, administrator, accounts):
|
||||||
|
"""Initialises the client object."""
|
||||||
|
self.client_id = client_id
|
||||||
|
self.name = name
|
||||||
|
self.birthdate = birthdate
|
||||||
|
self.opening_timestamp = opening_timestamp
|
||||||
|
self.address = address
|
||||||
|
self.phone_number = phone_number
|
||||||
|
self.email = email
|
||||||
|
self.hash = hash
|
||||||
|
self.notes = notes
|
||||||
|
self.enabled = enabled
|
||||||
|
self.administrator = administrator
|
||||||
|
self.accounts = accounts if accounts is not None else []
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
"""Returns the client as a dictionary."""
|
||||||
|
return {
|
||||||
|
"client_id": self.client_id,
|
||||||
|
"name": self.name,
|
||||||
|
"birthdate": self.birthdate,
|
||||||
|
"opening_timestamp": self.opening_timestamp,
|
||||||
|
"address": self.address,
|
||||||
|
"phone_number": self.phone_number,
|
||||||
|
"email": self.email,
|
||||||
|
}
|
||||||
|
|
||||||
38
database/class_transaction.py
Normal file
38
database/class_transaction.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# Lucas Mathews - Fontys Student ID: 5023572
|
||||||
|
# Banking System Transaction Class
|
||||||
|
|
||||||
|
from sqlalchemy import Column, String, Integer, ForeignKey
|
||||||
|
|
||||||
|
from class_base import Base
|
||||||
|
|
||||||
|
class Transaction(Base):
|
||||||
|
__tablename__ = 'transactions'
|
||||||
|
transaction_id = Column("transaction_id", String, primary_key=True)
|
||||||
|
transaction_type = Column("transaction_type", String)
|
||||||
|
amount = Column("amount", Integer)
|
||||||
|
timestamp = Column("timestamp", String)
|
||||||
|
description = Column("description", String)
|
||||||
|
account_id = Column(String, ForeignKey('accounts.account_id'))
|
||||||
|
recipient_account_id = Column(String, ForeignKey('accounts.account_id'))
|
||||||
|
|
||||||
|
def __init__(self, transaction_id, transaction_type, amount, timestamp, description, account_id, recipient_account_id = None):
|
||||||
|
"""Initialises the Transaction object."""
|
||||||
|
self.transaction_id = transaction_id
|
||||||
|
self.transaction_type = transaction_type
|
||||||
|
self.amount = amount
|
||||||
|
self.timestamp = timestamp
|
||||||
|
self.description = description
|
||||||
|
self.account_id = account_id
|
||||||
|
self.recipient_account_id = recipient_account_id
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
"""Converts the Transaction object to a dictionary."""
|
||||||
|
return {
|
||||||
|
"transaction_id": self.transaction_id,
|
||||||
|
"transaction_type": self.transaction_type,
|
||||||
|
"amount": self.amount,
|
||||||
|
"timestamp": self.timestamp,
|
||||||
|
"description": self.description,
|
||||||
|
"account_id": self.account_id,
|
||||||
|
"recipient_account_id": self.recipient_account_id
|
||||||
|
}
|
||||||
7
database/config.py
Normal file
7
database/config.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Lucas Mathews - Fontys Student ID: 5023572
|
||||||
|
# Banking System Config Parser
|
||||||
|
|
||||||
|
import configparser
|
||||||
|
|
||||||
|
CONFIG = configparser.ConfigParser()
|
||||||
|
CONFIG.read("database.ini")
|
||||||
5
database/database.ini
Normal file
5
database/database.ini
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[database]
|
||||||
|
name=bank.db
|
||||||
|
|
||||||
|
[server]
|
||||||
|
url=http://0.0.0.0:80
|
||||||
@@ -5,7 +5,7 @@ ADMIN_EMAIL = "lmath56@hotmail.com"
|
|||||||
|
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
from class_base import Base
|
from server.class_base import Base
|
||||||
from class_account import Account
|
from class_account import Account
|
||||||
from class_client import Client
|
from class_client import Client
|
||||||
from class_transaction import Transaction
|
from class_transaction import Transaction
|
||||||
Reference in New Issue
Block a user