diff --git a/django_ledger/io/io_core.py b/django_ledger/io/io_core.py index cd31a447..519d0cbb 100644 --- a/django_ledger/io/io_core.py +++ b/django_ledger/io/io_core.py @@ -549,7 +549,7 @@ def python_digest(self, force_queryset_sorting: bool = False, **kwargs) -> IOResult: """ - Performs the appropriate transaction post-processing after DB aggregation.. + Performs the appropriate transaction post-processing after DB aggregation. Parameters @@ -938,6 +938,7 @@ def digest_balance_sheet(self, balance_sheet_statement=True, txs_queryset=txs_queryset, as_io_digest=True, + signs=True, **kwargs ) @@ -991,6 +992,7 @@ def digest_income_statement(self, income_statement=True, txs_queryset=txs_queryset, as_io_digest=True, + sings=True, **kwargs ) @@ -1046,6 +1048,7 @@ def digest_cash_flow_statement(self, cash_flow_statement=True, txs_queryset=txs_queryset, as_io_digest=True, + signs=True, **kwargs ) diff --git a/django_ledger/models/coa_default.py b/django_ledger/models/coa_default.py index 5fdeb5bc..95d810e5 100644 --- a/django_ledger/models/coa_default.py +++ b/django_ledger/models/coa_default.py @@ -2,10 +2,6 @@ Django Ledger created by Miguel Sanda . Copyright© EDMA Group Inc licensed under the GPLv3 Agreement. -Contributions to this module: - * Miguel Sanda - * Pranav P Tulshyan - This is the base Chart of Accounts that has all the possible accounts that are useful for the preparation of the Financial Statements. A user may choose to use the default CoA at the creation of each EntityModel but it is not required. The default CoA is intended to provide a QuickStart solution for most use cases. @@ -14,8 +10,10 @@ 1. Assets: 2. Liabilities 3. Shareholder's Equity - 4. Expenses - 5. Revenue + 4. Income + 5. COGS + 6. Expenses + The Django Ledger Default Chart of Accounts must include the following fields: * Code - String @@ -75,7 +73,8 @@ 6040 ex_regular debit Bad Debt root_expenses 6050 ex_regular debit Bank Charges root_expenses 6060 ex_regular debit Commission Expense root_expenses - 6080 ex_regular debit Employee Benefits root_expenses + 6080 ex_regular debit Employee Benefits root_expenses + 6081 ex_regular debit Employee Wages root_expenses 6090 ex_regular debit Freight root_expenses 6110 ex_regular debit Gifts root_expenses 6120 ex_regular debit Insurance root_expenses @@ -83,7 +82,7 @@ 6150 ex_regular debit License Expense root_expenses 6170 ex_regular debit Maintenance Expense root_expenses 6180 ex_regular debit Meals & Entertainment root_expenses - 6190 ex_regular debit Office Expense root_expenses + 6190 ex_regular debit Office Expense root_expenses 6220 ex_regular debit Printing root_expenses 6230 ex_regular debit Postage root_expenses 6240 ex_regular debit Rent root_expenses @@ -262,6 +261,8 @@ 'parent': None}, {'code': '6080', 'role': roles.EXPENSE_OPERATIONAL, 'balance_type': 'debit', 'name': 'Employee Benefits', 'parent': None}, + {'code': '6081', 'role': roles.EXPENSE_OPERATIONAL, 'balance_type': 'debit', 'name': 'Employee Wages', + 'parent': None}, {'code': '6090', 'role': roles.EXPENSE_OPERATIONAL, 'balance_type': 'debit', 'name': 'Freight', 'parent': None}, {'code': '6110', 'role': roles.EXPENSE_OPERATIONAL, 'balance_type': 'debit', 'name': 'Gifts', 'parent': None}, {'code': '6120', 'role': roles.EXPENSE_OPERATIONAL, 'balance_type': 'debit', 'name': 'Insurance', 'parent': None}, diff --git a/notebooks/DjangoCon2024.ipynb b/notebooks/DjangoCon2024.ipynb index b69fd805..310885ac 100644 --- a/notebooks/DjangoCon2024.ipynb +++ b/notebooks/DjangoCon2024.ipynb @@ -9,11 +9,13 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:46.820329Z", + "start_time": "2024-09-24T13:23:46.815235Z" + } }, - "outputs": [], "source": [ "import os\n", "from datetime import date, datetime\n", @@ -40,7 +42,9 @@ "\n", "from django.contrib.auth import get_user_model\n", "from django_ledger.io import roles" - ] + ], + "outputs": [], + "execution_count": 4 }, { "cell_type": "markdown", @@ -51,11 +55,13 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:46.827345Z", + "start_time": "2024-09-24T13:23:46.824325Z" + } }, - "outputs": [], "source": [ "# change this to your preferred django username...\n", "MY_USERNAME = 'ceo_user'\n", @@ -68,7 +74,9 @@ " user_model = UserModel(username=MY_USERNAME)\n", " user_model.set_password(MY_PASSWORD)\n", " user_model.save()" - ] + ], + "outputs": [], + "execution_count": 5 }, { "cell_type": "markdown", @@ -79,11 +87,13 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:46.849607Z", + "start_time": "2024-09-24T13:23:46.838637Z" + } }, - "outputs": [], "source": [ "from django_ledger.models.entity import EntityModel\n", "\n", @@ -97,7 +107,20 @@ ")\n", "\n", "entity_model" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 6 }, { "cell_type": "markdown", @@ -126,40 +149,74 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:46.872419Z", + "start_time": "2024-09-24T13:23:46.869922Z" + } }, - "outputs": [], "source": [ "entity_model.has_default_coa()" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 7 }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:47.000400Z", + "start_time": "2024-09-24T13:23:46.949769Z" + } }, - "outputs": [], "source": [ "default_coa_model = entity_model.create_chart_of_accounts(\n", " assign_as_default=True,\n", " commit=True,\n", " coa_name='My QuickStart CoA'\n", ")" - ] + ], + "outputs": [], + "execution_count": 8 }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:47.006594Z", + "start_time": "2024-09-24T13:23:47.004523Z" + } }, - "outputs": [], "source": [ "default_coa_model" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 9 }, { "cell_type": "markdown", @@ -170,26 +227,56 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:47.079227Z", + "start_time": "2024-09-24T13:23:47.077353Z" + } }, - "outputs": [], "source": [ "entity_model.has_default_coa()" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 10 }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:47.148233Z", + "start_time": "2024-09-24T13:23:47.145777Z" + } }, - "outputs": [], "source": [ "default_coa_model = entity_model.get_default_coa()\n", "default_coa_model" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 11 }, { "cell_type": "markdown", @@ -200,17 +287,32 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:47.173600Z", + "start_time": "2024-09-24T13:23:47.171252Z" } }, - "outputs": [], "source": [ "entity_model.default_coa == default_coa_model" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 12 }, { "cell_type": "markdown", @@ -221,32 +323,51 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:47.228559Z", + "start_time": "2024-09-24T13:23:47.197351Z" + } }, - "outputs": [], "source": [ "another_coa_model = entity_model.create_chart_of_accounts(\n", " assign_as_default=False,\n", " commit=True,\n", " coa_name='My Empty Chart of Accounts'\n", ")" - ] + ], + "outputs": [], + "execution_count": 13 }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:47.234739Z", + "start_time": "2024-09-24T13:23:47.232599Z" } }, - "outputs": [], "source": [ "another_coa_model" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 14 }, { "cell_type": "markdown", @@ -271,14 +392,18 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:47.245600Z", + "start_time": "2024-09-24T13:23:47.243581Z" + } }, - "outputs": [], "source": [ "START_DTTM = datetime(year=2022, month=10, day=1, tzinfo=ZoneInfo('UTC'))" - ] + ], + "outputs": [], + "execution_count": 15 }, { "cell_type": "markdown", @@ -298,14 +423,18 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:50.880263Z", + "start_time": "2024-09-24T13:23:47.249574Z" + } }, - "outputs": [], "source": [ "entity_model.populate_random_data(start_date=START_DTTM)" - ] + ], + "outputs": [], + "execution_count": 16 }, { "cell_type": "markdown", @@ -328,15 +457,188 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:50.894817Z", + "start_time": "2024-09-24T13:23:50.884306Z" + } }, - "outputs": [], "source": [ "default_coa_accounts_qs = entity_model.get_default_coa_accounts()\n", "pd.DataFrame(default_coa_accounts_qs.values('code', 'name', 'role', 'balance_type', 'active', 'locked'))" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + " code name role balance_type active \\\n", + "0 1010 Cash asset_ca_cash debit True \n", + "1 1050 Short Term Investments asset_ca_mkt_sec debit True \n", + "2 1100 Accounts Receivable asset_ca_recv debit True \n", + "3 1110 Uncollectibles asset_ca_uncoll credit True \n", + "4 1200 Inventory asset_ca_inv debit True \n", + ".. ... ... ... ... ... \n", + "84 6294 Garbage ex_regular debit True \n", + "85 6295 Electricity ex_regular debit True \n", + "86 6300 Property Management ex_regular debit True \n", + "87 6400 Vacancy ex_regular debit True \n", + "88 6500 Misc. Expense ex_other debit True \n", + "\n", + " locked \n", + "0 False \n", + "1 False \n", + "2 False \n", + "3 False \n", + "4 False \n", + ".. ... \n", + "84 False \n", + "85 False \n", + "86 False \n", + "87 False \n", + "88 False \n", + "\n", + "[89 rows x 6 columns]" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
codenamerolebalance_typeactivelocked
01010Cashasset_ca_cashdebitTrueFalse
11050Short Term Investmentsasset_ca_mkt_secdebitTrueFalse
21100Accounts Receivableasset_ca_recvdebitTrueFalse
31110Uncollectiblesasset_ca_uncollcreditTrueFalse
41200Inventoryasset_ca_invdebitTrueFalse
.....................
846294Garbageex_regulardebitTrueFalse
856295Electricityex_regulardebitTrueFalse
866300Property Managementex_regulardebitTrueFalse
876400Vacancyex_regulardebitTrueFalse
886500Misc. Expenseex_otherdebitTrueFalse
\n", + "

89 rows × 6 columns

\n", + "
" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 17 }, { "cell_type": "markdown", @@ -347,15 +649,188 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:50.916629Z", + "start_time": "2024-09-24T13:23:50.911099Z" + } }, - "outputs": [], "source": [ "coa_accounts_by_coa_model_qs = entity_model.get_coa_accounts(coa_model=default_coa_model)\n", "pd.DataFrame(coa_accounts_by_coa_model_qs.values('code', 'name', 'role', 'balance_type', 'active', 'locked'))" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + " code name role balance_type active \\\n", + "0 1010 Cash asset_ca_cash debit True \n", + "1 1050 Short Term Investments asset_ca_mkt_sec debit True \n", + "2 1100 Accounts Receivable asset_ca_recv debit True \n", + "3 1110 Uncollectibles asset_ca_uncoll credit True \n", + "4 1200 Inventory asset_ca_inv debit True \n", + ".. ... ... ... ... ... \n", + "84 6294 Garbage ex_regular debit True \n", + "85 6295 Electricity ex_regular debit True \n", + "86 6300 Property Management ex_regular debit True \n", + "87 6400 Vacancy ex_regular debit True \n", + "88 6500 Misc. Expense ex_other debit True \n", + "\n", + " locked \n", + "0 False \n", + "1 False \n", + "2 False \n", + "3 False \n", + "4 False \n", + ".. ... \n", + "84 False \n", + "85 False \n", + "86 False \n", + "87 False \n", + "88 False \n", + "\n", + "[89 rows x 6 columns]" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
codenamerolebalance_typeactivelocked
01010Cashasset_ca_cashdebitTrueFalse
11050Short Term Investmentsasset_ca_mkt_secdebitTrueFalse
21100Accounts Receivableasset_ca_recvdebitTrueFalse
31110Uncollectiblesasset_ca_uncollcreditTrueFalse
41200Inventoryasset_ca_invdebitTrueFalse
.....................
846294Garbageex_regulardebitTrueFalse
856295Electricityex_regulardebitTrueFalse
866300Property Managementex_regulardebitTrueFalse
876400Vacancyex_regulardebitTrueFalse
886500Misc. Expenseex_otherdebitTrueFalse
\n", + "

89 rows × 6 columns

\n", + "
" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 18 }, { "cell_type": "markdown", @@ -371,18 +846,61 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:50.936945Z", + "start_time": "2024-09-24T13:23:50.932831Z" } }, - "outputs": [], "source": [ "coa_accounts_by_coa_model_qs = entity_model.get_coa_accounts(coa_model=another_coa_model)\n", "pd.DataFrame(coa_accounts_by_coa_model_qs.values('code', 'name', 'role', 'balance_type', 'active', 'locked'))" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "Empty DataFrame\n", + "Columns: []\n", + "Index: []" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
\n", + "
" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 19 }, { "cell_type": "markdown", @@ -394,15 +912,188 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:51.135750Z", + "start_time": "2024-09-24T13:23:51.128874Z" + } }, - "outputs": [], "source": [ "coa_accounts_by_coa_uuid_qs = entity_model.get_coa_accounts(coa_model=default_coa_model.uuid)\n", "pd.DataFrame(coa_accounts_by_coa_uuid_qs.values('code', 'name', 'role', 'balance_type', 'active', 'locked'))" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + " code name role balance_type active \\\n", + "0 1010 Cash asset_ca_cash debit True \n", + "1 1050 Short Term Investments asset_ca_mkt_sec debit True \n", + "2 1100 Accounts Receivable asset_ca_recv debit True \n", + "3 1110 Uncollectibles asset_ca_uncoll credit True \n", + "4 1200 Inventory asset_ca_inv debit True \n", + ".. ... ... ... ... ... \n", + "84 6294 Garbage ex_regular debit True \n", + "85 6295 Electricity ex_regular debit True \n", + "86 6300 Property Management ex_regular debit True \n", + "87 6400 Vacancy ex_regular debit True \n", + "88 6500 Misc. Expense ex_other debit True \n", + "\n", + " locked \n", + "0 False \n", + "1 False \n", + "2 False \n", + "3 False \n", + "4 False \n", + ".. ... \n", + "84 False \n", + "85 False \n", + "86 False \n", + "87 False \n", + "88 False \n", + "\n", + "[89 rows x 6 columns]" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
codenamerolebalance_typeactivelocked
01010Cashasset_ca_cashdebitTrueFalse
11050Short Term Investmentsasset_ca_mkt_secdebitTrueFalse
21100Accounts Receivableasset_ca_recvdebitTrueFalse
31110Uncollectiblesasset_ca_uncollcreditTrueFalse
41200Inventoryasset_ca_invdebitTrueFalse
.....................
846294Garbageex_regulardebitTrueFalse
856295Electricityex_regulardebitTrueFalse
866300Property Managementex_regulardebitTrueFalse
876400Vacancyex_regulardebitTrueFalse
886500Misc. Expenseex_otherdebitTrueFalse
\n", + "

89 rows × 6 columns

\n", + "
" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 20 }, { "cell_type": "markdown", @@ -414,15 +1105,188 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:51.382152Z", + "start_time": "2024-09-24T13:23:51.377163Z" + } }, - "outputs": [], "source": [ "coa_accounts_by_coa_slug_qs = entity_model.get_coa_accounts(coa_model=default_coa_model.slug)\n", "pd.DataFrame(coa_accounts_by_coa_slug_qs.values('code', 'name', 'role', 'balance_type', 'active', 'locked'))" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + " code name role balance_type active \\\n", + "0 1010 Cash asset_ca_cash debit True \n", + "1 1050 Short Term Investments asset_ca_mkt_sec debit True \n", + "2 1100 Accounts Receivable asset_ca_recv debit True \n", + "3 1110 Uncollectibles asset_ca_uncoll credit True \n", + "4 1200 Inventory asset_ca_inv debit True \n", + ".. ... ... ... ... ... \n", + "84 6294 Garbage ex_regular debit True \n", + "85 6295 Electricity ex_regular debit True \n", + "86 6300 Property Management ex_regular debit True \n", + "87 6400 Vacancy ex_regular debit True \n", + "88 6500 Misc. Expense ex_other debit True \n", + "\n", + " locked \n", + "0 False \n", + "1 False \n", + "2 False \n", + "3 False \n", + "4 False \n", + ".. ... \n", + "84 False \n", + "85 False \n", + "86 False \n", + "87 False \n", + "88 False \n", + "\n", + "[89 rows x 6 columns]" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
codenamerolebalance_typeactivelocked
01010Cashasset_ca_cashdebitTrueFalse
11050Short Term Investmentsasset_ca_mkt_secdebitTrueFalse
21100Accounts Receivableasset_ca_recvdebitTrueFalse
31110Uncollectiblesasset_ca_uncollcreditTrueFalse
41200Inventoryasset_ca_invdebitTrueFalse
.....................
846294Garbageex_regulardebitTrueFalse
856295Electricityex_regulardebitTrueFalse
866300Property Managementex_regulardebitTrueFalse
876400Vacancyex_regulardebitTrueFalse
886500Misc. Expenseex_otherdebitTrueFalse
\n", + "

89 rows × 6 columns

\n", + "
" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 21 }, { "cell_type": "markdown", @@ -434,15 +1298,82 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:51.482515Z", + "start_time": "2024-09-24T13:23:51.477989Z" + } }, - "outputs": [], "source": [ "coa_accounts_by_codes_qs = entity_model.get_accounts_with_codes(code_list=['1010', '1050'])\n", "pd.DataFrame(coa_accounts_by_codes_qs.values('code', 'name', 'role', 'balance_type', 'active', 'locked'))" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + " code name role balance_type active locked\n", + "0 1010 Cash asset_ca_cash debit True False\n", + "1 1050 Short Term Investments asset_ca_mkt_sec debit True False" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
codenamerolebalance_typeactivelocked
01010Cashasset_ca_cashdebitTrueFalse
11050Short Term Investmentsasset_ca_mkt_secdebitTrueFalse
\n", + "
" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 22 }, { "cell_type": "markdown", @@ -458,21 +1389,64 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:51.601346Z", + "start_time": "2024-09-24T13:23:51.597798Z" } }, - "outputs": [], "source": [ "coa_accounts_by_codes_qs = entity_model.get_accounts_with_codes(\n", - " code_list=['1010', '1050'], \n", + " code_list=['1010', '1050'],\n", " coa_model=another_coa_model\n", ")\n", "pd.DataFrame(coa_accounts_by_codes_qs.values('code', 'name', 'role', 'balance_type', 'active', 'locked'))" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "Empty DataFrame\n", + "Columns: []\n", + "Index: []" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
\n", + "
" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 23 }, { "cell_type": "markdown", @@ -488,17 +1462,21 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:51.677510Z", + "start_time": "2024-09-24T13:23:51.672447Z" } }, - "outputs": [], "source": [ "coa_qs, coa_map = entity_model.get_all_coa_accounts()" - ] + ], + "outputs": [], + "execution_count": 24 }, { "cell_type": "markdown", @@ -514,45 +1492,204 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:51.748758Z", + "start_time": "2024-09-24T13:23:51.745027Z" } }, - "outputs": [], "source": [ "coa_map" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "{: ,\n", + " : , , , , , , , , , , , , , , , , , , , , '...(remaining elements truncated)...']>}" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 25 }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:51.821610Z", + "start_time": "2024-09-24T13:23:51.815312Z" } }, - "outputs": [], "source": [ "pd.DataFrame(coa_map[default_coa_model])" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + " 0\n", + "0 ASSETS - 1010: Cash (ASSET_CA_CASH/debit)\n", + "1 ASSETS - 1050: Short Term Investments (ASSET_C...\n", + "2 ASSETS - 1100: Accounts Receivable (ASSET_CA_R...\n", + "3 ASSETS - 1110: Uncollectibles (ASSET_CA_UNCOLL...\n", + "4 ASSETS - 1200: Inventory (ASSET_CA_INV/debit)\n", + ".. ...\n", + "84 EQUITY - 6294: Garbage (EX_REGULAR/debit)\n", + "85 EQUITY - 6295: Electricity (EX_REGULAR/debit)\n", + "86 EQUITY - 6300: Property Management (EX_REGULAR...\n", + "87 EQUITY - 6400: Vacancy (EX_REGULAR/debit)\n", + "88 EQUITY - 6500: Misc. Expense (EX_OTHER/debit)\n", + "\n", + "[89 rows x 1 columns]" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
0
0ASSETS - 1010: Cash (ASSET_CA_CASH/debit)
1ASSETS - 1050: Short Term Investments (ASSET_C...
2ASSETS - 1100: Accounts Receivable (ASSET_CA_R...
3ASSETS - 1110: Uncollectibles (ASSET_CA_UNCOLL...
4ASSETS - 1200: Inventory (ASSET_CA_INV/debit)
......
84EQUITY - 6294: Garbage (EX_REGULAR/debit)
85EQUITY - 6295: Electricity (EX_REGULAR/debit)
86EQUITY - 6300: Property Management (EX_REGULAR...
87EQUITY - 6400: Vacancy (EX_REGULAR/debit)
88EQUITY - 6500: Misc. Expense (EX_OTHER/debit)
\n", + "

89 rows × 1 columns

\n", + "
" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 26 }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:51.878534Z", + "start_time": "2024-09-24T13:23:51.875307Z" } }, - "outputs": [], "source": [ "pd.DataFrame(coa_map[another_coa_model])" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "Empty DataFrame\n", + "Columns: []\n", + "Index: []" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
\n", + "
" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 27 }, { "cell_type": "markdown", @@ -564,11 +1701,13 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:51.964820Z", + "start_time": "2024-09-24T13:23:51.957550Z" + } }, - "outputs": [], "source": [ "account_model = entity_model.create_account(\n", " coa_model=another_coa_model,\n", @@ -578,30 +1717,107 @@ " balance_type=roles.DEBIT,\n", " active=True\n", ")" - ] + ], + "outputs": [], + "execution_count": 28 }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:51.999338Z", + "start_time": "2024-09-24T13:23:51.997107Z" + } }, - "outputs": [], "source": [ "account_model" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 29 }, { "cell_type": "code", - "execution_count": null, "metadata": { - "tags": [] + "tags": [], + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.042593Z", + "start_time": "2024-09-24T13:23:52.038007Z" + } }, - "outputs": [], "source": [ "another_coa_accounts_qs = entity_model.get_coa_accounts(coa_model=another_coa_model)\n", "pd.DataFrame(another_coa_accounts_qs.values('code', 'name', 'role', 'balance_type', 'active', 'locked'))" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + " code name role \\\n", + "0 1220 A new account created from the EntityModel API! asset_ca_inv \n", + "\n", + " balance_type active locked \n", + "0 debit True False " + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
codenamerolebalance_typeactivelocked
01220A new account created from the EntityModel API!asset_ca_invdebitTrueFalse
\n", + "
" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 30 }, { "cell_type": "markdown", @@ -625,20 +1841,24 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.086711Z", + "start_time": "2024-09-24T13:23:52.084054Z" } }, - "outputs": [], "source": [ "ledger_model = entity_model.create_ledger(\n", - " name='My October 2023 Ledger', \n", + " name='My October 2023 Ledger',\n", " posted=True\n", ")" - ] + ], + "outputs": [], + "execution_count": 31 }, { "cell_type": "markdown", @@ -649,14 +1869,19 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.111433Z", + "start_time": "2024-09-24T13:23:52.108395Z" + } + }, "source": [ "from django_ledger.io.io_library import IOLibrary\n", "\n", "library = IOLibrary(name='djangocon-2024-library')" - ] + ], + "outputs": [], + "execution_count": 32 }, { "cell_type": "markdown", @@ -667,12 +1892,16 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.153127Z", + "start_time": "2024-09-24T13:23:52.150980Z" + } + }, "source": [ "from django_ledger.io.io_library import IOBluePrint\n", "\n", + "\n", "@library.register\n", "def sale_blueprint(\n", " sale_amount: Union[int, float, Decimal],\n", @@ -686,7 +1915,9 @@ " blueprint.credit(account_code='1200', amount=cogs_amount, description=description)\n", " blueprint.debit(account_code='5010', amount=cogs_amount, description=description)\n", " return blueprint" - ] + ], + "outputs": [], + "execution_count": 33 }, { "cell_type": "markdown", @@ -697,15 +1928,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.191363Z", + "start_time": "2024-09-24T13:23:52.189652Z" + } + }, "source": [ "cursor = library.get_cursor(\n", - " entity_model=entity_model, \n", + " entity_model=entity_model,\n", " user_model=user_model\n", ")" - ] + ], + "outputs": [], + "execution_count": 34 }, { "cell_type": "markdown", @@ -716,9 +1952,12 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.230922Z", + "start_time": "2024-09-24T13:23:52.227927Z" + } + }, "source": [ "# Option 1 - Use A Ledger Model\n", "cursor.dispatch('sale_blueprint',\n", @@ -733,7 +1972,9 @@ " sale_amount=90.43,\n", " contribution_margin_percent=0.17,\n", " description='Order ID: 123')" - ] + ], + "outputs": [], + "execution_count": 35 }, { "cell_type": "markdown", @@ -746,17 +1987,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.261251Z", + "start_time": "2024-09-24T13:23:52.240581Z" + } + }, "source": [ "stub = cursor.commit(\n", " post_new_ledgers=True,\n", " post_journal_entries=True,\n", - " je_timestamp=datetime(2023,12,2,12,10)\n", + " je_timestamp=datetime(2023, 12, 2, 12, 10)\n", " # je_timestamp='2023-12-02 12:10'\n", ")" - ] + ], + "outputs": [], + "execution_count": 36 }, { "cell_type": "markdown", @@ -784,14 +2030,16 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.277830Z", + "start_time": "2024-09-24T13:23:52.268470Z" } }, - "outputs": [], "source": [ "bs_data = ledger_model.digest_balance_sheet(\n", " to_date=date(2023, 12, 31),\n", @@ -799,7 +2047,56 @@ ")\n", "\n", "bs_data.get_balance_sheet_data()" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "{'assets': {'total_balance': Decimal('4.4800000000000'),\n", + " 'is_block': True,\n", + " 'roles': {'asset_ca_cash': {'accounts': [{'account_uuid': UUID('2cca5fdc-3c5f-4f3f-a4f6-d6b9cc435930'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'assets',\n", + " 'role': 'asset_ca_cash',\n", + " 'code': '1010',\n", + " 'name': 'Cash',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('34.4500000000000'),\n", + " 'balance_abs': Decimal('34.4500000000000')}],\n", + " 'total_balance': Decimal('34.4500000000000'),\n", + " 'role_name': 'Current Asset'},\n", + " 'asset_ca_inv': {'accounts': [{'account_uuid': UUID('b8ff69f3-2c16-4f54-80a2-5fe3fb31c418'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'assets',\n", + " 'role': 'asset_ca_inv',\n", + " 'code': '1200',\n", + " 'name': 'Inventory',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-29.9700000000000'),\n", + " 'balance_abs': Decimal('29.9700000000000')}],\n", + " 'total_balance': Decimal('-29.9700000000000'),\n", + " 'role_name': 'Inventory'}}},\n", + " 'equity_balance': Decimal('4.4800000000000'),\n", + " 'retained_earnings_balance': Decimal('4.4800000000000'),\n", + " 'liabilities_equity_balance': Decimal('4.4800000000000')}" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 37 }, { "cell_type": "markdown", @@ -815,14 +2112,16 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.296475Z", + "start_time": "2024-09-24T13:23:52.291940Z" } }, - "outputs": [], "source": [ "is_data = ledger_model.digest_income_statement(\n", " from_date=date(2023, 1, 1),\n", @@ -831,7 +2130,61 @@ ")\n", "\n", "is_data.get_income_statement_data()" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "{'operating': {'revenues': [{'account_uuid': UUID('c04a349d-40ef-42b5-ab2d-3e10f4a7aa36'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'in_operational',\n", + " 'code': '4010',\n", + " 'name': 'Sales Income',\n", + " 'balance_type': 'credit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('34.4500000000000'),\n", + " 'balance_abs': Decimal('34.4500000000000'),\n", + " 'role_name': 'Operational Income'}],\n", + " 'cogs': [{'account_uuid': UUID('cc15e8ea-2853-4eb6-80ce-a5071fe83d5c'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'cogs_regular',\n", + " 'code': '5010',\n", + " 'name': 'Cost of Goods Sold',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-29.9700000000000'),\n", + " 'balance_abs': Decimal('29.9700000000000'),\n", + " 'role_name': 'Cost of Goods Sold'}],\n", + " 'expenses': [],\n", + " 'gross_profit': Decimal('4.4800000000000'),\n", + " 'net_operating_income': Decimal('4.4800000000000'),\n", + " 'net_operating_revenue': Decimal('34.4500000000000'),\n", + " 'net_cogs': Decimal('-29.9700000000000'),\n", + " 'net_operating_expenses': 0},\n", + " 'other': {'revenues': [],\n", + " 'expenses': [],\n", + " 'net_other_revenues': 0,\n", + " 'net_other_expenses': 0,\n", + " 'net_other_income': 0},\n", + " 'net_income': Decimal('4.4800000000000')}" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 38 }, { "cell_type": "markdown", @@ -847,14 +2200,16 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.316129Z", + "start_time": "2024-09-24T13:23:52.312002Z" } }, - "outputs": [], "source": [ "cfs_data = ledger_model.digest_cash_flow_statement(\n", " from_date=date(2023, 1, 1),\n", @@ -863,7 +2218,51 @@ ")\n", "\n", "cfs_data.get_cash_flow_statement_data()" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "{'operating': {'GROUP_CFS_NET_INCOME': {'description': 'Net Income',\n", + " 'balance': Decimal('4.4800000000000')},\n", + " 'GROUP_CFS_OP_DEPRECIATION_AMORTIZATION': {'description': 'Depreciation & Amortization of Assets',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_INVESTMENT_GAINS': {'description': 'Gain/Loss Sale of Assets',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_ACCOUNTS_RECEIVABLE': {'description': 'Accounts Receivable',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_INVENTORY': {'description': 'Inventories',\n", + " 'balance': Decimal('29.9700000000000')},\n", + " 'GROUP_CFS_OP_ACCOUNTS_PAYABLE': {'description': 'Accounts Payable',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_OTHER_CURRENT_ASSETS_ADJUSTMENT': {'description': 'Other Current Assets',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_OTHER_CURRENT_LIABILITIES_ADJUSTMENT': {'description': 'Other Current Liabilities',\n", + " 'balance': 0}},\n", + " 'net_cash_by_activity': {'OPERATING': Decimal('34.4500000000000'),\n", + " 'FINANCING': 0,\n", + " 'INVESTING': 0},\n", + " 'financing': {'GROUP_CFS_FIN_ISSUING_EQUITY': {'description': 'Common Stock, Preferred Stock and Capital Raised',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_FIN_DIVIDENDS': {'description': 'Dividends Payed Out to Shareholders',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_FIN_ST_DEBT_PAYMENTS': {'description': 'Increase/Reduction of Short-Term Debt Principal',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_FIN_LT_DEBT_PAYMENTS': {'description': 'Increase/Reduction of Long-Term Debt Principal',\n", + " 'balance': 0}},\n", + " 'investing': {'GROUP_CFS_INVESTING_SECURITIES': {'description': 'Purchase, Maturity and Sales of Investments & Securities',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_INVESTING_PPE': {'description': 'Addition and Disposition of Property, Plant & Equipment',\n", + " 'balance': 0}},\n", + " 'net_cash': Decimal('34.4500000000000')}" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 39 }, { "cell_type": "markdown", @@ -879,14 +2278,16 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.334757Z", + "start_time": "2024-09-24T13:23:52.331490Z" } }, - "outputs": [], "source": [ "fin_digest = ledger_model.digest_financial_statements(\n", " from_date=date(2023, 1, 1),\n", @@ -895,49 +2296,204 @@ ")\n", "\n", "statement_data = fin_digest.get_financial_statements_data()" - ] + ], + "outputs": [], + "execution_count": 40 }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.344708Z", + "start_time": "2024-09-24T13:23:52.342271Z" } }, - "outputs": [], "source": [ "statement_data['balance_sheet']" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "{'assets': {'total_balance': Decimal('4.4800000000000'),\n", + " 'is_block': True,\n", + " 'roles': {'asset_ca_cash': {'accounts': [{'account_uuid': UUID('2cca5fdc-3c5f-4f3f-a4f6-d6b9cc435930'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': 'op',\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'assets',\n", + " 'role': 'asset_ca_cash',\n", + " 'code': '1010',\n", + " 'name': 'Cash',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('34.4500000000000'),\n", + " 'balance_abs': Decimal('34.4500000000000')}],\n", + " 'total_balance': Decimal('34.4500000000000'),\n", + " 'role_name': 'Current Asset'},\n", + " 'asset_ca_inv': {'accounts': [{'account_uuid': UUID('b8ff69f3-2c16-4f54-80a2-5fe3fb31c418'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': 'op',\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'assets',\n", + " 'role': 'asset_ca_inv',\n", + " 'code': '1200',\n", + " 'name': 'Inventory',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-29.9700000000000'),\n", + " 'balance_abs': Decimal('29.9700000000000')}],\n", + " 'total_balance': Decimal('-29.9700000000000'),\n", + " 'role_name': 'Inventory'}}},\n", + " 'equity_balance': Decimal('4.4800000000000'),\n", + " 'retained_earnings_balance': Decimal('4.4800000000000'),\n", + " 'liabilities_equity_balance': Decimal('4.4800000000000')}" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 41 }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.356449Z", + "start_time": "2024-09-24T13:23:52.353811Z" } }, - "outputs": [], "source": [ "statement_data['income_statement']" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "{'operating': {'revenues': [{'account_uuid': UUID('c04a349d-40ef-42b5-ab2d-3e10f4a7aa36'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': 'op',\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'in_operational',\n", + " 'code': '4010',\n", + " 'name': 'Sales Income',\n", + " 'balance_type': 'credit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('34.4500000000000'),\n", + " 'balance_abs': Decimal('34.4500000000000'),\n", + " 'role_name': 'Operational Income'}],\n", + " 'cogs': [{'account_uuid': UUID('cc15e8ea-2853-4eb6-80ce-a5071fe83d5c'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': 'op',\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'cogs_regular',\n", + " 'code': '5010',\n", + " 'name': 'Cost of Goods Sold',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-29.9700000000000'),\n", + " 'balance_abs': Decimal('29.9700000000000'),\n", + " 'role_name': 'Cost of Goods Sold'}],\n", + " 'expenses': [],\n", + " 'gross_profit': Decimal('4.4800000000000'),\n", + " 'net_operating_income': Decimal('4.4800000000000'),\n", + " 'net_operating_revenue': Decimal('34.4500000000000'),\n", + " 'net_cogs': Decimal('-29.9700000000000'),\n", + " 'net_operating_expenses': 0},\n", + " 'other': {'revenues': [],\n", + " 'expenses': [],\n", + " 'net_other_revenues': 0,\n", + " 'net_other_expenses': 0,\n", + " 'net_other_income': 0},\n", + " 'net_income': Decimal('4.4800000000000')}" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 42 }, { "cell_type": "code", - "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false + }, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.378524Z", + "start_time": "2024-09-24T13:23:52.376095Z" } }, - "outputs": [], "source": [ "statement_data['cash_flow_statement']" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "{'operating': {'GROUP_CFS_NET_INCOME': {'description': 'Net Income',\n", + " 'balance': Decimal('4.4800000000000')},\n", + " 'GROUP_CFS_OP_DEPRECIATION_AMORTIZATION': {'description': 'Depreciation & Amortization of Assets',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_INVESTMENT_GAINS': {'description': 'Gain/Loss Sale of Assets',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_ACCOUNTS_RECEIVABLE': {'description': 'Accounts Receivable',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_INVENTORY': {'description': 'Inventories',\n", + " 'balance': Decimal('29.9700000000000')},\n", + " 'GROUP_CFS_OP_ACCOUNTS_PAYABLE': {'description': 'Accounts Payable',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_OTHER_CURRENT_ASSETS_ADJUSTMENT': {'description': 'Other Current Assets',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_OTHER_CURRENT_LIABILITIES_ADJUSTMENT': {'description': 'Other Current Liabilities',\n", + " 'balance': 0}},\n", + " 'net_cash_by_activity': {'OPERATING': Decimal('34.4500000000000'),\n", + " 'FINANCING': 0,\n", + " 'INVESTING': 0},\n", + " 'financing': {'GROUP_CFS_FIN_ISSUING_EQUITY': {'description': 'Common Stock, Preferred Stock and Capital Raised',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_FIN_DIVIDENDS': {'description': 'Dividends Payed Out to Shareholders',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_FIN_ST_DEBT_PAYMENTS': {'description': 'Increase/Reduction of Short-Term Debt Principal',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_FIN_LT_DEBT_PAYMENTS': {'description': 'Increase/Reduction of Long-Term Debt Principal',\n", + " 'balance': 0}},\n", + " 'investing': {'GROUP_CFS_INVESTING_SECURITIES': {'description': 'Purchase, Maturity and Sales of Investments & Securities',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_INVESTING_PPE': {'description': 'Addition and Disposition of Property, Plant & Equipment',\n", + " 'balance': 0}},\n", + " 'net_cash': Decimal('34.4500000000000')}" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 43 }, { "cell_type": "markdown", @@ -964,9 +2520,12 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.434615Z", + "start_time": "2024-09-24T13:23:52.397520Z" + } + }, "source": [ "bs_report = entity_model.get_balance_sheet_statement(\n", " to_date=date(2022, 12, 31),\n", @@ -974,16 +2533,122 @@ " filepath='./'\n", ")\n", "bs_data = bs_report.get_report_data()" - ] + ], + "outputs": [], + "execution_count": 44 }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.441842Z", + "start_time": "2024-09-24T13:23:52.439203Z" + } + }, "source": [ "bs_data" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "{'assets': {'total_balance': Decimal('48565.05000000000'),\n", + " 'is_block': True,\n", + " 'roles': {'asset_ca_cash': {'accounts': [{'account_uuid': UUID('2cca5fdc-3c5f-4f3f-a4f6-d6b9cc435930'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'assets',\n", + " 'role': 'asset_ca_cash',\n", + " 'code': '1010',\n", + " 'name': 'Cash',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('40176.3600000000'),\n", + " 'balance_abs': Decimal('40176.3600000000')}],\n", + " 'total_balance': Decimal('40176.3600000000'),\n", + " 'role_name': 'Current Asset'},\n", + " 'asset_ca_recv': {'accounts': [{'account_uuid': UUID('6c9050ba-b6bf-4a12-a480-20e63ece1513'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'assets',\n", + " 'role': 'asset_ca_recv',\n", + " 'code': '1100',\n", + " 'name': 'Accounts Receivable',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('1946.64000000000'),\n", + " 'balance_abs': Decimal('1946.64000000000')}],\n", + " 'total_balance': Decimal('1946.64000000000'),\n", + " 'role_name': 'Receivables'},\n", + " 'asset_ca_inv': {'accounts': [{'account_uuid': UUID('b8ff69f3-2c16-4f54-80a2-5fe3fb31c418'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'assets',\n", + " 'role': 'asset_ca_inv',\n", + " 'code': '1200',\n", + " 'name': 'Inventory',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('6442.05000000000'),\n", + " 'balance_abs': Decimal('6442.05000000000')}],\n", + " 'total_balance': Decimal('6442.05000000000'),\n", + " 'role_name': 'Inventory'}}},\n", + " 'liabilities': {'total_balance': Decimal('714.0000000000'),\n", + " 'is_block': True,\n", + " 'roles': {'lia_cl_acc_payable': {'accounts': [{'account_uuid': UUID('e2b4f980-bfc6-4865-b835-1be83eb73b88'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'liabilities',\n", + " 'role': 'lia_cl_acc_payable',\n", + " 'code': '2010',\n", + " 'name': 'Accounts Payable',\n", + " 'balance_type': 'credit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('714.0000000000'),\n", + " 'balance_abs': Decimal('714.0000000000')}],\n", + " 'total_balance': Decimal('714.0000000000'),\n", + " 'role_name': 'Accounts Payable'}}},\n", + " 'equity': {'total_balance': Decimal('50000'),\n", + " 'is_block': True,\n", + " 'roles': {'eq_capital': {'accounts': [{'account_uuid': UUID('e350e6b4-9314-43e1-b73a-bf2223eef0ef'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'eq_capital',\n", + " 'code': '3030',\n", + " 'name': 'Capital Account 3',\n", + " 'balance_type': 'credit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('50000'),\n", + " 'balance_abs': Decimal('50000')}],\n", + " 'total_balance': Decimal('50000'),\n", + " 'role_name': 'Capital'}}},\n", + " 'equity_balance': Decimal('47851.0500000000000'),\n", + " 'retained_earnings_balance': Decimal('-2148.9500000000000'),\n", + " 'liabilities_equity_balance': Decimal('48565.0500000000000')}" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 45 }, { "cell_type": "markdown", @@ -994,12 +2659,116 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.571843Z", + "start_time": "2024-09-24T13:23:52.567140Z" + } + }, "source": [ "bs_report.get_report_data()" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "{'assets': {'total_balance': Decimal('48565.05000000000'),\n", + " 'is_block': True,\n", + " 'roles': {'asset_ca_cash': {'accounts': [{'account_uuid': UUID('2cca5fdc-3c5f-4f3f-a4f6-d6b9cc435930'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'assets',\n", + " 'role': 'asset_ca_cash',\n", + " 'code': '1010',\n", + " 'name': 'Cash',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('40176.3600000000'),\n", + " 'balance_abs': Decimal('40176.3600000000')}],\n", + " 'total_balance': Decimal('40176.3600000000'),\n", + " 'role_name': 'Current Asset'},\n", + " 'asset_ca_recv': {'accounts': [{'account_uuid': UUID('6c9050ba-b6bf-4a12-a480-20e63ece1513'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'assets',\n", + " 'role': 'asset_ca_recv',\n", + " 'code': '1100',\n", + " 'name': 'Accounts Receivable',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('1946.64000000000'),\n", + " 'balance_abs': Decimal('1946.64000000000')}],\n", + " 'total_balance': Decimal('1946.64000000000'),\n", + " 'role_name': 'Receivables'},\n", + " 'asset_ca_inv': {'accounts': [{'account_uuid': UUID('b8ff69f3-2c16-4f54-80a2-5fe3fb31c418'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'assets',\n", + " 'role': 'asset_ca_inv',\n", + " 'code': '1200',\n", + " 'name': 'Inventory',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('6442.05000000000'),\n", + " 'balance_abs': Decimal('6442.05000000000')}],\n", + " 'total_balance': Decimal('6442.05000000000'),\n", + " 'role_name': 'Inventory'}}},\n", + " 'liabilities': {'total_balance': Decimal('714.0000000000'),\n", + " 'is_block': True,\n", + " 'roles': {'lia_cl_acc_payable': {'accounts': [{'account_uuid': UUID('e2b4f980-bfc6-4865-b835-1be83eb73b88'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'liabilities',\n", + " 'role': 'lia_cl_acc_payable',\n", + " 'code': '2010',\n", + " 'name': 'Accounts Payable',\n", + " 'balance_type': 'credit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('714.0000000000'),\n", + " 'balance_abs': Decimal('714.0000000000')}],\n", + " 'total_balance': Decimal('714.0000000000'),\n", + " 'role_name': 'Accounts Payable'}}},\n", + " 'equity': {'total_balance': Decimal('50000'),\n", + " 'is_block': True,\n", + " 'roles': {'eq_capital': {'accounts': [{'account_uuid': UUID('e350e6b4-9314-43e1-b73a-bf2223eef0ef'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'eq_capital',\n", + " 'code': '3030',\n", + " 'name': 'Capital Account 3',\n", + " 'balance_type': 'credit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('50000'),\n", + " 'balance_abs': Decimal('50000')}],\n", + " 'total_balance': Decimal('50000'),\n", + " 'role_name': 'Capital'}}},\n", + " 'equity_balance': Decimal('47851.0500000000000'),\n", + " 'retained_earnings_balance': Decimal('-2148.9500000000000'),\n", + " 'liabilities_equity_balance': Decimal('48565.0500000000000')}" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 46 }, { "cell_type": "markdown", @@ -1010,9 +2779,12 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.606585Z", + "start_time": "2024-09-24T13:23:52.595618Z" + } + }, "source": [ "ic_report = entity_model.get_income_statement(\n", " from_date=date(2022, 1, 1),\n", @@ -1022,7 +2794,9 @@ ")\n", "\n", "ic_data = ic_report.get_report_data()" - ] + ], + "outputs": [], + "execution_count": 47 }, { "cell_type": "markdown", @@ -1033,14 +2807,324 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { - "scrolled": true + "scrolled": true, + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.618689Z", + "start_time": "2024-09-24T13:23:52.614358Z" + } }, - "outputs": [], "source": [ "ic_data" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "{'operating': {'revenues': [{'account_uuid': UUID('c04a349d-40ef-42b5-ab2d-3e10f4a7aa36'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'in_operational',\n", + " 'code': '4010',\n", + " 'name': 'Sales Income',\n", + " 'balance_type': 'credit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('5088.79000000000'),\n", + " 'balance_abs': Decimal('5088.79000000000'),\n", + " 'role_name': 'Operational Income'}],\n", + " 'cogs': [{'account_uuid': UUID('cc15e8ea-2853-4eb6-80ce-a5071fe83d5c'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'cogs_regular',\n", + " 'code': '5010',\n", + " 'name': 'Cost of Goods Sold',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-1354.91000000000'),\n", + " 'balance_abs': Decimal('1354.91000000000'),\n", + " 'role_name': 'Cost of Goods Sold'}],\n", + " 'expenses': [{'account_uuid': UUID('26957fc3-349a-4470-b09a-53bff2698411'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6260',\n", + " 'name': 'Salaries',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-51.9700000000000'),\n", + " 'balance_abs': Decimal('51.9700000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('42cc60df-4204-4edd-93a4-7063548bbf2e'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6254',\n", + " 'name': 'Snow Removal',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-383.900000000000'),\n", + " 'balance_abs': Decimal('383.900000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('45e2cff6-ee2a-4a1b-9eec-48e116ae0dca'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6170',\n", + " 'name': 'Maintenance Expense',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-346.760000000000'),\n", + " 'balance_abs': Decimal('346.760000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('5d783917-f20f-4c9c-ad1c-24b814b64e46'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6230',\n", + " 'name': 'Postage',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-137.220000000000'),\n", + " 'balance_abs': Decimal('137.220000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('6258db05-8aae-43a7-b5d8-9606b83f8a62'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6252',\n", + " 'name': 'Repairs',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-164.510000000000'),\n", + " 'balance_abs': Decimal('164.510000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('69b7793c-d221-4fc2-b949-4f5ce8979999'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6120',\n", + " 'name': 'Insurance',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-413'),\n", + " 'balance_abs': Decimal('413'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('7b9626d2-35a7-457c-9530-b7995a5b71cd'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6080',\n", + " 'name': 'Employee Benefits',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-187.510000000000'),\n", + " 'balance_abs': Decimal('187.510000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('7f2d0bf4-e73f-4d38-997a-500eaf15f9bc'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6270',\n", + " 'name': 'Supplies',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-814.110000000000'),\n", + " 'balance_abs': Decimal('814.110000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('8f5ec4a3-fc81-4fb6-a6ff-a93db9c1f8b3'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6150',\n", + " 'name': 'License Expense',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-51.7000000000000'),\n", + " 'balance_abs': Decimal('51.7000000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('92ac5521-96ef-4549-805a-2dff703d7597'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6180',\n", + " 'name': 'Meals & Entertainment',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-374.460000000000'),\n", + " 'balance_abs': Decimal('374.460000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('c7e4e135-482a-44a8-bc6e-41dae2e9eaad'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6292',\n", + " 'name': 'Sewer',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-288.260000000000'),\n", + " 'balance_abs': Decimal('288.260000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('c8a89ead-bf89-4739-bdf5-c6766e034ab9'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6060',\n", + " 'name': 'Commission Expense',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-1050.32000000000'),\n", + " 'balance_abs': Decimal('1050.32000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('d1145169-3b63-45c6-b6bb-05c377abd405'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6140',\n", + " 'name': 'Professional Fees',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-583.470000000000'),\n", + " 'balance_abs': Decimal('583.470000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('d1e666dd-92e6-4016-a7d2-a9bf231b3156'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6050',\n", + " 'name': 'Bank Charges',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-146.820000000000'),\n", + " 'balance_abs': Decimal('146.820000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('d87964e1-b8c4-4c0e-8e5c-5cd627901a6a'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6400',\n", + " 'name': 'Vacancy',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-132.200000000000'),\n", + " 'balance_abs': Decimal('132.200000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('dccaa889-69b5-4cb2-9e76-6ea118d6912b'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6290',\n", + " 'name': 'Utilities',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-596.120000000000'),\n", + " 'balance_abs': Decimal('596.120000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('f904bd60-ddf7-4588-9d33-0cfdb408171e'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6020',\n", + " 'name': 'Amortization',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-160.5'),\n", + " 'balance_abs': Decimal('160.5'),\n", + " 'role_name': 'Regular Expense'}],\n", + " 'gross_profit': Decimal('3733.88000000000'),\n", + " 'net_operating_income': Decimal('-2148.9500000000000'),\n", + " 'net_operating_revenue': Decimal('5088.79000000000'),\n", + " 'net_cogs': Decimal('-1354.91000000000'),\n", + " 'net_operating_expenses': Decimal('-5882.8300000000000')},\n", + " 'other': {'revenues': [],\n", + " 'expenses': [],\n", + " 'net_other_revenues': 0,\n", + " 'net_other_expenses': 0,\n", + " 'net_other_income': 0},\n", + " 'net_income': Decimal('-2148.9500000000000')}" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 48 }, { "cell_type": "markdown", @@ -1051,9 +3135,12 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.640203Z", + "start_time": "2024-09-24T13:23:52.627035Z" + } + }, "source": [ "cf_report = entity_model.get_cash_flow_statement(\n", " from_date=date(2022, 1, 1),\n", @@ -1063,7 +3150,9 @@ ")\n", "\n", "cf_data = cf_report.get_report_data()" - ] + ], + "outputs": [], + "execution_count": 49 }, { "cell_type": "markdown", @@ -1074,12 +3163,59 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.650523Z", + "start_time": "2024-09-24T13:23:52.647429Z" + } + }, "source": [ "cf_data" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "{'operating': {'GROUP_CFS_NET_INCOME': {'description': 'Net Income',\n", + " 'balance': Decimal('-2148.9500000000000')},\n", + " 'GROUP_CFS_OP_DEPRECIATION_AMORTIZATION': {'description': 'Depreciation & Amortization of Assets',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_INVESTMENT_GAINS': {'description': 'Gain/Loss Sale of Assets',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_ACCOUNTS_RECEIVABLE': {'description': 'Accounts Receivable',\n", + " 'balance': Decimal('-1946.64000000000')},\n", + " 'GROUP_CFS_OP_INVENTORY': {'description': 'Inventories',\n", + " 'balance': Decimal('-6442.05000000000')},\n", + " 'GROUP_CFS_OP_ACCOUNTS_PAYABLE': {'description': 'Accounts Payable',\n", + " 'balance': Decimal('714.0000000000')},\n", + " 'GROUP_CFS_OP_OTHER_CURRENT_ASSETS_ADJUSTMENT': {'description': 'Other Current Assets',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_OTHER_CURRENT_LIABILITIES_ADJUSTMENT': {'description': 'Other Current Liabilities',\n", + " 'balance': 0}},\n", + " 'net_cash_by_activity': {'OPERATING': Decimal('-9823.6400000000000'),\n", + " 'FINANCING': Decimal('37034.2100000000'),\n", + " 'INVESTING': 0},\n", + " 'financing': {'GROUP_CFS_FIN_ISSUING_EQUITY': {'description': 'Common Stock, Preferred Stock and Capital Raised',\n", + " 'balance': Decimal('50000')},\n", + " 'GROUP_CFS_FIN_DIVIDENDS': {'description': 'Dividends Payed Out to Shareholders',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_FIN_ST_DEBT_PAYMENTS': {'description': 'Increase/Reduction of Short-Term Debt Principal',\n", + " 'balance': Decimal('-12965.7900000000')},\n", + " 'GROUP_CFS_FIN_LT_DEBT_PAYMENTS': {'description': 'Increase/Reduction of Long-Term Debt Principal',\n", + " 'balance': 0}},\n", + " 'investing': {'GROUP_CFS_INVESTING_SECURITIES': {'description': 'Purchase, Maturity and Sales of Investments & Securities',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_INVESTING_PPE': {'description': 'Addition and Disposition of Property, Plant & Equipment',\n", + " 'balance': 0}},\n", + " 'net_cash': Decimal('27210.5700000000000')}" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 50 }, { "cell_type": "markdown", @@ -1090,9 +3226,12 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.684206Z", + "start_time": "2024-09-24T13:23:52.660501Z" + } + }, "source": [ "reports = entity_model.get_financial_statements(\n", " user_model=user_model,\n", @@ -1101,73 +3240,730 @@ " save_pdf=True,\n", " filepath='./'\n", ")" - ] + ], + "outputs": [], + "execution_count": 51 }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.695732Z", + "start_time": "2024-09-24T13:23:52.693367Z" + } + }, "source": [ "bs_data = reports.balance_sheet_statement.get_report_data()\n", "ic_data = reports.income_statement.get_report_data()\n", "cf_data = reports.cash_flow_statement.get_report_data()" - ] + ], + "outputs": [], + "execution_count": 52 }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.707270Z", + "start_time": "2024-09-24T13:23:52.702394Z" + } + }, "source": [ "reports.income_statement.get_report_data()" - ] + ], + "outputs": [ + { + "data": { + "text/plain": [ + "{'operating': {'revenues': [{'account_uuid': UUID('c04a349d-40ef-42b5-ab2d-3e10f4a7aa36'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'in_operational',\n", + " 'code': '4010',\n", + " 'name': 'Sales Income',\n", + " 'balance_type': 'credit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('5088.79000000000'),\n", + " 'balance_abs': Decimal('5088.79000000000'),\n", + " 'role_name': 'Operational Income'}],\n", + " 'cogs': [{'account_uuid': UUID('cc15e8ea-2853-4eb6-80ce-a5071fe83d5c'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'cogs_regular',\n", + " 'code': '5010',\n", + " 'name': 'Cost of Goods Sold',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-1354.91000000000'),\n", + " 'balance_abs': Decimal('1354.91000000000'),\n", + " 'role_name': 'Cost of Goods Sold'}],\n", + " 'expenses': [{'account_uuid': UUID('26957fc3-349a-4470-b09a-53bff2698411'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6260',\n", + " 'name': 'Salaries',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-51.9700000000000'),\n", + " 'balance_abs': Decimal('51.9700000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('42cc60df-4204-4edd-93a4-7063548bbf2e'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6254',\n", + " 'name': 'Snow Removal',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-383.900000000000'),\n", + " 'balance_abs': Decimal('383.900000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('45e2cff6-ee2a-4a1b-9eec-48e116ae0dca'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6170',\n", + " 'name': 'Maintenance Expense',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-346.760000000000'),\n", + " 'balance_abs': Decimal('346.760000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('5d783917-f20f-4c9c-ad1c-24b814b64e46'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6230',\n", + " 'name': 'Postage',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-137.220000000000'),\n", + " 'balance_abs': Decimal('137.220000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('6258db05-8aae-43a7-b5d8-9606b83f8a62'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6252',\n", + " 'name': 'Repairs',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-164.510000000000'),\n", + " 'balance_abs': Decimal('164.510000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('69b7793c-d221-4fc2-b949-4f5ce8979999'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6120',\n", + " 'name': 'Insurance',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-413'),\n", + " 'balance_abs': Decimal('413'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('7b9626d2-35a7-457c-9530-b7995a5b71cd'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6080',\n", + " 'name': 'Employee Benefits',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-187.510000000000'),\n", + " 'balance_abs': Decimal('187.510000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('7f2d0bf4-e73f-4d38-997a-500eaf15f9bc'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6270',\n", + " 'name': 'Supplies',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-814.110000000000'),\n", + " 'balance_abs': Decimal('814.110000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('8f5ec4a3-fc81-4fb6-a6ff-a93db9c1f8b3'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6150',\n", + " 'name': 'License Expense',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-51.7000000000000'),\n", + " 'balance_abs': Decimal('51.7000000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('92ac5521-96ef-4549-805a-2dff703d7597'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6180',\n", + " 'name': 'Meals & Entertainment',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-374.460000000000'),\n", + " 'balance_abs': Decimal('374.460000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('c7e4e135-482a-44a8-bc6e-41dae2e9eaad'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6292',\n", + " 'name': 'Sewer',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-288.260000000000'),\n", + " 'balance_abs': Decimal('288.260000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('c8a89ead-bf89-4739-bdf5-c6766e034ab9'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6060',\n", + " 'name': 'Commission Expense',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-1050.32000000000'),\n", + " 'balance_abs': Decimal('1050.32000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('d1145169-3b63-45c6-b6bb-05c377abd405'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6140',\n", + " 'name': 'Professional Fees',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-583.470000000000'),\n", + " 'balance_abs': Decimal('583.470000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('d1e666dd-92e6-4016-a7d2-a9bf231b3156'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6050',\n", + " 'name': 'Bank Charges',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-146.820000000000'),\n", + " 'balance_abs': Decimal('146.820000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('d87964e1-b8c4-4c0e-8e5c-5cd627901a6a'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6400',\n", + " 'name': 'Vacancy',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-132.200000000000'),\n", + " 'balance_abs': Decimal('132.200000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('dccaa889-69b5-4cb2-9e76-6ea118d6912b'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6290',\n", + " 'name': 'Utilities',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-596.120000000000'),\n", + " 'balance_abs': Decimal('596.120000000000'),\n", + " 'role_name': 'Regular Expense'},\n", + " {'account_uuid': UUID('f904bd60-ddf7-4588-9d33-0cfdb408171e'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'ex_regular',\n", + " 'code': '6020',\n", + " 'name': 'Amortization',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-160.5'),\n", + " 'balance_abs': Decimal('160.5'),\n", + " 'role_name': 'Regular Expense'}],\n", + " 'gross_profit': Decimal('3733.88000000000'),\n", + " 'net_operating_income': Decimal('-2148.9500000000000'),\n", + " 'net_operating_revenue': Decimal('5088.79000000000'),\n", + " 'net_cogs': Decimal('-1354.91000000000'),\n", + " 'net_operating_expenses': Decimal('-5882.8300000000000')},\n", + " 'other': {'revenues': [],\n", + " 'expenses': [],\n", + " 'net_other_revenues': 0,\n", + " 'net_other_expenses': 0,\n", + " 'net_other_income': 0},\n", + " 'net_income': Decimal('-2148.9500000000000')}" + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 53 }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.743637Z", + "start_time": "2024-09-24T13:23:52.739891Z" + } + }, "source": [ "reports.cash_flow_statement.get_report_data()" + ], + "outputs": [ + { + "data": { + "text/plain": [ + "{'operating': {'GROUP_CFS_NET_INCOME': {'description': 'Net Income',\n", + " 'balance': Decimal('-2148.9500000000000')},\n", + " 'GROUP_CFS_OP_DEPRECIATION_AMORTIZATION': {'description': 'Depreciation & Amortization of Assets',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_INVESTMENT_GAINS': {'description': 'Gain/Loss Sale of Assets',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_ACCOUNTS_RECEIVABLE': {'description': 'Accounts Receivable',\n", + " 'balance': Decimal('-1946.64000000000')},\n", + " 'GROUP_CFS_OP_INVENTORY': {'description': 'Inventories',\n", + " 'balance': Decimal('-6442.05000000000')},\n", + " 'GROUP_CFS_OP_ACCOUNTS_PAYABLE': {'description': 'Accounts Payable',\n", + " 'balance': Decimal('714.0000000000')},\n", + " 'GROUP_CFS_OP_OTHER_CURRENT_ASSETS_ADJUSTMENT': {'description': 'Other Current Assets',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_OP_OTHER_CURRENT_LIABILITIES_ADJUSTMENT': {'description': 'Other Current Liabilities',\n", + " 'balance': 0}},\n", + " 'net_cash_by_activity': {'OPERATING': Decimal('-9823.6400000000000'),\n", + " 'FINANCING': Decimal('37034.2100000000'),\n", + " 'INVESTING': 0},\n", + " 'financing': {'GROUP_CFS_FIN_ISSUING_EQUITY': {'description': 'Common Stock, Preferred Stock and Capital Raised',\n", + " 'balance': Decimal('50000')},\n", + " 'GROUP_CFS_FIN_DIVIDENDS': {'description': 'Dividends Payed Out to Shareholders',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_FIN_ST_DEBT_PAYMENTS': {'description': 'Increase/Reduction of Short-Term Debt Principal',\n", + " 'balance': Decimal('-12965.7900000000')},\n", + " 'GROUP_CFS_FIN_LT_DEBT_PAYMENTS': {'description': 'Increase/Reduction of Long-Term Debt Principal',\n", + " 'balance': 0}},\n", + " 'investing': {'GROUP_CFS_INVESTING_SECURITIES': {'description': 'Purchase, Maturity and Sales of Investments & Securities',\n", + " 'balance': 0},\n", + " 'GROUP_CFS_INVESTING_PPE': {'description': 'Addition and Disposition of Property, Plant & Equipment',\n", + " 'balance': 0}},\n", + " 'net_cash': Decimal('27210.5700000000000')}" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 54 + }, + { + "metadata": {}, + "cell_type": "markdown", + "source": "# Extending Django Ledger" + }, + { + "metadata": {}, + "cell_type": "markdown", + "source": [ + "### Simple Payroll Example\n", + "This will not work in the context of a jupyter notebook" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-24T13:23:52.942896Z", + "start_time": "2024-09-24T13:23:52.752936Z" + } + }, "source": [ "from django.db import models\n", "from django_ledger.models import LedgerModel\n", + "from django_ledger.io.io_library import IOLibrary\n", + "\n", + "# Create A Payroll Library\n", + "payroll_library = IOLibrary('payroll')\n", + "\n", + "# Register a Blueprint...\n", + "@payroll_library.register\n", + "def process_employee_payroll(gross_pay, tax_bracket):\n", + " deductions = gross_pay * tax_bracket\n", + " payout = gross_pay - deductions\n", + " bp = IOBluePrint()\n", + " bp.credit(account_code='1010', amount=gross_pay) # Bank Account\n", + " bp.debit(account_code='6070', amount=payout) # Wages Expense\n", + " bp.debit(account_code='6210', amount=deductions) # Payroll Taxes\n", + " return bp\n", "\n", + "\n", + "# Extend the Ledger Model...\n", "class EmployeeModel(LedgerModel):\n", - " \n", - " dob = models.DateField()\n", - " salary = models.DecimalField()\n", " first_name = models.CharField(max_length=50)\n", " last_name = models.CharField(max_length=50)\n", - " \n", - " def process_payroll(self, month):\n", - " raise NotImplementedError()\n", - " \n", - " def send_payroll_report(self, month):\n", - " raise NotImplementedError()" - ] + " dob = models.DateField()\n", + " salary = models.DecimalField()\n", + " tax_bracket = models.DecimalField()\n", + "\n", + " def get_gross_pay(self):\n", + " # bi-monthly payments...\n", + " return self.salary / 24\n", + "\n", + " def process_payroll(self, pay_date, user_model):\n", + " cursor = payroll_library.get_cursor(\n", + " entity_model=self.entity,\n", + " user_model=user_model\n", + " )\n", + " gross_pay = self.get_gross_pay()\n", + " cursor.dispatch('process_employee_payroll',\n", + " gross_pay=gross_pay,\n", + " tax_bracket=self.tax_bracket)\n", + " return cursor.commit(\n", + " post_new_ledgers=False,\n", + " post_journal_entries=True,\n", + " je_timestamp=pay_date\n", + " )\n", + "\n", + " def send_employee_payroll_report(self, from_date, to_date, user_model):\n", + " financial_data = self.get_income_statement(\n", + " from_date=from_date,\n", + " to_date=to_date,\n", + " user_model=user_model)\n", + " # Send report...\n", + " return financial_data" + ], + "outputs": [ + { + "ename": "RuntimeError", + "evalue": "Model class __main__.EmployeeModel doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.", + "output_type": "error", + "traceback": [ + "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", + "\u001B[0;31mRuntimeError\u001B[0m Traceback (most recent call last)", + "Cell \u001B[0;32mIn[55], line 21\u001B[0m\n\u001B[1;32m 17\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m bp\n\u001B[1;32m 20\u001B[0m \u001B[38;5;66;03m# Extend the Ledger Model...\u001B[39;00m\n\u001B[0;32m---> 21\u001B[0m \u001B[38;5;28;43;01mclass\u001B[39;49;00m\u001B[43m \u001B[49m\u001B[38;5;21;43;01mEmployeeModel\u001B[39;49;00m\u001B[43m(\u001B[49m\u001B[43mLedgerModel\u001B[49m\u001B[43m)\u001B[49m\u001B[43m:\u001B[49m\n\u001B[1;32m 22\u001B[0m \u001B[43m \u001B[49m\u001B[43mfirst_name\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43m \u001B[49m\u001B[43mmodels\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mCharField\u001B[49m\u001B[43m(\u001B[49m\u001B[43mmax_length\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;241;43m50\u001B[39;49m\u001B[43m)\u001B[49m\n\u001B[1;32m 23\u001B[0m \u001B[43m \u001B[49m\u001B[43mlast_name\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43m \u001B[49m\u001B[43mmodels\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mCharField\u001B[49m\u001B[43m(\u001B[49m\u001B[43mmax_length\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;241;43m50\u001B[39;49m\u001B[43m)\u001B[49m\n", + "File \u001B[0;32m~/.local/share/virtualenvs/django-ledger-_-pJZtVO/lib/python3.11/site-packages/django/db/models/base.py:134\u001B[0m, in \u001B[0;36mModelBase.__new__\u001B[0;34m(cls, name, bases, attrs, **kwargs)\u001B[0m\n\u001B[1;32m 132\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m app_config \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m:\n\u001B[1;32m 133\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m abstract:\n\u001B[0;32m--> 134\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mRuntimeError\u001B[39;00m(\n\u001B[1;32m 135\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mModel class \u001B[39m\u001B[38;5;132;01m%s\u001B[39;00m\u001B[38;5;124m.\u001B[39m\u001B[38;5;132;01m%s\u001B[39;00m\u001B[38;5;124m doesn\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mt declare an explicit \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[1;32m 136\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mapp_label and isn\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mt in an application in \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[1;32m 137\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mINSTALLED_APPS.\u001B[39m\u001B[38;5;124m\"\u001B[39m \u001B[38;5;241m%\u001B[39m (module, name)\n\u001B[1;32m 138\u001B[0m )\n\u001B[1;32m 140\u001B[0m \u001B[38;5;28;01melse\u001B[39;00m:\n\u001B[1;32m 141\u001B[0m app_label \u001B[38;5;241m=\u001B[39m app_config\u001B[38;5;241m.\u001B[39mlabel\n", + "\u001B[0;31mRuntimeError\u001B[0m: Model class __main__.EmployeeModel doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS." + ] + } + ], + "execution_count": 55 + }, + { + "metadata": {}, + "cell_type": "markdown", + "source": "# Billing / Invoicing" }, { + "metadata": {}, "cell_type": "code", - "execution_count": null, + "source": [ + "from django_ledger.models import BillModel, ItemTransactionModel\n", + "from random import choices" + ], + "outputs": [], + "execution_count": null + }, + { "metadata": {}, + "cell_type": "code", + "source": [ + "vendor_model = entity_model.get_vendors().first()\n", + "bill_model = entity_model.create_bill(\n", + " vendor_model=vendor_model,\n", + " terms=BillModel.TERMS_NET_30\n", + ")\n", + "bill_model\n" + ], "outputs": [], - "source": [] + "execution_count": null }, { + "metadata": {}, "cell_type": "code", - "execution_count": null, + "source": [ + "expense_items_qs = choices(entity_model.get_items_for_bill(), k=3)\n", + "bill_items = [\n", + " ItemTransactionModel(\n", + " item_model=i,\n", + " quantity=3,\n", + " unit_cost=5,\n", + " bill_model=bill_model\n", + " ) for i in expense_items_qs\n", + "]\n", + "for i in bill_items:\n", + " i.clean()\n", + "bill_model.itemtransactionmodel_set.bulk_create(bill_items)\n" + ], + "outputs": [], + "execution_count": null + }, + { + "metadata": {}, + "cell_type": "code", + "source": [ + "item_model_qs = bill_model.update_amount_due()\n", + "bill_model.amount_due" + ], + "outputs": [], + "execution_count": null + }, + { + "metadata": {}, + "cell_type": "code", + "source": [ + "bill_model.mark_as_review()\n", + "bill_model.mark_as_approved(user_model=user_model)\n", + "bill_model.mark_as_paid(commit=True, user_model=user_model)" + ], + "outputs": [], + "execution_count": null + }, + { + "metadata": {}, + "cell_type": "code", + "source": "", + "outputs": [], + "execution_count": null + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-25T03:09:35.233799Z", + "start_time": "2024-09-25T03:09:35.218081Z" + } + }, + "cell_type": "code", + "source": [ + "# bs_report = entity_model.get_balance_sheet_statement(to_date=date(2024, 12, 13))\n", + "bs_report = entity_model.get_income_statement(from_date=date(2023, 12, 13), to_date=date(2024, 12, 13))" + ], + "outputs": [], + "execution_count": 97 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-25T03:09:36.010102Z", + "start_time": "2024-09-25T03:09:36.007276Z" + } + }, + "cell_type": "code", + "source": "bs_report", + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 98, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 98 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-25T03:09:36.171947Z", + "start_time": "2024-09-25T03:09:36.169960Z" + } + }, + "cell_type": "code", + "source": "bs_data = bs_report.get_report_data()", + "outputs": [], + "execution_count": 99 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-25T03:09:36.372514Z", + "start_time": "2024-09-25T03:09:36.371232Z" + } + }, + "cell_type": "code", + "source": "", + "outputs": [], + "execution_count": null + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-25T13:09:44.122215Z", + "start_time": "2024-09-25T13:09:44.115403Z" + } + }, + "cell_type": "code", + "source": "bs_data", + "outputs": [ + { + "data": { + "text/plain": [ + "{'operating': {'revenues': [{'account_uuid': UUID('c04a349d-40ef-42b5-ab2d-3e10f4a7aa36'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'in_operational',\n", + " 'code': '4010',\n", + " 'name': 'Sales Income',\n", + " 'balance_type': 'credit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('-568.820000000000'),\n", + " 'balance_abs': Decimal('568.820000000000'),\n", + " 'role_name': 'Operational Income'}],\n", + " 'cogs': [{'account_uuid': UUID('cc15e8ea-2853-4eb6-80ce-a5071fe83d5c'),\n", + " 'unit_uuid': None,\n", + " 'unit_name': None,\n", + " 'activity': None,\n", + " 'period_year': None,\n", + " 'period_month': None,\n", + " 'role_bs': 'equity',\n", + " 'role': 'cogs_regular',\n", + " 'code': '5010',\n", + " 'name': 'Cost of Goods Sold',\n", + " 'balance_type': 'debit',\n", + " 'tx_type': None,\n", + " 'balance': Decimal('148.700000000000'),\n", + " 'balance_abs': Decimal('148.700000000000'),\n", + " 'role_name': 'Cost of Goods Sold'}],\n", + " 'expenses': [],\n", + " 'gross_profit': Decimal('-420.120000000000'),\n", + " 'net_operating_income': Decimal('-420.120000000000'),\n", + " 'net_operating_revenue': Decimal('-568.820000000000'),\n", + " 'net_cogs': Decimal('148.700000000000'),\n", + " 'net_operating_expenses': 0},\n", + " 'other': {'revenues': [],\n", + " 'expenses': [],\n", + " 'net_other_revenues': 0,\n", + " 'net_other_expenses': 0,\n", + " 'net_other_income': 0},\n", + " 'net_income': Decimal('-420.120000000000')}" + ] + }, + "execution_count": 101, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 101 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2024-09-25T16:56:03.402656Z", + "start_time": "2024-09-25T16:56:03.397071Z" + } + }, + "cell_type": "code", + "source": "bs_data['other']", + "outputs": [ + { + "data": { + "text/plain": [ + "{'revenues': [],\n", + " 'expenses': [],\n", + " 'net_other_revenues': 0,\n", + " 'net_other_expenses': 0,\n", + " 'net_other_income': 0}" + ] + }, + "execution_count": 109, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 109 + }, + { "metadata": {}, + "cell_type": "code", "outputs": [], - "source": [] + "execution_count": null, + "source": "" } ], "metadata": {