mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-23 14:26:58 +00:00
Expand view for #780
This commit is contained in:
@@ -17,6 +17,7 @@ use Carbon\Carbon;
|
|||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||||
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalTaskerInterface;
|
use FireflyIII\Repositories\Journal\JournalTaskerInterface;
|
||||||
@@ -28,7 +29,6 @@ use Log;
|
|||||||
use Navigation;
|
use Navigation;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Response;
|
use Response;
|
||||||
use Steam;
|
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -168,7 +168,7 @@ class TransactionController extends Controller
|
|||||||
$what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
$what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
||||||
$subTitle = trans('firefly.' . $what) . ' "' . e($journal->description) . '"';
|
$subTitle = trans('firefly.' . $what) . ' "' . e($journal->description) . '"';
|
||||||
|
|
||||||
return view('transactions.show', compact('journal', 'events', 'subTitle', 'what', 'transactions', 'linkTypes','links'));
|
return view('transactions.show', compact('journal', 'events', 'subTitle', 'what', 'transactions', 'linkTypes', 'links'));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ class TransactionController extends Controller
|
|||||||
$cache->addProperty('transaction-list-entries');
|
$cache->addProperty('transaction-list-entries');
|
||||||
|
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get(); // @codeCoverageIgnore
|
// return $cache->get(); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::debug(sprintf('Going to get period expenses and incomes between %s and %s.', $start->format('Y-m-d'), $end->format('Y-m-d')));
|
Log::debug(sprintf('Going to get period expenses and incomes between %s and %s.', $start->format('Y-m-d'), $end->format('Y-m-d')));
|
||||||
@@ -212,35 +212,24 @@ class TransactionController extends Controller
|
|||||||
$collector = app(JournalCollectorInterface::class);
|
$collector = app(JournalCollectorInterface::class);
|
||||||
$collector->setAllAssetAccounts()->setRange($end, $currentEnd)->withOpposingAccount()->setTypes($types);
|
$collector->setAllAssetAccounts()->setRange($end, $currentEnd)->withOpposingAccount()->setTypes($types);
|
||||||
$collector->removeFilter(InternalTransferFilter::class);
|
$collector->removeFilter(InternalTransferFilter::class);
|
||||||
$set = $collector->getJournals();
|
$journals = $collector->getJournals();
|
||||||
$sum = $set->sum('transaction_amount');
|
$sum = $journals->sum('transaction_amount');
|
||||||
$journals = $set->count();
|
|
||||||
|
// count per currency:
|
||||||
|
$sums = $this->sumPerCurrency($journals);
|
||||||
$dateStr = $end->format('Y-m-d');
|
$dateStr = $end->format('Y-m-d');
|
||||||
$dateName = Navigation::periodShow($end, $range);
|
$dateName = Navigation::periodShow($end, $range);
|
||||||
$array = [
|
$array = [
|
||||||
'string' => $dateStr,
|
'string' => $dateStr,
|
||||||
'name' => $dateName,
|
'name' => $dateName,
|
||||||
'count' => $journals,
|
'sum' => $sum,
|
||||||
'spent' => 0,
|
'sums' => $sums,
|
||||||
'earned' => 0,
|
'date' => clone $end,
|
||||||
'transferred' => 0,
|
|
||||||
'date' => clone $end,
|
|
||||||
];
|
];
|
||||||
Log::debug(sprintf('What is %s', $what));
|
Log::debug(sprintf('What is %s', $what));
|
||||||
switch ($what) {
|
if ($journals->count() > 0) {
|
||||||
case 'withdrawal':
|
$entries->push($array);
|
||||||
$array['spent'] = $sum;
|
|
||||||
break;
|
|
||||||
case 'deposit':
|
|
||||||
$array['earned'] = $sum;
|
|
||||||
break;
|
|
||||||
case 'transfers':
|
|
||||||
case 'transfer':
|
|
||||||
$array['transferred'] = Steam::positive($sum);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
$entries->push($array);
|
|
||||||
$end = Navigation::subtractPeriod($end, $range, 1);
|
$end = Navigation::subtractPeriod($end, $range, 1);
|
||||||
}
|
}
|
||||||
Log::debug('End of loop');
|
Log::debug('End of loop');
|
||||||
@@ -249,4 +238,41 @@ class TransactionController extends Controller
|
|||||||
return $entries;
|
return $entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $collection
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function sumPerCurrency(Collection $collection): array
|
||||||
|
{
|
||||||
|
$return = [];
|
||||||
|
/** @var Transaction $transaction */
|
||||||
|
foreach ($collection as $transaction) {
|
||||||
|
$currencyId = $transaction->transaction_currency_id;
|
||||||
|
|
||||||
|
// save currency information:
|
||||||
|
if (!isset($return[$currencyId])) {
|
||||||
|
$currencySymbol = $transaction->transaction_currency_symbol;
|
||||||
|
$decimalPlaces = $transaction->transaction_currency_dp;
|
||||||
|
$currencyCode = $transaction->transaction_currency_code;
|
||||||
|
$return[$currencyId] = [
|
||||||
|
'currency' => [
|
||||||
|
'id' => $currencyId,
|
||||||
|
'code' => $currencyCode,
|
||||||
|
'symbol' => $currencySymbol,
|
||||||
|
'dp' => $decimalPlaces,
|
||||||
|
],
|
||||||
|
'sum' => '0',
|
||||||
|
'count' => 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
// save amount:
|
||||||
|
$return[$currencyId]['sum'] = bcadd($return[$currencyId]['sum'], $transaction->transaction_amount);
|
||||||
|
$return[$currencyId]['count']++;
|
||||||
|
}
|
||||||
|
asort($return);
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -22,43 +22,47 @@ use Watson\Validating\ValidatingTrait;
|
|||||||
/**
|
/**
|
||||||
* Class Transaction
|
* Class Transaction
|
||||||
*
|
*
|
||||||
* @property-read int $journal_id
|
* @property-read int $journal_id
|
||||||
* @property-read Carbon $date
|
* @property-read Carbon $date
|
||||||
* @property-read string $transaction_description
|
* @property-read string $transaction_description
|
||||||
* @property-read string $transaction_amount
|
* @property-read string $transaction_amount
|
||||||
* @property-read string $transaction_foreign_amount
|
* @property-read string $transaction_foreign_amount
|
||||||
* @property-read string $transaction_type_type
|
* @property-read string $transaction_type_type
|
||||||
*
|
*
|
||||||
* @property-read int $account_id
|
* @property-read int $account_id
|
||||||
* @property-read string $account_name
|
* @property-read string $account_name
|
||||||
* @property string $account_iban
|
* @property string $account_iban
|
||||||
* @property string $account_number
|
* @property string $account_number
|
||||||
* @property string $account_bic
|
* @property string $account_bic
|
||||||
* @property string $account_currency_code
|
* @property string $account_currency_code
|
||||||
*
|
*
|
||||||
* @property-read int $opposing_account_id
|
* @property-read int $opposing_account_id
|
||||||
* @property string $opposing_account_name
|
* @property string $opposing_account_name
|
||||||
* @property string $opposing_account_iban
|
* @property string $opposing_account_iban
|
||||||
* @property string $opposing_account_number
|
* @property string $opposing_account_number
|
||||||
* @property string $opposing_account_bic
|
* @property string $opposing_account_bic
|
||||||
* @property string $opposing_currency_code
|
* @property string $opposing_currency_code
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @property-read int $transaction_budget_id
|
* @property-read int $transaction_budget_id
|
||||||
* @property-read string $transaction_budget_name
|
* @property-read string $transaction_budget_name
|
||||||
* @property-read int $transaction_journal_budget_id
|
* @property-read int $transaction_journal_budget_id
|
||||||
* @property-read string $transaction_journal_budget_name
|
* @property-read string $transaction_journal_budget_name
|
||||||
*
|
*
|
||||||
* @property-read int $transaction_category_id
|
* @property-read int $transaction_category_id
|
||||||
* @property-read string $transaction_category_name
|
* @property-read string $transaction_category_name
|
||||||
* @property-read int $transaction_journal_category_id
|
* @property-read int $transaction_journal_category_id
|
||||||
* @property-read string $transaction_journal_category_name
|
* @property-read string $transaction_journal_category_name
|
||||||
*
|
*
|
||||||
* @property-read int $bill_id
|
* @property-read int $bill_id
|
||||||
* @property string $bill_name
|
* @property string $bill_name
|
||||||
*
|
*
|
||||||
* @property string $notes
|
* @property string $notes
|
||||||
* @property string $tags
|
* @property string $tags
|
||||||
|
*
|
||||||
|
* @property string $transaction_currency_symbol
|
||||||
|
* @property int $transaction_currency_dp
|
||||||
|
* @property string $transaction_currency_code
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Models
|
* @package FireflyIII\Models
|
||||||
*/
|
*/
|
||||||
|
@@ -158,6 +158,7 @@ return [
|
|||||||
'Lang',
|
'Lang',
|
||||||
'Preferences',
|
'Preferences',
|
||||||
'URL',
|
'URL',
|
||||||
|
'Steam',
|
||||||
'Config',
|
'Config',
|
||||||
'Request',
|
'Request',
|
||||||
'ExpandedForm' => [
|
'ExpandedForm' => [
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{# list with journals #}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="{% if periods.count > 0 %}col-lg-10 col-md-10 col-sm-12{% else %}col-lg-12 col-md-12 col-sm-12{% endif %}">
|
<div class="{% if periods.count > 0 %}col-lg-10 col-md-10 col-sm-12{% else %}col-lg-12 col-md-12 col-sm-12{% endif %}">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
@@ -22,7 +23,10 @@
|
|||||||
<h3 class="box-title">{{ subTitle }}</h3>
|
<h3 class="box-title">{{ subTitle }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body ">
|
<div class="box-body ">
|
||||||
|
{# actual list #}
|
||||||
{% include 'list.journals' with {'journals': journals} %}
|
{% include 'list.journals' with {'journals': journals} %}
|
||||||
|
|
||||||
|
{# links for other views #}
|
||||||
{% if periods.count > 0 %}
|
{% if periods.count > 0 %}
|
||||||
<p>
|
<p>
|
||||||
<i class="fa fa-calendar"></i>
|
<i class="fa fa-calendar"></i>
|
||||||
@@ -38,10 +42,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{# boxes with info #}
|
||||||
{% if periods.count > 0 %}
|
{% if periods.count > 0 %}
|
||||||
<div class="col-lg-2 col-md-2 col-sm-12 col-xs-12">
|
<div class="col-lg-2 col-md-2 col-sm-12 col-xs-12">
|
||||||
{% for period in periods %}
|
{% for period in periods %}
|
||||||
{% if period.count > 0 %}
|
|
||||||
|
{% if period.sum != 0 %}
|
||||||
|
|
||||||
<div class="box {% if period.date == start %}box-solid box-primary{% endif %}">
|
<div class="box {% if period.date == start %}box-solid box-primary{% endif %}">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title"><a href="{{ route('transactions.index',[what, period.string]) }}">{{ period.name }}</a>
|
<h3 class="box-title"><a href="{{ route('transactions.index',[what, period.string]) }}">{{ period.name }}</a>
|
||||||
@@ -49,29 +56,34 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="box-body no-padding">
|
<div class="box-body no-padding">
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<tr>
|
<tbody>
|
||||||
<td style="width:33%;">{{ 'transactions'|_ }}</td>
|
{% for sum in period.sums %}
|
||||||
<td style="text-align: right;">{{ period.count }}</td>
|
|
||||||
</tr>
|
|
||||||
{% if what == 'withdrawal' %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width:33%;">{{ 'spent'|_ }}</td>
|
<td style="width:33%;">
|
||||||
<td style="text-align: right;">{{ period.spent|formatAmount }}</td>
|
{% if what == 'withdrawal' %}
|
||||||
|
{{ 'spent'|_ }}
|
||||||
|
{% endif %}
|
||||||
|
{% if what == 'deposit' %}
|
||||||
|
{{ 'earned'|_ }}
|
||||||
|
{% endif %}
|
||||||
|
{% if what == 'transfers' or what == 'transfer' %}
|
||||||
|
{{ 'transferred'|_ }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td style="text-align: right;" title="{{ trans('list.number_of_transactions') }}: {{ sum.count }}">
|
||||||
|
{% if what == 'transfers' or what == 'transfer' %}
|
||||||
|
<span class="text-info">
|
||||||
|
{{ formatAmountBySymbol(Steam.positive(sum.sum), sum.currency.symbol, sum.currency.dp, false) }}
|
||||||
|
</span>
|
||||||
|
{% else %}
|
||||||
|
{{ formatAmountBySymbol(sum.sum, sum.currency.symbol, sum.currency.dp) }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endfor %}
|
||||||
{% if what == 'deposit' %}
|
</tbody>
|
||||||
<tr>
|
|
||||||
<td style="width:33%;">{{ 'earned'|_ }}</td>
|
|
||||||
<td style="text-align: right;">{{ period.earned|formatAmount }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
{% if what == 'transfers' or what == 'transfer' %}
|
|
||||||
<tr>
|
|
||||||
<td style="width:33%;">{{ 'transferred'|_ }}</td>
|
|
||||||
<td style="text-align: right;" class="text-info">{{ period.transferred|formatAmountPlain }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Reference in New Issue
Block a user