diff --git a/django_ledger/__init__.py b/django_ledger/__init__.py index 22206e05..d68ea051 100644 --- a/django_ledger/__init__.py +++ b/django_ledger/__init__.py @@ -9,7 +9,7 @@ default_app_config = 'django_ledger.apps.DjangoLedgerConfig' """Django Ledger""" -__version__ = '0.6.1' +__version__ = '0.6.2' __license__ = 'GPLv3 License' __author__ = 'Miguel Sanda' diff --git a/django_ledger/io/io_core.py b/django_ledger/io/io_core.py index 62fe131f..cd31a447 100644 --- a/django_ledger/io/io_core.py +++ b/django_ledger/io/io_core.py @@ -343,7 +343,7 @@ def database_digest(self, Returns results aggregated by accounting if needed. Defaults to False. by_unit: bool Returns results aggregated by unit if needed. Defaults to False. - use_closing_entry: bool + use_closing_entries: bool Overrides the DJANGO_LEDGER_USE_CLOSING_ENTRIES setting. Returns ------- @@ -587,7 +587,7 @@ def python_digest(self, signs: bool Changes the balance of an account to negative if it represents a "negative" for display purposes. (i.e. Expense accounts will show balance as negative and Income accounts as positive.) - force_closing_entry_use: bool + use_closing_entries: bool Forces the use of closing entries if DJANGO_LEDGER_USE_CLOSING_ENTRIES setting is set to False. force_queryset_sorting: bool Forces sorting of the TransactionModelQuerySet before aggregation balances. diff --git a/django_ledger/templates/django_ledger/financial_statements/tags/balance_sheet_statement.html b/django_ledger/templates/django_ledger/financial_statements/tags/balance_sheet_statement.html index 53fdafa8..6cc6708f 100644 --- a/django_ledger/templates/django_ledger/financial_statements/tags/balance_sheet_statement.html +++ b/django_ledger/templates/django_ledger/financial_statements/tags/balance_sheet_statement.html @@ -4,7 +4,6 @@
- {% for bs_role, bs_role_data in tx_digest.balance_sheet.items %} {% if bs_role_data.is_block %} diff --git a/django_ledger/templatetags/django_ledger.py b/django_ledger/templatetags/django_ledger.py index 891019a7..0801ea57 100644 --- a/django_ledger/templatetags/django_ledger.py +++ b/django_ledger/templatetags/django_ledger.py @@ -137,7 +137,7 @@ def cash_flow_statement(context, io_model): @register.inclusion_tag('django_ledger/financial_statements/tags/income_statement.html', takes_context=True) def income_statement_table(context, io_model, from_date=None, to_date=None): - user_model: EntityUnitModel = context['user'] + user_model = context['user'] activity = context['request'].GET.get('activity') activity = validate_activity(activity, raise_404=True) entity_slug = context['view'].kwargs.get('entity_slug') diff --git a/django_ledger/views/entity.py b/django_ledger/views/entity.py index b16f3f42..5bb45eb3 100644 --- a/django_ledger/views/entity.py +++ b/django_ledger/views/entity.py @@ -199,8 +199,8 @@ class EntityModelDetailBaseView(DjangoLedgerSecurityMixIn, FETCH_UNPAID_BILLS = True FETCH_UNPAID_INVOICES = True - IO_DIGEST = True - IO_DIGEST_EQUITY = True + IO_DIGEST_UNBOUNDED = True + IO_DIGEST_BOUNDED = True def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) diff --git a/django_ledger/views/mixins.py b/django_ledger/views/mixins.py index f1928383..c44fbf22 100644 --- a/django_ledger/views/mixins.py +++ b/django_ledger/views/mixins.py @@ -24,7 +24,18 @@ from django_ledger.settings import DJANGO_LEDGER_PDF_SUPPORT_ENABLED, DJANGO_LEDGER_AUTHORIZED_SUPERUSER -class YearlyReportMixIn(YearMixin, EntityModelFiscalPeriodMixIn): +class ContextFromToDateMixin: + FROM_DATE_CONTEXT_NAME = 'from_date' + TO_DATE_CONTEXT_NAME = 'to_date' + + def get_from_date_context_name(self) -> str: + return self.FROM_DATE_CONTEXT_NAME + + def get_to_date_context_name(self) -> str: + return self.TO_DATE_CONTEXT_NAME + + +class YearlyReportMixIn(YearMixin, ContextFromToDateMixin, EntityModelFiscalPeriodMixIn): def get_from_date(self, year: int = None, fy_start: int = None, **kwargs) -> date: return self.get_year_start_date(year, fy_start) @@ -58,16 +69,16 @@ def get_context_data(self, **kwargs): context['year_start'] = year_start context['year_end'] = year_end - if 'from_date' not in context: - context['from_date'] = year_start - if 'to_date' not in context: - context['to_date'] = year_end + if self.get_from_date_context_name() not in context: + context[self.get_from_date_context_name()] = year_start + if self.get_to_date_context_name() not in context: + context[self.get_to_date_context_name()] = year_end context['has_year'] = True return context -class QuarterlyReportMixIn(YearMixin, EntityModelFiscalPeriodMixIn): +class QuarterlyReportMixIn(YearMixin, ContextFromToDateMixin, EntityModelFiscalPeriodMixIn): quarter = None quarter_url_kwarg = 'quarter' @@ -137,10 +148,10 @@ def get_context_data(self, **kwargs) -> dict: context['quarter_start'] = quarter_start context['quarter_end'] = quarter_end - if 'from_date' not in context: - context['from_date'] = quarter_start - if 'to_date' not in context: - context['to_date'] = quarter_end + if self.get_from_date_context_name() not in context: + context[self.get_from_date_context_name()] = quarter_start + if self.get_to_date_context_name() not in context: + context[self.get_to_date_context_name()] = quarter_end context['has_quarter'] = True return context @@ -154,7 +165,7 @@ def get_previous_quarter(self, quarter) -> int: return quarter - 1 -class MonthlyReportMixIn(YearlyReportMixIn, MonthMixin): +class MonthlyReportMixIn(YearlyReportMixIn, ContextFromToDateMixin, MonthMixin): def get_from_date(self, month: int = None, year: int = None, **kwargs) -> date: return self.get_month_start_date(month=month, year=year) @@ -206,13 +217,17 @@ def get_context_data(self, **kwargs): month_end = self.get_month_end_date(year=year, month=month) context['month_start'] = month_start context['month_end'] = month_end - context['from_date'] = month_start - context['to_date'] = month_end + + if self.get_from_date_context_name() not in context: + context[self.get_from_date_context_name()] = month_start + if self.get_to_date_context_name() not in context: + context[self.get_to_date_context_name()] = month_end + context['has_month'] = True return context -class DateReportMixIn(MonthlyReportMixIn, DayMixin): +class DateReportMixIn(MonthlyReportMixIn, ContextFromToDateMixin, DayMixin): def get_context_data(self, **kwargs): context = super(MonthlyReportMixIn, self).get_context_data(**kwargs) @@ -221,8 +236,12 @@ def get_context_data(self, **kwargs): context['next_day'] = view_date + timedelta(days=1) context['previous_day'] = view_date - timedelta(days=1) context['view_date'] = view_date - context['from_date'] = view_date - context['to_date'] = view_date + + if self.get_from_date_context_name() not in context: + context[self.get_from_date_context_name()] = view_date + if self.get_to_date_context_name() not in context: + context[self.get_to_date_context_name()] = view_date + return context def get_date(self) -> date: @@ -243,7 +262,8 @@ def get_from_to_dates(self, month: int = None, year: int = None, **kwargs) -> Tu return dt, dt -class FromToDatesMixIn: +# todo: need to incorporate in base view... +class FromToDatesParseMixIn: DJL_FROM_DATE_PARAM: str = 'from_date' DJL_TO_DATE_PARAM: str = 'to_date' DJL_NO_FROM_DATE_RAISE_404: bool = True @@ -369,6 +389,7 @@ def get_context_data(self, **kwargs): class DigestContextMixIn: + IO_DIGEST_UNBOUNDED = False IO_DIGEST_BOUNDED = False @@ -435,8 +456,8 @@ def get_io_digest(self, from_date=from_date, unit_slug=unit_slug, by_period=True if by_period else False, - process_ratios=False, - process_roles=False, + process_ratios=True, + process_roles=True, process_groups=True) context[self.get_io_manager_bounded_context_name()] = io_digest_equity diff --git a/pyproject.toml b/pyproject.toml index c9ebaef6..59ac9668 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "django-ledger" -version = "0.6.1" +version = "0.6.2" readme = "README.md" requires-python = ">=3.10" description = "Double entry accounting system built on the Django Web Framework."