Skip to content

Firefly III: a personal finances manager

Fix #1967

James Cole7e1d43000354
diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php
index cfd7a7c7e2..2251706607 100644
--- a/app/Http/Controllers/BillController.php
+++ b/app/Http/Controllers/BillController.php
@@ -26,9 +26,11 @@ use Carbon\Carbon;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Http\Requests\BillFormRequest;
+use FireflyIII\Models\Attachment;
use FireflyIII\Models\Bill;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\TransactionRules\TransactionMatcher;
+use FireflyIII\Transformers\AttachmentTransformer;
use FireflyIII\Transformers\BillTransformer;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
@@ -315,8 +317,21 @@ class BillController extends Controller
$transactions = $collector->getPaginatedTransactions();
$transactions->setPath(route('bills.show', [$bill->id]));
+ // transform any attachments as well.
+ $collection = $this->billRepository->getAttachments($bill);
+ $attachments = new Collection;
+ if ($collection->count() > 0) {
+ /** @var AttachmentTransformer $transformer */
+ $transformer = app(AttachmentTransformer::class);
+ $attachments = $collection->each(
+ function (Attachment $attachment) use ($transformer) {
+ return $transformer->transform($attachment);
+ }
+ );
+ }
+
- return view('bills.show', compact('transactions', 'rules', 'yearAverage', 'overallAverage', 'year', 'object', 'bill', 'subTitle'));
+ return view('bills.show', compact('attachments', 'transactions', 'rules', 'yearAverage', 'overallAverage', 'year', 'object', 'bill', 'subTitle'));
}
diff --git a/resources/views/v1/bills/show.twig b/resources/views/v1/bills/show.twig
index 0510ecdbf5..26afa17311 100644
--- a/resources/views/v1/bills/show.twig
+++ b/resources/views/v1/bills/show.twig
@@ -102,14 +102,15 @@
</div>
{% endif %}
- {% if object.data.attachments_count > 0 %}
+
+ {% if attachments.count > 0 %}
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'attachments'|_ }}</h3>
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
- {% for att in object.data.attachments.data %}
+ {% for att in attachments %}
<tr>
<td>
<div class="btn-group btn-group-xs">