mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Updated some code [skip ci]
This commit is contained in:
@@ -6,7 +6,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Input;
|
||||
use Preferences;
|
||||
use Redirect;
|
||||
use Route;
|
||||
use Session;
|
||||
use Steam;
|
||||
|
||||
|
@@ -108,4 +108,4 @@ class NewUserController extends Controller
|
||||
|
||||
return Redirect::route('index');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,4 +24,4 @@ use Zizaco\Entrust\EntrustPermission;
|
||||
*/
|
||||
class Permission extends EntrustPermission
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -25,4 +25,4 @@ use Zizaco\Entrust\EntrustRole;
|
||||
*/
|
||||
class Role extends EntrustRole
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@ use Carbon\Carbon;
|
||||
use Crypt;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Collection;
|
||||
use FireflyIII\Repositories\Shared\ComponentRepository;
|
||||
/**
|
||||
|
@@ -4,6 +4,7 @@ namespace FireflyIII\Repositories\Shared;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class ComponentRepository
|
||||
@@ -15,42 +16,42 @@ class ComponentRepository
|
||||
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param stdClass $object
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @param bool $shared
|
||||
* @param bool $shared
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function spentInPeriod($object, Carbon $start, Carbon $end, $shared = false)
|
||||
protected function spentInPeriod(stdClass $object, Carbon $start, Carbon $end, $shared = false)
|
||||
{
|
||||
if ($shared === true) {
|
||||
// shared is true.
|
||||
// always ignore transfers between accounts!
|
||||
$sum
|
||||
= $object->transactionjournals()
|
||||
->transactionTypes(['Withdrawal'])
|
||||
->before($end)->after($start)->get(['transaction_journals.*'])->sum('amount');
|
||||
->transactionTypes(['Withdrawal'])
|
||||
->before($end)->after($start)->get(['transaction_journals.*'])->sum('amount');
|
||||
|
||||
} else {
|
||||
// do something else, SEE budgets.
|
||||
// get all journals in this month where the asset account is NOT shared.
|
||||
$sum = $object->transactionjournals()
|
||||
->before($end)
|
||||
->after($start)
|
||||
->transactionTypes(['Withdrawal'])
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
||||
->leftJoin(
|
||||
'account_meta', function (JoinClause $join) {
|
||||
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
|
||||
}
|
||||
)
|
||||
->where('account_meta.data', '!=', '"sharedAsset"')
|
||||
->get(['transaction_journals.*'])->sum('amount');
|
||||
->before($end)
|
||||
->after($start)
|
||||
->transactionTypes(['Withdrawal'])
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
||||
->leftJoin(
|
||||
'account_meta', function (JoinClause $join) {
|
||||
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
|
||||
}
|
||||
)
|
||||
->where('account_meta.data', '!=', '"sharedAsset"')
|
||||
->get(['transaction_journals.*'])->sum('amount');
|
||||
}
|
||||
|
||||
return $sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -75,26 +75,18 @@ class CacheProperties
|
||||
foreach ($this->properties as $property) {
|
||||
|
||||
if ($property instanceof Collection || $property instanceof EloquentCollection) {
|
||||
$this->md5 .= print_r($property->toArray(), true);
|
||||
$this->md5 .= json_encode($property->toArray());
|
||||
continue;
|
||||
}
|
||||
if ($property instanceof Carbon) {
|
||||
$this->md5 .= $property->toRfc3339String();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($property)) {
|
||||
$this->md5 .= print_r($property, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_object($property)) {
|
||||
$this->md5 .= $property->__toString();
|
||||
}
|
||||
if (is_array($property)) {
|
||||
$this->md5 .= print_r($property, true);
|
||||
}
|
||||
$this->md5 .= (string) $property;
|
||||
|
||||
$this->md5 .= json_encode($property);
|
||||
}
|
||||
|
||||
$this->md5 = md5($this->md5);
|
||||
@@ -107,4 +99,4 @@ class CacheProperties
|
||||
{
|
||||
Cache::forever($this->md5, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user