├── core ├── __init__.py ├── migrations │ ├── __init__.py │ └── __pycache__ │ │ ├── __init__.cpython-39.pyc │ │ └── __init__.cpython-310.pyc ├── tests.py ├── admin.py ├── models.py ├── static │ └── img │ │ └── bank.jpg ├── __pycache__ │ ├── apps.cpython-39.pyc │ ├── admin.cpython-310.pyc │ ├── admin.cpython-39.pyc │ ├── apps.cpython-310.pyc │ ├── models.cpython-39.pyc │ ├── views.cpython-310.pyc │ ├── views.cpython-39.pyc │ ├── __init__.cpython-310.pyc │ ├── __init__.cpython-39.pyc │ └── models.cpython-310.pyc ├── apps.py ├── views.py └── templates │ ├── footer.html │ ├── messages.html │ ├── base.html │ ├── index.html │ └── navbar.html ├── accounts ├── __init__.py ├── migrations │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-310.pyc │ │ ├── __init__.cpython-39.pyc │ │ ├── 0001_initial.cpython-310.pyc │ │ └── 0001_initial.cpython-39.pyc │ └── 0001_initial.py ├── tests.py ├── __pycache__ │ ├── admin.cpython-39.pyc │ ├── apps.cpython-310.pyc │ ├── apps.cpython-39.pyc │ ├── forms.cpython-39.pyc │ ├── urls.cpython-310.pyc │ ├── urls.cpython-39.pyc │ ├── views.cpython-39.pyc │ ├── admin.cpython-310.pyc │ ├── forms.cpython-310.pyc │ ├── models.cpython-310.pyc │ ├── models.cpython-39.pyc │ ├── views.cpython-310.pyc │ ├── __init__.cpython-310.pyc │ ├── __init__.cpython-39.pyc │ ├── constants.cpython-310.pyc │ └── constants.cpython-39.pyc ├── apps.py ├── constants.py ├── admin.py ├── urls.py ├── models.py ├── views.py ├── templates │ └── accounts │ │ ├── user_login.html │ │ ├── profile.html │ │ └── user_registration.html └── forms.py ├── mamar_bank ├── __init__.py ├── __pycache__ │ ├── urls.cpython-310.pyc │ ├── urls.cpython-39.pyc │ ├── wsgi.cpython-310.pyc │ ├── wsgi.cpython-39.pyc │ ├── __init__.cpython-39.pyc │ ├── settings.cpython-39.pyc │ ├── __init__.cpython-310.pyc │ └── settings.cpython-310.pyc ├── asgi.py ├── wsgi.py ├── urls.py └── settings.py ├── transactions ├── __init__.py ├── migrations │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-310.pyc │ │ ├── __init__.cpython-39.pyc │ │ ├── 0001_initial.cpython-39.pyc │ │ └── 0001_initial.cpython-310.pyc │ └── 0001_initial.py ├── tests.py ├── __pycache__ │ ├── admin.cpython-310.pyc │ ├── admin.cpython-39.pyc │ ├── apps.cpython-310.pyc │ ├── apps.cpython-39.pyc │ ├── forms.cpython-310.pyc │ ├── forms.cpython-39.pyc │ ├── models.cpython-39.pyc │ ├── urls.cpython-310.pyc │ ├── urls.cpython-39.pyc │ ├── views.cpython-310.pyc │ ├── views.cpython-39.pyc │ ├── __init__.cpython-39.pyc │ ├── models.cpython-310.pyc │ ├── __init__.cpython-310.pyc │ ├── constants.cpython-310.pyc │ └── constants.cpython-39.pyc ├── apps.py ├── constants.py ├── admin.py ├── urls.py ├── models.py ├── templates │ └── transactions │ │ ├── transaction_form.html │ │ ├── loan_request.html │ │ └── transaction_report.html ├── forms.py └── views.py ├── db.sqlite3 └── manage.py /core/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /accounts/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mamar_bank/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /core/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /transactions/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /accounts/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /transactions/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /core/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/db.sqlite3 -------------------------------------------------------------------------------- /transactions/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /accounts/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | # test 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /core/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | # admin 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /core/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | # models py 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /core/static/img/bank.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/core/static/img/bank.jpg -------------------------------------------------------------------------------- /core/__pycache__/apps.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/core/__pycache__/apps.cpython-39.pyc -------------------------------------------------------------------------------- /core/__pycache__/admin.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/core/__pycache__/admin.cpython-310.pyc -------------------------------------------------------------------------------- /core/__pycache__/admin.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/core/__pycache__/admin.cpython-39.pyc -------------------------------------------------------------------------------- /core/__pycache__/apps.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/core/__pycache__/apps.cpython-310.pyc -------------------------------------------------------------------------------- /core/__pycache__/models.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/core/__pycache__/models.cpython-39.pyc -------------------------------------------------------------------------------- /core/__pycache__/views.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/core/__pycache__/views.cpython-310.pyc -------------------------------------------------------------------------------- /core/__pycache__/views.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/core/__pycache__/views.cpython-39.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/admin.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/admin.cpython-39.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/apps.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/apps.cpython-310.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/apps.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/apps.cpython-39.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/forms.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/forms.cpython-39.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/urls.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/urls.cpython-310.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/urls.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/urls.cpython-39.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/views.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/views.cpython-39.pyc -------------------------------------------------------------------------------- /core/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/core/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /core/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/core/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /core/__pycache__/models.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/core/__pycache__/models.cpython-310.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/admin.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/admin.cpython-310.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/forms.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/forms.cpython-310.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/models.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/models.cpython-310.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/models.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/models.cpython-39.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/views.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/views.cpython-310.pyc -------------------------------------------------------------------------------- /mamar_bank/__pycache__/urls.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/mamar_bank/__pycache__/urls.cpython-310.pyc -------------------------------------------------------------------------------- /mamar_bank/__pycache__/urls.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/mamar_bank/__pycache__/urls.cpython-39.pyc -------------------------------------------------------------------------------- /mamar_bank/__pycache__/wsgi.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/mamar_bank/__pycache__/wsgi.cpython-310.pyc -------------------------------------------------------------------------------- /mamar_bank/__pycache__/wsgi.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/mamar_bank/__pycache__/wsgi.cpython-39.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/constants.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/constants.cpython-310.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/constants.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/__pycache__/constants.cpython-39.pyc -------------------------------------------------------------------------------- /mamar_bank/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/mamar_bank/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /mamar_bank/__pycache__/settings.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/mamar_bank/__pycache__/settings.cpython-39.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/admin.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/admin.cpython-310.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/admin.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/admin.cpython-39.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/apps.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/apps.cpython-310.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/apps.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/apps.cpython-39.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/forms.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/forms.cpython-310.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/forms.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/forms.cpython-39.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/models.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/models.cpython-39.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/urls.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/urls.cpython-310.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/urls.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/urls.cpython-39.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/views.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/views.cpython-310.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/views.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/views.cpython-39.pyc -------------------------------------------------------------------------------- /mamar_bank/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/mamar_bank/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /mamar_bank/__pycache__/settings.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/mamar_bank/__pycache__/settings.cpython-310.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/models.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/models.cpython-310.pyc -------------------------------------------------------------------------------- /core/migrations/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/core/migrations/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/constants.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/constants.cpython-310.pyc -------------------------------------------------------------------------------- /transactions/__pycache__/constants.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/__pycache__/constants.cpython-39.pyc -------------------------------------------------------------------------------- /core/migrations/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/core/migrations/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /accounts/migrations/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/migrations/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /accounts/migrations/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/migrations/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /core/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | # apps 4 | class CoreConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'core' 7 | -------------------------------------------------------------------------------- /accounts/migrations/__pycache__/0001_initial.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/migrations/__pycache__/0001_initial.cpython-310.pyc -------------------------------------------------------------------------------- /accounts/migrations/__pycache__/0001_initial.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/accounts/migrations/__pycache__/0001_initial.cpython-39.pyc -------------------------------------------------------------------------------- /transactions/migrations/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/migrations/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /transactions/migrations/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/migrations/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /accounts/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | # apps js 4 | class AccountsConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'accounts' 7 | -------------------------------------------------------------------------------- /transactions/migrations/__pycache__/0001_initial.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/migrations/__pycache__/0001_initial.cpython-39.pyc -------------------------------------------------------------------------------- /transactions/migrations/__pycache__/0001_initial.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hazrat-Ali9/Bank-Management-Backend/HEAD/transactions/migrations/__pycache__/0001_initial.cpython-310.pyc -------------------------------------------------------------------------------- /accounts/constants.py: -------------------------------------------------------------------------------- 1 | ACCOUNT_TYPE = ( 2 | ('Savings', 'Savings'), 3 | ('Current', 'Current'), 4 | ) 5 | GENDER_TYPE = ( 6 | ('Male', 'Male'), 7 | ('Female', 'Female'), 8 | ) 9 | # constants -------------------------------------------------------------------------------- /transactions/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | # apps 4 | class TransactionsConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'transactions' 7 | -------------------------------------------------------------------------------- /core/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.views.generic import TemplateView 3 | # Create your views here. 4 | 5 | class HomeView(TemplateView): 6 | template_name = 'index.html' 7 | -------------------------------------------------------------------------------- /accounts/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import UserBankAccount, UserAddress 3 | # Register your models here. 4 | 5 | admin.site.register(UserBankAccount) 6 | admin.site.register(UserAddress) -------------------------------------------------------------------------------- /transactions/constants.py: -------------------------------------------------------------------------------- 1 | DEPOSIT = 1 2 | WITHDRAWAL = 2 3 | LOAN = 3 4 | LOAN_PAID = 4 5 | 6 | TRANSACTION_TYPE = ( 7 | (DEPOSIT, 'Deposite'), 8 | (WITHDRAWAL, 'Withdrawal'), 9 | (LOAN, 'Loan'), 10 | (LOAN_PAID, 'Loan Paid'), 11 | 12 | ) -------------------------------------------------------------------------------- /accounts/urls.py: -------------------------------------------------------------------------------- 1 | # urls 2 | from django.urls import path 3 | from .views import UserRegistrationView, UserLoginView, UserLogoutView,UserBankAccountUpdateView 4 | 5 | urlpatterns = [ 6 | path('register/', UserRegistrationView.as_view(), name='register'), 7 | path('login/', UserLoginView.as_view(), name='login'), 8 | path('logout/', UserLogoutView.as_view(), name='logout'), 9 | path('profile/', UserBankAccountUpdateView.as_view(), name='profile' ) 10 | ] -------------------------------------------------------------------------------- /mamar_bank/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for mamar_bank project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mamar_bank.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /mamar_bank/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for mamar_bank project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mamar_bank.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /core/templates/footer.html: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /transactions/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | # admin 3 | # from transactions.models import Transaction 4 | from .models import Transaction 5 | @admin.register(Transaction) 6 | class TransactionAdmin(admin.ModelAdmin): 7 | list_display = ['account', 'amount', 'balance_after_transaction', 'transaction_type', 'loan_approve'] 8 | 9 | def save_model(self, request, obj, form, change): 10 | obj.account.balance += obj.amount 11 | obj.balance_after_transaction = obj.account.balance 12 | obj.account.save() 13 | super().save_model(request, obj, form, change) 14 | 15 | -------------------------------------------------------------------------------- /transactions/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from .views import DepositMoneyView, WithdrawMoneyView, TransactionReportView,LoanRequestView,LoanListView,PayLoanView 3 | 4 | 5 | # app_name = 'transactions' 6 | urlpatterns = [ 7 | path("deposit/", DepositMoneyView.as_view(), name="deposit_money"), 8 | path("report/", TransactionReportView.as_view(), name="transaction_report"), 9 | path("withdraw/", WithdrawMoneyView.as_view(), name="withdraw_money"), 10 | path("loan_request/", LoanRequestView.as_view(), name="loan_request"), 11 | path("loans/", LoanListView.as_view(), name="loan_list"), 12 | path("loans//", PayLoanView.as_view(), name="pay"), 13 | ] -------------------------------------------------------------------------------- /core/templates/messages.html: -------------------------------------------------------------------------------- 1 | {% for message in messages %} 2 | 3 | 12 | 13 | {% endfor %} 14 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | """Django's command-line utility for administrative tasks.""" 2 | import os 3 | import sys 4 | 5 | # manage py 6 | def main(): 7 | """Run administrative tasks.""" 8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mamar_bank.settings') 9 | try: 10 | from django.core.management import execute_from_command_line 11 | except ImportError as exc: 12 | raise ImportError( 13 | "Couldn't import Django. Are you sure it's installed and " 14 | "available on your PYTHONPATH environment variable? Did you " 15 | "forget to activate a virtual environment?" 16 | ) from exc 17 | execute_from_command_line(sys.argv) 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | -------------------------------------------------------------------------------- /transactions/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from accounts.models import UserBankAccount 3 | # Create your models here. 4 | from .constants import TRANSACTION_TYPE 5 | 6 | class Transaction(models.Model): 7 | account = models.ForeignKey(UserBankAccount, related_name = 'transactions', on_delete = models.CASCADE) # ekjon user er multiple transactions hote pare 8 | 9 | amount = models.DecimalField(decimal_places=2, max_digits = 12) 10 | balance_after_transaction = models.DecimalField(decimal_places=2, max_digits = 12) 11 | transaction_type = models.IntegerField(choices=TRANSACTION_TYPE, null = True) 12 | timestamp = models.DateTimeField(auto_now_add=True) 13 | loan_approve = models.BooleanField(default=False) 14 | 15 | class Meta: 16 | ordering = ['timestamp'] -------------------------------------------------------------------------------- /mamar_bank/urls.py: -------------------------------------------------------------------------------- 1 | """ 2 | URL configuration for mamar_bank project. 3 | 4 | The `urlpatterns` list routes URLs to views. For more information please see: 5 | https://docs.djangoproject.com/en/4.2/topics/http/urls/ 6 | Examples: 7 | Function views 8 | 1. Add an import: from my_app import views 9 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 10 | Class-based views 11 | 1. Add an import: from other_app.views import Home 12 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 13 | Including another URLconf 14 | 1. Import the include() function: from django.urls import include, path 15 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 16 | """ 17 | from django.contrib import admin 18 | from django.urls import path, include 19 | from core.views import HomeView 20 | urlpatterns = [ 21 | path('', HomeView.as_view(), name='home'), 22 | path('admin/', admin.site.urls), 23 | path('accounts/', include('accounts.urls')), 24 | path('transactions/', include('transactions.urls')), 25 | ] 26 | 27 | # accounts/login 28 | # accounts/register -------------------------------------------------------------------------------- /core/templates/base.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {% block head_title %}Banking System{% endblock %} 10 | 11 | 12 | 13 | {% block head_extra %}{% endblock %} 14 | 21 | 22 | 23 | {% include 'navbar.html' %} 24 | {% block body %} 25 |
26 | {% include 'messages.html' %} 27 | {% block content %} 28 | {% endblock %} 29 |
30 | {% include 'footer.html' %} 31 | 32 | {% endblock %} 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /transactions/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.4 on 2023-08-20 01:26 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | initial = True 10 | 11 | dependencies = [ 12 | ('accounts', '0001_initial'), 13 | ] 14 | 15 | operations = [ 16 | migrations.CreateModel( 17 | name='Transaction', 18 | fields=[ 19 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 20 | ('amount', models.DecimalField(decimal_places=2, max_digits=12)), 21 | ('balance_after_transaction', models.DecimalField(decimal_places=2, max_digits=12)), 22 | ('transaction_type', models.IntegerField(choices=[(1, 'Deposite'), (2, 'Withdrawal'), (3, 'Loan'), (4, 'Loan Paid')], null=True)), 23 | ('timestamp', models.DateTimeField(auto_now_add=True)), 24 | ('loan_approve', models.BooleanField(default=False)), 25 | ('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='transactions', to='accounts.userbankaccount')), 26 | ], 27 | options={ 28 | 'ordering': ['timestamp'], 29 | }, 30 | ), 31 | ] 32 | -------------------------------------------------------------------------------- /accounts/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.contrib.auth.models import User 3 | from .constants import ACCOUNT_TYPE, GENDER_TYPE 4 | # django amaderke built in user niye kaj korar facility dey 5 | # Models 6 | 7 | class UserBankAccount(models.Model): 8 | user = models.OneToOneField(User, related_name='account', on_delete=models.CASCADE) 9 | account_type = models.CharField(max_length=10, choices=ACCOUNT_TYPE) 10 | account_no = models.IntegerField(unique=True) # account no duijon user er kokhono same hobe na 11 | birth_date = models.DateField(null=True, blank=True) 12 | gender = models.CharField(max_length=10, choices=GENDER_TYPE) 13 | initial_deposite_date = models.DateField(auto_now_add=True) 14 | balance = models.DecimalField(default=0, max_digits=12, decimal_places=2) # ekjon user 12 digit obdi taka rakhte parbe, dui doshomik ghor obdi rakhte parben 1000.50 15 | def __str__(self): 16 | return str(self.account_no) 17 | 18 | class UserAddress(models.Model): 19 | user = models.OneToOneField(User, related_name='address', on_delete=models.CASCADE) 20 | street_address = models.CharField(max_length=100) 21 | city = models.CharField(max_length= 100) 22 | postal_code = models.IntegerField() 23 | country = models.CharField(max_length=100) 24 | def __str__(self): 25 | return str(self.user.email) 26 | -------------------------------------------------------------------------------- /core/templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load static %} 3 | 4 | {% block head_title %}Banking System{% endblock %} {% block content %} 5 |
6 | 7 | 8 |
9 |

Welcome to Hazrat Bank

10 |

11 | This is a simple Hazrat Bank where you can deposit money, withdraw money, take loan. You can also create an account, login, logout. Lorem ipsum dolor sit amet consectetur adipisicing elit. Sed nemo quaerat quo dicta, adipisci eum fuga ratione id numquam eius veniam placeat voluptatum, itaque tempora molestias vel, blanditiis fugiat ipsam! 12 | 13 |

14 |
15 | Register 16 |
17 |
18 |
19 | 20 |
21 |
22 | 23 | {% endblock %} -------------------------------------------------------------------------------- /transactions/templates/transactions/transaction_form.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% block head_title %}{{ title }}{% endblock %} {% block content %} 2 | 3 |
4 |
5 | {% if title == 'Request For Loan' %} 6 |
View All Loan List
7 | {% endif %} 8 | 9 |

{{ title }}

10 |
11 | {% csrf_token %} 12 | 13 |
14 | 17 | 18 |
19 | {% if form.amount.errors %} {% for error in form.amount.errors %} 20 |

{{ error }}

21 | {% endfor %} {% endif %} 22 |
23 | 26 |
27 |
28 |
29 | 30 |
31 | {% endblock %} -------------------------------------------------------------------------------- /accounts/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.views.generic import FormView 3 | from .forms import UserRegistrationForm,UserUpdateForm 4 | from django.contrib.auth import login, logout 5 | from django.urls import reverse_lazy 6 | from django.contrib.auth.views import LoginView, LogoutView 7 | from django.views import View 8 | from django.shortcuts import redirect 9 | # views 10 | class UserRegistrationView(FormView): 11 | template_name = 'accounts/user_registration.html' 12 | form_class = UserRegistrationForm 13 | success_url = reverse_lazy('profile') 14 | 15 | def form_valid(self,form): 16 | print(form.cleaned_data) 17 | user = form.save() 18 | login(self.request, user) 19 | print(user) 20 | return super().form_valid(form) # form_valid function call hobe jodi sob thik thake 21 | 22 | 23 | class UserLoginView(LoginView): 24 | template_name = 'accounts/user_login.html' 25 | def get_success_url(self): 26 | return reverse_lazy('home') 27 | 28 | class UserLogoutView(LogoutView): 29 | def get_success_url(self): 30 | if self.request.user.is_authenticated: 31 | logout(self.request) 32 | return reverse_lazy('home') 33 | 34 | 35 | class UserBankAccountUpdateView(View): 36 | template_name = 'accounts/profile.html' 37 | 38 | def get(self, request): 39 | form = UserUpdateForm(instance=request.user) 40 | return render(request, self.template_name, {'form': form}) 41 | 42 | def post(self, request): 43 | form = UserUpdateForm(request.POST, instance=request.user) 44 | if form.is_valid(): 45 | form.save() 46 | return redirect('profile') # Redirect to the user's profile page 47 | return render(request, self.template_name, {'form': form}) 48 | 49 | 50 | -------------------------------------------------------------------------------- /transactions/templates/transactions/loan_request.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% block head_title %}{{ title }}{% endblock %} 3 | {% block content %} 4 |
5 |

Loan Report

6 |
7 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | {% for loan in loans %} 22 | 23 | 26 | 33 | 36 | 43 | 44 | {% endfor %} 45 | 46 |
LOAN IDLoan AmountLoan ApprovedAction
24 | {{ loan.id }} 25 | 27 | 30 | {{ loan.amount }} 31 | 32 | 34 | {{ loan.loan_approve }} 35 | 37 | {% if loan.loan_approve %} 38 | Pay 39 | {% else %} 40 |

Loan Pending

41 | {% endif %} 42 |
47 |
48 | {% endblock %} -------------------------------------------------------------------------------- /accounts/templates/accounts/user_login.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% block content %} {% if form.non_field_errors %} {% for error in form.non_field_errors %} 2 | 6 | {% endfor %} {% endif %} 7 |
8 |
9 |
10 |

Login

11 |
12 |
13 | {% csrf_token %} {% for hidden_field in form.hidden_fields %} {{ hidden_field.errors }} {{ hidden_field }} {% endfor %} 14 | {% for field in form.visible_fields %} 15 |
16 | 19 | 20 |
21 | {% if field.errors %} {% for error in field.errors %} 22 |

{{ error }}

23 | {% endfor %} {% endif %} {% endfor %} 24 | 25 |
26 | 29 |
30 |
31 |
32 |
33 |
34 | {% endblock %} -------------------------------------------------------------------------------- /accounts/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.2.4 on 2023-08-17 15:41 2 | 3 | from django.conf import settings 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | initial = True 11 | 12 | dependencies = [ 13 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 14 | ] 15 | 16 | operations = [ 17 | migrations.CreateModel( 18 | name='UserBankAccount', 19 | fields=[ 20 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 21 | ('account_type', models.CharField(choices=[('Savings', 'Savings'), ('Current', 'Current')], max_length=10)), 22 | ('account_no', models.IntegerField(unique=True)), 23 | ('birth_date', models.DateField(blank=True, null=True)), 24 | ('gender', models.CharField(choices=[('Male', 'Male'), ('Female', 'Female')], max_length=10)), 25 | ('initial_deposite_date', models.DateField(auto_now_add=True)), 26 | ('balance', models.DecimalField(decimal_places=2, default=0, max_digits=12)), 27 | ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='account', to=settings.AUTH_USER_MODEL)), 28 | ], 29 | ), 30 | migrations.CreateModel( 31 | name='UserAddress', 32 | fields=[ 33 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 34 | ('street_address', models.CharField(max_length=100)), 35 | ('city', models.CharField(max_length=100)), 36 | ('postal_code', models.IntegerField()), 37 | ('country', models.CharField(max_length=100)), 38 | ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='address', to=settings.AUTH_USER_MODEL)), 39 | ], 40 | ), 41 | ] 42 | -------------------------------------------------------------------------------- /transactions/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from .models import Transaction 3 | class TransactionForm(forms.ModelForm): 4 | class Meta: 5 | model = Transaction 6 | fields = [ 7 | 'amount', 8 | 'transaction_type' 9 | ] 10 | 11 | def __init__(self, *args, **kwargs): 12 | self.account = kwargs.pop('account') # account value ke pop kore anlam 13 | super().__init__(*args, **kwargs) 14 | self.fields['transaction_type'].disabled = True # ei field disable thakbe 15 | self.fields['transaction_type'].widget = forms.HiddenInput() # user er theke hide kora thakbe 16 | 17 | def save(self, commit=True): 18 | self.instance.account = self.account 19 | self.instance.balance_after_transaction = self.account.balance 20 | return super().save() 21 | 22 | 23 | class DepositForm(TransactionForm): 24 | def clean_amount(self): # amount field ke filter korbo 25 | min_deposit_amount = 100 26 | amount = self.cleaned_data.get('amount') # user er fill up kora form theke amra amount field er value ke niye aslam, 50 27 | if amount < min_deposit_amount: 28 | raise forms.ValidationError( 29 | f'You need to deposit at least {min_deposit_amount} $' 30 | ) 31 | 32 | return amount 33 | 34 | 35 | class WithdrawForm(TransactionForm): 36 | 37 | def clean_amount(self): 38 | account = self.account 39 | min_withdraw_amount = 500 40 | max_withdraw_amount = 20000 41 | balance = account.balance # 1000 42 | amount = self.cleaned_data.get('amount') 43 | if amount < min_withdraw_amount: 44 | raise forms.ValidationError( 45 | f'You can withdraw at least {min_withdraw_amount} $' 46 | ) 47 | 48 | if amount > max_withdraw_amount: 49 | raise forms.ValidationError( 50 | f'You can withdraw at most {max_withdraw_amount} $' 51 | ) 52 | 53 | if amount > balance: # amount = 5000, tar balance ache 200 54 | raise forms.ValidationError( 55 | f'You have {balance} $ in your account. ' 56 | 'You can not withdraw more than your account balance' 57 | ) 58 | 59 | return amount 60 | 61 | 62 | 63 | class LoanRequestForm(TransactionForm): 64 | def clean_amount(self): 65 | amount = self.cleaned_data.get('amount') 66 | 67 | return amount -------------------------------------------------------------------------------- /core/templates/navbar.html: -------------------------------------------------------------------------------- 1 | 45 | -------------------------------------------------------------------------------- /transactions/templates/transactions/transaction_report.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load static %} 3 | {% load humanize %} 4 | {% block head_title %} Transaction Report{% endblock %} {% block content %} 5 | 6 | 7 |
8 |

