Skip to content

Firefly III: a personal finances manager

Expand the visible balances and sums.

James Coleb9412ea61158
diff --git a/resources/assets/v3/js/pages/accounts/index.js b/resources/assets/v3/js/pages/accounts/index.js
index b0f3b34b3c..f05c404cd1 100644
--- a/resources/assets/v3/js/pages/accounts/index.js
+++ b/resources/assets/v3/js/pages/accounts/index.js
@@ -163,58 +163,42 @@ let index = function () {
if (Object.hasOwn(response.data.data, i)) {
let current = response.data.data[i];
- // collect sums and debts for each account (in primary or not):
- this.sums[current.attributes.currency_code] =
- this.sums[current.attributes.currency_code] || 0;
- this.sums[current.attributes.primary_currency_code] =
- this.sums[current.attributes.primary_currency_code] || 0;
- this.debts[current.attributes.currency_code] =
- this.debts[current.attributes.currency_code] || 0;
- this.debts[current.attributes.primary_currency_code] =
- this.debts[current.attributes.primary_currency_code] || 0;
+ // collect sums, debts and differences for each account (in primary or not):
+ this.sums[current.attributes.currency_code] = this.sums[current.attributes.currency_code] || 0;
+ this.sums[current.attributes.primary_currency_code] = this.sums[current.attributes.primary_currency_code] || 0;
+ this.debts[current.attributes.currency_code] = this.debts[current.attributes.currency_code] || 0;
+ this.debts[current.attributes.primary_currency_code] = this.debts[current.attributes.primary_currency_code] || 0;
+ this.differences[current.attributes.currency_code] = this.differences[current.attributes.currency_code] || 0;
+ this.differences[current.attributes.primary_currency_code] = this.differences[current.attributes.primary_currency_code] || 0;
- let balanceDifference = formatMoney(
- current.attributes.balance_difference,
- current.attributes.currency_code,
- true,
- );
+ let balanceDifference = formatMoney(current.attributes.balance_difference, current.attributes.currency_code, true,);
let balanceDiffFloat = parseFloat(current.attributes.balance_difference);
- let currentBalance = formatMoney(
- current.attributes.current_balance,
- current.attributes.currency_code,
- );
+ let currentBalance = formatMoney(current.attributes.current_balance, current.attributes.currency_code,);
let currentBalanceFloat = parseFloat(current.attributes.current_balance);
- let currentDebt = formatMoney(
- current.attributes.debt_amount,
- current.attributes.currency_code,
- );
+
+ let currentDebt = formatMoney(current.attributes.debt_amount, current.attributes.currency_code,);
let currentDebtFloat = parseFloat(current.attributes.debt_amount);
// this.sums[current.attributes.currency_code] += currentBalanceFloat;
if (!convertToPrimary) {
this.sums[current.attributes.currency_code] += currentBalanceFloat;
this.debts[current.attributes.currency_code] += currentDebtFloat;
+ this.differences[current.attributes.currency_code] += balanceDiffFloat;
}
if (convertToPrimary) {
- balanceDifference = formatMoney(
- current.attributes.pc_balance_difference,
- current.attributes.primary_currency_code,
- true,
- );
+ balanceDifference = formatMoney(current.attributes.pc_balance_difference, current.attributes.primary_currency_code, true,);
balanceDiffFloat = parseFloat(current.attributes.pc_balance_difference);
- currentBalance = formatMoney(
- current.attributes.pc_current_balance,
- current.attributes.primary_currency_code,
- );
+
+ currentBalance = formatMoney(current.attributes.pc_current_balance, current.attributes.primary_currency_code,);
currentBalanceFloat = parseFloat(current.attributes.pc_current_balance);
- currentDebt = formatMoney(
- current.attributes.pc_debt_amount,
- current.attributes.primary_currency_code,
- );
+
+ currentDebt = formatMoney(current.attributes.pc_debt_amount, current.attributes.primary_currency_code,);
currentDebtFloat = parseFloat(current.attributes.pc_debt_amount);
+
this.sums[current.attributes.primary_currency_code] += currentBalanceFloat;
this.debts[current.attributes.primary_currency_code] += currentDebtFloat;
+ this.differences[current.attributes.primary_currency_code] += balanceDiffFloat;
}
let lastActivity = this.formatDate(current.attributes.last_activity);
let noLastActivity = false;
diff --git a/resources/views/accounts/index.blade.php b/resources/views/accounts/index.blade.php
index 6c564180b7..58fb9050eb 100644
--- a/resources/views/accounts/index.blade.php
+++ b/resources/views/accounts/index.blade.php
@@ -23,7 +23,7 @@
<span class="visually-hidden">{{ __('firefly.thinking') }}</span>
</div>
</div>
- <table class="table table-bordered table-valign-middle table-sm table-hover sortable">
+ <table class="table table-valign-middle table-sm table-hover sortable">
<thead>
<tr>
<th data-column="order"
@@ -219,6 +219,7 @@
<template x-if="'liabilities' === objectType">
<td colspan="3">&nbsp;</td>
</template>
+ <template x-if="'liabilities' !== objectType">
<td class="text-end">
<template x-for="(sum, code) in sums">
<span>
@@ -234,15 +235,58 @@
<br>
</span>
</template>
-
</span>
</template>
</td>
+ </template>
<template x-if="'liabilities' === objectType">
- <td colspan="3">&nbsp;</td>
+ <td class="text-end">
+ <template x-for="(sum, code) in debts">
+ <span>
+ <template x-if="sum > 0">
+ <span>
+ <span class="money-positive" x-text="formatMoney(sum, code)"></span>
+ <br>
+ </span>
+ </template>
+ <template x-if="sum < 0">
+ <span>
+ <span class="money-negative" x-text="formatMoney(sum, code)"></span>
+ <br>
+ </span>
+ </template>
+ </span>
+ </template>
+ </td>
</template>
+ <td>&nbsp;</td> <!-- is active column -->
<template x-if="'liabilities' !== objectType">
- <td colspan="4">&nbsp;</td>
+ <td>&nbsp;</td> {{-- last activity column --}}
+ </template>
+ <td class="text-end">
+ <template x-for="(sum, code) in differences">
+ <span>
+ <template x-if="sum > 0">
+ <span>
+ <span class="money-positive" x-text="formatMoney(sum, code)"></span>
+ <br>
+ </span>
+ </template>
+ <template x-if="sum < 0">
+ <span>
+ <span class="money-negative" x-text="formatMoney(sum, code)"></span>
+ <br>
+ </span>
+ </template>
+ </span>
+ </template>
+ </td>
+ <template x-if="'liabilities' === objectType">
+ <td>&nbsp;</td>
+ </template>
+
+ <template x-if="'liabilities' !== objectType">
+ <td>&nbsp;</td>
</template>
</tr>
</tfoot>