mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 18:54:58 +00:00 
			
		
		
		
	Better chart for bills.
This commit is contained in:
		| @@ -3,6 +3,7 @@ | |||||||
| use App; | use App; | ||||||
| use Auth; | use Auth; | ||||||
| use Carbon\Carbon; | use Carbon\Carbon; | ||||||
|  | use Crypt; | ||||||
| use DB; | use DB; | ||||||
| use Exception; | use Exception; | ||||||
| use FireflyIII\Helpers\Report\ReportQueryInterface; | use FireflyIII\Helpers\Report\ReportQueryInterface; | ||||||
| @@ -26,7 +27,6 @@ use Preferences; | |||||||
| use Response; | use Response; | ||||||
| use Session; | use Session; | ||||||
| use Steam; | use Steam; | ||||||
| use Crypt; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Class GoogleChartController |  * Class GoogleChartController | ||||||
| @@ -256,7 +256,7 @@ class GoogleChartController extends Controller | |||||||
|                                    ->where('transaction_types.type', 'Withdrawal') |                                    ->where('transaction_types.type', 'Withdrawal') | ||||||
|                                    ->groupBy('categories.id') |                                    ->groupBy('categories.id') | ||||||
|                                    ->orderBy('sum', 'DESC') |                                    ->orderBy('sum', 'DESC') | ||||||
|                                    ->get(['categories.id','categories.encrypted', 'categories.name', \DB::Raw('SUM(`transactions`.`amount`) AS `sum`')]); |                                    ->get(['categories.id', 'categories.encrypted', 'categories.name', \DB::Raw('SUM(`transactions`.`amount`) AS `sum`')]); | ||||||
|  |  | ||||||
|         foreach ($set as $entry) { |         foreach ($set as $entry) { | ||||||
|             $isEncrypted = intval($entry->encrypted) == 1 ? true : false; |             $isEncrypted = intval($entry->encrypted) == 1 ? true : false; | ||||||
| @@ -291,22 +291,18 @@ class GoogleChartController extends Controller | |||||||
|         } else { |         } else { | ||||||
|             $start = new Carbon; |             $start = new Carbon; | ||||||
|         } |         } | ||||||
|         $end = new Carbon; |  | ||||||
|         while ($start <= $end) { |         $results = $bill->transactionjournals()->after($start)->get(); | ||||||
|             $result = $bill->transactionjournals()->before($end)->after($start)->first(); |         /** @var TransactionJournal $result */ | ||||||
|             if ($result) { |         foreach ($results as $result) { | ||||||
|  |             $amount = 0; | ||||||
|             /** @var Transaction $tr */ |             /** @var Transaction $tr */ | ||||||
|             foreach ($result->transactions()->get() as $tr) { |             foreach ($result->transactions()->get() as $tr) { | ||||||
|                 if (floatval($tr->amount) > 0) { |                 if (floatval($tr->amount) > 0) { | ||||||
|                     $amount = floatval($tr->amount); |                     $amount = floatval($tr->amount); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             } else { |             $chart->addRow(clone $result->date, $bill->amount_max, $bill->amount_min, $amount); | ||||||
|                 $amount = 0; |  | ||||||
|             } |  | ||||||
|             unset($result); |  | ||||||
|             $chart->addRow(clone $start, $bill->amount_max, $bill->amount_min, $amount); |  | ||||||
|             $start = Navigation::addPeriod($start, $bill->repeat_freq, 0); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $chart->generate(); |         $chart->generate(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user