simplebooks 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- simplebooks-0.1.0/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- simplebooks-0.1.0/.github/ISSUE_TEMPLATE/documentation.md +25 -0
- simplebooks-0.1.0/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
- simplebooks-0.1.0/.gitignore +10 -0
- simplebooks-0.1.0/PKG-INFO +187 -0
- simplebooks-0.1.0/asyncql_dox.md +327 -0
- simplebooks-0.1.0/dox.md +340 -0
- simplebooks-0.1.0/license +15 -0
- simplebooks-0.1.0/pyproject.toml +37 -0
- simplebooks-0.1.0/readme.md +151 -0
- simplebooks-0.1.0/requirements.txt +4 -0
- simplebooks-0.1.0/simplebooks/__init__.py +51 -0
- simplebooks-0.1.0/simplebooks/asyncql/Account.py +91 -0
- simplebooks-0.1.0/simplebooks/asyncql/AccountType.py +16 -0
- simplebooks-0.1.0/simplebooks/asyncql/Currency.py +67 -0
- simplebooks-0.1.0/simplebooks/asyncql/Customer.py +23 -0
- simplebooks-0.1.0/simplebooks/asyncql/Entry.py +86 -0
- simplebooks-0.1.0/simplebooks/asyncql/EntryType.py +7 -0
- simplebooks-0.1.0/simplebooks/asyncql/Identity.py +26 -0
- simplebooks-0.1.0/simplebooks/asyncql/Ledger.py +54 -0
- simplebooks-0.1.0/simplebooks/asyncql/Transaction.py +121 -0
- simplebooks-0.1.0/simplebooks/asyncql/Vendor.py +23 -0
- simplebooks-0.1.0/simplebooks/asyncql/__init__.py +53 -0
- simplebooks-0.1.0/simplebooks/models/Account.py +88 -0
- simplebooks-0.1.0/simplebooks/models/AccountType.py +16 -0
- simplebooks-0.1.0/simplebooks/models/Currency.py +67 -0
- simplebooks-0.1.0/simplebooks/models/Customer.py +23 -0
- simplebooks-0.1.0/simplebooks/models/Entry.py +75 -0
- simplebooks-0.1.0/simplebooks/models/EntryType.py +7 -0
- simplebooks-0.1.0/simplebooks/models/Identity.py +26 -0
- simplebooks-0.1.0/simplebooks/models/Ledger.py +64 -0
- simplebooks-0.1.0/simplebooks/models/Transaction.py +121 -0
- simplebooks-0.1.0/simplebooks/models/Vendor.py +23 -0
- simplebooks-0.1.0/simplebooks/models/__init__.py +32 -0
- simplebooks-0.1.0/tests/context.py +6 -0
- simplebooks-0.1.0/tests/test_async_basic_e2e.py +208 -0
- simplebooks-0.1.0/tests/test_basic_e2e.py +211 -0
- simplebooks-0.1.0/tests/test_misc.py +120 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: 'Bug: '
|
|
5
|
+
labels: bug
|
|
6
|
+
assignees: k98kurz
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
### Describe the bug
|
|
11
|
+
|
|
12
|
+
A clear and concise description of what the bug is.
|
|
13
|
+
|
|
14
|
+
### To Reproduce
|
|
15
|
+
|
|
16
|
+
Steps to reproduce the behavior:
|
|
17
|
+
1. ...
|
|
18
|
+
2. ...
|
|
19
|
+
3. ...
|
|
20
|
+
|
|
21
|
+
### Expected behavior
|
|
22
|
+
|
|
23
|
+
A clear and concise description of what you expected to happen.
|
|
24
|
+
|
|
25
|
+
### Screenshots
|
|
26
|
+
|
|
27
|
+
If applicable, add screenshots to help explain your problem.
|
|
28
|
+
|
|
29
|
+
### Platform and Version (please complete the following information)
|
|
30
|
+
|
|
31
|
+
- Platform/device: [e.g. desktop or specific phone model]
|
|
32
|
+
- OS: [e.g. Ubuntu]
|
|
33
|
+
- Python Version: [e.g. 3.10]
|
|
34
|
+
- Library Version [e.g. 0.1.0]
|
|
35
|
+
|
|
36
|
+
### Additional context
|
|
37
|
+
|
|
38
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Documentation
|
|
3
|
+
about: Improve the documentation
|
|
4
|
+
title: 'Documentation: '
|
|
5
|
+
labels: documentation
|
|
6
|
+
assignees: k98kurz
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
### Describe the Issue
|
|
11
|
+
|
|
12
|
+
A clear and concise description of the documentation issue.
|
|
13
|
+
|
|
14
|
+
### Documentation Files and Sections
|
|
15
|
+
|
|
16
|
+
- readme.md: "Usage"
|
|
17
|
+
- dox.md: "Classes > Entry"
|
|
18
|
+
|
|
19
|
+
### Discrepancies from Documentation Encountered
|
|
20
|
+
|
|
21
|
+
A clear and concise description of what discrepancies you found.
|
|
22
|
+
|
|
23
|
+
### Additional context
|
|
24
|
+
|
|
25
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: 'Feature Request: '
|
|
5
|
+
labels: enhancement
|
|
6
|
+
assignees: k98kurz
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
### Is your feature request related to a problem? Please describe.
|
|
11
|
+
|
|
12
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
13
|
+
|
|
14
|
+
### Describe the solution you'd like
|
|
15
|
+
|
|
16
|
+
A clear and concise description of what you want to happen.
|
|
17
|
+
|
|
18
|
+
### Describe alternatives you've considered
|
|
19
|
+
|
|
20
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
|
21
|
+
|
|
22
|
+
### Additional context
|
|
23
|
+
|
|
24
|
+
Add any other context or screenshots about the feature request here.
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: simplebooks
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Simple double-entry accounting system using sqloquent for data storage.
|
|
5
|
+
Project-URL: Homepage, https://github.com/k98kurz/simplebooks
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/k98kurz/simplebooks/issues
|
|
7
|
+
Author-email: k98kurz <k98kurz@gmail.com>
|
|
8
|
+
License: Copyright (c) 2024 Jonathan Voss (k98kurz)
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software
|
|
11
|
+
for any personal, non-commercial purpose is hereby granted, provided
|
|
12
|
+
that the above copyright notice and this permission notice appear in
|
|
13
|
+
all copies. For other uses, contact the software author.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
|
16
|
+
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
|
17
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
|
19
|
+
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
20
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
22
|
+
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
+
Classifier: Development Status :: 3 - Alpha
|
|
24
|
+
Classifier: License :: OSI Approved :: ISC License (ISCL)
|
|
25
|
+
Classifier: Operating System :: OS Independent
|
|
26
|
+
Classifier: Programming Language :: Python :: 3
|
|
27
|
+
Classifier: Topic :: Database :: Front-Ends
|
|
28
|
+
Classifier: Topic :: Office/Business :: Financial :: Accounting
|
|
29
|
+
Requires-Python: >=3.10
|
|
30
|
+
Requires-Dist: sqloquent>=0.5.3
|
|
31
|
+
Provides-Extra: asyncql
|
|
32
|
+
Requires-Dist: sqloquent[asyncql]>=0.5.3; extra == 'asyncql'
|
|
33
|
+
Provides-Extra: docs
|
|
34
|
+
Requires-Dist: autodox>=0.1.16; extra == 'docs'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# SimpleBooks
|
|
38
|
+
|
|
39
|
+
SimpleBooks is a simple accounting library that uses sqlite3 to persist data for
|
|
40
|
+
identities, ledgers, accounts, transactions, and entries. Included are tools for
|
|
41
|
+
accomplishing basic bookkeeping tasks. The basic accounting formula is this:
|
|
42
|
+
`Assets = Liabilities + Equity`. Assets are debit-balance; liabilities and
|
|
43
|
+
equity are credit-balance. Every transaction must have entries that have no net
|
|
44
|
+
difference between the amount of credits and the amount of debits.
|
|
45
|
+
|
|
46
|
+
This is a simplification of [bookchain](https://pypi.org/project/bookchain): all
|
|
47
|
+
cryptographic features have been removed. This may be useful in scenarios when
|
|
48
|
+
cryptographic features cannot be supported.
|
|
49
|
+
|
|
50
|
+
## Status
|
|
51
|
+
|
|
52
|
+
All initially planned features have been implemented and tested.
|
|
53
|
+
|
|
54
|
+
Open issues can be found [here](https://github.com/k98kurz/simplebooks/issues).
|
|
55
|
+
|
|
56
|
+
The async implementation has an upstream issue from the sqloquent dependency
|
|
57
|
+
that can be tracked [here](https://github.com/k98kurz/sqloquent/issues/16). Once
|
|
58
|
+
that is fixed, the dependency will be updated, and this notice will be removed.
|
|
59
|
+
|
|
60
|
+
## Overview
|
|
61
|
+
|
|
62
|
+
This library provides an accounting system using sqloquent for persistence,
|
|
63
|
+
packify for deterministic encoding, and the classic rules of double-entry
|
|
64
|
+
bookkeeping. The `Transaction.prepare` and `Transaction.validate` ensure that
|
|
65
|
+
the accounting rule is followed.
|
|
66
|
+
|
|
67
|
+
### Class organization
|
|
68
|
+
|
|
69
|
+
`Currency` represents a currency/unit of account for a `Ledger`. It includes the
|
|
70
|
+
number of subunits to track and optionally the base for conversion to decimal
|
|
71
|
+
(defaults to 10), FX symbol, prefix symbol, and/or postfix symbol to be used with
|
|
72
|
+
the `format` method (e.g. `USD.format(1200)` could result in "12.00 USD",
|
|
73
|
+
"$12.00", or "12.00$", respectively). It also includes `to_decimal` method for
|
|
74
|
+
formatting int amounts into `Decimal`s.
|
|
75
|
+
|
|
76
|
+
`Identity` represents a legal person or other entity that can sign contracts
|
|
77
|
+
or engage in transactions. It includes the name, details, and optionally public
|
|
78
|
+
key bytes and private key seed bytes.
|
|
79
|
+
|
|
80
|
+
`Ledger` represents a general ledger for a given `Identity` using a specific
|
|
81
|
+
`Currency`. It includes a name, the `Identity` id, and the `Currency` id.
|
|
82
|
+
|
|
83
|
+
`Account` represents an account for a given `Ledger`. It includes a name, a type
|
|
84
|
+
(one of the `AccountType` enum options), the `Ledger` id, an optional locking
|
|
85
|
+
script for access control, and optional details.
|
|
86
|
+
|
|
87
|
+
`AccountType` is an enum representing the valid account types. The options are
|
|
88
|
+
`DEBIT_BALANCE`, `ASSET`, `CONTRA_ASSET`, `CREDIT_BALANCE`, `LIABILITY`,
|
|
89
|
+
`EQUITY`, `CONTRA_LIABILITY`, and `CONTRA_EQUITY`.
|
|
90
|
+
|
|
91
|
+
`Entry` represents an entry in the general ledger for a given `Account`. It
|
|
92
|
+
includes a type (one of the `EntryType` enum options), an amount, a nonce, the
|
|
93
|
+
`Account` id, and optional details.
|
|
94
|
+
|
|
95
|
+
`EntryType` is an enum representing the valid entry types. The options are
|
|
96
|
+
CREDIT and DEBIT.
|
|
97
|
+
|
|
98
|
+
`Transaction` represents a transaction made of `Entry`s. It includes the `Entry`
|
|
99
|
+
ids, `Ledger` ids, a timestamp, and the details. Each `Transaction` must include
|
|
100
|
+
entries that balance the number of credits and debits applied to each ledger
|
|
101
|
+
affected by the transaction. Use `Transaction.prepare` to prepare a transaction
|
|
102
|
+
-- it will raise validation errors if the transaction is not valid -- then call
|
|
103
|
+
`.save()` on the result to persist it to the database. Transactions in the
|
|
104
|
+
database can be validated by using `.validate()`, which will return `True` if it
|
|
105
|
+
is valid and `False` if it is not (it will also raise errors in some situations
|
|
106
|
+
that require more information about the validation failure).
|
|
107
|
+
|
|
108
|
+
`Customer` and `Vendor` are provided in case they are useful in some way, but no
|
|
109
|
+
relations are set up for them currently. This is likely to change in a future
|
|
110
|
+
release.
|
|
111
|
+
|
|
112
|
+
- `Identity` has many `Ledger`s
|
|
113
|
+
- `Ledger` belongs to `Identity` and `Currency`, has many `Account`s, and is within `Transaction`s
|
|
114
|
+
- `Account` belongs to `Ledger` and has many `Entry`s
|
|
115
|
+
- `Entry` belongs to `Account` and is within `Transaction`s
|
|
116
|
+
- `Transaction` contains `Ledger`s and `Entry`s
|
|
117
|
+
|
|
118
|
+
## Installation and Setup
|
|
119
|
+
|
|
120
|
+
Install with `pip install simplebooks`. If you want to use the async version,
|
|
121
|
+
instead install with `pip install simplebooks[asyncql]`.
|
|
122
|
+
|
|
123
|
+
Once installed, use the following to setup your project as appropriate:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
import simplebooks
|
|
127
|
+
|
|
128
|
+
simplebooks.publish_migrations(path_to_migrations_folder)
|
|
129
|
+
simplebooks.automigrate(path_to_migrations_folder, db_file_path)
|
|
130
|
+
simplebooks.set_connection_info(db_file_path)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
To use the async version:
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
import simplebooks
|
|
137
|
+
import simplebooks.asyncql
|
|
138
|
+
|
|
139
|
+
simplebooks.publish_migrations(path_to_migrations_folder)
|
|
140
|
+
simplebooks.automigrate(path_to_migrations_folder, db_file_path)
|
|
141
|
+
simplebooks.asyncql.set_connection_info(db_file_path)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## More Resources
|
|
145
|
+
|
|
146
|
+
Documentation generated by [autodox](https://pypi.org/project/autodox) can be
|
|
147
|
+
found [here](https://github.com/k98kurz/simplebooks/blob/v0.1.0/dox.md). Docs for
|
|
148
|
+
the async version can be found
|
|
149
|
+
[here](https://github.com/k98kurz/simplebooks/blob/v0.1.0/asyncql_dox.md).
|
|
150
|
+
|
|
151
|
+
Check out the [Pycelium discord server](https://discord.gg/b2QFEJDX69). If you
|
|
152
|
+
experience a problem, please discuss it on the Discord server. All suggestions
|
|
153
|
+
for improvement are also welcome, and the best place for that is also Discord.
|
|
154
|
+
If you experience a bug and do not use Discord, open an issue on Github.
|
|
155
|
+
|
|
156
|
+
## Tests
|
|
157
|
+
|
|
158
|
+
There are a total of 7 tests (2 e2e tests and 5 tests for miscellaneous
|
|
159
|
+
tools/features). To run them, clone the repo, set up a virtual environment
|
|
160
|
+
(e.g. `python -m venv venv && source venv/bin/activate`), install the
|
|
161
|
+
dependencies with `pip install -r requirements.txt`, and then run the following:
|
|
162
|
+
`find tests -name test_*.py -print -exec python {} \;`. On Windows, the 3 test
|
|
163
|
+
files will have to be individually run with the following:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
python tests/test_async_basic_e2e.py
|
|
167
|
+
python tests/test_basic_e2e.py
|
|
168
|
+
python tests/test_misc.py
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Personal, Non-commercial Use License
|
|
172
|
+
|
|
173
|
+
Copyright (c) 2024 Jonathan Voss (k98kurz)
|
|
174
|
+
|
|
175
|
+
Permission to use, copy, modify, and/or distribute this software
|
|
176
|
+
for any personal, non-commercial purpose is hereby granted, provided
|
|
177
|
+
that the above copyright notice and this permission notice appear in
|
|
178
|
+
all copies. For other uses, contact the software author.
|
|
179
|
+
|
|
180
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
|
181
|
+
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
|
182
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
|
183
|
+
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
|
184
|
+
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
185
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
|
186
|
+
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
187
|
+
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
# simplebooks.asyncql
|
|
2
|
+
|
|
3
|
+
## Classes
|
|
4
|
+
|
|
5
|
+
### `AccountType(Enum)`
|
|
6
|
+
|
|
7
|
+
Enum of valid Account types: DEBIT_BALANCE, ASSET, CONTRA_ASSET, CREDIT_BALANCE,
|
|
8
|
+
LIABILITY, EQUITY, CONTRA_LIABILITY, CONTRA_EQUITY.
|
|
9
|
+
|
|
10
|
+
### `EntryType(Enum)`
|
|
11
|
+
|
|
12
|
+
Enum of valid Entry types: CREDIT and DEBIT.
|
|
13
|
+
|
|
14
|
+
### `Entry(AsyncSqlModel)`
|
|
15
|
+
|
|
16
|
+
#### Annotations
|
|
17
|
+
|
|
18
|
+
- table: str
|
|
19
|
+
- id_column: str
|
|
20
|
+
- columns: tuple[str]
|
|
21
|
+
- id: str
|
|
22
|
+
- name: str
|
|
23
|
+
- query_builder_class: Type[AsyncQueryBuilderProtocol]
|
|
24
|
+
- connection_info: str
|
|
25
|
+
- data: dict
|
|
26
|
+
- data_original: MappingProxyType
|
|
27
|
+
- _event_hooks: dict[str, list[Callable]]
|
|
28
|
+
- type: str
|
|
29
|
+
- amount: int
|
|
30
|
+
- nonce: bytes
|
|
31
|
+
- account_id: str
|
|
32
|
+
- details: bytes
|
|
33
|
+
- account: AsyncRelatedModel
|
|
34
|
+
- transactions: AsyncRelatedCollection
|
|
35
|
+
|
|
36
|
+
#### Properties
|
|
37
|
+
|
|
38
|
+
- type: The EntryType of the Entry.
|
|
39
|
+
- details: A packify.SerializableType stored in the database as a blob.
|
|
40
|
+
- account: The related Account. Setting raises TypeError if the precondition
|
|
41
|
+
check fails.
|
|
42
|
+
- transactions: The related Transactions. Setting raises TypeError if the
|
|
43
|
+
precondition check fails.
|
|
44
|
+
|
|
45
|
+
#### Methods
|
|
46
|
+
|
|
47
|
+
##### `__hash__() -> int:`
|
|
48
|
+
|
|
49
|
+
##### `@staticmethod parse(models: Entry | list[Entry]) -> Entry | list[Entry]:`
|
|
50
|
+
|
|
51
|
+
##### `@classmethod async insert(data: dict) -> Entry | None:`
|
|
52
|
+
|
|
53
|
+
Ensure data is encoded before inserting.
|
|
54
|
+
|
|
55
|
+
##### `@classmethod async insert_many(items: list[dict]) -> int:`
|
|
56
|
+
|
|
57
|
+
Ensure data is encoded before inserting.
|
|
58
|
+
|
|
59
|
+
##### `@classmethod query(conditions: dict = None) -> AsyncQueryBuilderProtocol:`
|
|
60
|
+
|
|
61
|
+
Ensure conditions are encoded properly before querying.
|
|
62
|
+
|
|
63
|
+
### `Account(AsyncSqlModel)`
|
|
64
|
+
|
|
65
|
+
#### Annotations
|
|
66
|
+
|
|
67
|
+
- table: str
|
|
68
|
+
- id_column: str
|
|
69
|
+
- columns: tuple[str]
|
|
70
|
+
- id: str
|
|
71
|
+
- name: str
|
|
72
|
+
- query_builder_class: Type[AsyncQueryBuilderProtocol]
|
|
73
|
+
- connection_info: str
|
|
74
|
+
- data: dict
|
|
75
|
+
- data_original: MappingProxyType
|
|
76
|
+
- _event_hooks: dict[str, list[Callable]]
|
|
77
|
+
- type: str
|
|
78
|
+
- ledger_id: str
|
|
79
|
+
- parent_id: str
|
|
80
|
+
- code: str | None
|
|
81
|
+
- category: str | None
|
|
82
|
+
- details: bytes | None
|
|
83
|
+
- ledger: AsyncRelatedModel
|
|
84
|
+
- parent: AsyncRelatedModel
|
|
85
|
+
- children: AsyncRelatedCollection
|
|
86
|
+
- entries: AsyncRelatedCollection
|
|
87
|
+
|
|
88
|
+
#### Properties
|
|
89
|
+
|
|
90
|
+
- type: The AccountType of the Account.
|
|
91
|
+
- details: A packify.SerializableType stored in the database as a blob.
|
|
92
|
+
- ledger: The related Ledger. Setting raises TypeError if the precondition check
|
|
93
|
+
fails.
|
|
94
|
+
- children: The related Accounts. Setting raises TypeError if the precondition
|
|
95
|
+
check fails.
|
|
96
|
+
- parent: The related Account. Setting raises TypeError if the precondition
|
|
97
|
+
check fails.
|
|
98
|
+
- entries: The related Entrys. Setting raises TypeError if the precondition
|
|
99
|
+
check fails.
|
|
100
|
+
|
|
101
|
+
#### Methods
|
|
102
|
+
|
|
103
|
+
##### `@classmethod async insert(data: dict) -> Account | None:`
|
|
104
|
+
|
|
105
|
+
Ensure data is encoded before inserting.
|
|
106
|
+
|
|
107
|
+
##### `async balance(include_sub_accounts: bool = True) -> int:`
|
|
108
|
+
|
|
109
|
+
Tally all entries for this account. Includes the balances of all sub-accounts if
|
|
110
|
+
include_sub_accounts is True.
|
|
111
|
+
|
|
112
|
+
### `Currency(AsyncSqlModel)`
|
|
113
|
+
|
|
114
|
+
#### Annotations
|
|
115
|
+
|
|
116
|
+
- table: <class 'str'>
|
|
117
|
+
- id_column: <class 'str'>
|
|
118
|
+
- columns: tuple[str]
|
|
119
|
+
- id: <class 'str'>
|
|
120
|
+
- name: <class 'str'>
|
|
121
|
+
- query_builder_class: Type[AsyncQueryBuilderProtocol]
|
|
122
|
+
- connection_info: <class 'str'>
|
|
123
|
+
- data: dict
|
|
124
|
+
- data_original: MappingProxyType
|
|
125
|
+
- _event_hooks: dict[str, list[Callable]]
|
|
126
|
+
- prefix_symbol: str | None
|
|
127
|
+
- postfix_symbol: str | None
|
|
128
|
+
- fx_symbol: str | None
|
|
129
|
+
- unit_divisions: <class 'int'>
|
|
130
|
+
- base: int | None
|
|
131
|
+
- details: str | None
|
|
132
|
+
|
|
133
|
+
#### Methods
|
|
134
|
+
|
|
135
|
+
##### `to_decimal(amount: int) -> Decimal:`
|
|
136
|
+
|
|
137
|
+
Convert the amount into a Decimal representation.
|
|
138
|
+
|
|
139
|
+
##### `get_units(amount: int) -> tuple[int]:`
|
|
140
|
+
|
|
141
|
+
Get the full units and subunits. The number of subunit figures will be equal to
|
|
142
|
+
unit_divisions; e.g. if base=10 and unit_divisions=2, get_units(200) will return
|
|
143
|
+
(2, 0, 0); if base=60 and unit_divisions=2, get_units(200) will return (0, 3,
|
|
144
|
+
20).
|
|
145
|
+
|
|
146
|
+
##### `format(amount: int, /, *, use_fx_symbol: bool = False, use_postfix: bool = False, use_prefix: bool = True, decimal_places: int = 2) -> str:`
|
|
147
|
+
|
|
148
|
+
Format an amount using the correct number of decimal_places.
|
|
149
|
+
|
|
150
|
+
### `Customer(AsyncSqlModel)`
|
|
151
|
+
|
|
152
|
+
#### Annotations
|
|
153
|
+
|
|
154
|
+
- table: <class 'str'>
|
|
155
|
+
- id_column: <class 'str'>
|
|
156
|
+
- columns: tuple[str]
|
|
157
|
+
- id: <class 'str'>
|
|
158
|
+
- name: <class 'str'>
|
|
159
|
+
- query_builder_class: Type[AsyncQueryBuilderProtocol]
|
|
160
|
+
- connection_info: <class 'str'>
|
|
161
|
+
- data: dict
|
|
162
|
+
- data_original: MappingProxyType
|
|
163
|
+
- _event_hooks: dict[str, list[Callable]]
|
|
164
|
+
- code: str | None
|
|
165
|
+
- details: str | None
|
|
166
|
+
|
|
167
|
+
#### Properties
|
|
168
|
+
|
|
169
|
+
- details: A packify.SerializableType stored in the database as a blob.
|
|
170
|
+
|
|
171
|
+
### `Ledger(AsyncSqlModel)`
|
|
172
|
+
|
|
173
|
+
#### Annotations
|
|
174
|
+
|
|
175
|
+
- table: str
|
|
176
|
+
- id_column: str
|
|
177
|
+
- columns: tuple[str]
|
|
178
|
+
- id: str
|
|
179
|
+
- name: str
|
|
180
|
+
- query_builder_class: Type[AsyncQueryBuilderProtocol]
|
|
181
|
+
- connection_info: str
|
|
182
|
+
- data: dict
|
|
183
|
+
- data_original: MappingProxyType
|
|
184
|
+
- _event_hooks: dict[str, list[Callable]]
|
|
185
|
+
- identity_id: str
|
|
186
|
+
- currency_id: str
|
|
187
|
+
- owner: AsyncRelatedModel
|
|
188
|
+
- currency: AsyncRelatedModel
|
|
189
|
+
- accounts: AsyncRelatedCollection
|
|
190
|
+
- transactions: AsyncRelatedCollection
|
|
191
|
+
|
|
192
|
+
#### Properties
|
|
193
|
+
|
|
194
|
+
- owner: The related Identity. Setting raises TypeError if the precondition
|
|
195
|
+
check fails.
|
|
196
|
+
- currency: The related Currency. Setting raises TypeError if the precondition
|
|
197
|
+
check fails.
|
|
198
|
+
- accounts: The related Accounts. Setting raises TypeError if the precondition
|
|
199
|
+
check fails.
|
|
200
|
+
- transactions: The related Transactions. Setting raises TypeError if the
|
|
201
|
+
precondition check fails.
|
|
202
|
+
|
|
203
|
+
#### Methods
|
|
204
|
+
|
|
205
|
+
##### `async balances(reload: bool = False) -> dict[str, tuple[int, AccountType]]:`
|
|
206
|
+
|
|
207
|
+
Return a dict mapping account ids to their balances. Accounts with sub-accounts
|
|
208
|
+
will not include the sub-account balances; the sub-account balances will be
|
|
209
|
+
returned separately.
|
|
210
|
+
|
|
211
|
+
##### `setup_basic_accounts() -> list[Account]:`
|
|
212
|
+
|
|
213
|
+
Creates and returns a list of 3 unsaved Accounts covering the 3 basic
|
|
214
|
+
categories: Asset, Liability, Equity.
|
|
215
|
+
|
|
216
|
+
### `Identity(AsyncSqlModel)`
|
|
217
|
+
|
|
218
|
+
#### Annotations
|
|
219
|
+
|
|
220
|
+
- table: str
|
|
221
|
+
- id_column: str
|
|
222
|
+
- columns: tuple[str]
|
|
223
|
+
- id: str
|
|
224
|
+
- name: str
|
|
225
|
+
- query_builder_class: Type[AsyncQueryBuilderProtocol]
|
|
226
|
+
- connection_info: str
|
|
227
|
+
- data: dict
|
|
228
|
+
- data_original: MappingProxyType
|
|
229
|
+
- _event_hooks: dict[str, list[Callable]]
|
|
230
|
+
- columns_excluded_from_hash: tuple[str]
|
|
231
|
+
- details: bytes
|
|
232
|
+
- pubkey: bytes | None
|
|
233
|
+
- seed: bytes | None
|
|
234
|
+
- secret_details: bytes | None
|
|
235
|
+
- ledgers: AsyncRelatedCollection
|
|
236
|
+
|
|
237
|
+
#### Properties
|
|
238
|
+
|
|
239
|
+
- ledgers: The related Ledgers. Setting raises TypeError if the precondition
|
|
240
|
+
check fails.
|
|
241
|
+
|
|
242
|
+
#### Methods
|
|
243
|
+
|
|
244
|
+
##### `public() -> dict:`
|
|
245
|
+
|
|
246
|
+
Return the public data for cloning the Identity.
|
|
247
|
+
|
|
248
|
+
### `Transaction(AsyncSqlModel)`
|
|
249
|
+
|
|
250
|
+
#### Annotations
|
|
251
|
+
|
|
252
|
+
- table: str
|
|
253
|
+
- id_column: str
|
|
254
|
+
- columns: tuple[str]
|
|
255
|
+
- id: str
|
|
256
|
+
- name: str
|
|
257
|
+
- query_builder_class: Type[AsyncQueryBuilderProtocol]
|
|
258
|
+
- connection_info: str
|
|
259
|
+
- data: dict
|
|
260
|
+
- data_original: MappingProxyType
|
|
261
|
+
- _event_hooks: dict[str, list[Callable]]
|
|
262
|
+
- entry_ids: str
|
|
263
|
+
- ledger_ids: str
|
|
264
|
+
- timestamp: str
|
|
265
|
+
- details: bytes
|
|
266
|
+
- entries: AsyncRelatedCollection
|
|
267
|
+
- ledgers: AsyncRelatedCollection
|
|
268
|
+
|
|
269
|
+
#### Properties
|
|
270
|
+
|
|
271
|
+
- details: A packify.SerializableType stored in the database as a blob.
|
|
272
|
+
- entries: The related Entrys. Setting raises TypeError if the precondition
|
|
273
|
+
check fails.
|
|
274
|
+
- ledgers: The related Ledgers. Setting raises TypeError if the precondition
|
|
275
|
+
check fails.
|
|
276
|
+
|
|
277
|
+
#### Methods
|
|
278
|
+
|
|
279
|
+
##### `@classmethod async prepare(entries: list[Entry], timestamp: str, details: packify.SerializableType = None, reload: bool = False) -> Transaction:`
|
|
280
|
+
|
|
281
|
+
Prepare a transaction. Raises TypeError for invalid arguments. Raises ValueError
|
|
282
|
+
if the entries do not balance for each ledger; if a required auth script is
|
|
283
|
+
missing; or if any of the entries is contained within an existing Transaction.
|
|
284
|
+
Entries and Transaction will have IDs generated but will not be persisted to the
|
|
285
|
+
database and must be saved separately.
|
|
286
|
+
|
|
287
|
+
##### `async validate(reload: bool = False) -> bool:`
|
|
288
|
+
|
|
289
|
+
Determines if a Transaction is valid using the rules of accounting. Raises
|
|
290
|
+
TypeError for invalid arguments. Raises ValueError if the entries do not balance
|
|
291
|
+
for each ledger; or if any of the entries is contained within an existing
|
|
292
|
+
Transaction. If reload is set to True, entries and accounts will be reloaded
|
|
293
|
+
from the database.
|
|
294
|
+
|
|
295
|
+
##### `async save(reload: bool = False) -> Transaction:`
|
|
296
|
+
|
|
297
|
+
Validate the transaction, save the entries, then save the transaction.
|
|
298
|
+
|
|
299
|
+
### `Vendor(AsyncSqlModel)`
|
|
300
|
+
|
|
301
|
+
#### Annotations
|
|
302
|
+
|
|
303
|
+
- table: <class 'str'>
|
|
304
|
+
- id_column: <class 'str'>
|
|
305
|
+
- columns: tuple[str]
|
|
306
|
+
- id: <class 'str'>
|
|
307
|
+
- name: <class 'str'>
|
|
308
|
+
- query_builder_class: Type[AsyncQueryBuilderProtocol]
|
|
309
|
+
- connection_info: <class 'str'>
|
|
310
|
+
- data: dict
|
|
311
|
+
- data_original: MappingProxyType
|
|
312
|
+
- _event_hooks: dict[str, list[Callable]]
|
|
313
|
+
- code: str | None
|
|
314
|
+
- details: str | None
|
|
315
|
+
|
|
316
|
+
#### Properties
|
|
317
|
+
|
|
318
|
+
- details: A packify.SerializableType stored in the database as a blob.
|
|
319
|
+
|
|
320
|
+
## Functions
|
|
321
|
+
|
|
322
|
+
### `set_connection_info(db_file_path: str):`
|
|
323
|
+
|
|
324
|
+
Set the connection info for all models to use the specified sqlite3 database
|
|
325
|
+
file path.
|
|
326
|
+
|
|
327
|
+
|