Transaction Report

9 |
10 |
11 |
12 |
15 | 16 | 22 |
23 | 24 |
27 | 28 | 34 |
35 |
36 | 42 |
43 |
44 |
45 | 48 | 49 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | {% for transaction in object_list %} 60 | 61 | 64 | 71 | 74 | 77 | 78 | {% endfor %} 79 | 80 | 81 | 84 | 85 | 86 |
DateTransaction TypeAmountBalance After Transaction
62 | {{ transaction.timestamp|date:"F d, Y h:i A" }} 63 | 65 | 68 | {{ transaction.get_transaction_type_display }} 69 | 70 | 72 | $ {{ transaction.amount|floatformat:2|intcomma }} 73 | 75 | $ {{ transaction.balance_after_transaction|floatformat:2|intcomma }} 76 |
Current Balance 82 | $ {{ account.balance|floatformat:2|intcomma }} 83 |
87 |
88 | {% endblock %} 89 | -------------------------------------------------------------------------------- /mamar_bank/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for mamar_bank project. 3 | # seetings 4 | Generated by 'django-admin startproject' using Django 4.2.4. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.2/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/4.2/ref/settings/ 11 | """ 12 | 13 | from pathlib import Path 14 | 15 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 16 | BASE_DIR = Path(__file__).resolve().parent.parent 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = 'django-insecure-*p4#3n$&4($^#xomcfs&m7m*t_9hid%ajvl1qals^d6(t=%#2@' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'django.contrib.humanize', 41 | 'accounts', 42 | 'core', 43 | 'transactions', 44 | ] 45 | 46 | MIDDLEWARE = [ 47 | 'django.middleware.security.SecurityMiddleware', 48 | 'django.contrib.sessions.middleware.SessionMiddleware', 49 | 'django.middleware.common.CommonMiddleware', 50 | 'django.middleware.csrf.CsrfViewMiddleware', 51 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 52 | 'django.contrib.messages.middleware.MessageMiddleware', 53 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 54 | ] 55 | 56 | ROOT_URLCONF = 'mamar_bank.urls' 57 | 58 | TEMPLATES = [ 59 | { 60 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 61 | 'DIRS': [], 62 | 'APP_DIRS': True, 63 | 'OPTIONS': { 64 | 'context_processors': [ 65 | 'django.template.context_processors.debug', 66 | 'django.template.context_processors.request', 67 | 'django.contrib.auth.context_processors.auth', 68 | 'django.contrib.messages.context_processors.messages', 69 | ], 70 | }, 71 | }, 72 | ] 73 | 74 | WSGI_APPLICATION = 'mamar_bank.wsgi.application' 75 | 76 | 77 | # Database 78 | # https://docs.djangoproject.com/en/4.2/ref/settings/#databases 79 | 80 | DATABASES = { 81 | 'default': { 82 | 'ENGINE': 'django.db.backends.sqlite3', 83 | 'NAME': BASE_DIR / 'db.sqlite3', 84 | } 85 | } 86 | 87 | 88 | # Password validation 89 | # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators 90 | 91 | AUTH_PASSWORD_VALIDATORS = [ 92 | { 93 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 94 | }, 95 | { 96 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 97 | }, 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 100 | }, 101 | { 102 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 103 | }, 104 | ] 105 | 106 | 107 | # Internationalization 108 | # https://docs.djangoproject.com/en/4.2/topics/i18n/ 109 | 110 | LANGUAGE_CODE = 'en-us' 111 | 112 | TIME_ZONE = 'UTC' 113 | 114 | USE_I18N = True 115 | 116 | USE_TZ = True 117 | 118 | 119 | # Static files (CSS, JavaScript, Images) 120 | # https://docs.djangoproject.com/en/4.2/howto/static-files/ 121 | 122 | STATIC_URL = 'static/' 123 | STATIC_ROOT = BASE_DIR / 'static' 124 | 125 | 126 | # Default primary key field type 127 | # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field 128 | 129 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 130 | -------------------------------------------------------------------------------- /accounts/forms.py: -------------------------------------------------------------------------------- 1 | # forms 2 | from django.contrib.auth.forms import UserCreationForm 3 | from django import forms 4 | from .constants import ACCOUNT_TYPE, GENDER_TYPE 5 | from django.contrib.auth.models import User 6 | from .models import UserBankAccount, UserAddress 7 | 8 | class UserRegistrationForm(UserCreationForm): 9 | birth_date = forms.DateField(widget=forms.DateInput(attrs={'type':'date'})) 10 | gender = forms.ChoiceField(choices=GENDER_TYPE) 11 | account_type = forms.ChoiceField(choices=ACCOUNT_TYPE) 12 | street_address = forms.CharField(max_length=100) 13 | city = forms.CharField(max_length= 100) 14 | postal_code = forms.IntegerField() 15 | country = forms.CharField(max_length=100) 16 | class Meta: 17 | model = User 18 | fields = ['username', 'password1', 'password2', 'first_name', 'last_name', 'email', 'account_type', 'birth_date','gender', 'postal_code', 'city','country', 'street_address'] 19 | 20 | # form.save() 21 | def save(self, commit=True): 22 | our_user = super().save(commit=False) # ami database e data save korbo na ekhn 23 | if commit == True: 24 | our_user.save() # user model e data save korlam 25 | account_type = self.cleaned_data.get('account_type') 26 | gender = self.cleaned_data.get('gender') 27 | postal_code = self.cleaned_data.get('postal_code') 28 | country = self.cleaned_data.get('country') 29 | birth_date = self.cleaned_data.get('birth_date') 30 | city = self.cleaned_data.get('city') 31 | street_address = self.cleaned_data.get('street_address') 32 | 33 | UserAddress.objects.create( 34 | user = our_user, 35 | postal_code = postal_code, 36 | country = country, 37 | city = city, 38 | street_address = street_address 39 | ) 40 | UserBankAccount.objects.create( 41 | user = our_user, 42 | account_type = account_type, 43 | gender = gender, 44 | birth_date =birth_date, 45 | account_no = 100000+ our_user.id 46 | ) 47 | return our_user 48 | 49 | def __init__(self, *args, **kwargs): 50 | super().__init__(*args, **kwargs) 51 | 52 | for field in self.fields: 53 | self.fields[field].widget.attrs.update({ 54 | 55 | 'class' : ( 56 | 'appearance-none block w-full bg-gray-200 ' 57 | 'text-gray-700 border border-gray-200 rounded ' 58 | 'py-3 px-4 leading-tight focus:outline-none ' 59 | 'focus:bg-white focus:border-gray-500' 60 | ) 61 | }) 62 | 63 | 64 | # profile ki ki jinis update korte parbe amader user 65 | 66 | class UserUpdateForm(forms.ModelForm): 67 | birth_date = forms.DateField(widget=forms.DateInput(attrs={'type':'date'})) 68 | gender = forms.ChoiceField(choices=GENDER_TYPE) 69 | account_type = forms.ChoiceField(choices=ACCOUNT_TYPE) 70 | street_address = forms.CharField(max_length=100) 71 | city = forms.CharField(max_length= 100) 72 | postal_code = forms.IntegerField() 73 | country = forms.CharField(max_length=100) 74 | 75 | class Meta: 76 | model = User 77 | fields = ['first_name', 'last_name', 'email'] 78 | 79 | def __init__(self, *args, **kwargs): 80 | super().__init__(*args, **kwargs) 81 | for field in self.fields: 82 | self.fields[field].widget.attrs.update({ 83 | 'class': ( 84 | 'appearance-none block w-full bg-gray-200 ' 85 | 'text-gray-700 border border-gray-200 rounded ' 86 | 'py-3 px-4 leading-tight focus:outline-none ' 87 | 'focus:bg-white focus:border-gray-500' 88 | ) 89 | }) 90 | # jodi user er account thake 91 | if self.instance: 92 | try: 93 | user_account = self.instance.account 94 | user_address = self.instance.address 95 | except UserBankAccount.DoesNotExist: 96 | user_account = None 97 | user_address = None 98 | 99 | if user_account: 100 | self.fields['account_type'].initial = user_account.account_type 101 | self.fields['gender'].initial = user_account.gender 102 | self.fields['birth_date'].initial = user_account.birth_date 103 | self.fields['street_address'].initial = user_address.street_address 104 | self.fields['city'].initial = user_address.city 105 | self.fields['postal_code'].initial = user_address.postal_code 106 | self.fields['country'].initial = user_address.country 107 | 108 | def save(self, commit=True): 109 | user = super().save(commit=False) 110 | if commit: 111 | user.save() 112 | 113 | user_account, created = UserBankAccount.objects.get_or_create(user=user) # jodi account thake taile seta jabe user_account ar jodi account na thake taile create hobe ar seta created er moddhe jabe 114 | user_address, created = UserAddress.objects.get_or_create(user=user) 115 | 116 | user_account.account_type = self.cleaned_data['account_type'] 117 | user_account.gender = self.cleaned_data['gender'] 118 | user_account.birth_date = self.cleaned_data['birth_date'] 119 | user_account.save() 120 | 121 | user_address.street_address = self.cleaned_data['street_address'] 122 | user_address.city = self.cleaned_data['city'] 123 | user_address.postal_code = self.cleaned_data['postal_code'] 124 | user_address.country = self.cleaned_data['country'] 125 | user_address.save() 126 | 127 | return user -------------------------------------------------------------------------------- /transactions/views.py: -------------------------------------------------------------------------------- 1 | from django.contrib import messages 2 | from django.contrib.auth.mixins import LoginRequiredMixin 3 | from django.urls import reverse_lazy 4 | from django.utils import timezone 5 | from django.shortcuts import get_object_or_404, redirect 6 | from django.views import View 7 | from django.http import HttpResponse 8 | from django.views.generic import CreateView, ListView 9 | from transactions.constants import DEPOSIT, WITHDRAWAL,LOAN, LOAN_PAID 10 | from datetime import datetime 11 | from django.db.models import Sum 12 | from transactions.forms import ( 13 | DepositForm, 14 | WithdrawForm, 15 | LoanRequestForm, 16 | ) 17 | from transactions.models import Transaction 18 | 19 | class TransactionCreateMixin(LoginRequiredMixin, CreateView): 20 | template_name = 'transactions/transaction_form.html' 21 | model = Transaction 22 | title = '' 23 | success_url = reverse_lazy('transaction_report') 24 | 25 | def get_form_kwargs(self): 26 | kwargs = super().get_form_kwargs() 27 | kwargs.update({ 28 | 'account': self.request.user.account 29 | }) 30 | return kwargs 31 | 32 | def get_context_data(self, **kwargs): 33 | context = super().get_context_data(**kwargs) # template e context data pass kora 34 | context.update({ 35 | 'title': self.title 36 | }) 37 | 38 | return context 39 | 40 | 41 | class DepositMoneyView(TransactionCreateMixin): 42 | form_class = DepositForm 43 | title = 'Deposit' 44 | 45 | def get_initial(self): 46 | initial = {'transaction_type': DEPOSIT} 47 | return initial 48 | 49 | def form_valid(self, form): 50 | amount = form.cleaned_data.get('amount') 51 | account = self.request.user.account 52 | # if not account.initial_deposit_date: 53 | # now = timezone.now() 54 | # account.initial_deposit_date = now 55 | account.balance += amount # amount = 200, tar ager balance = 0 taka new balance = 0+200 = 200 56 | account.save( 57 | update_fields=[ 58 | 'balance' 59 | ] 60 | ) 61 | 62 | messages.success( 63 | self.request, 64 | f'{"{:,.2f}".format(float(amount))}$ was deposited to your account successfully' 65 | ) 66 | 67 | return super().form_valid(form) 68 | 69 | 70 | class WithdrawMoneyView(TransactionCreateMixin): 71 | form_class = WithdrawForm 72 | title = 'Withdraw Money' 73 | 74 | def get_initial(self): 75 | initial = {'transaction_type': WITHDRAWAL} 76 | return initial 77 | 78 | def form_valid(self, form): 79 | amount = form.cleaned_data.get('amount') 80 | 81 | self.request.user.account.balance -= form.cleaned_data.get('amount') 82 | # balance = 300 83 | # amount = 5000 84 | self.request.user.account.save(update_fields=['balance']) 85 | 86 | messages.success( 87 | self.request, 88 | f'Successfully withdrawn {"{:,.2f}".format(float(amount))}$ from your account' 89 | ) 90 | 91 | return super().form_valid(form) 92 | 93 | class LoanRequestView(TransactionCreateMixin): 94 | form_class = LoanRequestForm 95 | title = 'Request For Loan' 96 | 97 | def get_initial(self): 98 | initial = {'transaction_type': LOAN} 99 | return initial 100 | 101 | def form_valid(self, form): 102 | amount = form.cleaned_data.get('amount') 103 | current_loan_count = Transaction.objects.filter( 104 | account=self.request.user.account,transaction_type=3,loan_approve=True).count() 105 | if current_loan_count >= 3: 106 | return HttpResponse("You have cross the loan limits") 107 | messages.success( 108 | self.request, 109 | f'Loan request for {"{:,.2f}".format(float(amount))}$ submitted successfully' 110 | ) 111 | 112 | return super().form_valid(form) 113 | 114 | class TransactionReportView(LoginRequiredMixin, ListView): 115 | template_name = 'transactions/transaction_report.html' 116 | model = Transaction 117 | balance = 0 # filter korar pore ba age amar total balance ke show korbe 118 | 119 | def get_queryset(self): 120 | queryset = super().get_queryset().filter( 121 | account=self.request.user.account 122 | ) 123 | start_date_str = self.request.GET.get('start_date') 124 | end_date_str = self.request.GET.get('end_date') 125 | 126 | if start_date_str and end_date_str: 127 | start_date = datetime.strptime(start_date_str, '%Y-%m-%d').date() 128 | end_date = datetime.strptime(end_date_str, '%Y-%m-%d').date() 129 | 130 | queryset = queryset.filter(timestamp__date__gte=start_date, timestamp__date__lte=end_date) 131 | self.balance = Transaction.objects.filter( 132 | timestamp__date__gte=start_date, timestamp__date__lte=end_date 133 | ).aggregate(Sum('amount'))['amount__sum'] 134 | else: 135 | self.balance = self.request.user.account.balance 136 | 137 | return queryset.distinct() # unique queryset hote hobe 138 | 139 | def get_context_data(self, **kwargs): 140 | context = super().get_context_data(**kwargs) 141 | context.update({ 142 | 'account': self.request.user.account 143 | }) 144 | 145 | return context 146 | 147 | 148 | class PayLoanView(LoginRequiredMixin, View): 149 | def get(self, request, loan_id): 150 | loan = get_object_or_404(Transaction, id=loan_id) 151 | print(loan) 152 | if loan.loan_approve: 153 | user_account = loan.account 154 | # Reduce the loan amount from the user's balance 155 | # 5000, 500 + 5000 = 5500 156 | # balance = 3000, loan = 5000 157 | if loan.amount < user_account.balance: 158 | user_account.balance -= loan.amount 159 | loan.balance_after_transaction = user_account.balance 160 | user_account.save() 161 | loan.loan_approved = True 162 | loan.transaction_type = LOAN_PAID 163 | loan.save() 164 | return redirect('transactions:loan_list') 165 | else: 166 | messages.error( 167 | self.request, 168 | f'Loan amount is greater than available balance' 169 | ) 170 | 171 | return redirect('loan_list') 172 | 173 | 174 | class LoanListView(LoginRequiredMixin,ListView): 175 | model = Transaction 176 | template_name = 'transactions/loan_request.html' 177 | context_object_name = 'loans' # loan list ta ei loans context er moddhe thakbe 178 | 179 | def get_queryset(self): 180 | user_account = self.request.user.account 181 | queryset = Transaction.objects.filter(account=user_account,transaction_type=3) 182 | print(queryset) 183 | return queryset -------------------------------------------------------------------------------- /accounts/templates/accounts/profile.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% load static %} {% block head_title %}Banking System{% endblock %} {% block content %} {% if form.non_field_errors %} {% for error in form.non_field_errors %} 2 | 6 | {% endfor %} {% endif %} {% if form.non_field_errors %} {% for error in form.non_field_errors %} 7 | 11 | {% endfor %} {% endif %} 12 |
13 | 14 |

