mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-22 20:16:22 +00:00 
			
		
		
		
	Use PSR-12 code style
This commit is contained in:
		| @@ -90,7 +90,7 @@ class AccountRepository implements AccountRepositoryInterface | ||||
|      */ | ||||
|     public function expandWithDoubles(Collection $accounts): Collection | ||||
|     { | ||||
|         $result = new Collection; | ||||
|         $result = new Collection(); | ||||
|         /** @var Account $account */ | ||||
|         foreach ($accounts as $account) { | ||||
|             $byName = $this->user->accounts()->where('name', $account->name) | ||||
| @@ -113,7 +113,6 @@ class AccountRepository implements AccountRepositoryInterface | ||||
|         } | ||||
|  | ||||
|         return $result; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -294,8 +293,7 @@ class AccountRepository implements AccountRepositoryInterface | ||||
|      */ | ||||
|     public function getCreditTransactionGroup(Account $account): ?TransactionGroup | ||||
|     { | ||||
|         $journal = TransactionJournal | ||||
|             ::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') | ||||
|         $journal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') | ||||
|             ->where('transactions.account_id', $account->id) | ||||
|             ->transactionTypes([TransactionType::LIABILITY_CREDIT]) | ||||
|             ->first(['transaction_journals.*']); | ||||
| @@ -364,7 +362,6 @@ class AccountRepository implements AccountRepositoryInterface | ||||
|      */ | ||||
|     public function getOpeningBalanceAmount(Account $account): ?string | ||||
|     { | ||||
|  | ||||
|         $journal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') | ||||
|                                      ->where('transactions.account_id', $account->id) | ||||
|                                      ->transactionTypes([TransactionType::OPENING_BALANCE]) | ||||
| @@ -419,8 +416,7 @@ class AccountRepository implements AccountRepositoryInterface | ||||
|      */ | ||||
|     public function getOpeningBalance(Account $account): ?TransactionJournal | ||||
|     { | ||||
|         return TransactionJournal | ||||
|             ::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') | ||||
|         return TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') | ||||
|             ->where('transactions.account_id', $account->id) | ||||
|             ->transactionTypes([TransactionType::OPENING_BALANCE]) | ||||
|             ->first(['transaction_journals.*']); | ||||
| @@ -490,7 +486,7 @@ class AccountRepository implements AccountRepositoryInterface | ||||
|         $list = config('firefly.valid_currency_account_types'); | ||||
|  | ||||
|         // return null if not in this list. | ||||
|         if(!in_array($type, $list, true)) { | ||||
|         if (!in_array($type, $list, true)) { | ||||
|             return null; | ||||
|         } | ||||
|         $currencyId = (int) $this->getMetaValue($account, 'currency_id'); | ||||
| @@ -701,7 +697,6 @@ class AccountRepository implements AccountRepositoryInterface | ||||
|                 $search = sprintf('%%%s%%', $part); | ||||
|                 $dbQuery->where('name', 'LIKE', $search); | ||||
|             } | ||||
|  | ||||
|         } | ||||
|         if (!empty($types)) { | ||||
|             $dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); | ||||
| @@ -787,5 +782,4 @@ class AccountRepository implements AccountRepositoryInterface | ||||
|  | ||||
|         return $service->update($account, $data); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -136,7 +136,6 @@ class OperationsRepository implements OperationsRepositoryInterface | ||||
|         $journals = $this->getTransactions($start, $end, $accounts, TransactionType::DEPOSIT); | ||||
|  | ||||
|         return $this->sortByCurrency($journals, 'positive'); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -150,13 +149,16 @@ class OperationsRepository implements OperationsRepositoryInterface | ||||
|     /** | ||||
|      * @inheritDoc | ||||
|      */ | ||||
|     public function sumExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $expense = null, ?TransactionCurrency $currency = null | ||||
|     ): array | ||||
|     { | ||||
|     public function sumExpenses( | ||||
|         Carbon $start, | ||||
|         Carbon $end, | ||||
|         ?Collection $accounts = null, | ||||
|         ?Collection $expense = null, | ||||
|         ?TransactionCurrency $currency = null | ||||
|     ): array { | ||||
|         $journals = $this->getTransactionsForSum(TransactionType::WITHDRAWAL, $start, $end, $accounts, $expense, $currency); | ||||
|  | ||||
|         return $this->groupByCurrency($journals, 'negative'); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -170,10 +172,13 @@ class OperationsRepository implements OperationsRepositoryInterface | ||||
|      * @return array | ||||
|      */ | ||||
|     private function getTransactionsForSum( | ||||
|         string $type, Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $opposing = null, ?TransactionCurrency $currency = null | ||||
|  | ||||
|     ): array | ||||
|     { | ||||
|         string $type, | ||||
|         Carbon $start, | ||||
|         Carbon $end, | ||||
|         ?Collection $accounts = null, | ||||
|         ?Collection $opposing = null, | ||||
|         ?TransactionCurrency $currency = null | ||||
|     ): array { | ||||
|         $start->startOfDay(); | ||||
|         $end->endOfDay(); | ||||
|  | ||||
| @@ -284,9 +289,12 @@ class OperationsRepository implements OperationsRepositoryInterface | ||||
|      * @inheritDoc | ||||
|      */ | ||||
|     public function sumExpensesByDestination( | ||||
|         Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $expense = null, ?TransactionCurrency $currency = null | ||||
|     ): array | ||||
|     { | ||||
|         Carbon $start, | ||||
|         Carbon $end, | ||||
|         ?Collection $accounts = null, | ||||
|         ?Collection $expense = null, | ||||
|         ?TransactionCurrency $currency = null | ||||
|     ): array { | ||||
|         $journals = $this->getTransactionsForSum(TransactionType::WITHDRAWAL, $start, $end, $accounts, $expense, $currency); | ||||
|  | ||||
|         return $this->groupByDirection($journals, 'destination', 'negative'); | ||||
| @@ -343,9 +351,12 @@ class OperationsRepository implements OperationsRepositoryInterface | ||||
|      * @inheritDoc | ||||
|      */ | ||||
|     public function sumExpensesBySource( | ||||
|         Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $expense = null, ?TransactionCurrency $currency = null | ||||
|     ): array | ||||
|     { | ||||
|         Carbon $start, | ||||
|         Carbon $end, | ||||
|         ?Collection $accounts = null, | ||||
|         ?Collection $expense = null, | ||||
|         ?TransactionCurrency $currency = null | ||||
|     ): array { | ||||
|         $journals = $this->getTransactionsForSum(TransactionType::WITHDRAWAL, $start, $end, $accounts, $expense, $currency); | ||||
|  | ||||
|         return $this->groupByDirection($journals, 'source', 'negative'); | ||||
| @@ -354,9 +365,13 @@ class OperationsRepository implements OperationsRepositoryInterface | ||||
|     /** | ||||
|      * @inheritDoc | ||||
|      */ | ||||
|     public function sumIncome(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $revenue = null, ?TransactionCurrency $currency = null | ||||
|     ): array | ||||
|     { | ||||
|     public function sumIncome( | ||||
|         Carbon $start, | ||||
|         Carbon $end, | ||||
|         ?Collection $accounts = null, | ||||
|         ?Collection $revenue = null, | ||||
|         ?TransactionCurrency $currency = null | ||||
|     ): array { | ||||
|         $journals = $this->getTransactionsForSum(TransactionType::DEPOSIT, $start, $end, $accounts, $revenue, $currency); | ||||
|  | ||||
|         return $this->groupByCurrency($journals, 'positive'); | ||||
| @@ -366,9 +381,12 @@ class OperationsRepository implements OperationsRepositoryInterface | ||||
|      * @inheritDoc | ||||
|      */ | ||||
|     public function sumIncomeByDestination( | ||||
|         Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $revenue = null, ?TransactionCurrency $currency = null | ||||
|     ): array | ||||
|     { | ||||
|         Carbon $start, | ||||
|         Carbon $end, | ||||
|         ?Collection $accounts = null, | ||||
|         ?Collection $revenue = null, | ||||
|         ?TransactionCurrency $currency = null | ||||
|     ): array { | ||||
|         $journals = $this->getTransactionsForSum(TransactionType::DEPOSIT, $start, $end, $accounts, $revenue, $currency); | ||||
|  | ||||
|         return $this->groupByDirection($journals, 'destination', 'positive'); | ||||
| @@ -378,9 +396,12 @@ class OperationsRepository implements OperationsRepositoryInterface | ||||
|      * @inheritDoc | ||||
|      */ | ||||
|     public function sumIncomeBySource( | ||||
|         Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $revenue = null, ?TransactionCurrency $currency = null | ||||
|     ): array | ||||
|     { | ||||
|         Carbon $start, | ||||
|         Carbon $end, | ||||
|         ?Collection $accounts = null, | ||||
|         ?Collection $revenue = null, | ||||
|         ?TransactionCurrency $currency = null | ||||
|     ): array { | ||||
|         $journals = $this->getTransactionsForSum(TransactionType::DEPOSIT, $start, $end, $accounts, $revenue, $currency); | ||||
|  | ||||
|         return $this->groupByDirection($journals, 'source', 'positive'); | ||||
| @@ -512,7 +533,6 @@ class OperationsRepository implements OperationsRepositoryInterface | ||||
|             // destination  account? money comes in: | ||||
|             $return[$destKey]['in']         = bcadd($return[$destKey]['in'], $amount); | ||||
|             $return[$destKey]['difference'] = bcadd($return[$destKey]['out'], $return[$destKey]['in']); | ||||
|  | ||||
|         } | ||||
|  | ||||
|         return $return; | ||||
|   | ||||
| @@ -75,7 +75,12 @@ interface OperationsRepositoryInterface | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
|     public function sumExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $expense = null, ?TransactionCurrency $currency = null | ||||
|     public function sumExpenses( | ||||
|         Carbon $start, | ||||
|         Carbon $end, | ||||
|         ?Collection $accounts = null, | ||||
|         ?Collection $expense = null, | ||||
|         ?TransactionCurrency $currency = null | ||||
|     ): array; | ||||
|  | ||||
|     /** | ||||
| @@ -90,7 +95,11 @@ interface OperationsRepositoryInterface | ||||
|      * @return array | ||||
|      */ | ||||
|     public function sumExpensesByDestination( | ||||
|         Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $expense = null, ?TransactionCurrency $currency = null | ||||
|         Carbon $start, | ||||
|         Carbon $end, | ||||
|         ?Collection $accounts = null, | ||||
|         ?Collection $expense = null, | ||||
|         ?TransactionCurrency $currency = null | ||||
|     ): array; | ||||
|  | ||||
|     /** | ||||
| @@ -105,7 +114,11 @@ interface OperationsRepositoryInterface | ||||
|      * @return array | ||||
|      */ | ||||
|     public function sumExpensesBySource( | ||||
|         Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $expense = null, ?TransactionCurrency $currency = null | ||||
|         Carbon $start, | ||||
|         Carbon $end, | ||||
|         ?Collection $accounts = null, | ||||
|         ?Collection $expense = null, | ||||
|         ?TransactionCurrency $currency = null | ||||
|     ): array; | ||||
|  | ||||
|     /** | ||||
| @@ -119,7 +132,12 @@ interface OperationsRepositoryInterface | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
|     public function sumIncome(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $revenue = null, ?TransactionCurrency $currency = null | ||||
|     public function sumIncome( | ||||
|         Carbon $start, | ||||
|         Carbon $end, | ||||
|         ?Collection $accounts = null, | ||||
|         ?Collection $revenue = null, | ||||
|         ?TransactionCurrency $currency = null | ||||
|     ): array; | ||||
|  | ||||
|     /** | ||||
| @@ -133,8 +151,12 @@ interface OperationsRepositoryInterface | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
|     public function sumIncomeByDestination(Carbon               $start, Carbon $end, ?Collection $accounts = null, ?Collection $revenue = null, | ||||
|                                            ?TransactionCurrency $currency = null | ||||
|     public function sumIncomeByDestination( | ||||
|         Carbon               $start, | ||||
|         Carbon $end, | ||||
|         ?Collection $accounts = null, | ||||
|         ?Collection $revenue = null, | ||||
|         ?TransactionCurrency $currency = null | ||||
|     ): array; | ||||
|  | ||||
|     /** | ||||
| @@ -148,8 +170,12 @@ interface OperationsRepositoryInterface | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
|     public function sumIncomeBySource(Carbon               $start, Carbon $end, ?Collection $accounts = null, ?Collection $revenue = null, | ||||
|                                       ?TransactionCurrency $currency = null | ||||
|     public function sumIncomeBySource( | ||||
|         Carbon               $start, | ||||
|         Carbon $end, | ||||
|         ?Collection $accounts = null, | ||||
|         ?Collection $revenue = null, | ||||
|         ?TransactionCurrency $currency = null | ||||
|     ): array; | ||||
|  | ||||
|     /** | ||||
|   | ||||
		Reference in New Issue
	
	Block a user