mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Tag view update.
This commit is contained in:
parent
37250cbde3
commit
260ef1a07e
@ -194,17 +194,13 @@ class TagController extends Controller
|
|||||||
$end = null;
|
$end = null;
|
||||||
$periods = new Collection;
|
$periods = new Collection;
|
||||||
$apiKey = env('GOOGLE_MAPS_API_KEY', '');
|
$apiKey = env('GOOGLE_MAPS_API_KEY', '');
|
||||||
$sum = '0';
|
|
||||||
$path = route('tags.show', [$tag->id]);
|
$path = route('tags.show', [$tag->id]);
|
||||||
|
|
||||||
|
|
||||||
// prep for "all" view.
|
// prep for "all" view.
|
||||||
if ($moment === 'all') {
|
if ($moment === 'all') {
|
||||||
$subTitle = trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);
|
$subTitle = trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);
|
||||||
$start = $repository->firstUseDate($tag);
|
$start = $repository->firstUseDate($tag);
|
||||||
$end = new Carbon;
|
$end = new Carbon;
|
||||||
$sum = $repository->sumOfTag($tag, null, null);
|
|
||||||
$result = $repository->resultOfTag($tag, null, null);
|
|
||||||
$path = route('tags.show', [$tag->id, 'all']);
|
$path = route('tags.show', [$tag->id, 'all']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,20 +214,16 @@ class TagController extends Controller
|
|||||||
'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
||||||
);
|
);
|
||||||
$periods = $this->getPeriodOverview($tag);
|
$periods = $this->getPeriodOverview($tag);
|
||||||
$sum = $repository->sumOfTag($tag, $start, $end);
|
|
||||||
$result = $repository->resultOfTag($tag, $start, $end);
|
|
||||||
$path = route('tags.show', [$tag->id, $moment]);
|
$path = route('tags.show', [$tag->id, $moment]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// prep for current period
|
// prep for current period
|
||||||
if (strlen($moment) === 0) {
|
if (strlen($moment) === 0) {
|
||||||
/** @var Carbon $start */
|
/** @var Carbon $start */
|
||||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||||
/** @var Carbon $end */
|
/** @var Carbon $end */
|
||||||
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||||
$periods = $this->getPeriodOverview($tag);
|
$periods = $this->getPeriodOverview($tag);
|
||||||
$sum = $repository->sumOfTag($tag, $start, $end);
|
|
||||||
$result = $repository->resultOfTag($tag, $start, $end);
|
|
||||||
$subTitle = trans(
|
$subTitle = trans(
|
||||||
'firefly.journals_in_period_for_tag',
|
'firefly.journals_in_period_for_tag',
|
||||||
['tag' => $tag->tag, 'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
['tag' => $tag->tag, 'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
||||||
@ -245,8 +237,9 @@ class TagController extends Controller
|
|||||||
$journals = $collector->getPaginatedJournals();
|
$journals = $collector->getPaginatedJournals();
|
||||||
$journals->setPath($path);
|
$journals->setPath($path);
|
||||||
|
|
||||||
|
$sums = $repository->sumsOfTag($tag, $start, $end);
|
||||||
|
|
||||||
return view('tags.show', compact('apiKey', 'tag', 'result', 'periods', 'subTitle', 'subTitleIcon', 'journals', 'sum', 'start', 'end', 'moment'));
|
return view('tags.show', compact('apiKey', 'tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'journals', 'start', 'end', 'moment'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,34 +186,6 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
return new Carbon;
|
return new Carbon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Same as sum of tag but substracts income instead of adding it as well.
|
|
||||||
*
|
|
||||||
* @param Tag $tag
|
|
||||||
* @param Carbon|null $start
|
|
||||||
* @param Carbon|null $end
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function resultOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): string
|
|
||||||
{
|
|
||||||
/** @var JournalCollectorInterface $collector */
|
|
||||||
$collector = app(JournalCollectorInterface::class);
|
|
||||||
|
|
||||||
if (!is_null($start) && !is_null($end)) {
|
|
||||||
$collector->setRange($start, $end);
|
|
||||||
}
|
|
||||||
|
|
||||||
$collector->setAllAssetAccounts()->setTag($tag);
|
|
||||||
$journals = $collector->getJournals();
|
|
||||||
$sum = '0';
|
|
||||||
foreach ($journals as $journal) {
|
|
||||||
$sum = bcadd($sum, strval($journal->transaction_amount));
|
|
||||||
}
|
|
||||||
|
|
||||||
return strval($sum);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
@ -290,6 +262,43 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
return strval($sum);
|
return strval($sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Tag $tag
|
||||||
|
* @param Carbon|null $start
|
||||||
|
* @param Carbon|null $end
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function sumsOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): array
|
||||||
|
{
|
||||||
|
/** @var JournalCollectorInterface $collector */
|
||||||
|
$collector = app(JournalCollectorInterface::class);
|
||||||
|
|
||||||
|
if (!is_null($start) && !is_null($end)) {
|
||||||
|
$collector->setRange($start, $end);
|
||||||
|
}
|
||||||
|
|
||||||
|
$collector->setAllAssetAccounts()->setTag($tag);
|
||||||
|
$journals = $collector->getJournals();
|
||||||
|
|
||||||
|
$sums = [
|
||||||
|
TransactionType::WITHDRAWAL => '0',
|
||||||
|
TransactionType::DEPOSIT => '0',
|
||||||
|
TransactionType::TRANSFER => '0',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($journals as $journal) {
|
||||||
|
$amount = app('steam')->positive(strval($journal->transaction_amount));
|
||||||
|
$type = $journal->transaction_type_type;
|
||||||
|
if ($type === TransactionType::WITHDRAWAL) {
|
||||||
|
$amount = bcmul($amount, '-1');
|
||||||
|
}
|
||||||
|
$sums[$type] = bcadd($sums[$type], $amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sums;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a tag cloud.
|
* Generates a tag cloud.
|
||||||
*
|
*
|
||||||
|
@ -103,15 +103,6 @@ interface TagRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function lastUseDate(Tag $tag): Carbon;
|
public function lastUseDate(Tag $tag): Carbon;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Tag $tag
|
|
||||||
* @param Carbon|null $start
|
|
||||||
* @param Carbon|null $end
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function resultOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
@ -126,6 +117,17 @@ interface TagRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function spentInPeriod(Tag $tag, Carbon $start, Carbon $end): string;
|
public function spentInPeriod(Tag $tag, Carbon $start, Carbon $end): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates various amounts in tag.
|
||||||
|
*
|
||||||
|
* @param Tag $tag
|
||||||
|
* @param Carbon|null $start
|
||||||
|
* @param Carbon|null $end
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function sumsOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method stores a tag.
|
* This method stores a tag.
|
||||||
*
|
*
|
||||||
|
@ -329,6 +329,7 @@ return [
|
|||||||
'without_date' => 'Without date',
|
'without_date' => 'Without date',
|
||||||
'result' => 'Result',
|
'result' => 'Result',
|
||||||
'total_result' => 'Total result',
|
'total_result' => 'Total result',
|
||||||
|
'sums_apply_to_range' => 'All sums apply to the selected range',
|
||||||
|
|
||||||
// preferences
|
// preferences
|
||||||
'pref_home_screen_accounts' => 'Home screen accounts',
|
'pref_home_screen_accounts' => 'Home screen accounts',
|
||||||
|
@ -12,76 +12,80 @@ declare(strict_types=1);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'buttons' => 'Buttons',
|
'buttons' => 'Buttons',
|
||||||
'icon' => 'Icon',
|
'icon' => 'Icon',
|
||||||
'id' => 'ID',
|
'id' => 'ID',
|
||||||
'create_date' => 'Created at',
|
'create_date' => 'Created at',
|
||||||
'update_date' => 'Updated at',
|
'update_date' => 'Updated at',
|
||||||
'balance_before' => 'Balance before',
|
'balance_before' => 'Balance before',
|
||||||
'balance_after' => 'Balance after',
|
'balance_after' => 'Balance after',
|
||||||
'name' => 'Name',
|
'name' => 'Name',
|
||||||
'role' => 'Role',
|
'role' => 'Role',
|
||||||
'currentBalance' => 'Current balance',
|
'currentBalance' => 'Current balance',
|
||||||
'active' => 'Is active?',
|
'active' => 'Is active?',
|
||||||
'lastActivity' => 'Last activity',
|
'lastActivity' => 'Last activity',
|
||||||
'balanceDiff' => 'Balance difference between :start and :end',
|
'balanceDiff' => 'Balance difference between :start and :end',
|
||||||
'matchesOn' => 'Matched on',
|
'matchesOn' => 'Matched on',
|
||||||
'account_type' => 'Account type',
|
'account_type' => 'Account type',
|
||||||
'created_at' => 'Created at',
|
'created_at' => 'Created at',
|
||||||
'account' => 'Account',
|
'account' => 'Account',
|
||||||
'matchingAmount' => 'Amount',
|
'matchingAmount' => 'Amount',
|
||||||
'split_number' => 'Split #',
|
'split_number' => 'Split #',
|
||||||
'destination' => 'Destination',
|
'destination' => 'Destination',
|
||||||
'source' => 'Source',
|
'source' => 'Source',
|
||||||
'next_expected_match' => 'Next expected match',
|
'next_expected_match' => 'Next expected match',
|
||||||
'automatch' => 'Auto match?',
|
'automatch' => 'Auto match?',
|
||||||
'repeat_freq' => 'Repeats',
|
'repeat_freq' => 'Repeats',
|
||||||
'description' => 'Description',
|
'description' => 'Description',
|
||||||
'amount' => 'Amount',
|
'amount' => 'Amount',
|
||||||
'internal_reference' => 'Internal reference',
|
'internal_reference' => 'Internal reference',
|
||||||
'date' => 'Date',
|
'date' => 'Date',
|
||||||
'interest_date' => 'Interest date',
|
'interest_date' => 'Interest date',
|
||||||
'book_date' => 'Book date',
|
'book_date' => 'Book date',
|
||||||
'process_date' => 'Processing date',
|
'process_date' => 'Processing date',
|
||||||
'due_date' => 'Due date',
|
'due_date' => 'Due date',
|
||||||
'payment_date' => 'Payment date',
|
'payment_date' => 'Payment date',
|
||||||
'invoice_date' => 'Invoice date',
|
'invoice_date' => 'Invoice date',
|
||||||
'interal_reference' => 'Internal reference',
|
'interal_reference' => 'Internal reference',
|
||||||
'notes' => 'Notes',
|
'notes' => 'Notes',
|
||||||
'from' => 'From',
|
'from' => 'From',
|
||||||
'piggy_bank' => 'Piggy bank',
|
'piggy_bank' => 'Piggy bank',
|
||||||
'to' => 'To',
|
'to' => 'To',
|
||||||
'budget' => 'Budget',
|
'budget' => 'Budget',
|
||||||
'category' => 'Category',
|
'category' => 'Category',
|
||||||
'bill' => 'Bill',
|
'bill' => 'Bill',
|
||||||
'withdrawal' => 'Withdrawal',
|
'withdrawal' => 'Withdrawal',
|
||||||
'deposit' => 'Deposit',
|
'deposit' => 'Deposit',
|
||||||
'transfer' => 'Transfer',
|
'transfer' => 'Transfer',
|
||||||
'type' => 'Type',
|
'type' => 'Type',
|
||||||
'completed' => 'Completed',
|
'completed' => 'Completed',
|
||||||
'iban' => 'IBAN',
|
'iban' => 'IBAN',
|
||||||
'paid_current_period' => 'Paid this period',
|
'paid_current_period' => 'Paid this period',
|
||||||
'email' => 'Email',
|
'email' => 'Email',
|
||||||
'registered_at' => 'Registered at',
|
'registered_at' => 'Registered at',
|
||||||
'is_blocked' => 'Is blocked',
|
'is_blocked' => 'Is blocked',
|
||||||
'is_admin' => 'Is admin',
|
'is_admin' => 'Is admin',
|
||||||
'has_two_factor' => 'Has 2FA',
|
'has_two_factor' => 'Has 2FA',
|
||||||
'blocked_code' => 'Block code',
|
'blocked_code' => 'Block code',
|
||||||
'source_account' => 'Source account',
|
'source_account' => 'Source account',
|
||||||
'destination_account' => 'Destination account',
|
'destination_account' => 'Destination account',
|
||||||
'accounts_count' => 'Number of accounts',
|
'accounts_count' => 'Number of accounts',
|
||||||
'journals_count' => 'Number of transactions',
|
'journals_count' => 'Number of transactions',
|
||||||
'attachments_count' => 'Number of attachments',
|
'attachments_count' => 'Number of attachments',
|
||||||
'bills_count' => 'Number of bills',
|
'bills_count' => 'Number of bills',
|
||||||
'categories_count' => 'Number of categories',
|
'categories_count' => 'Number of categories',
|
||||||
'export_jobs_count' => 'Number of export jobs',
|
'export_jobs_count' => 'Number of export jobs',
|
||||||
'import_jobs_count' => 'Number of import jobs',
|
'import_jobs_count' => 'Number of import jobs',
|
||||||
'budget_count' => 'Number of budgets',
|
'budget_count' => 'Number of budgets',
|
||||||
'rule_and_groups_count' => 'Number of rules and rule groups',
|
'rule_and_groups_count' => 'Number of rules and rule groups',
|
||||||
'tags_count' => 'Number of tags',
|
'tags_count' => 'Number of tags',
|
||||||
'inward' => 'Inward description',
|
'inward' => 'Inward description',
|
||||||
'outward' => 'Outward description',
|
'outward' => 'Outward description',
|
||||||
'number_of_transactions' => 'Number of transactions',
|
'number_of_transactions' => 'Number of transactions',
|
||||||
'total_amount' => 'Total amount',
|
'total_amount' => 'Total amount',
|
||||||
|
'sum' => 'Sum',
|
||||||
|
'sum_excluding_transfers' => 'Sum (excluding transfers)',
|
||||||
|
'sum_withdrawals' => 'Sum of withdrawals',
|
||||||
|
'sum_deposits' => 'Sum of deposits',
|
||||||
|
'sum_transfers' => 'Sum of transfers',
|
||||||
];
|
];
|
||||||
|
@ -26,34 +26,56 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body no-padding">
|
||||||
|
<table class="table table-bordered">
|
||||||
{% if tag.description %}
|
{% if tag.description %}
|
||||||
<p class="text-info">
|
<tr>
|
||||||
{{ tag.description }}
|
<td>
|
||||||
</p>
|
{{ trans('list.description') }}
|
||||||
{% endif %}
|
</td>
|
||||||
|
<td>{{ tag.description }}</td>
|
||||||
{% if tag.date %}
|
</tr>
|
||||||
<p>{{ 'date'|_ }}: {{ tag.date.formatLocalized(monthAndDayFormat) }}</p>
|
{% endif %}
|
||||||
{% endif %}
|
{% if tag.date %}
|
||||||
{% if moment == 'all' %}
|
<tr>
|
||||||
<p>
|
<td>
|
||||||
{{ 'total_sum'|_ }}: {{ sum|formatAmount }}<br/>
|
{{ trans('list.date') }}
|
||||||
{{ 'total_result'|_ }}: {{ result|formatAmount }}<br/>
|
</td>
|
||||||
</p>
|
<td>
|
||||||
{% else %}
|
{{ tag.date.formatLocalized(monthAndDayFormat) }}
|
||||||
<p>
|
</td>
|
||||||
{{ 'sum'|_ }}: {{ sum|formatAmount }}<br/>
|
</tr>
|
||||||
{{ 'result'|_ }}: {{ result|formatAmount }}<br/>
|
{% endif %}
|
||||||
</p>
|
<tr>
|
||||||
{% endif %}
|
<td>{{ trans('list.sum') }}</td>
|
||||||
<div class="btn-group">
|
<td> {{ (sums.Withdrawal + sums.Transfer + sums.Deposit)|formatAmount }}</td>
|
||||||
<a href="{{ route('tags.edit',tag.id) }}" class="btn btn-default">
|
</tr>
|
||||||
<i class="fa fa-pencil fa-fw"></i> {{ trans('firefly.edit_tag',{tag: tag.tag}) }}</a>
|
<tr>
|
||||||
<a href="{{ route('tags.delete',tag.id) }}" class="btn btn-danger"><i
|
<td>{{ trans('list.sum_excluding_transfers') }}</td>
|
||||||
class="fa fa-trash fa-fw"></i> {{ trans('firefly.delete_tag',{tag: tag.tag}) }}</a>
|
<td> {{ (sums.Withdrawal + sums.Deposit)|formatAmount }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ trans('list.sum_withdrawals') }}</td>
|
||||||
|
<td> {{ sums.Withdrawal|formatAmount }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ trans('list.sum_deposits') }}</td>
|
||||||
|
<td> {{ sums.Deposit|formatAmount }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ trans('list.sum_transfers') }}</td>
|
||||||
|
<td> {{ sums.Transfer|formatAmount }}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="box-footer">
|
||||||
|
<div class="btn-group btn-group-sm">
|
||||||
|
<a href="{{ route('tags.edit',tag.id) }}" class="btn btn-default"><i class="fa fa-pencil fa-fw"></i></a>
|
||||||
|
<a href="{{ route('tags.delete',tag.id) }}" class="btn btn-danger"><i class="fa fa-trash fa-fw"></i></a>
|
||||||
</div>
|
</div>
|
||||||
|
<p class="text-muted">
|
||||||
|
<small>{{ 'sums_apply_to_range'|_ }}</small>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user