mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			84 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			84 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
|  * Created by PhpStorm.
 | |
|  * User: sander
 | |
|  * Date: 27/06/15
 | |
|  * Time: 17:21
 | |
|  */
 | |
| 
 | |
| namespace FireflyIII\Generator\Chart\Bill;
 | |
| 
 | |
| use FireflyIII\Models\Bill;
 | |
| use FireflyIII\Models\TransactionJournal;
 | |
| use Illuminate\Support\Collection;
 | |
| 
 | |
| /**
 | |
|  * Class ChartJsBillChartGenerator
 | |
|  *
 | |
|  * @package FireflyIII\Generator\Chart\Bill
 | |
|  */
 | |
| class ChartJsBillChartGenerator implements BillChartGenerator
 | |
| {
 | |
| 
 | |
|     /**
 | |
|      * @param Collection $paid
 | |
|      * @param Collection $unpaid
 | |
|      *
 | |
|      * @return array
 | |
|      */
 | |
|     public function frontpage(Collection $paid, Collection $unpaid)
 | |
|     {
 | |
| 
 | |
|         // loop paid and create single entry:
 | |
|         $paidDescriptions   = [];
 | |
|         $paidAmount         = 0;
 | |
|         $unpaidDescriptions = [];
 | |
|         $unpaidAmount       = 0;
 | |
| 
 | |
| 
 | |
|         /** @var TransactionJournal $entry */
 | |
|         foreach ($paid as $entry) {
 | |
| 
 | |
|             $paidDescriptions[] = $entry->description;
 | |
|             $paidAmount += floatval($entry->amount);
 | |
|         }
 | |
| 
 | |
|         // loop unpaid:
 | |
|         /** @var Bill $entry */
 | |
|         foreach ($unpaid as $entry) {
 | |
|             $description          = $entry[0]->name . ' (' . $entry[1]->format('jS M Y') . ')';
 | |
|             $amount               = ($entry[0]->amount_max + $entry[0]->amount_min) / 2;
 | |
|             $unpaidDescriptions[] = $description;
 | |
|             $unpaidAmount += $amount;
 | |
|             unset($amount, $description);
 | |
|         }
 | |
| 
 | |
|         $data = [
 | |
|             [
 | |
|                 'value'     => $unpaidAmount,
 | |
|                 'color'     => 'rgba(53, 124, 165,0.7)',
 | |
|                 'highlight' => 'rgba(53, 124, 165,0.9)',
 | |
|                 'label'     => trans('firefly.unpaid'),
 | |
|             ],
 | |
|             [
 | |
|                 'value'     => $paidAmount,
 | |
|                 'color'     => 'rgba(0, 141, 76, 0.7)',
 | |
|                 'highlight' => 'rgba(0, 141, 76, 0.9)',
 | |
|                 'label'     => trans('firefly.paid'),
 | |
|             ]
 | |
|         ];
 | |
| 
 | |
|         return $data;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @param Bill       $bill
 | |
|      * @param Collection $entries
 | |
|      *
 | |
|      * @return array
 | |
|      */
 | |
|     public function single(Bill $bill, Collection $entries)
 | |
|     {
 | |
|     }
 | |
| }
 |