Compare commits

..

14 Commits
v0.1.0 ... main

Author SHA1 Message Date
7086c26ce7 Updated README.rst for the current Flask project. 2023-04-05 12:52:44 +08:00
2ec072854b Advanced to version 0.2.0. 2023-04-04 19:19:53 +08:00
a41d381322 Added a warning to the last Django release. 2023-04-04 19:19:15 +08:00
c301f7ca74 Renamed the project from "Mia! Accounting" to "Mia! Accounting Django". 2023-04-04 19:01:57 +08:00
020555602d Removed the deprecated and unused USE_L10N setting from the test site. 2023-01-22 08:08:42 +08:00
9176be3c11 Added requirements.txt for readthedocs.io. 2022-12-08 01:07:08 +08:00
1d16b250d8 Revised the documentation. 2022-12-08 01:06:15 +08:00
72b9555e29 Added the build directory to .gitignore. 2022-12-08 00:53:03 +08:00
d09255432d Applied Sphinx autodoc, and added the automatically-generated module documents to the documentation. 2022-12-08 00:52:49 +08:00
64e81a64ef Added the Sphinx documentation skeleton. 2022-12-08 00:42:55 +08:00
e14a0432b2 Applied a random secret key to the settings of the test site, although it is not important. 2022-12-06 08:14:39 +08:00
7e7d428b52 Added the test URI variables in the test_run test of the RunTestCase test case. 2022-12-06 07:07:49 +08:00
353ebd7242 Revised the test_run test of the RunTestCase test case to test the failure adding the transfer transaction. 2022-12-06 07:07:25 +08:00
467739e0c8 Revised the test_run test of the RunTestCase test case to test if the result is successful. 2022-12-06 07:07:14 +08:00
21 changed files with 448 additions and 32 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
*.pyc
__pycache__
dist
build
*.egg-info
migrations
*.mo

View File

@ -1,8 +1,38 @@
======================================
The Mia! Django Accounting Application
The Mia! Accounting Django Application
======================================
Obsolete Project
================
This project is obsolete. No further Django release will be
available. Check the current `Mia! Accounting project`_ for Flask_,
and the current `Mia! Accounting live demonstration`_.
.. _Mia! Accounting project: https://github.com/imacat/mia-accounting
.. _Flask: https://flask.palletsprojects.com
.. _Mia! Accounting live demonstration: https://accounting.imacat.idv.tw
Warning
=======
This is the last release of Django. It will be replaced by a new
Flask_ release, starting from scratch. Do not upgrade to the next
release, as it will not work.
This was my first large Python project, and at that time, I had zero
experience with Django. I ended up in a mess with Django MVT. The
code is unnecessarily complicated, and I do not actually know how the
views work anymore.
If you are new to the Mia! Accounting project, please skip this and
try the new release. You may contact me if you have problems with
the existing installation, but I may not be able to help you.
Description
===========
@ -13,7 +43,7 @@ a modern back-end framework and front-end technology like jQuery. The
first revision was in Perl/Mojolicious_ in 2019. This is the second
revision in Python/Django in 2020.
The Mia! Django accounting application comes with two parts:
The Mia! Accounting Django application comes with two parts:
- The ``accounting`` application contains the main accounting
application.
@ -23,7 +53,7 @@ The Mia! Django accounting application comes with two parts:
You may try it in live demonstration at:
- URL: https://accounting.imacat.idv.tw/accounting
- URL: https://accounting-django.imacat.idv.tw/accounting
- Username: ``admin``
- Password: ``12345``
@ -38,14 +68,14 @@ Installation
Install
-------
The Mia! Django accounting application requires Python 3.7 and Django
The Mia! Accounting Django application requires Python 3.7 and Django
3.1.
Install ``mia-accounting`` with ``pip``.
Install ``mia-accounting-django`` with ``pip``.
.. code::
pip install mia-accounting
pip install mia-accounting-django
``settings.py``
---------------
@ -147,7 +177,7 @@ And you are done.
Management Commands
===================
The following management commands are added by *the Mia! accounting
The following management commands are added by *the Mia! Accounting Django
application* to ``manage.py``:
``accounting_accounts``
@ -283,9 +313,9 @@ The following advanced settings are available in ``settings.py``.
Bugs and Supports
=================
The Mia! Django accounting application is hosted on GitHub.
The Mia! Accounting Django application is hosted on GitHub.
https://github.com/imacat/mia-accounting
https://github.com/imacat/mia-accounting-django
Address all bugs and support requests to imacat@mail.imacat.idv.tw.
@ -293,7 +323,7 @@ Address all bugs and support requests to imacat@mail.imacat.idv.tw.
Copyright
=========
Copyright (c) 2020-2021 imacat.
Copyright (c) 2020-2023 imacat.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

20
docs/Makefile Normal file
View File

@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

35
docs/make.bat Normal file
View File

