mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-11-13 12:23:44 +01:00
Merge pull request #657 from eitchtee/feat/distribution-totals-bracket
feat(distribution): show combined projected + current percentage
This commit is contained in:
2 files changed
+22
-65
No files matched your search
@@ -377,70 +377,9 @@ def calculate_percentage_distribution(currency_totals):
|
||||
"expense_projected": 0,
|
||||
}
|
||||
|
||||
# If there's exchanged data, calculate percentages for that too
|
||||
if "exchanged" in data:
|
||||
exchanged_total = sum(
|
||||
[
|
||||
abs(data.get("exchanged", {}).get("income_current", Decimal("0"))),
|
||||
abs(
|
||||
data.get("exchanged", {}).get("income_projected", Decimal("0"))
|
||||
),
|
||||
abs(data.get("exchanged", {}).get("expense_current", Decimal("0"))),
|
||||
abs(data.get("exchanged", {}).get("income_current", Decimal("0"))),
|
||||
]
|
||||
)
|
||||
|
||||
percentages[currency_id]["exchanged"] = {
|
||||
"currency": data["exchanged"]["currency"],
|
||||
"percentages": {},
|
||||
}
|
||||
|
||||
if exchanged_total > 0:
|
||||
percentages[currency_id]["exchanged"]["percentages"] = {
|
||||
"income_current": (
|
||||
abs(
|
||||
data.get("exchanged", {}).get(
|
||||
"income_current", Decimal("0")
|
||||
)
|
||||
)
|
||||
/ exchanged_total
|
||||
)
|
||||
* 100,
|
||||
"income_projected": (
|
||||
abs(
|
||||
data.get("exchanged", {}).get(
|
||||
"income_projected", Decimal("0")
|
||||
)
|
||||
)
|
||||
/ exchanged_total
|
||||
)
|
||||
* 100,
|
||||
"expense_current": (
|
||||
abs(
|
||||
data.get("exchanged", {}).get(
|
||||
"expense_current", Decimal("0")
|
||||
)
|
||||
)
|
||||
/ exchanged_total
|
||||
)
|
||||
* 100,
|
||||
"expense_projected": (
|
||||
abs(
|
||||
data.get("exchanged", {}).get(
|
||||
"income_current", Decimal("0")
|
||||
)
|
||||
)
|
||||
/ exchanged_total
|
||||
)
|
||||
* 100,
|
||||
}
|
||||
else:
|
||||
percentages[currency_id]["exchanged"]["percentages"] = {
|
||||
"income_current": 0,
|
||||
"income_projected": 0,
|
||||
"expense_current": 0,
|
||||
"expense_projected": 0,
|
||||
}
|
||||
p = percentages[currency_id]["percentages"]
|
||||
p["income_total"] = p["income_current"] + p["income_projected"]
|
||||
p["expense_total"] = p["expense_current"] + p["expense_projected"]
|
||||
|
||||
return percentages
|
||||
|
||||
|
||||
@@ -54,4 +54,22 @@
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% with p=percentage.percentages %}
|
||||
{% if p.income_projected > 0 and p.income_current > 0 or p.expense_projected > 0 and p.expense_current > 0 %}
|
||||
<div class="flex w-full text-xs text-base-content/70" aria-hidden="true">
|
||||
<div style="width: {{ p.income_total|floatformat:'2u' }}%">
|
||||
{% if p.income_projected > 0 and p.income_current > 0 %}
|
||||
<div class="h-1.5 border-x border-b border-base-content/40 rounded-b mx-px"></div>
|
||||
<div class="text-center">{{ p.income_total|floatformat:2 }}%</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div style="width: {{ p.expense_total|floatformat:'2u' }}%">
|
||||
{% if p.expense_projected > 0 and p.expense_current > 0 %}
|
||||
<div class="h-1.5 border-x border-b border-base-content/40 rounded-b mx-px"></div>
|
||||
<div class="text-center">{{ p.expense_total|floatformat:2 }}%</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
Reference in new issue
Block a user