This commit is contained in:
James Cole 2019-09-26 20:57:24 +02:00
parent 3ff8aa7509
commit 21f98be3e7
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 16 additions and 9 deletions

View File

@ -41,6 +41,7 @@ use FireflyIII\Transformers\TransactionGroupTransformer;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection;
use League\Fractal\Resource\Item;
@ -87,15 +88,18 @@ class TransactionController extends Controller
}
/**
* @param TransactionJournal $transactionJournal
* @param TransactionGroup $transactionGroup
*
* @return JsonResponse
* @codeCoverageIgnore
*/
public function attachments(TransactionJournal $transactionJournal): JsonResponse
public function attachments(TransactionGroup $transactionGroup): JsonResponse
{
$manager = $this->getManager();
$attachments = $this->journalAPIRepository->getAttachments($transactionJournal);
$attachments = new Collection;
foreach ($transactionGroup->transactionJournals as $transactionJournal) {
$attachments = $this->journalAPIRepository->getAttachments($transactionJournal)->merge($attachments);
}
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
@ -189,15 +193,18 @@ class TransactionController extends Controller
}
/**
* @param TransactionJournal $transactionJournal
* @param TransactionGroup $transactionGroup
*
* @return JsonResponse
* @codeCoverageIgnore
*/
public function piggyBankEvents(TransactionJournal $transactionJournal): JsonResponse
public function piggyBankEvents(TransactionGroup $transactionGroup): JsonResponse
{
$manager = $this->getManager();
$events = $this->journalAPIRepository->getPiggyBankEvents($transactionJournal);
$events = new Collection;
foreach ($transactionGroup->transactionJournals as $transactionJournal) {
$events = $this->journalAPIRepository->getPiggyBankEvents($transactionJournal)->merge($events);
}
/** @var PiggyBankEventTransformer $transformer */
$transformer = app(PiggyBankEventTransformer::class);

View File

@ -15,7 +15,7 @@
{% endif %}
<td>
{% if event.transaction_journal_id %}
<a href="{{ route('transactions.show',event.transaction_journal_id) }}"
<a href="{{ route('transactions.show',event.transactionJournal.transaction_group_id) }}"
title="{{ event.transactionJournal.description }}">{{ event.date.formatLocalized(monthAndDayFormat) }}</a>
{% else %}
{{ event.date.formatLocalized(monthAndDayFormat) }}

View File

@ -423,8 +423,8 @@ Route::group(
Route::get('', ['uses' => 'TransactionController@index', 'as' => 'index']);
Route::post('', ['uses' => 'TransactionController@store', 'as' => 'store']);
Route::get('{transactionGroup}', ['uses' => 'TransactionController@show', 'as' => 'show']);
Route::get('{transactionJournal}/attachments', ['uses' => 'TransactionController@attachments', 'as' => 'attachments']);
Route::get('{transactionJournal}/piggy_bank_events', ['uses' => 'TransactionController@piggyBankEvents', 'as' => 'piggy_bank_events']);
Route::get('{transactionGroup}/attachments', ['uses' => 'TransactionController@attachments', 'as' => 'attachments']);
Route::get('{transactionGroup}/piggy_bank_events', ['uses' => 'TransactionController@piggyBankEvents', 'as' => 'piggy_bank_events']);
Route::put('{transactionGroup}', ['uses' => 'TransactionController@update', 'as' => 'update']);
Route::delete('{transactionGroup}/{transactionJournal}', ['uses' => 'TransactionController@deleteJournal', 'as' => 'delete-journal']);
Route::delete('{transactionGroup}', ['uses' => 'TransactionController@delete', 'as' => 'delete']);