mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 12:24:50 +00:00
Some new code, transaction groups among them.
This commit is contained in:
@@ -115,8 +115,11 @@ class ReportController extends BaseController
|
||||
$journals = App::make('FireflyIII\Database\TransactionJournal');
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $journals->first();
|
||||
|
||||
$date = clone $journal->date;
|
||||
if (is_null($journal)) {
|
||||
$date = Carbon::now();
|
||||
} else {
|
||||
$date = clone $journal->date;
|
||||
}
|
||||
$years = [];
|
||||
$months = [];
|
||||
while ($date <= Carbon::now()) {
|
||||
@@ -124,7 +127,11 @@ class ReportController extends BaseController
|
||||
$date->addYear();
|
||||
}
|
||||
// months
|
||||
$date = clone $journal->date;
|
||||
if (is_null($journal)) {
|
||||
$date = Carbon::now();
|
||||
} else {
|
||||
$date = clone $journal->date;
|
||||
}
|
||||
while ($date <= Carbon::now()) {
|
||||
$months[] = [
|
||||
'formatted' => $date->format('F Y'),
|
||||
@@ -182,15 +189,15 @@ class ReportController extends BaseController
|
||||
}
|
||||
);
|
||||
/*
|
||||
* Filter transfers:
|
||||
* Filter transfers (not yet used)
|
||||
*/
|
||||
$transfers = $journals->filter(
|
||||
function (TransactionJournal $journal) {
|
||||
if ($journal->transactionType->type == 'Transfer') {
|
||||
return $journal;
|
||||
}
|
||||
}
|
||||
);
|
||||
// $transfers = $journals->filter(
|
||||
// function (TransactionJournal $journal) {
|
||||
// if ($journal->transactionType->type == 'Transfer') {
|
||||
// return $journal;
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
|
||||
/*
|
||||
* Filter withdrawals without a counter-transfer (into this account)
|
||||
@@ -205,24 +212,22 @@ class ReportController extends BaseController
|
||||
->where('account_id', '=', $transaction->account_id)
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->where('transaction_journals.description', 'LIKE', '%' . e($journal->description) . '%')
|
||||
->count();
|
||||
if($counters == 0) {
|
||||
->get(['transactions.*']);
|
||||
if ($counters->count() == 0) {
|
||||
return $journal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/*
|
||||
* Filter deposits without a counter-transfer (away from this account)
|
||||
*/
|
||||
$deposits = $deposits->filter(
|
||||
function (TransactionJournal $journal) {
|
||||
echo 'Now at #'.$journal->id.': '.$journal->description.'<br>';
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
|
||||
if (floatval($transaction->amount) < 0) {
|
||||
if (floatval($transaction->amount) > 0) {
|
||||
$account = $transaction->account;
|
||||
// find counter transfer:
|
||||
$counters = $account->transactions()->where('amount', floatval($transaction->amount) * -1)
|
||||
@@ -230,21 +235,15 @@ class ReportController extends BaseController
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->where('transaction_journals.description', 'LIKE', '%' . e($journal->description) . '%')
|
||||
->get(['transactions.*']);
|
||||
/** @var Transaction $transaction */
|
||||
foreach($counters as $transaction) {
|
||||
echo 'Found possible counter: #'.$transaction->transaction_journal_id.': '.$transaction->transactionJournal->description.'<br>';
|
||||
}
|
||||
if($counters->count() == 0) {
|
||||
if ($counters->count() == 0) {
|
||||
return $journal;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '<br>';
|
||||
}
|
||||
);
|
||||
exit;
|
||||
|
||||
return View::make('reports.unbalanced', compact('start', 'end', 'title', 'subTitle', 'subTitleIcon', 'mainTitleIcon', 'withdrawals','deposits'));
|
||||
return View::make('reports.unbalanced', compact('start', 'end', 'title', 'subTitle', 'subTitleIcon', 'mainTitleIcon', 'withdrawals', 'deposits'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,9 +275,10 @@ class ReportController extends BaseController
|
||||
|
||||
|
||||
// draw some charts etc.
|
||||
return View::make('reports.year', compact('summary'))->with('title', 'Reports')->with('mainTitleIcon', 'fa-line-chart')->with('subTitle', $year)->with(
|
||||
'subTitleIcon', 'fa-bar-chart'
|
||||
)->with('year', $year);
|
||||
return View::make('reports.year', compact('summary', 'date'))->with('title', 'Reports')->with('mainTitleIcon', 'fa-line-chart')->with('subTitle', $year)
|
||||
->with(
|
||||
'subTitleIcon', 'fa-bar-chart'
|
||||
)->with('year', $year);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
/**
|
||||
@@ -286,10 +287,27 @@ class TransactionController extends BaseController
|
||||
break;
|
||||
}
|
||||
|
||||
return View::make('transactions.index', compact('subTitle', 'subTitleIcon', 'journals'))->with('what', $what);
|
||||
return View::make('transactions.index', compact('subTitle', 'what', 'subTitleIcon', 'journals'));
|
||||
|
||||
}
|
||||
|
||||
public function relate(TransactionJournal $journal)
|
||||
{
|
||||
$groups = $journal->transactiongroups()->get();
|
||||
$members = new Collection;
|
||||
/** @var TransactionGroup $group */
|
||||
foreach ($groups as $group) {
|
||||
/** @var TransactionJournal $jrnl */
|
||||
foreach ($group->transactionjournals()->get() as $jrnl) {
|
||||
if ($jrnl->id != $journal->id) {
|
||||
$members->push($jrnl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return View::make('transactions.relate', compact('journal', 'members'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
@@ -309,9 +327,18 @@ class TransactionController extends BaseController
|
||||
$t->after = $t->before + $t->amount;
|
||||
}
|
||||
);
|
||||
$members = new Collection;
|
||||
/** @var TransactionGroup $group */
|
||||
foreach($journal->transactiongroups()->get() as $group) {
|
||||
/** @var TransactionJournal $jrnl */
|
||||
foreach($group->transactionjournals()->get() as $jrnl) {
|
||||
if($jrnl->id != $journal->id) {
|
||||
$members->push($jrnl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return View::make('transactions.show')->with('journal', $journal)->with(
|
||||
return View::make('transactions.show', compact('journal', 'members'))->with(
|
||||
'subTitle', $journal->transactionType->type . ' "' . $journal->description . '"'
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user