| 
									
										
										
										
											2015-02-22 09:46:21 +01:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2016-02-05 12:08:25 +01:00
										 |  |  | declare(strict_types = 1); | 
					
						
							| 
									
										
										
										
											2015-02-22 09:46:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace FireflyIII\Repositories\Budget; | 
					
						
							| 
									
										
										
										
											2015-02-23 21:19:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | use Carbon\Carbon; | 
					
						
							| 
									
										
										
										
											2015-02-22 09:46:21 +01:00
										 |  |  | use FireflyIII\Models\Budget; | 
					
						
							| 
									
										
										
										
											2015-02-22 15:40:13 +01:00
										 |  |  | use FireflyIII\Models\LimitRepetition; | 
					
						
							| 
									
										
										
										
											2015-05-26 20:28:18 +02:00
										 |  |  | use Illuminate\Pagination\LengthAwarePaginator; | 
					
						
							| 
									
										
										
										
											2015-04-05 10:36:28 +02:00
										 |  |  | use Illuminate\Support\Collection; | 
					
						
							| 
									
										
										
										
											2015-02-23 21:19:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-22 09:46:21 +01:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Interface BudgetRepositoryInterface | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @package FireflyIII\Repositories\Budget | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | interface BudgetRepositoryInterface | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-01-01 19:46:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * Same as ::spentInPeriod but corrects journals for a set of accounts | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param Budget     $budget | 
					
						
							|  |  |  |      * @param Carbon     $start | 
					
						
							|  |  |  |      * @param Carbon     $end | 
					
						
							|  |  |  |      * @param Collection $accounts | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function balanceInPeriod(Budget $budget, Carbon $start, Carbon $end, Collection $accounts); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-06 09:15:59 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @return void | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function cleanupBudgets(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-29 08:27:13 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @param Budget $budget | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * @return boolean | 
					
						
							| 
									
										
										
										
											2015-12-29 08:27:13 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |     public function destroy(Budget $budget); | 
					
						
							| 
									
										
										
										
											2015-12-29 08:27:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-31 17:46:34 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @param Budget $budget | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return Carbon | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function firstActivity(Budget $budget); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @return Collection | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |     public function getActiveBudgets(); | 
					
						
							| 
									
										
										
										
											2016-01-01 19:46:12 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-29 08:45:43 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @param Carbon $start | 
					
						
							|  |  |  |      * @param Carbon $end | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * @return Collection | 
					
						
							| 
									
										
										
										
											2015-12-29 08:45:43 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |     public function getAllBudgetLimitRepetitions(Carbon $start, Carbon $end); | 
					
						
							| 
									
										
										
										
											2015-12-29 08:45:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-01 13:54:23 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * Get the budgeted amounts for each budgets in each year. | 
					
						
							| 
									
										
										
										
											2016-01-01 13:54:23 +01:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * @param Collection $budgets | 
					
						
							| 
									
										
										
										
											2016-01-01 21:15:03 +01:00
										 |  |  |      * @param Carbon     $start | 
					
						
							|  |  |  |      * @param Carbon     $end | 
					
						
							| 
									
										
										
										
											2016-01-01 13:54:23 +01:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * @return Collection | 
					
						
							| 
									
										
										
										
											2016-01-01 13:54:23 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |     public function getBudgetedPerYear(Collection $budgets, Carbon $start, Carbon $end); | 
					
						
							| 
									
										
										
										
											2015-12-31 17:46:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-22 15:40:13 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * @return Collection | 
					
						
							| 
									
										
										
										
											2015-02-22 15:40:13 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |     public function getBudgets(); | 
					
						
							| 
									
										
										
										
											2015-02-22 09:46:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-28 17:57:03 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Returns an array with every budget in it and the expenses for each budget | 
					
						
							|  |  |  |      * per month. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-12-28 19:56:28 +01:00
										 |  |  |      * @param Collection $accounts | 
					
						
							|  |  |  |      * @param Carbon     $start | 
					
						
							|  |  |  |      * @param Carbon     $end | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function getBudgetsAndExpensesPerMonth(Collection $accounts, Carbon $start, Carbon $end); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Returns an array with every budget in it and the expenses for each budget | 
					
						
							|  |  |  |      * per year for. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param Collection $budgets | 
					
						
							|  |  |  |      * @param Collection $accounts | 
					
						
							|  |  |  |      * @param Carbon     $start | 
					
						
							|  |  |  |      * @param Carbon     $end | 
					
						
							| 
									
										
										
										
											2015-12-28 17:57:03 +01:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return array | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-12-28 19:56:28 +01:00
										 |  |  |     public function getBudgetsAndExpensesPerYear(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end); | 
					
						
							| 
									
										
										
										
											2015-12-28 17:57:03 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-05 10:36:28 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * Returns a list of budgets, budget limits and limit repetitions | 
					
						
							|  |  |  |      * (doubling any of them in a left join) | 
					
						
							| 
									
										
										
										
											2015-12-28 19:56:28 +01:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * @param Carbon $start | 
					
						
							|  |  |  |      * @param Carbon $end | 
					
						
							| 
									
										
										
										
											2015-12-28 19:56:28 +01:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return Collection | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |     public function getBudgetsAndLimitsInRange(Carbon $start, Carbon $end); | 
					
						
							| 
									
										
										
										
											2015-04-05 10:36:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-01 13:54:23 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * @param Budget $budget | 
					
						
							| 
									
										
										
										
											2016-01-01 13:54:23 +01:00
										 |  |  |      * @param Carbon $start | 
					
						
							|  |  |  |      * @param Carbon $end | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * @return LimitRepetition|null | 
					
						
							| 
									
										
										
										
											2015-04-06 09:15:59 +02:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |     public function getCurrentRepetition(Budget $budget, Carbon $start, Carbon $end); | 
					
						
							| 
									
										
										
										
											2015-04-03 19:39:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-27 21:17:04 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * Returns the expenses for this budget grouped per day, with the date | 
					
						
							|  |  |  |      * in "date" (a string, not a Carbon) and the amount in "dailyAmount". | 
					
						
							| 
									
										
										
										
											2015-12-27 21:17:04 +01:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * @param Budget $budget | 
					
						
							| 
									
										
										
										
											2015-12-27 21:17:04 +01:00
										 |  |  |      * @param Carbon $start | 
					
						
							|  |  |  |      * @param Carbon $end | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return Collection | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |     public function getExpensesPerDay(Budget $budget, Carbon $start, Carbon $end); | 
					
						
							| 
									
										
										
										
											2015-12-27 21:17:04 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-22 09:46:21 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * Returns the expenses for this budget grouped per month, with the date | 
					
						
							|  |  |  |      * in "date" (a string, not a Carbon) and the amount in "dailyAmount". | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-02-22 09:46:21 +01:00
										 |  |  |      * @param Budget $budget | 
					
						
							| 
									
										
										
										
											2015-09-27 17:44:49 +02:00
										 |  |  |      * @param Carbon $start | 
					
						
							|  |  |  |      * @param Carbon $end | 
					
						
							| 
									
										
										
										
											2015-02-22 09:46:21 +01:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * @return Collection | 
					
						
							| 
									
										
										
										
											2015-02-22 09:46:21 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |     public function getExpensesPerMonth(Budget $budget, Carbon $start, Carbon $end); | 
					
						
							| 
									
										
										
										
											2015-02-22 09:46:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-07 17:51:22 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @param Budget $budget | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return Carbon | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function getFirstBudgetLimitDate(Budget $budget); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-05 10:36:28 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @return Collection | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-04-06 09:15:59 +02:00
										 |  |  |     public function getInactiveBudgets(); | 
					
						
							| 
									
										
										
										
											2015-04-05 10:36:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2015-04-06 09:15:59 +02:00
										 |  |  |      * Returns all the transaction journals for a limit, possibly limited by a limit repetition. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param Budget          $budget | 
					
						
							|  |  |  |      * @param LimitRepetition $repetition | 
					
						
							|  |  |  |      * @param int             $take | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-05-26 20:28:18 +02:00
										 |  |  |      * @return LengthAwarePaginator | 
					
						
							| 
									
										
										
										
											2015-04-06 09:15:59 +02:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-02-05 09:30:06 +01:00
										 |  |  |     public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50); | 
					
						
							| 
									
										
										
										
											2015-04-06 09:15:59 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @param Carbon $start | 
					
						
							|  |  |  |      * @param Carbon $end | 
					
						
							| 
									
										
										
										
											2015-04-05 10:36:28 +02:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return Collection | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-04-06 09:15:59 +02:00
										 |  |  |     public function getWithoutBudget(Carbon $start, Carbon $end); | 
					
						
							| 
									
										
										
										
											2015-04-05 10:36:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2015-04-06 09:15:59 +02:00
										 |  |  |      * @param Carbon $start | 
					
						
							|  |  |  |      * @param Carbon $end | 
					
						
							| 
									
										
										
										
											2015-04-05 10:36:28 +02:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-04-06 09:15:59 +02:00
										 |  |  |      * @return mixed | 
					
						
							| 
									
										
										
										
											2015-04-05 10:36:28 +02:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-04-06 09:15:59 +02:00
										 |  |  |     public function getWithoutBudgetSum(Carbon $start, Carbon $end); | 
					
						
							| 
									
										
										
										
											2015-04-05 10:36:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-11 17:53:17 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * Returns an array with the following key:value pairs: | 
					
						
							| 
									
										
										
										
											2015-12-11 17:53:17 +01:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * yyyy-mm-dd:<array> | 
					
						
							| 
									
										
										
										
											2015-12-11 17:53:17 +01:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * That array contains: | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * budgetid:<amount> | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * Where yyyy-mm-dd is the date and <amount> is the money spent using WITHDRAWALS in the $budget | 
					
						
							|  |  |  |      * from the given users accounts.. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param Collection $accounts | 
					
						
							| 
									
										
										
										
											2015-12-11 17:53:17 +01:00
										 |  |  |      * @param Carbon     $start | 
					
						
							|  |  |  |      * @param Carbon     $end | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function spentAllPerDayForAccounts(Collection $accounts, Carbon $start, Carbon $end); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Returns a list of expenses (in the field "spent", grouped per budget per account. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param Collection $budgets | 
					
						
							| 
									
										
										
										
											2015-12-11 17:53:17 +01:00
										 |  |  |      * @param Collection $accounts | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * @param Carbon     $start | 
					
						
							|  |  |  |      * @param Carbon     $end | 
					
						
							| 
									
										
										
										
											2015-12-11 17:53:17 +01:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |      * @return Collection | 
					
						
							| 
									
										
										
										
											2015-12-11 17:53:17 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-01-20 15:21:27 +01:00
										 |  |  |     public function spentPerBudgetPerAccount(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Returns an array with the following key:value pairs: | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * yyyy-mm-dd:<amount> | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * Where yyyy-mm-dd is the date and <amount> is the money spent using WITHDRAWALS in the $budget | 
					
						
							|  |  |  |      * from all the users accounts. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param Budget $budget | 
					
						
							|  |  |  |      * @param Carbon $start | 
					
						
							|  |  |  |      * @param Carbon $end | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function spentPerDay(Budget $budget, Carbon $start, Carbon $end); | 
					
						
							| 
									
										
										
										
											2015-12-11 17:53:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-22 15:40:13 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @param array $data | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return Budget | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function store(array $data); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @param Budget $budget | 
					
						
							| 
									
										
										
										
											2015-02-23 21:19:16 +01:00
										 |  |  |      * @param array  $data | 
					
						
							| 
									
										
										
										
											2015-02-22 15:40:13 +01:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return Budget | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function update(Budget $budget, array $data); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2015-04-06 09:15:59 +02:00
										 |  |  |      * @param Budget $budget | 
					
						
							|  |  |  |      * @param Carbon $date | 
					
						
							| 
									
										
										
										
											2016-02-05 15:41:40 +01:00
										 |  |  |      * @param int       $amount | 
					
						
							| 
									
										
										
										
											2015-02-22 15:40:13 +01:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-04-06 09:15:59 +02:00
										 |  |  |      * @return mixed | 
					
						
							| 
									
										
										
										
											2015-02-22 15:40:13 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-02-05 15:41:40 +01:00
										 |  |  |     public function updateLimitAmount(Budget $budget, Carbon $date, int $amount); | 
					
						
							| 
									
										
										
										
											2015-02-22 15:40:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-29 08:14:32 +02:00
										 |  |  | } |