@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)
if "%1" == "" goto help
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

4
docs/requirements.txt Normal file
View File

@ -0,0 +1,4 @@
django
django-dirtyfields
titlecase
django-decorator-include

View File

View File

View File

@ -0,0 +1,21 @@
accounting.migrations package
=============================
Submodules
----------
accounting.migrations.0001\_initial module
------------------------------------------
.. automodule:: accounting.migrations.0001_initial
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: accounting.migrations
:members:
:undoc-members:
:show-inheritance:

View File

@ -0,0 +1,94 @@
accounting package
==================
Subpackages
-----------
.. toctree::
:maxdepth: 4
accounting.migrations
accounting.templatetags
Submodules
----------
accounting.apps module
----------------------
.. automodule:: accounting.apps
:members:
:undoc-members:
:show-inheritance:
accounting.converters module
----------------------------
.. automodule:: accounting.converters
:members:
:undoc-members:
:show-inheritance:
accounting.forms module
-----------------------
.. automodule:: accounting.forms
:members:
:undoc-members:
:show-inheritance:
accounting.models module
------------------------
.. automodule:: accounting.models
:members:
:undoc-members:
:show-inheritance:
accounting.tests module
-----------------------
.. automodule:: accounting.tests
:members:
:undoc-members:
:show-inheritance:
accounting.urls module
----------------------
.. automodule:: accounting.urls
:members:
:undoc-members:
:show-inheritance:
accounting.utils module
-----------------------
.. automodule:: accounting.utils
:members:
:undoc-members:
:show-inheritance:
accounting.validators module
----------------------------
.. automodule:: accounting.validators
:members:
:undoc-members:
:show-inheritance:
accounting.views module
-----------------------
.. automodule:: accounting.views
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: accounting
:members:
:undoc-members:
:show-inheritance:

View File

@ -0,0 +1,21 @@
accounting.templatetags package
===============================
Submodules
----------
accounting.templatetags.accounting module
-----------------------------------------
.. automodule:: accounting.templatetags.accounting
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: accounting.templatetags
:members:
:undoc-members:
:show-inheritance:

36
docs/source/conf.py Normal file
View File

@ -0,0 +1,36 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
import os
import sys
import django
sys.path.insert(0, os.path.abspath('../../src/'))
sys.path.append(os.path.abspath('../../tests/test_site/'))
os.environ["DJANGO_SETTINGS_MODULE"] = "test_site.settings"
django.setup()
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'Mia! Accounting Django'
copyright = '2022-2023, imacat'
author = 'imacat'
release = '0.2.0'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = ["sphinx.ext.autodoc"]
templates_path = ['_templates']
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']

20
docs/source/index.rst Normal file
View File

@ -0,0 +1,20 @@
.. Mia! Accounting Django documentation master file, created by
sphinx-quickstart on Thu Dec 8 00:42:14 2022.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Mia! Accounting Django's documentation!
==================================================
.. toctree::
:maxdepth: 2
:caption: Contents:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

View File

@ -0,0 +1,10 @@
mia\_core.migrations package
============================
Module contents
---------------
.. automodule:: mia_core.migrations
:members:
:undoc-members:
:show-inheritance:

70
docs/source/mia_core.rst Normal file
View File

@ -0,0 +1,70 @@
mia\_core package
=================
Subpackages
-----------
.. toctree::
:maxdepth: 4
mia_core.migrations
mia_core.templatetags
Submodules
----------
mia\_core.apps module
---------------------
.. automodule:: mia_core.apps
:members:
:undoc-members:
:show-inheritance:
mia\_core.models module
-----------------------
.. automodule:: mia_core.models
:members:
:undoc-members:
:show-inheritance:
mia\_core.period module
-----------------------
.. automodule:: mia_core.period
:members:
:undoc-members:
:show-inheritance:
mia\_core.tests module
----------------------
.. automodule:: mia_core.tests
:members:
:undoc-members:
:show-inheritance:
mia\_core.utils module
----------------------
.. automodule:: mia_core.utils
:members:
:undoc-members:
:show-inheritance:
mia\_core.views module
----------------------
.. automodule:: mia_core.views
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: mia_core
:members:
:undoc-members:
:show-inheritance:

View File

@ -0,0 +1,21 @@
mia\_core.templatetags package
==============================
Submodules
----------
mia\_core.templatetags.mia\_core module
---------------------------------------
.. automodule:: mia_core.templatetags.mia_core
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: mia_core.templatetags
:members:
:undoc-members:
:show-inheritance:

8
docs/source/modules.rst Normal file
View File

@ -0,0 +1,8 @@
src
===
.. toctree::
:maxdepth: 4
accounting
mia_core

View File

