mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-23 01:16:46 -06:00
Expand report email.
This commit is contained in:
parent
5d01955133
commit
49de4f2200
@ -90,7 +90,7 @@ class CreateRecurringTransactions implements ShouldQueue
|
||||
// will now send email to users.
|
||||
foreach ($result as $userId => $journals) {
|
||||
//// random bunch to make mail.
|
||||
$journals = TransactionJournal::where('user_id', $userId)->inRandomOrder()->take(1)->get();
|
||||
//$journals = TransactionJournal::where('user_id', $userId)->inRandomOrder()->take(1)->get();
|
||||
event(new RequestedReportOnJournals($userId, $journals));
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property bool $is_split
|
||||
* @property int $attachmentCount
|
||||
* @property int $transaction_currency_id
|
||||
* @property int $foreign_currency_id
|
||||
*/
|
||||
class Transaction extends Model
|
||||
{
|
||||
|
@ -96,10 +96,51 @@ class TransactionJournal extends Twig_Extension
|
||||
* @return string
|
||||
*/
|
||||
public function totalAmount(JournalModel $journal): string
|
||||
{
|
||||
$type = $journal->transactionType->type;
|
||||
$totals = $this->getTotalAmount($journal);
|
||||
$array = [];
|
||||
foreach ($totals as $total) {
|
||||
if (TransactionType::WITHDRAWAL === $type) {
|
||||
$total['amount'] = bcmul($total['amount'], '-1');
|
||||
}
|
||||
$array[] = app('amount')->formatAnything($total['currency'], $total['amount']);
|
||||
}
|
||||
|
||||
return implode(' / ', $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param JournalModel $journal
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function totalAmountPlain(JournalModel $journal): string
|
||||
{
|
||||
$type = $journal->transactionType->type;
|
||||
$totals = $this->getTotalAmount($journal);
|
||||
$array = [];
|
||||
|
||||
foreach ($totals as $total) {
|
||||
if (TransactionType::WITHDRAWAL === $type) {
|
||||
$total['amount'] = bcmul($total['amount'], '-1');
|
||||
}
|
||||
$array[] = app('amount')->formatAnything($total['currency'], $total['amount'], false);
|
||||
}
|
||||
|
||||
return implode(' / ', $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param JournalModel $journal
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getTotalAmount(JournalModel $journal): array
|
||||
{
|
||||
$transactions = $journal->transactions()->where('amount', '>', 0)->get();
|
||||
$totals = [];
|
||||
$type = $journal->transactionType->type;
|
||||
|
||||
/** @var TransactionModel $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$currencyId = $transaction->transaction_currency_id;
|
||||
@ -128,14 +169,7 @@ class TransactionJournal extends Twig_Extension
|
||||
);
|
||||
}
|
||||
}
|
||||
$array = [];
|
||||
foreach ($totals as $total) {
|
||||
if (TransactionType::WITHDRAWAL === $type) {
|
||||
$total['amount'] = bcmul($total['amount'], '-1');
|
||||
}
|
||||
$array[] = app('amount')->formatAnything($total['currency'], $total['amount']);
|
||||
}
|
||||
|
||||
return implode(' / ', $array);
|
||||
return $totals;
|
||||
}
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ class Journal extends Twig_Extension
|
||||
{
|
||||
$filters = [
|
||||
new Twig_SimpleFilter('journalTotalAmount', [TransactionJournalExtension::class, 'totalAmount'], ['is_safe' => ['html']]),
|
||||
new Twig_SimpleFilter('journalTotalAmountPlain', [TransactionJournalExtension::class, 'totalAmountPlain'], ['is_safe' => ['html']]),
|
||||
];
|
||||
|
||||
return $filters;
|
||||
|
@ -11,9 +11,9 @@
|
||||
|
||||
{% if journals.count == 1 %}
|
||||
<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">
|
||||
You can find in in your Firefly III installation:
|
||||
You can find it in your Firefly III installation:<br />
|
||||
{% for journal in journals %}
|
||||
<a href="{{ route('transactions.show', journal.id) }}">{{ journal.description }}</a>
|
||||
<a href="{{ route('transactions.show', journal.id) }}">{{ journal.description }}</a> ({{ journal|journalTotalAmount }})
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
@ -24,7 +24,9 @@
|
||||
</p>
|
||||
<ul>
|
||||
{% for journal in journals %}
|
||||
<li><a href="{{ route('transactions.show', journal.id) }}">{{ journal.description }}</a></li>
|
||||
<li>
|
||||
<a href="{{ route('transactions.show', journal.id) }}">{{ journal.description }}</a> ({{ journal|journalTotalAmount }})
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
@ -10,7 +10,7 @@ Firefly III has created {{ journals.count }} transactions for you.
|
||||
You can find in in your Firefly III installation:
|
||||
|
||||
{% for journal in journals %}
|
||||
{{ journal.description }}: {{ route('transactions.show', journal.id) }}
|
||||
{{ journal.description }}: {{ route('transactions.show', journal.id) }} ({{ journal|journalTotalAmountPlain }})
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
@ -18,7 +18,7 @@ You can find in in your Firefly III installation:
|
||||
You can find them in your Firefly III installation:
|
||||
|
||||
{% for journal in journals %}
|
||||
- {{ journal.description }}: {{ route('transactions.show', journal.id) }}
|
||||
- {{ journal.description }}: {{ route('transactions.show', journal.id) }} ({{ journal|journalTotalAmountPlain }})
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user