diff --git a/app/apps/insights/utils/category_explorer.py b/app/apps/insights/utils/category_explorer.py index f7dc401..487d53d 100644 --- a/app/apps/insights/utils/category_explorer.py +++ b/app/apps/insights/utils/category_explorer.py @@ -14,8 +14,7 @@ def get_category_sums_by_account(queryset, category=None): current_income=Coalesce( Sum( Case( - When(type="IN", then="amount"), - When(is_paid=True, then="amount"), + When(type="IN", is_paid=True, then="amount"), default=Value(0), output_field=DecimalField(max_digits=42, decimal_places=30), ) @@ -26,8 +25,7 @@ def get_category_sums_by_account(queryset, category=None): current_expense=Coalesce( Sum( Case( - When(type="EX", then=-F("amount")), - When(is_paid=True, then="amount"), + When(type="EX", is_paid=True, then=-F("amount")), default=Value(0), output_field=DecimalField(max_digits=42, decimal_places=30), ) @@ -38,8 +36,7 @@ def get_category_sums_by_account(queryset, category=None): projected_income=Coalesce( Sum( Case( - When(type="IN", then="amount"), - When(is_paid=False, then="amount"), + When(type="IN", is_paid=False, then="amount"), default=Value(0), output_field=DecimalField(max_digits=42, decimal_places=30), ) @@ -50,8 +47,7 @@ def get_category_sums_by_account(queryset, category=None): projected_expense=Coalesce( Sum( Case( - When(type="EX", then=-F("amount")), - When(is_paid=False, then="amount"), + When(type="EX", is_paid=False, then=-F("amount")), default=Value(0), output_field=DecimalField(max_digits=42, decimal_places=30), ) @@ -97,8 +93,7 @@ def get_category_sums_by_currency(queryset, category=None): current_income=Coalesce( Sum( Case( - When(type="IN", then="amount"), - When(is_paid=True, then="amount"), + When(type="IN", is_paid=True, then="amount"), default=Value(0), output_field=DecimalField(max_digits=42, decimal_places=30), ) @@ -109,8 +104,7 @@ def get_category_sums_by_currency(queryset, category=None): current_expense=Coalesce( Sum( Case( - When(type="EX", then=-F("amount")), - When(is_paid=True, then="amount"), + When(type="EX", is_paid=True, then=-F("amount")), default=Value(0), output_field=DecimalField(max_digits=42, decimal_places=30), ) @@ -121,8 +115,7 @@ def get_category_sums_by_currency(queryset, category=None): projected_income=Coalesce( Sum( Case( - When(type="IN", then="amount"), - When(is_paid=False, then="amount"), + When(type="IN", is_paid=False, then="amount"), default=Value(0), output_field=DecimalField(max_digits=42, decimal_places=30), ) @@ -133,8 +126,7 @@ def get_category_sums_by_currency(queryset, category=None): projected_expense=Coalesce( Sum( Case( - When(type="EX", then=-F("amount")), - When(is_paid=False, then="amount"), + When(type="EX", is_paid=False, then=-F("amount")), default=Value(0), output_field=DecimalField(max_digits=42, decimal_places=30), ) diff --git a/app/templates/insights/fragments/category_explorer/charts/account.html b/app/templates/insights/fragments/category_explorer/charts/account.html index 5ed053a..5078442 100644 --- a/app/templates/insights/fragments/category_explorer/charts/account.html +++ b/app/templates/insights/fragments/category_explorer/charts/account.html @@ -57,9 +57,9 @@ labels: accountData.labels, datasets: [ { - label: "{% trans 'Current Income' %}", - data: accountData.datasets[0].data, - backgroundColor: '#4dde80', + label: "{% trans 'Projected Expenses' %}", + data: accountData.datasets[3].data, + backgroundColor: '#f8717180', // Added transparency stack: 'stack0' }, { @@ -68,18 +68,19 @@ backgroundColor: '#f87171', stack: 'stack0' }, + { + label: "{% trans 'Current Income' %}", + data: accountData.datasets[0].data, + backgroundColor: '#4dde80', + stack: 'stack0' + }, { label: "{% trans 'Projected Income' %}", data: accountData.datasets[2].data, backgroundColor: '#4dde8080', // Added transparency stack: 'stack0' }, - { - label: "{% trans 'Projected Expenses' %}", - data: accountData.datasets[3].data, - backgroundColor: '#f8717180', // Added transparency - stack: 'stack0' - } + ] }, options: { diff --git a/app/templates/insights/fragments/category_explorer/charts/currency.html b/app/templates/insights/fragments/category_explorer/charts/currency.html index b3ab300..c30a9c5 100644 --- a/app/templates/insights/fragments/category_explorer/charts/currency.html +++ b/app/templates/insights/fragments/category_explorer/charts/currency.html @@ -57,9 +57,9 @@ labels: currencyData.labels, datasets: [ { - label: "{% trans 'Current Income' %}", - data: currencyData.datasets[0].data, - backgroundColor: '#4dde80', + label: "{% trans 'Projected Expenses' %}", + data: currencyData.datasets[3].data, + backgroundColor: '#f8717180', // Added transparency stack: 'stack0' }, { @@ -68,18 +68,19 @@ backgroundColor: '#f87171', stack: 'stack0' }, + { + label: "{% trans 'Current Income' %}", + data: currencyData.datasets[0].data, + backgroundColor: '#4dde80', + stack: 'stack0' + }, { label: "{% trans 'Projected Income' %}", data: currencyData.datasets[2].data, backgroundColor: '#4dde8080', // Added transparency stack: 'stack0' }, - { - label: "{% trans 'Projected Expenses' %}", - data: currencyData.datasets[3].data, - backgroundColor: '#f8717180', // Added transparency - stack: 'stack0' - } + ] }, options: chartOptions