Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Expand report email.
James Cole49de4f2200ac
diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.phpindex 5c378811d4..65a42a6ea9 100644--- a/app/Jobs/CreateRecurringTransactions.php+++ b/app/Jobs/CreateRecurringTransactions.php@@ -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));}diff --git a/app/Models/Transaction.php b/app/Models/Transaction.phpindex 2a9ffa0a69..4742467e29 100644--- a/app/Models/Transaction.php+++ b/app/Models/Transaction.php@@ -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{diff --git a/app/Support/Twig/Extension/TransactionJournal.php b/app/Support/Twig/Extension/TransactionJournal.phpindex c9b56a3d8b..66f05708d3 100644--- a/app/Support/Twig/Extension/TransactionJournal.php+++ b/app/Support/Twig/Extension/TransactionJournal.php@@ -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;}}diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.phpindex d8613a6e4f..c6502a8f72 100644--- a/app/Support/Twig/Journal.php+++ b/app/Support/Twig/Journal.php@@ -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;diff --git a/resources/views/emails/report-new-journals-html.twig b/resources/views/emails/report-new-journals-html.twigindex c25899b2d7..a3022d0775 100644--- a/resources/views/emails/report-new-journals-html.twig+++ b/resources/views/emails/report-new-journals-html.twig@@ -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 %}diff --git a/resources/views/emails/report-new-journals-text.twig b/resources/views/emails/report-new-journals-text.twigindex 780e62133a..81faa232d5 100644--- a/resources/views/emails/report-new-journals-text.twig+++ b/resources/views/emails/report-new-journals-text.twig@@ -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 %}