mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-07-08 13:55:21 +02:00
fix(insights:category-explorer): wrong sums
This commit is contained in:
@@ -14,8 +14,7 @@ def get_category_sums_by_account(queryset, category=None):
|
|||||||
current_income=Coalesce(
|
current_income=Coalesce(
|
||||||
Sum(
|
Sum(
|
||||||
Case(
|
Case(
|
||||||
When(type="IN", then="amount"),
|
When(type="IN", is_paid=True, then="amount"),
|
||||||
When(is_paid=True, then="amount"),
|
|
||||||
default=Value(0),
|
default=Value(0),
|
||||||
output_field=DecimalField(max_digits=42, decimal_places=30),
|
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(
|
current_expense=Coalesce(
|
||||||
Sum(
|
Sum(
|
||||||
Case(
|
Case(
|
||||||
When(type="EX", then=-F("amount")),
|
When(type="EX", is_paid=True, then=-F("amount")),
|
||||||
When(is_paid=True, then="amount"),
|
|
||||||
default=Value(0),
|
default=Value(0),
|
||||||
output_field=DecimalField(max_digits=42, decimal_places=30),
|
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(
|
projected_income=Coalesce(
|
||||||
Sum(
|
Sum(
|
||||||
Case(
|
Case(
|
||||||
When(type="IN", then="amount"),
|
When(type="IN", is_paid=False, then="amount"),
|
||||||
When(is_paid=False, then="amount"),
|
|
||||||
default=Value(0),
|
default=Value(0),
|
||||||
output_field=DecimalField(max_digits=42, decimal_places=30),
|
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(
|
projected_expense=Coalesce(
|
||||||
Sum(
|
Sum(
|
||||||
Case(
|
Case(
|
||||||
When(type="EX", then=-F("amount")),
|
When(type="EX", is_paid=False, then=-F("amount")),
|
||||||
When(is_paid=False, then="amount"),
|
|
||||||
default=Value(0),
|
default=Value(0),
|
||||||
output_field=DecimalField(max_digits=42, decimal_places=30),
|
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(
|
current_income=Coalesce(
|
||||||
Sum(
|
Sum(
|
||||||
Case(
|
Case(
|
||||||
When(type="IN", then="amount"),
|
When(type="IN", is_paid=True, then="amount"),
|
||||||
When(is_paid=True, then="amount"),
|
|
||||||
default=Value(0),
|
default=Value(0),
|
||||||
output_field=DecimalField(max_digits=42, decimal_places=30),
|
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(
|
current_expense=Coalesce(
|
||||||
Sum(
|
Sum(
|
||||||
Case(
|
Case(
|
||||||
When(type="EX", then=-F("amount")),
|
When(type="EX", is_paid=True, then=-F("amount")),
|
||||||
When(is_paid=True, then="amount"),
|
|
||||||
default=Value(0),
|
default=Value(0),
|
||||||
output_field=DecimalField(max_digits=42, decimal_places=30),
|
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(
|
projected_income=Coalesce(
|
||||||
Sum(
|
Sum(
|
||||||
Case(
|
Case(
|
||||||
When(type="IN", then="amount"),
|
When(type="IN", is_paid=False, then="amount"),
|
||||||
When(is_paid=False, then="amount"),
|
|
||||||
default=Value(0),
|
default=Value(0),
|
||||||
output_field=DecimalField(max_digits=42, decimal_places=30),
|
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(
|
projected_expense=Coalesce(
|
||||||
Sum(
|
Sum(
|
||||||
Case(
|
Case(
|
||||||
When(type="EX", then=-F("amount")),
|
When(type="EX", is_paid=False, then=-F("amount")),
|
||||||
When(is_paid=False, then="amount"),
|
|
||||||
default=Value(0),
|
default=Value(0),
|
||||||
output_field=DecimalField(max_digits=42, decimal_places=30),
|
output_field=DecimalField(max_digits=42, decimal_places=30),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -57,9 +57,9 @@
|
|||||||
labels: accountData.labels,
|
labels: accountData.labels,
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
label: "{% trans 'Current Income' %}",
|
label: "{% trans 'Projected Expenses' %}",
|
||||||
data: accountData.datasets[0].data,
|
data: accountData.datasets[3].data,
|
||||||
backgroundColor: '#4dde80',
|
backgroundColor: '#f8717180', // Added transparency
|
||||||
stack: 'stack0'
|
stack: 'stack0'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -68,18 +68,19 @@
|
|||||||
backgroundColor: '#f87171',
|
backgroundColor: '#f87171',
|
||||||
stack: 'stack0'
|
stack: 'stack0'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "{% trans 'Current Income' %}",
|
||||||
|
data: accountData.datasets[0].data,
|
||||||
|
backgroundColor: '#4dde80',
|
||||||
|
stack: 'stack0'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "{% trans 'Projected Income' %}",
|
label: "{% trans 'Projected Income' %}",
|
||||||
data: accountData.datasets[2].data,
|
data: accountData.datasets[2].data,
|
||||||
backgroundColor: '#4dde8080', // Added transparency
|
backgroundColor: '#4dde8080', // Added transparency
|
||||||
stack: 'stack0'
|
stack: 'stack0'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: "{% trans 'Projected Expenses' %}",
|
|
||||||
data: accountData.datasets[3].data,
|
|
||||||
backgroundColor: '#f8717180', // Added transparency
|
|
||||||
stack: 'stack0'
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
|
|||||||
@@ -57,9 +57,9 @@
|
|||||||
labels: currencyData.labels,
|
labels: currencyData.labels,
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
label: "{% trans 'Current Income' %}",
|
label: "{% trans 'Projected Expenses' %}",
|
||||||
data: currencyData.datasets[0].data,
|
data: currencyData.datasets[3].data,
|
||||||
backgroundColor: '#4dde80',
|
backgroundColor: '#f8717180', // Added transparency
|
||||||
stack: 'stack0'
|
stack: 'stack0'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -68,18 +68,19 @@
|
|||||||
backgroundColor: '#f87171',
|
backgroundColor: '#f87171',
|
||||||
stack: 'stack0'
|
stack: 'stack0'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "{% trans 'Current Income' %}",
|
||||||
|
data: currencyData.datasets[0].data,
|
||||||
|
backgroundColor: '#4dde80',
|
||||||
|
stack: 'stack0'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "{% trans 'Projected Income' %}",
|
label: "{% trans 'Projected Income' %}",
|
||||||
data: currencyData.datasets[2].data,
|
data: currencyData.datasets[2].data,
|
||||||
backgroundColor: '#4dde8080', // Added transparency
|
backgroundColor: '#4dde8080', // Added transparency
|
||||||
stack: 'stack0'
|
stack: 'stack0'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: "{% trans 'Projected Expenses' %}",
|
|
||||||
data: currencyData.datasets[3].data,
|
|
||||||
backgroundColor: '#f8717180', // Added transparency
|
|
||||||
stack: 'stack0'
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
options: chartOptions
|
options: chartOptions
|
||||||
|
|||||||
Reference in New Issue
Block a user