Account NO: {{request.user.account.account_no}}

15 |

Update Profile Information

16 |
17 |
18 | {% csrf_token %} {% for hidden_field in form.hidden_fields %} {{ hidden_field.errors }} {{ hidden_field }} {% endfor %} 19 |
20 |
21 | {{ form.first_name }} {% if form.first_name.errors %} {% for error in form.first_name.errors %} 24 |

{{ error }}

25 | {% endfor %} {% endif %} 26 |
27 |
28 | {{ form.last_name }} {% if form.last_name.errors %} {% for error in form.last_name.errors %} 31 |

{{ error }}

32 | {% endfor %} {% endif %} 33 |
34 |
35 |
36 |
37 | {{ form.email }} {% if form.email.errors %} {% for error in form.email.errors %} 40 |

{{ error }}

41 | {% endfor %} {% endif %} 42 |
43 |
44 | {{ form.account_type }} {% if form.account_type.errors %} {% for error in form.account_type.errors %} 47 |

{{ error }}

48 | {% endfor %} {% endif %} 49 |
50 |
51 |
52 |
53 | {{ form.gender }} {% if form.gender.errors %} {% for error in form.gender.errors %} 56 |

{{ error }}

57 | {% endfor %} {% endif %} 58 |
59 |
60 | {{ form.birth_date }} {% if form.birth_date.errors %} {% for error in form.birth_date.errors %} 63 |

