Skip to content

Commit faf3533

Browse files
authored
V0.8.1 (#285)
* - Introduced `ReceiptModel` as a concrete implementation for handling sales, expense receipts, refunds, and transfers. - Added `ReceiptModelQuerySet` and `ReceiptModelManager` to provide custom query methods such as `for_user`, `for_dates`, `for_vendor`, `for_customer`, and `for_entity`. - Implemented validation and utility methods within `ReceiptModelAbstract`: - Receipt lifecycle management (e.g., `delete`, `is_configured`, `can_delete`, `can_generate_receipt_number`, `configure`, and `migrate_receipt`). - Receipt type determination (`is_sales_receipt`, `is_expense_receipt`, `get_receipt_type_for_amount`). - Pre-save and validation logic using `clean` and `receiptmodel_presave`. - Enhanced reporting and navigation through URL helper methods, including `get_absolute_url`, `get_delete_url`, and report URLs for customers and vendors. - Added database-level indexing for fields like `receipt_number`, `receipt_date`, and `receipt_type`. - Introduced sequence number generation for receipt numbering using `EntityStateModel`. **Summary**: Added a robust `ReceiptModel` implementation with comprehensive query, validation, navigation, and lifecycle management features. Ensured proper database indexing and compatibility. **Backwards Compatibility**: No breaking changes, new functionality added. * - Refactored query methods in `TransactionModelQuerySet` to improve readability and updated docstrings for clarity. - Added `entity_slug` and `ledger_uuid` properties to `TransactionModelAbstract` for streamlined access to linked entity and ledger metadata. - Introduced `get_ledger_detail_url` and `get_journal_entry_detail_url` helper methods to generate navigation URLs for ledger and journal entry details. - Enhanced validation method formatting and error messages throughout `TransactionModelAbstract` and its mixins. - Reformatted model and field definitions, ensuring consistent usage of parameters like `validators`, `verbose_name`, and `help_text`. - Applied consistent code formatting, improving readability for long method signatures and conditional logic. - Added missing annotations and typing hints to methods in both `TransactionModelAbstract` and mixins for better type checking. - Updated imports ordering and grouped them logically. **Summary**: Comprehensive refactoring of `TransactionModel` and related mixins for improved readability, navigation, and consistency. Added new helper properties and methods for better data handling and URL generation. **Backwards Compatibility**: No breaking changes introduced. * - Refactored imports in `customer.py` and `data_import.py` for organized grouping and alphabetical sorting. - Reformatted long method signatures, annotations, and docstrings for readability: - Updated `for_entity` methods with multi-line signatures. - Improved explanations in docstrings for `ImportJobModelValidationError` and `StagedTransactionModelValidationError`. - Improved queryset logic with better annotations: - Enhanced `ready_to_import` and `can_split_into_je` conditions to include customers, vendors, and receipt types. - Added `children_mapping_pending_count` and `children_mapping_done` fields. - Updated field attributes (e.g., `verbose_name`, `help_text`) for clarity and standardization. - Removed unnecessary blank lines and tightened spacing in complex queries (`StagedTransactionModelManager`). **Summary**: Major refactor of `customer.py` and `data_import.py` to improve readability, consistency, and functional enhancements. Introduced new query annotations and streamlined validation across models. **Backwards Compatibility**: No breaking changes, purely refactor and enhancements. * - **Refactored various imports for improved readability and logical grouping**: - Reorganized imports in `django_ledger/io/io_core.py`. - Sorted imports alphabetically wherever applicable. - **Introduced a staged transaction model accessor**: - Added `STAGED_TRANSACTION_MODEL_CLASS` attribute and a corresponding `get_staged_transaction_model` method in `IODatabaseMixIn`. - **Refactored and reformatted method signatures and parameters**: - Updated method signatures (`digest`, `database_digest`, `python_digest`, etc.) for better alignment and readability. - Renamed `use_closing_entries` to `use_closing_entry` for naming consistency. - **Enhanced readability of conditional logic and annotations**: - Reformatted if-else conditions, transaction correction logic, and filters for clearness. - Improved annotation and alignment in multi-line statements and querysets. - **Improved docstring consistency**: - Ensured method docstrings follow a standardized format. - Refined descriptions for better clarity and accuracy. **Summary**: Refactored the `io_core.py` module for enhanced readability, consistency, and maintainability. Introduced `STAGED_TRANSACTION_MODEL_CLASS` accessor, improved naming conventions, and reformatted major methods for clarity. **Backwards Compatibility**: No breaking changes, focused on naming consistency and code refactoring. * - **Refactored and enhanced `data_import.py` forms and formsets**: - Reorganized imports for logical grouping and alphabetization. - Added new vendor and customer choices (`VENDOR_CHOICES`, `CUSTOMER_CHOICES`) with associated mappings. - Introduced `EXPENSE_ACCOUNT_CHOICES` and `SALES_ACCOUNT_CHOICES` for account filtering. - Updated `BaseStagedTransactionModelForm` to handle receipt type-based field visibility (e.g., `vendor_model`, `customer_model`, `receipt_type`). - Enhanced conditional logic in `clean` methods, including validation for receipt transaction splitting. - Improved field widget attributes, such as `unit_model`, `vendor_model`, and `receipt_type`, for consistency across forms. - Modified initialization of `BaseStagedTransactionModelFormSet` to streamline querysets for staged transactions. **Summary**: Improved clarity, functionality, and maintainability of forms and formsets in `data_import.py` by refactoring field handling, adding new account and vendor filters, and enhancing validation logic. **Backwards Compatibility**: No breaking changes, refactor and enhancements only. * - **Refactored and enhanced `account.py` forms for improved readability and consistency**: - Reorganized imports, grouping logically and formatting them vertically. - Reformatted widget attributes (e.g., `code`, `name`, `role`, `balance_type`) for consistency and readability. - Simplified and reformatted `ChoiceField` definitions (`_position`, `_ref_node_id`) and their widget attributes. - Updated docstrings for standardization and clarity in method descriptions (e.g., `mk_dropdown_tree`). - Streamlined conditional logic and data representation (e.g., `mk_dropdown_tree` and its return format). - **Adjusted period navigator template (`period_navigator.html`) for better UI scaling**: - Updated heading size classes to `is-size-4` and `is-size-5` for title and period labels, improving visibility at different screen sizes. - Separated fiscal year, month, quarter, and date display into distinct headings for visual clarity. **Summary**: Refactored `account.py` form definitions and `period_navigator.html` template for code readability and UI clarity. Enhanced overall maintainability and ease of use. **Backwards Compatibility**: No breaking changes, focused on refactoring and visual improvements. * - **Enhanced customer and vendor tables with navigation links**: - Updated customer and vendor names to link to their respective detail pages in `customer_table.html` and `vendor_table.html`. - Added "View" options in dropdown menus for customer and vendor tables. - **Adjusted sidebar layout for improved UI scaling**: - Reduced column size from `is-3` to `is-2` in `content_layout_1.html` and `entity_dashboard.html`. - **Refined staged transaction import tables**: - Added new columns for `Bundle` and `Split` in `data_import_job_txs_table.html`. - Introduced `Receipt Type` and `Customer/Vendor` fields with conditional visibility. - Highlighted mapping status using icons and added error display for invalid entries. - Updated row IDs for accurate identification in staged and imported transaction views. - **Enhanced imported transaction actions**: - Replaced static "View JE" button with a dropdown menu offering multiple actions: - Options to view receipt details (when available) or undo the import. - **Simplified `base.html` title structure**: - Adjusted title block to display `page_title` followed by entity model name. **Summary**: Improved navigation, UI layout, and table interactions across multiple templates. Introduced enhanced dropdown menus, error handling, and dynamic column visibility for transaction imports. **Backwards Compatibility**: No breaking changes, focused on usability and accessibility enhancements. * - **Added new URL patterns to enhance navigation and functionality**: - Introduced `customer-detail` URL pattern in `customer.py` for viewing customer detail pages. - Added `data-import-staged-tx-undo` URL pattern in `data_import.py` to support undoing staged transactions. - Added `vendor-detail` URL pattern in `vendor.py` for viewing vendor detail pages. - Included `receipt` URL pattern in `__init__.py` to link receipt-related functionalities. **Summary**: Extended URL patterns to improve customer, vendor, and receipt navigation, along with staged transaction management. No breaking changes introduced. * - **Enhanced transaction import processing and updated form handling**: - **Improved data import views (`data_import.py`)**: - Refactored import job queryset methods with consistent multi-line formatting for better readability. - Added `StagedTransactionUndoView` to enable undoing staged transaction imports. - Enhanced `post` method in `ImportJobModelTransactionUpdateView` to manage transactions more effectively, including receipt migration and transaction splitting logic. - Streamlined context data handling and minimized redundant queryset reinitialization. - **Updated customer views (`customer.py`)**: - Introduced `CustomerModelDetailView` for detailed customer information, including related invoices and receipts. - Enhanced form handling with refined URL navigation in create and update views. - Integrated customer-centric context variables in detail view templates. - **Improved mixins (`mixins.py`)**: - Reformatted mixin class declarations, method signatures, and conditional logic for readability and maintainability. - Enhanced `IOContextMixIn` and context data methods to conditionally render entity details and digest parameters. - Refined complex queries in `get_invoices_queryset` and `get_bills_queryset` within `DigestContextMixIn`. - **Refactored imports across multiple modules for consistency**: - Reorganized imports in `data_import.py`, `customer.py`, `mixins.py`, and `__init__.py` with alphabetical ordering and logical grouping. - **Enhanced transaction and receipt lifecycle management**: - Integrated validation logic improvements in staged transactions and receipts. - Added logic to manage and undo receipt imports based on validation criteria. **Summary**: Significant improvements to transaction import, undo, and receipt processing workflows. Enhanced customer navigation with new detail view support and streamlined import logic in various views and mixins. Code readability and maintainability further refined. **Backwards Compatibility**: No breaking changes introduced; purely enhancements and new functionality to existing modules. * - **Added receipt prefix configuration**: - Introduced `DJANGO_LEDGER_RECEIPT_NUMBER_PREFIX` setting in `settings.py` with default value `'R'`. - **Version bump**: - Updated the project version from `0.8.0` to `0.8.1` in `pyproject.toml`. - **Updated Ruff configuration**: - Added `[tool.ruff]` block with line-length configuration. - Configured quote style as single quotes under `[tool.ruff.format]`. - **Import reordering and consistency**: - Reorganized imports in `django_ledger/templatetags/django_ledger.py` for consistency and alphabetical order. - **Improved inclusion tag formatting**: - Reformatted inclusion tag methods in `django_ledger.py` to enhance readability with consistent multi-line formatting and eliminated redundant dictionary syntax. **Summary**: Introduced receipt numbering configuration, updated the project version, enhanced formatting in Ruff configuration, improved import organization, and refined template rendering in `django_ledger.py`. **Backwards Compatibility**: No breaking changes; purely enhancements and configuration updates. * - **Added receipt and detail templates for customers and vendors**: - Introduced `customer_detail.html` and `vendor_detail.html` for displaying customer/vendor information alongside related invoices, receipts, and bills. - Included tables for invoices (customer) and bills (vendor) with actionable links. - Structured content layout using `content_layout_1.html`. - **Introduced receipt management templates**: - Added `receipt_list.html` to display and filter receipts by type, period, or entity. - Created `receipt_detail.html` for detailed receipt information, including transactions and associated customer/vendor details. - Implemented `receipt_delete.html` to confirm and handle receipt deletions. - **Enhanced receipt reporting functionality**: - Developed `customer_receipt_report.html` and `vendor_receipt_report.html` to provide receipt reporting filtered by month, quarter, or year. - Included contextual navigation for easy filtering and date-based exploration. **Summary**: Added templates for enhanced receipt management, customer/vendor detail display, and comprehensive reporting capabilities. Structured content for better user navigation and interaction. **Backwards Compatibility**: No issues; all changes are new additions. * UV Update * - Refactored transaction import logic in `data_import.py` and `receipt.py`: - Replaced repetitive saving logic with a consolidated approach using a single `staged_to_save` list and set. - Removed redundant inline comments and unused code for clarity. - Optimized saving of `staged_tx_model` by batching updates through a deduplicated list. **Summary**: Simplified and optimized transaction commit logic in import and receipt migration workflows to improve maintainability and remove redundancy. **Backwards Compatibility**: No breaking changes; improvements are internal optimizations.
1 parent 386f415 commit faf3533

Some content is hidden

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

47 files changed

+6300
-2844
lines changed

django_ledger/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
default_app_config = 'django_ledger.apps.DjangoLedgerConfig'
77

88
"""Django Ledger"""
9-
__version__ = '0.8.0'
9+
__version__ = '0.8.1'
1010
__license__ = 'GPLv3 License'
1111

1212
__author__ = 'Miguel Sanda'

django_ledger/forms/account.py

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,19 @@
55
Contributions to this module:
66
* Miguel Sanda <msanda@arrobalytics.com>
77
"""
8+
89
from random import randint
910
from typing import Optional
1011

11-
from django.forms import TextInput, Select, ModelForm, ChoiceField, ValidationError, CheckboxInput, HiddenInput
12+
from django.forms import (
13+
TextInput,
14+
Select,
15+
ModelForm,
16+
ChoiceField,
17+
ValidationError,
18+
CheckboxInput,
19+
HiddenInput,
20+
)
1221
from django.utils.translation import gettext_lazy as _
1322
from treebeard.forms import MoveNodeForm
1423

@@ -62,33 +71,35 @@ class Meta:
6271
'balance_type',
6372
'active',
6473
'active',
65-
'coa_model'
74+
'coa_model',
6675
]
6776
widgets = {
68-
'code': TextInput(attrs={
69-
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES,
70-
'placeholder': _('Alpha Numeric (auto generated if not provided)...')
71-
}),
72-
'name': TextInput(attrs={
73-
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES,
74-
'placeholder': _('Account Name...')
75-
}),
76-
'role': Select(attrs={
77-
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES
78-
}),
77+
'code': TextInput(
78+
attrs={
79+
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES,
80+
'placeholder': _(
81+
'Alpha Numeric (auto generated if not provided)...'
82+
),
83+
}
84+
),
85+
'name': TextInput(
86+
attrs={
87+
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES,
88+
'placeholder': _('Account Name...'),
89+
}
90+
),
91+
'role': Select(attrs={'class': DJANGO_LEDGER_FORM_INPUT_CLASSES}),
7992
'role_default': CheckboxInput(),
80-
'balance_type': Select(attrs={
81-
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES
82-
}),
83-
'coa_model': HiddenInput()
93+
'balance_type': Select(attrs={'class': DJANGO_LEDGER_FORM_INPUT_CLASSES}),
94+
'coa_model': HiddenInput(),
8495
}
8596

8697

8798
class AccountModelUpdateForm(MoveNodeForm):
8899
"""
89100
AccountModelUpdateForm
90101
91-
A form for updating account model, inheriting from MoveNodeForm.
102+
A form for updating the account model, inheriting from MoveNodeForm.
92103
93104
Attributes
94105
----------
@@ -98,36 +109,32 @@ class AccountModelUpdateForm(MoveNodeForm):
98109
An optional choice field for selecting the relative node.
99110
"""
100111

101-
_position = ChoiceField(required=True,
102-
label=_('Position'),
103-
widget=Select(attrs={
104-
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES
105-
}))
106-
_ref_node_id = ChoiceField(required=False,
107-
label=_('Relative to'),
108-
widget=Select(attrs={
109-
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES
110-
}))
111-
112+
_position = ChoiceField(
113+
required=True,
114+
label=_('Position'),
115+
widget=Select(attrs={'class': DJANGO_LEDGER_FORM_INPUT_CLASSES}),
116+
)
117+
_ref_node_id = ChoiceField(
118+
required=False,
119+
label=_('Relative to'),
120+
widget=Select(attrs={'class': DJANGO_LEDGER_FORM_INPUT_CLASSES}),
121+
)
112122

113123
def __init__(self, *args, **kwargs):
114124
super().__init__(*args, **kwargs)
115125
self.fields['role'].disabled = True
116126
self.fields['coa_model'].disabled = True
117127

118-
119128
@classmethod
120129
def mk_dropdown_tree(cls, model, for_node: Optional[AccountModel] = None):
121-
""" Creates a tree-like list of choices """
130+
"""Creates a tree-like list of choices"""
122131

123132
if not for_node:
124133
raise ValidationError(message='Must provide for_node argument.')
125134

126135
qs = for_node.get_account_move_choice_queryset()
127136

128-
return [
129-
(i.uuid, f'{"-" * (i.depth - 1)} {i}') for i in qs
130-
]
137+
return [(i.uuid, f'{"-" * (i.depth - 1)} {i}') for i in qs]
131138

132139
def clean_role(self):
133140
return self.instance.role
@@ -147,17 +154,9 @@ class Meta:
147154
widgets = {
148155
'role': HiddenInput(),
149156
'coa_model': HiddenInput(),
150-
'parent': Select(attrs={
151-
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES
152-
}),
153-
'balance_type': Select(attrs={
154-
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES
155-
}),
156-
'code': TextInput(attrs={
157-
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES
158-
}),
159-
'name': TextInput(attrs={
160-
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES
161-
}),
157+
'parent': Select(attrs={'class': DJANGO_LEDGER_FORM_INPUT_CLASSES}),
158+
'balance_type': Select(attrs={'class': DJANGO_LEDGER_FORM_INPUT_CLASSES}),
159+
'code': TextInput(attrs={'class': DJANGO_LEDGER_FORM_INPUT_CLASSES}),
160+
'name': TextInput(attrs={'class': DJANGO_LEDGER_FORM_INPUT_CLASSES}),
162161
'role_default': CheckboxInput(),
163162
}

0 commit comments

Comments
 (0)