Some amount fixes.

This commit is contained in:
James Cole 2015-10-03 22:29:34 +02:00
parent ac0280d460
commit 8321663815

View File

@ -50,6 +50,7 @@
{% for limit in limits %} {% for limit in limits %}
{% for rep in limit.limitRepetitions %} {% for rep in limit.limitRepetitions %}
{% set spentInRep = (spentInRepetitionCorrected(rep)*-1) %}
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title"><a href="{{ route('budgets.show',[budget.id,rep.id]) }}">{{ rep.startdate.formatLocalized(monthFormat) }}</a> <h3 class="box-title"><a href="{{ route('budgets.show',[budget.id,rep.id]) }}">{{ rep.startdate.formatLocalized(monthFormat) }}</a>
@ -61,15 +62,15 @@
{{ 'amount'|_ }}: {{ rep.amount|formatAmount }} {{ 'amount'|_ }}: {{ rep.amount|formatAmount }}
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-6 col-md-6 col-sm-6">
{{ 'spent'|_ }}: {{ spentInRepetitionCorrected(rep)|formatAmount }} {{ 'spent'|_ }}: <span class="text-danger">{{ spentInRep|formatAmountPlain }}</span>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-lg-12 col-md-12 col-sm-12"> <div class="col-lg-12 col-md-12 col-sm-12">
{% set overspent = spentInRepetitionCorrected(rep) > rep.amount %} {% set overspent = spentInRep > rep.amount %}
{% if overspent %} {% if overspent %}
{% set spent = spentInRepetitionCorrected(rep) %} {% set pct = (spentInRep != 0 ? (rep.amount / spent)*100 : 0) %}
{% set pct = (spent != 0 ? (rep.amount / spent)*100 : 0) %}
<div class="progress progress-striped"> <div class="progress progress-striped">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="{{ pct|round }}" aria-valuemin="0" <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="{{ pct|round }}" aria-valuemin="0"
aria-valuemax="100" style="width: {{ pct|round }}%;"></div> aria-valuemax="100" style="width: {{ pct|round }}%;"></div>
@ -78,7 +79,7 @@
</div> </div>
{% else %} {% else %}
{% set amount = rep.amount %} {% set amount = rep.amount %}
{% set pct = (amount != 0 ? (spentInRepetitionCorrected(rep) / amount)*100 : 0) %} {% set pct = (amount != 0 ? spentInRep / amount)*100 : 0) %}
<div class="progress progress-striped"> <div class="progress progress-striped">
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="{{ pct|round }}" aria-valuemin="0" <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="{{ pct|round }}" aria-valuemin="0"
aria-valuemax="100" style="width: {{ pct|round }}%;"></div> aria-valuemax="100" style="width: {{ pct|round }}%;"></div>