mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +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); | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user