@ -1,7 +1,7 @@
# The setup.cfg
# by imacat <imacat@mail.imacat.idv.tw>, 2020/9/7
# Copyright (c) 2020 imacat.
# Copyright (c) 2020-2023 imacat.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -17,15 +17,15 @@
[metadata]
name = mia-accounting
version = 0.1.0
version = 0.2.0
author = imacat
author_email = imacat@mail.imacat.idv.tw
description = A Django accounting application.
description = The Mia! Accounting Django project.
long_description = file: README.rst
long_description_content_type = text/x-rst
url = https://github.com/imacat/mia-accounting
url = https://github.com/imacat/mia-accounting-django
project_urls =
Bug Tracker = https://github.com/imacat/mia-accounting/issues
Bug Tracker = https://github.com/imacat/mia-accounting-django/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: Apache Software License

View File

@ -80,10 +80,9 @@ class ReportUrl:
Args:
namespace: The namespace of the current application.
cash: The currently-specified account of the
cash account or cash summary.
ledger: The currently-specified account of the
ledger or leger summary.
cash: The currently-specified account of the cash account or cash
summary.
ledger: The currently-specified account of the ledger or leger summary.
period: The currently-specified period.
"""
@ -145,9 +144,8 @@ class DataFiller:
"""Adds accounts.
Args:
accounts (tuple[tuple[any]]): Tuples of
(code, English, Traditional Chinese, Simplified Chinese)
of the accounts.
accounts: Tuples of (code, English, Traditional Chinese, Simplified
Chinese) of the accounts.
"""
for data in accounts:
code = data[0]
@ -167,8 +165,7 @@ class DataFiller:
"""Adds a transfer transaction.
Args:
date: The date, or the number of days from
today.
date: The date, or the number of days from today.
debit: Tuples of (account, summary, amount) of the debit records.
credit: Tuples of (account, summary, amount) of the credit records.
"""

View File

@ -429,8 +429,7 @@ class Pagination:
url (str): The link URL, or for a non-link slot.
title (str): The title of the link.
is_active (bool): Whether this link is currently active.
is_small_screen (bool): Whether this link is for small
screens
is_small_screen (bool): Whether this link is for small screens.
"""
def __int__(self):
self.url = None

View File

@ -76,9 +76,13 @@ class RunTestCase(unittest.TestCase):
self.assertEqual(response.status_code, 200)
today: str = datetime.today().strftime("%Y-%m-%d")
expense_add_uri: str = "/accounting/transactions/expense/create?r=/ok"
income_add_uri: str = "/accounting/transactions/income/create?r=/ok"
transfer_add_uri: str \
= "/accounting/transactions/transfer/create?r=/ok"
response = self.client.post(
"/accounting/transactions/expense/create?r=/ok",
expense_add_uri,
{"date": today,
"debit-2-ord": 6,
"debit-2-summary": "lunch",
@ -90,9 +94,10 @@ class RunTestCase(unittest.TestCase):
"debit-8-account": "6273",
"notes": "yammy"})
self.assertEqual(response.status_code, 302)
self.assertNotEqual(response.headers["Location"], expense_add_uri)
response = self.client.post(
"/accounting/transactions/income/create?r=/ok",
income_add_uri,
{"date": today,
"credit-3-ord": 7,
"credit-3-summary": "withdrawal",
@ -104,9 +109,33 @@ class RunTestCase(unittest.TestCase):
"credit-6-account": "4611",
"notes": "wonderful"})
self.assertEqual(response.status_code, 302)
self.assertNotEqual(response.headers["Location"], income_add_uri)
response = self.client.post(
"/accounting/transactions/transfer/create?r=/ok",
transfer_add_uri,
{"date": today,
"debit-2-ord": 6,
"debit-2-summary": "lunch",
"debit-2-amount": 80,
"debit-2-account": "6272",
"debit-8-ord": 4,
"debit-8-summary": "movies",
"debit-8-amount": 320,
"debit-8-account": "6273",
"credit-3-ord": 7,
"credit-3-summary": "withdrawal",
"credit-3-amount": 100,
"credit-3-account": "1113",
"credit-6-ord": 3,
"credit-6-summary": "",
"credit-6-amount": 320,
"credit-6-account": "1111",
"notes": "nothing"})
self.assertEqual(response.status_code, 302)
self.assertEqual(response.headers["Location"], transfer_add_uri)
response = self.client.post(
transfer_add_uri,
{"date": today,
"debit-2-ord": 6,
"debit-2-summary": "lunch",
@ -126,3 +155,4 @@ class RunTestCase(unittest.TestCase):
"credit-6-account": "1111",
"notes": "nothing"})
self.assertEqual(response.status_code, 302)
self.assertNotEqual(response.headers["Location"], transfer_add_uri)

View File

@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import os
from pathlib import Path
from secrets import token_urlsafe
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@ -20,7 +21,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-vc+(5e-2xn%bc29&k#ah_vf17-)usz4af4y)njbp_k09)uev$$'
SECRET_KEY = token_urlsafe(48)
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
@ -111,8 +112,6 @@ TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True