10 Commits

19 changed files with 403 additions and 17 deletions

1
.gitignore vendored
View File

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

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'
copyright = '2022, imacat'
author = 'imacat'
release = '0.1.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 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'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

@ -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