mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-11-04 05:15:39 +00:00 
			
		
		
		
	Update available budgets code.
This commit is contained in:
		@@ -78,9 +78,7 @@ class BoxController extends Controller
 | 
			
		||||
        $incomes   = [];
 | 
			
		||||
        $expenses  = [];
 | 
			
		||||
        $sums      = [];
 | 
			
		||||
        $currency  = app('amount')->getDefaultCurrency();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        $currency                = $this->defaultCurrency;
 | 
			
		||||
        // collect income of user:
 | 
			
		||||
        /** @var GroupCollectorInterface $collector */
 | 
			
		||||
        $collector = app(GroupCollectorInterface::class);
 | 
			
		||||
@@ -91,7 +89,7 @@ class BoxController extends Controller
 | 
			
		||||
 | 
			
		||||
        /** @var array $journal */
 | 
			
		||||
        foreach ($set as $journal) {
 | 
			
		||||
            $currencyId           = $this->convertToNative ? $currency->id : (int) $journal['currency_id'];
 | 
			
		||||
            $currencyId           = $this->convertToNative && $this->defaultCurrency->id !== (int) $journal['currency_id'] ? $this->defaultCurrency->id : (int) $journal['currency_id'];
 | 
			
		||||
            $amount               = Amount::getAmountFromJournal($journal);
 | 
			
		||||
            $incomes[$currencyId] ??= '0';
 | 
			
		||||
            $incomes[$currencyId] = bcadd($incomes[$currencyId], app('steam')->positive($amount));
 | 
			
		||||
@@ -109,7 +107,7 @@ class BoxController extends Controller
 | 
			
		||||
 | 
			
		||||
        /** @var array $journal */
 | 
			
		||||
        foreach ($set as $journal) {
 | 
			
		||||
            $currencyId            = $this->convertToNative ? $currency->id : (int) $journal['currency_id'];
 | 
			
		||||
            $currencyId            = $this->convertToNative ? $this->defaultCurrency->id : (int) $journal['currency_id'];
 | 
			
		||||
            $amount                = Amount::getAmountFromJournal($journal);
 | 
			
		||||
            $expenses[$currencyId] ??= '0';
 | 
			
		||||
            $expenses[$currencyId] = bcadd($expenses[$currencyId], $amount);
 | 
			
		||||
@@ -126,10 +124,10 @@ class BoxController extends Controller
 | 
			
		||||
            $expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false);
 | 
			
		||||
        }
 | 
			
		||||
        if (0 === count($sums)) {
 | 
			
		||||
            $currency                = app('amount')->getDefaultCurrency();
 | 
			
		||||
            $sums[$currency->id]     = app('amount')->formatAnything($currency, '0', false);
 | 
			
		||||
            $incomes[$currency->id]  = app('amount')->formatAnything($currency, '0', false);
 | 
			
		||||
            $expenses[$currency->id] = app('amount')->formatAnything($currency, '0', false);
 | 
			
		||||
            $currency                = $this->defaultCurrency;
 | 
			
		||||
            $sums[$this->defaultCurrency->id]     = app('amount')->formatAnything($this->defaultCurrency, '0', false);
 | 
			
		||||
            $incomes[$this->defaultCurrency->id]  = app('amount')->formatAnything($this->defaultCurrency, '0', false);
 | 
			
		||||
            $expenses[$this->defaultCurrency->id] = app('amount')->formatAnything($this->defaultCurrency, '0', false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $response  = [
 | 
			
		||||
 
 | 
			
		||||
@@ -73,7 +73,7 @@ class ReconcileController extends Controller
 | 
			
		||||
    {
 | 
			
		||||
        $startBalance    = $request->get('startBalance');
 | 
			
		||||
        $endBalance      = $request->get('endBalance');
 | 
			
		||||
        $accountCurrency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
 | 
			
		||||
        $accountCurrency = $this->accountRepos->getAccountCurrency($account) ?? $this->defaultCurrency;
 | 
			
		||||
        $amount          = '0';
 | 
			
		||||
        $clearedAmount   = '0';
 | 
			
		||||
 | 
			
		||||
@@ -193,7 +193,7 @@ class ReconcileController extends Controller
 | 
			
		||||
        $startDate->subDay();
 | 
			
		||||
        $end->endOfDay();
 | 
			
		||||
 | 
			
		||||
        $currency       = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
 | 
			
		||||
        $currency       = $this->accountRepos->getAccountCurrency($account) ?? $this->defaultCurrency;
 | 
			
		||||
        $startBalance   = Steam::finalAccountBalance($account, $startDate)['balance'];
 | 
			
		||||
        $endBalance     = Steam::finalAccountBalance($account, $end)['balance'];
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user