Skip to content

Commit

Permalink
Enhance account handling and transaction filtering
Browse files Browse the repository at this point in the history
Added `entity_slug` and `user_model` to template context for better context data. Updated the form to include `balance_type` as a selectable field with proper styling. Adjusted transaction queryset to exclude closing entries in account views for more accurate filtering.
  • Loading branch information
elarroba committed Jan 6, 2025
1 parent f6b9bce commit 515b3ad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion django_ledger/forms/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,16 @@ def clean_role_default(self):

class Meta:
model = AccountModel
exclude = ('depth', 'numchild', 'path', 'balance_type')
exclude = ('depth', 'numchild', 'path')
widgets = {
'role': HiddenInput(),
'coa_model': HiddenInput(),
'parent': Select(attrs={
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES
}),
'balance_type': Select(attrs={
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES
}),
'code': TextInput(attrs={
'class': DJANGO_LEDGER_FORM_INPUT_CLASSES
}),
Expand Down
4 changes: 4 additions & 0 deletions django_ledger/templatetags/django_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def cash_flow_statement(context, io_model):
process_groups=True)

return {
'entity_slug': entity_slug,
'user_model': user_model,
'tx_digest': io_digest.get_io_data()
}

Expand Down Expand Up @@ -164,6 +166,8 @@ def income_statement_table(context, io_model, from_date=None, to_date=None):
)

return {
'entity_slug': entity_slug,
'user_model': user_model,
'tx_digest': io_digest.get_io_data()
}

Expand Down
2 changes: 1 addition & 1 deletion django_ledger/views/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def get_context_data(self, **kwargs):
account_model: AccountModel = context['object']
context['header_title'] = f'Account {account_model.code} - {account_model.name}'
context['page_title'] = f'Account {account_model.code} - {account_model.name}'
txs_qs = account_model.transactionmodel_set.all().posted().order_by(
txs_qs = account_model.transactionmodel_set.all().not_closing_entry().posted().order_by(
'journal_entry__timestamp'
).select_related(
'journal_entry',
Expand Down

0 comments on commit 515b3ad

Please sign in to comment.