diff --git a/app/Helpers/Report/ReportQuery.php b/app/Helpers/Report/ReportQuery.php deleted file mode 100644 index 365c66e171..0000000000 --- a/app/Helpers/Report/ReportQuery.php +++ /dev/null @@ -1,109 +0,0 @@ - '123.45' - * - * @param Collection $accounts - * @param Carbon $start - * @param Carbon $end - * - * @return array - */ - public function earnedPerMonth(Collection $accounts, Carbon $start, Carbon $end): array - { - $ids = $accounts->pluck('id')->toArray(); - $query = Auth::user()->transactionjournals() - ->leftJoin( - 'transactions AS t_from', function (JoinClause $join) { - $join->on('transaction_journals.id', '=', 't_from.transaction_journal_id')->where('t_from.amount', '<', 0); - } - ) - ->leftJoin( - 'transactions AS t_to', function (JoinClause $join) { - $join->on('transaction_journals.id', '=', 't_to.transaction_journal_id')->where('t_to.amount', '>', 0); - } - ) - ->whereIn('t_to.account_id', $ids) - ->whereNotIn('t_from.account_id', $ids) - ->after($start) - ->before($end) - ->transactionTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER, TransactionType::OPENING_BALANCE]) - ->groupBy('dateFormatted') - ->get( - [ - DB::raw('DATE_FORMAT(`transaction_journals`.`date`,"%Y-%m") AS `dateFormatted`'), - DB::raw('SUM(`t_to`.`amount`) AS `sum`'), - ] - ); - $array = []; - foreach ($query as $result) { - $array[$result->dateFormatted] = $result->sum; - } - - return $array; - } - - /** - * Returns an array of the amount of money spent in the given accounts (on withdrawals, opening balances and transfers) - * grouped by month like so: "2015-01" => '123.45' - * - * @param Collection $accounts - * @param Carbon $start - * @param Carbon $end - * - * @return array - */ - public function spentPerMonth(Collection $accounts, Carbon $start, Carbon $end): array - { - $ids = $accounts->pluck('id')->toArray(); - $query = Auth::user()->transactionjournals() - ->leftJoin( - 'transactions AS t_from', function (JoinClause $join) { - $join->on('transaction_journals.id', '=', 't_from.transaction_journal_id')->where('t_from.amount', '<', 0); - } - ) - ->leftJoin( - 'transactions AS t_to', function (JoinClause $join) { - $join->on('transaction_journals.id', '=', 't_to.transaction_journal_id')->where('t_to.amount', '>', 0); - } - ) - ->whereIn('t_from.account_id', $ids) - ->whereNotIn('t_to.account_id', $ids) - ->after($start) - ->before($end) - ->transactionTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER, TransactionType::OPENING_BALANCE]) - ->groupBy('dateFormatted') - ->get( - [ - DB::raw('DATE_FORMAT(`transaction_journals`.`date`,"%Y-%m") AS `dateFormatted`'), - DB::raw('SUM(`t_from`.`amount`) AS `sum`'), - ] - ); - $array = []; - foreach ($query as $result) { - $array[$result->dateFormatted] = $result->sum; - } - - return $array; - - } -} diff --git a/app/Helpers/Report/ReportQueryInterface.php b/app/Helpers/Report/ReportQueryInterface.php deleted file mode 100644 index 4dba7f3d5d..0000000000 --- a/app/Helpers/Report/ReportQueryInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - '123.45' - * - * @param Collection $accounts - * @param Carbon $start - * @param Carbon $end - * - * @return array - */ - public function earnedPerMonth(Collection $accounts, Carbon $start, Carbon $end): array; - - /** - * Returns an array of the amount of money spent in the given accounts (on withdrawals, opening balances and transfers) - * grouped by month like so: "2015-01" => '123.45' - * - * @param Collection $accounts - * @param Carbon $start - * @param Carbon $end - * - * @return array - */ - public function spentPerMonth(Collection $accounts, Carbon $start, Carbon $end): array; - - -}