{{ error }}

64 | {% endfor %} {% endif %} 65 |
66 |
67 |
68 |
69 | {{ form.password1 }} {% if form.password1.errors %} {% for error in form.password1.errors %} 72 |

{{ error }}

73 | {% endfor %} {% endif %} 74 |
75 |
76 | {{ form.password2 }} {% if form.password2.errors %} {% for error in form.password2.errors %} 79 |

{{ error }}

80 | {% endfor %} {% endif %} 81 |
82 |
83 | 84 | {% for hidden_field in form.hidden_fields %} {{ hidden_field.errors }} {{ hidden_field }} {% endfor %} 85 |
86 |
87 | {{ form.street_address }} {% if form.street_address.errors %} {% for error in form.street_address.errors %} 90 |

{{ error }}

91 | {% endfor %} {% endif %} 92 |
93 |
94 | {{ form.city }} {% if form.city.errors %} {% for error in form.city.errors %} 97 |

{{ error }}

98 | {% endfor %} {% endif %} 99 |
100 |
101 |
102 |
103 | {{ form.postal_code }} {% if form.postal_code.errors %} {% for error in form.postal_code.errors %} 106 |

{{ error }}

107 | {% endfor %} {% endif %} 108 |
109 |
110 | {{ form.country }} {% if form.country.errors %} {% for error in form.country.errors %} 113 |

