Skip to content

Commit bf3ea49

Browse files
committed
add django accounting app tutorial
1 parent 5e446fb commit bf3ea49

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+797
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
242242
- [How to Make a Todo App using Django in Python](https://www.thepythoncode.com/article/build-a-todo-app-with-django-in-python). ([code](https://github.com/chepkiruidorothy/todo-app-simple/tree/master))
243243
- [How to Build an Email Address Verifier App using Django in Python](https://www.thepythoncode.com/article/build-an-email-verifier-app-using-django-in-python). ([code](web-programming/webbased-emailverifier))
244244
- [How to Build a Web Assistant Using Django and OpenAI GPT-3.5 API in Python](https://www.thepythoncode.com/article/web-assistant-django-with-gpt3-api-python). ([code](web-programming/webassistant))
245+
- [How to Make an Accounting App with Django in Python](https://www.thepythoncode.com/article/make-an-accounting-app-with-django-in-python). ([code](web-programming/accounting-app))
245246

246247
- ### [GUI Programming](https://www.thepythoncode.com/topic/gui-programming)
247248
- [How to Make a Text Editor using Tkinter in Python](https://www.thepythoncode.com/article/text-editor-using-tkinter-python). ([code](gui-programming/text-editor))
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# [How to Make an Accounting App with Django in Python](https://www.thepythoncode.com/article/make-an-accounting-app-with-django-in-python)

web-programming/accounting-app/app/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.contrib import admin
2+
from .models import Portfolio, Transaction
3+
4+
# Register your models here.
5+
admin.site.register(Portfolio)
6+
admin.site.register(Transaction)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class AppConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'app'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from django import forms
2+
3+
class createjournal(forms.Form):
4+
journal_name = forms.CharField(label='Journal Name',max_length=30)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from django.db import models
2+
from django.contrib.auth.models import User
3+
4+
# Create your models here.
5+
6+
class Portfolio(models.Model):
7+
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True)
8+
name = models.CharField(max_length=30)
9+
10+
def __str__(self):
11+
return self.name
12+
13+
class Transaction(models.Model):
14+
journal_list = models.ForeignKey(Portfolio,on_delete=models.CASCADE)
15+
trans_name = models.CharField(max_length=30)
16+
trans_type = models.CharField(max_length=3)
17+
amount = models.IntegerField()
18+
date = models.DateField()
19+
20+
def __str__(self):
21+
return self.trans_name
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>{% block title %}{% endblock %}</title>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
8+
</head>
9+
<body>
10+
<div class="container w-25 p-3 my-5 text-primary-emphasis bg-primary-subtle border border-primary-subtle rounded-3">
11+
{% block content %}{% endblock %}
12+
</div>
13+
</body>
14+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>{% block title %}{% endblock %}</title>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
8+
</head>
9+
<body class="mb-3">
10+
<nav>
11+
<ul class="nav justify-content-end bg-dark-subtle">
12+
<li class="nav-item">
13+
<a class="nav-link active" href="{% url 'pfl-list' %}">Home</a>
14+
</li>
15+
<li class="nav-item">
16+
<a class="nav-link" href="{% url 'pfl-create' %}">Add Portfolio</a>
17+
</li>
18+
<li class="nav-item">
19+
<a class="nav-link" href="{% url 'logout' %}">Log out</a>
20+
</li>
21+
</ul>
22+
</nav>
23+
24+
<div class="container-fluid">
25+
<img src="https://cdn-icons-png.flaticon.com/512/552/552721.png" style="height: 25px;width: 25px;">
26+
<span class="fs-5">{{request.user}}</span>
27+
</div>
28+
29+
<div class="container">
30+
{% block content %}{% endblock %}
31+
</div>
32+
</body>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{% extends "app/base.html" %}
2+
3+
{% block title %}Home{% endblock %}
4+
5+
{% block content %}
6+
<div class="w-50 mx-auto p-3 bg-primary-subtle border border-primary-subtle rounded-3">
7+
<h2 class="text-center">MY PORTFOLIO LIST</h2>
8+
<table class="mx-auto">
9+
{% for pfl in portfolio.portfolio_set.all %}
10+
<tr>
11+
<td class="px-2">
12+
<h3>
13+
<a class="link link-primary" href="{% url 'pfl-detail' pfl.id %}">{{pfl.name}}</a>
14+
</h3>
15+
</td>
16+
<td>
17+
<button class="btn btn-danger" onclick="window.location.href='/pfl-delete/pk={{pfl.id}}' ">Delete</button>
18+
</td>
19+
</tr>
20+
{% endfor %}
21+
</table>
22+
</div>
23+
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{% extends 'app/base.html' %}
2+
{% load app_extras %}
3+
4+
{% block title %}Details{% endblock %}
5+
6+
{% block content %}
7+
<div class="w-75 mx-auto p-2">
8+
<h2>{{pfl.name}}'s Portfolio</h2>
9+
10+
{% journal_table pfl as jt %}
11+
<div>
12+
<table class="mx-auto table table-striped border border-primary-subtle">
13+
<thead>
14+
<tr class="bg-info">
15+
<td>Date</td>
16+
<td>Transaction</td>
17+
<td>Debit</td>
18+
<td>Credit</td>
19+
</tr>
20+
</thead>
21+
<tbody>
22+
{% for transaction in jt.tbl %}
23+
<tr class="bg-secondary-subtle">
24+
{% for items in transaction %}
25+
<td>{{items}}</td>
26+
{% endfor %}
27+
</tr>
28+
{% endfor %}
29+
<tr class="bg-info-subtle">
30+
<td></td>
31+
<td>Total:</td>
32+
<td>{{jt.dt}}</td>
33+
<td>{{jt.ct}}</td>
34+
</tr>
35+
</tbody>
36+
</table>
37+
</div>
38+
39+
<form method="post" action="">
40+
<div class="vstack gap-2">
41+
{% csrf_token %}
42+
43+
<div class="input-group">
44+
<label class="input-group-text" for="inputGroupSelect01">Debit Options</label>
45+
<select name="dbt" class="form-select" id="inputGroupSelect01">
46+
<option disabled="" selected="" value="">Select Debit Transaction type</option>
47+
<option value="asset">Asset</option>
48+
<option value="liability">Liability</option>
49+
<option value="capital">Capital</option>
50+
<option value="accounts receivable">Accounts Receivable</option>
51+
<option value="accounts payable">Accounts Payable</option>
52+
<option value="notes receivable">Notes Receivable</option>
53+
<option value="notes payable">Notes Payable</option>
54+
</select>
55+
</div>
56+
57+
<div class="input-group mb">
58+
<span class="input-group-text">$</span>
59+
<input type="number" class="form-control" name="dbt-amt" placeholder="Enter Debit amount...">
60+
<span class="input-group-text">.00</span>
61+
</div>
62+
63+
<div class="input-group">
64+
<label class="input-group-text" for="inputGroupSelect02">Credit Options</label>
65+
<select name="cdt" class="form-select" id="inputGroupSelect02">
66+
<option disabled="" selected="" value="">Select Credit Transaction type</option>
67+
<option value="asset">Asset</option>
68+
<option value="liability">Liability</option>
69+
<option value="capital">Capital</option>
70+
<option value="accounts receivable">Accounts Receivable</option>
71+
<option value="accounts payable">Accounts Payable</option>
72+
<option value="notes receivable">Notes Receivable</option>
73+
<option value="notes payable">Notes Payable</option>
74+
</select>
75+
</div>
76+
77+
<div class="input-group">
78+
<span class="input-group-text">$</span>
79+
<input type="number" class="form-control" name="cdt-amt" placeholder="Enter Credit amount...">
80+
<span class="input-group-text">.00</span>
81+
</div>
82+
83+
<div class="input-group d-grid col-6">
84+
<input type="date" name="trans-date">
85+
</div>
86+
87+
<div class="d-grid col-8 mx-auto">
88+
<input class="btn btn-success" type="submit" name="save" value="Save">
89+
</div>
90+
91+
</div>
92+
</form>
93+
94+
<div class="d-grid col-6 mx-auto mt-4">
95+
<button class="btn text-primary border-primary-subtle" onclick="window.location.href='/pfl-tb/pk={{pfl.id}}'">Trial Balance</button>
96+
</div>
97+
98+
</div>
99+
{% endblock %}
100+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% extends 'app/base.html' %}
2+
3+
{% block title %}Delete Confirmation{% endblock %}
4+
5+
{% block content %}
6+
<div class="w-50 mx-auto p-3 bg-primary-subtle border border-primary-subtle rounded-3">
7+
<h2 class="text-center">Delete Confirmation</h2>
8+
<form class="opt" method="post">
9+
{% csrf_token %}
10+
<p class="text-center">Are you sure you want to delete "{{object}}"?</p>
11+
<input class="btn btn-danger d-grid col-6 mx-auto" type="submit" value="Confirm">
12+
</form>
13+
</div>
14+
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% extends "app/base.html" %}
2+
3+
{% block title %}Portfolio Create{% endblock %}
4+
5+
{% block content %}
6+
<div class="w-50 mx-auto p-3 bg-primary-subtle border border-primary-subtle rounded-3">
7+
<h2 class="text-center">Create New Portfolio</h2>
8+
<form method="post" action="">
9+
{% csrf_token %}
10+
<div class="d-grid col-6 mx-auto gap-1">
11+
<input type="textbox" name="portfolio_name" placeholder="Portfolio Name">
12+
<input class="btn btn-success" type="submit" value="Create">
13+
</div>
14+
</form>
15+
</div>
16+
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{% extends 'app/auth_base.html' %}
2+
3+
{% block title %}Sign in{% endblock %}
4+
5+
{% block content %}
6+
<h1 class="text-center">Log In</h1>
7+
8+
{% for message in messages %}
9+
<p class="callout-warning">{{message}}</p>
10+
{% endfor %}
11+
12+
<form method="post" class="mb-1">
13+
{% csrf_token %}
14+
{% for field in form %}
15+
<div class="mb-3">
16+
<label for="signupField{{forloop.counter}}" class="form-label">{{field.label}}</label>
17+
<p id="signupField{{forloop.counter}}">{{field}}</p>
18+
</div>
19+
{% endfor %}
20+
<div class="d-grid gap-2">
21+
<button type="submit" class="btn btn-primary" name="signin">Sign in</button>
22+
</div>
23+
</form>
24+
<div class="d-grid gap-2 col-10 mx-auto">
25+
<button class="btn btn-secondary" onclick="location.href = '/signup'" class="nxt-pg">Create your Account</button>
26+
</div>
27+
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{% extends 'app/auth_base.html' %}
2+
3+
{% block title %}Sign up{% endblock %}
4+
5+
{% block content %}
6+
<h1 class="text-center">Sign Up</h1>
7+
8+
{% for message in messages %}
9+
<p class="callout-warning">{{message}}</p>
10+
{% endfor %}
11+
12+
<form method="post" class="mb-1">
13+
{% csrf_token %}
14+
{% for field in form %}
15+
<div class="mb-3">
16+
<label for="signupField{{forloop.counter}}" class="form-label">{{field.label}}</label>
17+
<p id="signupField{{forloop.counter}}">{{field}}</p>
18+
</div>
19+
{% endfor %}
20+
<div id="passwordHelpBlock" class="form-text mb-3">
21+
Your password must be 8-20 characters long, contain letters, numbers, and special characters.
22+
</div>
23+
<div class="d-grid gap-2">
24+
<button type="submit" class="btn btn-primary" name="signup">Sign Up</button>
25+
</div>
26+
</form>
27+
<div class="d-grid gap-2 col-10 mx-auto">
28+
<button class="btn btn-secondary" onclick="location.href = '/login'" class="nxt-pg">Login your Account</button>
29+
</div>
30+
{% endblock %}
31+
32+

0 commit comments

Comments
 (0)