mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	Fix #1449
This commit is contained in:
		| @@ -87,6 +87,8 @@ class BudgetController extends Controller | ||||
|         $budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount); | ||||
|         $largeDiff   = false; | ||||
|         $warnText    = ''; | ||||
|         $days        = 0; | ||||
|         $daysInMonth = 0; | ||||
|         if (0 === bccomp($amount, '0')) { | ||||
|             $budgetLimit = null; | ||||
|         } | ||||
| @@ -95,12 +97,15 @@ class BudgetController extends Controller | ||||
|         // otherwise, use diff between start and end. | ||||
|         $today = new Carbon; | ||||
|         if ($today->gte($start) && $today->lte($end)) { | ||||
|             $days = $end->diffInDays($today); | ||||
|             $days        = $end->diffInDays($today); | ||||
|             $daysInMonth = $start->diffInDays($today); | ||||
|         } | ||||
|         if ($today->lte($start) || $today->gte($end)) { | ||||
|             $days = $start->diffInDays($end); | ||||
|             $days        = $start->diffInDays($end); | ||||
|             $daysInMonth = $start->diffInDays($end); | ||||
|         } | ||||
|         $days = $days === 0 ? 1 : $days; | ||||
|         $days        = $days === 0 ? 1 : $days; | ||||
|         $daysInMonth = $daysInMonth === 0 ? 1 : $daysInMonth; | ||||
|  | ||||
|         // calculate left in budget: | ||||
|         $spent      = $repository->spentInPeriod(new Collection([$budget]), new Collection, $start, $end); | ||||
| @@ -146,6 +151,7 @@ class BudgetController extends Controller | ||||
|                 'large_diff'   => $largeDiff, | ||||
|                 'left_per_day' => $leftPerDay, | ||||
|                 'warn_text'    => $warnText, | ||||
|                 'daysInMonth'  => $daysInMonth, | ||||
|  | ||||
|             ] | ||||
|         ); | ||||
| @@ -229,22 +235,27 @@ class BudgetController extends Controller | ||||
|      */ | ||||
|     public function index(Request $request, string $moment = null) | ||||
|     { | ||||
|         $range    = Preferences::get('viewRange', '1M')->data; | ||||
|         $start    = session('start', new Carbon); | ||||
|         $end      = session('end', new Carbon); | ||||
|         $page     = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page'); | ||||
|         $pageSize = (int)Preferences::get('listPageSize', 50)->data; | ||||
|         $range       = Preferences::get('viewRange', '1M')->data; | ||||
|         $start       = session('start', new Carbon); | ||||
|         $end         = session('end', new Carbon); | ||||
|         $page        = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page'); | ||||
|         $pageSize    = (int)Preferences::get('listPageSize', 50)->data; | ||||
|         $days        = 0; | ||||
|         $daysInMonth = 0; | ||||
|  | ||||
|         // if today is between start and end, use the diff in days between end and today (days left) | ||||
|         // otherwise, use diff between start and end. | ||||
|         $today = new Carbon; | ||||
|         if ($today->gte($start) && $today->lte($end)) { | ||||
|             $days = $end->diffInDays($today); | ||||
|             $days        = $end->diffInDays($today); | ||||
|             $daysInMonth = $start->diffInDays($today); | ||||
|         } | ||||
|         if ($today->lte($start) || $today->gte($end)) { | ||||
|             $days = $start->diffInDays($end); | ||||
|             $days        = $start->diffInDays($end); | ||||
|             $daysInMonth = $start->diffInDays($end); | ||||
|         } | ||||
|         $days = $days === 0 ? 1 : $days; | ||||
|         $days        = $days === 0 ? 1 : $days; | ||||
|         $daysInMonth = $daysInMonth === 0 ? 1 : $daysInMonth; | ||||
|  | ||||
|         // make date if present: | ||||
|         if (null !== $moment || '' !== (string)$moment) { | ||||
| @@ -312,7 +323,7 @@ class BudgetController extends Controller | ||||
|         return view( | ||||
|             'budgets.index', compact( | ||||
|                                'available', 'currentMonth', 'next', 'nextText', 'prev', 'allBudgets', 'prevText', 'periodStart', 'periodEnd', 'days', 'page', | ||||
|                                'budgetInformation', | ||||
|                                'budgetInformation', 'daysInMonth', | ||||
|                                'inactive', 'budgets', 'spent', 'budgeted', 'previousLoop', 'nextLoop', 'start', 'end' | ||||
|                            ) | ||||
|         ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user