{{ error }}

114 | {% endfor %} {% endif %} 115 |
116 |
117 |
118 | 121 |
122 |
123 |
124 |
125 | {% endblock %} -------------------------------------------------------------------------------- /accounts/templates/accounts/user_registration.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% load static %} {% block head_title %}Banking System{% endblock %} {% block content %} 2 | 3 | {% if form.non_field_errors %} {% for error in form.non_field_errors %} 4 | 8 | {% endfor %} {% endif %} {% if form.non_field_errors %} {% for error in form.non_field_errors %} 9 | 13 | {% endfor %} {% endif %} 14 |
15 |

Sign In

16 |
17 |
18 | {% csrf_token %} {% for hidden_field in form.hidden_fields %} {{ hidden_field.errors }} {{ hidden_field }} {% endfor %} 19 | 20 |
21 |
22 | {{ form.username }} {% if form.username.errors %} {% for error in form.username.errors %} 25 |

{{ error }}

26 | {% endfor %} {% endif %} 27 |
28 |
29 | {{ form.first_name }} {% if form.first_name.errors %} {% for error in form.first_name.errors %} 32 |

{{ error }}

33 | {% endfor %} {% endif %} 34 |
35 |
36 | {{ form.last_name }} {% if form.last_name.errors %} {% for error in form.last_name.errors %} 39 |

