mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Some refactoring.
This commit is contained in:
@@ -58,18 +58,18 @@ class Chart implements ChartInterface
|
||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d'));
|
||||
}
|
||||
)
|
||||
->leftJoin(
|
||||
'transactions', function (JoinClause $join) {
|
||||
$join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '>', 0);
|
||||
}
|
||||
)
|
||||
->where('active', 1)
|
||||
->groupBy('bills.id')
|
||||
->get(
|
||||
['bills.id', 'bills.name', 'transaction_journals.description',
|
||||
'transaction_journals.id as journalId',
|
||||
\DB::Raw('SUM(`bills`.`amount_min` + `bills`.`amount_max`) / 2 as `averageAmount`'),
|
||||
'transactions.amount AS actualAmount']
|
||||
);
|
||||
->leftJoin(
|
||||
'transactions', function (JoinClause $join) {
|
||||
$join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '>', 0);
|
||||
}
|
||||
)
|
||||
->where('active', 1)
|
||||
->groupBy('bills.id')
|
||||
->get(
|
||||
['bills.id', 'bills.name', 'transaction_journals.description',
|
||||
'transaction_journals.id as journalId',
|
||||
\DB::Raw('SUM(`bills`.`amount_min` + `bills`.`amount_max`) / 2 as `averageAmount`'),
|
||||
'transactions.amount AS actualAmount']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class Bill implements CUD, CommonDatabaseCalls, BillInterface
|
||||
/*
|
||||
* Jump to the start of the period.
|
||||
*/
|
||||
$date = \DateKit::startOfPeriod($date, $data['repeat_freq']);
|
||||
$date = \DateKit::startOfPeriod($date, $data['repeat_freq']);
|
||||
$bill->date = $date;
|
||||
$bill->skip = intval($data['skip']);
|
||||
|
||||
@@ -193,9 +193,9 @@ class Bill implements CUD, CommonDatabaseCalls, BillInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Bill $bill
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param \Bill $bill
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return \TransactionJournal|null
|
||||
*/
|
||||
@@ -206,8 +206,8 @@ class Bill implements CUD, CommonDatabaseCalls, BillInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Bill $bill
|
||||
* @param \TransactionJournal $journal
|
||||
* @param \Bill $bill
|
||||
* @param \TransactionJournal $journal
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -238,6 +238,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
|
||||
/**
|
||||
* This method includes the time because otherwise, SQLite doesn't understand it.
|
||||
*
|
||||
* @param \Budget $budget
|
||||
* @param Carbon $date
|
||||
*
|
||||
@@ -369,6 +370,5 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
return $budget->budgetLimits()->where('startdate', $date->format('Y-m-d 00:00:00'))->first();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ use FireflyIII\Database\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\CUD;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace FireflyIII\Database\PiggyBank;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
@@ -6,9 +6,6 @@ namespace FireflyIII\Database\PiggyBank;
|
||||
use FireflyIII\Collection\PiggyBankPart;
|
||||
use FireflyIII\Database\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\CUD;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,8 +44,8 @@ class TransactionJournal
|
||||
public function update(\TransactionJournal $journal)
|
||||
{
|
||||
/** @var \FireflyIII\Database\Bill\Bill $repository */
|
||||
$repository = \App::make('FireflyIII\Database\Bill\Bill');
|
||||
$set = $repository->get();
|
||||
$repository = \App::make('FireflyIII\Database\Bill\Bill');
|
||||
$set = $repository->get();
|
||||
$journal->bill_id = null;
|
||||
$journal->save();
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ class Form
|
||||
$html .= \Form::input('text', $name, $value, $options);
|
||||
break;
|
||||
case 'amount':
|
||||
$html .= '<div class="input-group"><div class="input-group-addon">'.getCurrencySymbol().'</div>';
|
||||
$html .= '<div class="input-group"><div class="input-group-addon">' . getCurrencySymbol() . '</div>';
|
||||
$html .= \Form::input('number', $name, $value, $options);
|
||||
$html .= '</div>';
|
||||
break;
|
||||
|
||||
@@ -95,6 +95,29 @@ class ReportHelper implements ReportHelperInterface
|
||||
return $one;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort an array where all 'amount' keys are positive floats.
|
||||
*
|
||||
* @param array $array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sortArray(array $array)
|
||||
{
|
||||
uasort(
|
||||
$array, function ($left, $right) {
|
||||
if ($left['amount'] == $right['amount']) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ($left['amount'] < $right['amount']) ? 1 : -1;
|
||||
}
|
||||
);
|
||||
|
||||
return $array;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort an array where all 'amount' keys are negative floats.
|
||||
*
|
||||
@@ -116,25 +139,4 @@ class ReportHelper implements ReportHelperInterface
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort an array where all 'amount' keys are positive floats.
|
||||
*
|
||||
* @param array $array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sortArray(array $array) {
|
||||
uasort(
|
||||
$array, function ($left, $right) {
|
||||
if ($left['amount'] == $right['amount']) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ($left['amount'] < $right['amount']) ? 1 : -1;
|
||||
}
|
||||
);
|
||||
return $array;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -43,15 +43,6 @@ interface ReportHelperInterface
|
||||
*/
|
||||
public function mergeArrays(array $one, array $two);
|
||||
|
||||
/**
|
||||
* Sort an array where all 'amount' keys are negative floats.
|
||||
*
|
||||
* @param array $array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sortNegativeArray(array $array);
|
||||
|
||||
/**
|
||||
* Sort an array where all 'amount' keys are positive floats.
|
||||
*
|
||||
@@ -61,4 +52,13 @@ interface ReportHelperInterface
|
||||
*/
|
||||
public function sortArray(array $array);
|
||||
|
||||
/**
|
||||
* Sort an array where all 'amount' keys are negative floats.
|
||||
*
|
||||
* @param array $array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sortNegativeArray(array $array);
|
||||
|
||||
}
|
||||
@@ -44,8 +44,8 @@ class ReportQuery implements ReportQueryInterface
|
||||
* and are balanced by a transfer to make up for it.
|
||||
*
|
||||
* @param \Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
@@ -97,8 +97,8 @@ class ReportQuery implements ReportQueryInterface
|
||||
* and are balanced by a transfer to make up for it.
|
||||
*
|
||||
* @param \Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
|
||||
@@ -47,8 +47,8 @@ interface ReportQueryInterface
|
||||
* and are balanced by a transfer to make up for it.
|
||||
*
|
||||
* @param \Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
@@ -59,8 +59,8 @@ interface ReportQueryInterface
|
||||
* and are balanced by a transfer to make up for it.
|
||||
*
|
||||
* @param \Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
|
||||
@@ -24,6 +24,7 @@ class Preferences implements PreferencesInterface
|
||||
if (!is_null($pref)) {
|
||||
return $pref;
|
||||
}
|
||||
|
||||
return $this->set($name, $default);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Shared\Toolkit;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class Steam
|
||||
*/
|
||||
public function balance(\Account $account, Carbon $date = null)
|
||||
{
|
||||
\Log::debug('Now in Steam::balance() for account #' . $account->id.' ('.$account->name.')');
|
||||
\Log::debug('Now in Steam::balance() for account #' . $account->id . ' (' . $account->name . ')');
|
||||
if (is_null($date)) {
|
||||
$key = 'account.' . $account->id . '.latestBalance';
|
||||
} else {
|
||||
@@ -33,7 +33,7 @@ class Steam
|
||||
// TODO find a way to reliably remove cache entries for accounts.
|
||||
#return \Cache::get($key);
|
||||
}
|
||||
$date = is_null($date) ? Carbon::now() : $date;
|
||||
$date = is_null($date) ? Carbon::now() : $date;
|
||||
\Log::debug('Now reached the moment we fire the query.');
|
||||
$balance = floatval(
|
||||
$account->transactions()->leftJoin(
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<i class="fa fa-repeat"></i> Transactions ({{$result['transactions']->count()}})
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
@include('...lists.old.journals-small-noaccount',['transactions' => $result['transactions']])
|
||||
@include('list.journals-small',['journals' => $result['transactions']])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user