mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 10:47:00 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			94 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			94 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace FireflyIII\Helper\TransactionJournal;
 | |
| 
 | |
| use Illuminate\Support\Collection;
 | |
| 
 | |
| /**
 | |
|  * Class Helper
 | |
|  *
 | |
|  * @package FireflyIII\Helper\TransactionJournal
 | |
|  */
 | |
| class Helper implements HelperInterface
 | |
| {
 | |
| 
 | |
|     /**
 | |
|      * @param $what
 | |
|      *
 | |
|      * @return int
 | |
|      */
 | |
|     public function getTransactionTypeIdByWhat($what) {
 | |
| 
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      *
 | |
|      * Get the account_id, which is the asset account that paid for the transaction.
 | |
|      *
 | |
|      * @param string     $what
 | |
|      * @param Collection $transactions
 | |
|      *
 | |
|      * @return mixed
 | |
|      */
 | |
|     public function getAssetAccount($what, Collection $transactions)
 | |
|     {
 | |
|         if ($what == 'withdrawal') {
 | |
|             // transaction #1 is the one that paid for it.
 | |
|             return intval($transactions[1]->account->id);
 | |
|         }
 | |
| 
 | |
|         // otherwise (its a deposit), it's been paid into account #0.
 | |
|         return intval($transactions[0]->account->id);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @return Collection
 | |
|      */
 | |
|     public function getAssetAccounts()
 | |
|     {
 | |
|         /** @var \FireflyIII\Database\Account\Account $accountRepository */
 | |
|         $accountRepository = \App::make('FireflyIII\Database\Account\Account');
 | |
| 
 | |
|         return $accountRepository->getAssetAccounts();
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @return Collection
 | |
|      */
 | |
|     public function getBudgets()
 | |
|     {
 | |
|         /** @var \FireflyIII\Database\Budget\Budget $budgetRepository */
 | |
|         $budgetRepository = \App::make('FireflyIII\Database\Budget\Budget');
 | |
| 
 | |
|         return $budgetRepository->get();
 | |
| 
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @return Collection
 | |
|      */
 | |
|     public function getPiggyBanks()
 | |
|     {
 | |
|         /** @var \FireflyIII\Database\PiggyBank\PiggyBank $piggyRepository */
 | |
|         $piggyRepository = \App::make('FireflyIII\Database\PiggyBank\PiggyBank');
 | |
| 
 | |
|         return $piggyRepository->get();
 | |
| 
 | |
| 
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @return Collection
 | |
|      */
 | |
|     public function getRepeatedExpenses()
 | |
|     {
 | |
|         /** @var \FireflyIII\Database\PiggyBank\RepeatedExpense $repRepository */
 | |
|         $repRepository = \App::make('FireflyIII\Database\PiggyBank\RepeatedExpense');
 | |
| 
 | |
|         return $repRepository->get();
 | |
| 
 | |
| 
 | |
|     }
 | |
| 
 | |
| }
 |