{{ error }}

40 | {% endfor %} {% endif %} 41 |
42 |
43 |
44 |
45 | {{ form.email }} {% if form.email.errors %} {% for error in form.email.errors %} 48 |

{{ error }}

49 | {% endfor %} {% endif %} 50 |
51 |
52 | {{ form.account_type }} {% if form.account_type.errors %} {% for error in form.account_type.errors %} 55 |

{{ error }}

56 | {% endfor %} {% endif %} 57 |
58 |
59 |
60 |
61 | {{ form.gender }} {% if form.gender.errors %} {% for error in form.gender.errors %} 64 |

{{ error }}

65 | {% endfor %} {% endif %} 66 |
67 |
68 | {{ form.birth_date }} {% if form.birth_date.errors %} {% for error in form.birth_date.errors %} 71 |

{{ error }}

72 | {% endfor %} {% endif %} 73 |
74 |
75 |
76 |
77 | {{ form.password1 }} {% if form.password1.errors %} {% for error in form.password1.errors %} 80 |

{{ error }}

81 | {% endfor %} {% endif %} 82 |
83 |
84 | {{ form.password2 }} {% if form.password2.errors %} {% for error in form.password2.errors %} 87 |

{{ error }}

88 | {% endfor %} {% endif %} 89 |
90 |
91 | 92 | {% for hidden_field in form.hidden_fields %} {{ hidden_field.errors }} {{ hidden_field }} {% endfor %} 93 |
94 |
95 | {{ form.street_address }} {% if form.street_address.errors %} {% for error in form.street_address.errors %} 98 |

{{ error }}

99 | {% endfor %} {% endif %} 100 |
101 |
102 | {{ form.city }} {% if form.city.errors %} {% for error in form.city.errors %} 105 |

{{ error }}

106 | {% endfor %} {% endif %} 107 |
108 |
109 |
110 |
111 | {{ form.postal_code }} {% if form.postal_code.errors %} {% for error in form.postal_code.errors %} 114 |

{{ error }}

115 | {% endfor %} {% endif %} 116 |
117 |
118 | {{ form.country }} {% if form.country.errors %} {% for error in form.country.errors %} 121 |

{{ error }}

122 | {% endfor %} {% endif %} 123 |
124 |
125 |
126 | 129 |
130 |
131 |
132 |
133 | {% endblock %} --------------------------------------------------------------------------------