mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
Add transaction list to recurring transaction
This commit is contained in:
@@ -34,6 +34,29 @@ use Illuminate\Http\Request;
|
||||
*/
|
||||
class DeleteController extends Controller
|
||||
{
|
||||
/** @var RecurringRepositoryInterface */
|
||||
private $recurring;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// translations:
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', trans('firefly.recurrences'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Recurrence $recurrence
|
||||
*
|
||||
@@ -46,7 +69,7 @@ class DeleteController extends Controller
|
||||
$this->rememberPreviousUri('recurrences.delete.uri');
|
||||
|
||||
// todo actual number.
|
||||
$journalsCreated = 5;
|
||||
$journalsCreated = $this->recurring->getTransactions($recurrence)->count();
|
||||
|
||||
return view('recurring.delete', compact('recurrence', 'subTitle', 'journalsCreated'));
|
||||
}
|
||||
|
@@ -334,13 +334,12 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param Recurrence $recurrence
|
||||
*
|
||||
* @param int $page
|
||||
* @param int $pageSize
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getTransactions(Recurrence $recurrence, int $page, int $pageSize): LengthAwarePaginator
|
||||
public function getTransactionPaginator(Recurrence $recurrence, int $page, int $pageSize): LengthAwarePaginator
|
||||
{
|
||||
$journalMeta = TransactionJournalMeta
|
||||
::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
|
||||
@@ -356,8 +355,7 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setUser($recurrence->user);
|
||||
$collector->withOpposingAccount()->setAllAssetAccounts()->
|
||||
withCategoryInformation()->withBudgetInformation()->setLimit($pageSize)->setPage($page);
|
||||
$collector->withOpposingAccount()->setAllAssetAccounts()->withCategoryInformation()->withBudgetInformation()->setLimit($pageSize)->setPage($page);
|
||||
// filter on specific journals.
|
||||
$collector->removeFilter(InternalTransferFilter::class);
|
||||
$collector->setJournals(new Collection($search));
|
||||
@@ -365,6 +363,35 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
return $collector->getPaginatedJournals();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Recurrence $recurrence
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getTransactions(Recurrence $recurrence): Collection
|
||||
{
|
||||
$journalMeta = TransactionJournalMeta
|
||||
::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->where('transaction_journals.user_id', $this->user->id)
|
||||
->where('name', 'recurrence_id')
|
||||
->where('data', json_encode((string)$recurrence->id))
|
||||
->get()->pluck('transaction_journal_id')->toArray();
|
||||
$search = [];
|
||||
foreach ($journalMeta as $journalId) {
|
||||
$search[] = ['id' => (int)$journalId];
|
||||
}
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setUser($recurrence->user);
|
||||
$collector->withOpposingAccount()->setAllAssetAccounts()->withCategoryInformation()->withBudgetInformation();
|
||||
// filter on specific journals.
|
||||
$collector->removeFilter(InternalTransferFilter::class);
|
||||
$collector->setJournals(new Collection($search));
|
||||
|
||||
return $collector->getJournals();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the next X iterations starting on the date given in $date.
|
||||
*
|
||||
|
@@ -47,16 +47,6 @@ interface RecurringRepositoryInterface
|
||||
*/
|
||||
public function destroy(Recurrence $recurrence): void;
|
||||
|
||||
/**
|
||||
* @param Recurrence $recurrence
|
||||
*
|
||||
* @param int $page
|
||||
* @param int $pageSize
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getTransactions(Recurrence $recurrence, int $page, int $pageSize): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Returns all of the user's recurring transactions.
|
||||
*
|
||||
@@ -91,6 +81,7 @@ interface RecurringRepositoryInterface
|
||||
|
||||
/**
|
||||
* Returns the journals created for this recurrence, possibly limited by time.
|
||||
* TODO make consistent with getTransactions
|
||||
*
|
||||
* @param Recurrence $recurrence
|
||||
* @param Carbon|null $start
|
||||
@@ -131,6 +122,22 @@ interface RecurringRepositoryInterface
|
||||
*/
|
||||
public function getTags(Recurrence $recurrence): array;
|
||||
|
||||
/**
|
||||
* @param Recurrence $recurrence
|
||||
* @param int $page
|
||||
* @param int $pageSize
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getTransactionPaginator(Recurrence $recurrence, int $page, int $pageSize): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* @param Recurrence $recurrence
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getTransactions(Recurrence $recurrence): Collection;
|
||||
|
||||
/**
|
||||
* Calculate the next X iterations starting on the date given in $date.
|
||||
* Returns an array of Carbon objects.
|
||||
|
@@ -194,7 +194,7 @@
|
||||
</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{% include 'list.journals' with {sorting:false, hideBills:true, hideBudgets: true, hideCategories: true, showReconcile: false} %}
|
||||
{% include 'list.journals' with {sorting:false, hideBills:true, hideBudgets: true, showReconcile: false} %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -207,4 +207,5 @@
|
||||
|
||||
{% block scripts %}
|
||||
<script type="text/javascript" src="js/lib/bootstrap-sortable.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/transactions/list.js?v={{ FF_VERSION }}"></script>
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user