mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Some small fixes.
This commit is contained in:
parent
76a1b2cd51
commit
3172bc90da
@ -19,7 +19,6 @@ use Session;
|
|||||||
class Wizard implements WizardInterface
|
class Wizard implements WizardInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Reader $reader
|
* @param Reader $reader
|
||||||
* @param array $map
|
* @param array $map
|
||||||
@ -33,11 +32,12 @@ class Wizard implements WizardInterface
|
|||||||
/*
|
/*
|
||||||
* Loop over the CSV and collect mappable data:
|
* Loop over the CSV and collect mappable data:
|
||||||
*/
|
*/
|
||||||
|
$keys = array_keys($map);
|
||||||
foreach ($reader as $index => $row) {
|
foreach ($reader as $index => $row) {
|
||||||
if (($hasHeaders && $index > 1) || !$hasHeaders) {
|
if ($this->useRow($hasHeaders, $index)) {
|
||||||
// collect all map values
|
// collect all map values
|
||||||
foreach ($map as $column => $irrelevant) {
|
|
||||||
// check if $irrelevant is mappable!
|
foreach ($keys as $column) {
|
||||||
$values[$column][] = $row[$column];
|
$values[$column][] = $row[$column];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,7 +52,6 @@ class Wizard implements WizardInterface
|
|||||||
return $values;
|
return $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $roles
|
* @param array $roles
|
||||||
* @param mixed $map
|
* @param mixed $map
|
||||||
@ -120,7 +119,6 @@ class Wizard implements WizardInterface
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $map
|
* @param array $map
|
||||||
*
|
*
|
||||||
@ -168,4 +166,15 @@ class Wizard implements WizardInterface
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $hasHeaders
|
||||||
|
* @param int $index
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function useRow($hasHeaders, $index)
|
||||||
|
{
|
||||||
|
return ($hasHeaders && $index > 1) || !$hasHeaders;
|
||||||
|
}
|
||||||
}
|
}
|
@ -54,9 +54,7 @@ class ReportQuery implements ReportQueryInterface
|
|||||||
$query->where('transaction_types.type', 'Withdrawal'); // any withdrawal is fine.
|
$query->where('transaction_types.type', 'Withdrawal'); // any withdrawal is fine.
|
||||||
}
|
}
|
||||||
$query->orderBy('transaction_journals.date');
|
$query->orderBy('transaction_journals.date');
|
||||||
|
$data = $query->get( // get everything
|
||||||
// get everything
|
|
||||||
$data = $query->get(
|
|
||||||
['transaction_journals.*', 'transaction_types.type', 'ac_to.name as name', 'ac_to.id as account_id', 'ac_to.encrypted as account_encrypted']
|
['transaction_journals.*', 'transaction_types.type', 'ac_to.name as name', 'ac_to.id as account_id', 'ac_to.encrypted as account_encrypted']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -26,9 +26,7 @@ class ComponentRepository
|
|||||||
*/
|
*/
|
||||||
protected function spentInPeriod($object, Carbon $start, Carbon $end, $shared = false)
|
protected function spentInPeriod($object, Carbon $start, Carbon $end, $shared = false)
|
||||||
{
|
{
|
||||||
// we must cache this.
|
$cache = new CacheProperties; // we must cache this.
|
||||||
|
|
||||||
$cache = new CacheProperties;
|
|
||||||
$cache->addProperty($object->id);
|
$cache->addProperty($object->id);
|
||||||
$cache->addProperty(get_class($object));
|
$cache->addProperty(get_class($object));
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
@ -40,21 +38,13 @@ class ComponentRepository
|
|||||||
return $cache->get(); // @codeCoverageIgnore
|
return $cache->get(); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($shared === true) { // shared is true: always ignore transfers between accounts!
|
||||||
if ($shared === true) {
|
$sum = $object->transactionjournals()->transactionTypes(['Withdrawal'])->before($end)->after($start)
|
||||||
// shared is true.
|
->get(['transaction_journals.*'])->sum('amount');
|
||||||
// always ignore transfers between accounts!
|
|
||||||
$sum
|
|
||||||
= $object->transactionjournals()
|
|
||||||
->transactionTypes(['Withdrawal'])
|
|
||||||
->before($end)->after($start)->get(['transaction_journals.*'])->sum('amount');
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// do something else, SEE budgets.
|
// do something else, SEE budgets.
|
||||||
// get all journals in this month where the asset account is NOT shared.
|
// get all journals in this month where the asset account is NOT shared.
|
||||||
$sum = $object->transactionjournals()
|
$sum = $object->transactionjournals()->before($end)->after($start)
|
||||||
->before($end)
|
|
||||||
->after($start)
|
|
||||||
->transactionTypes(['Withdrawal'])
|
->transactionTypes(['Withdrawal'])
|
||||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
||||||
@ -62,9 +52,7 @@ class ComponentRepository
|
|||||||
'account_meta', function (JoinClause $join) {
|
'account_meta', function (JoinClause $join) {
|
||||||
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
|
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
|
||||||
}
|
}
|
||||||
)
|
)->where('account_meta.data', '!=', '"sharedAsset"')->get(['transaction_journals.*'])->sum('amount');
|
||||||
->where('account_meta.data', '!=', '"sharedAsset"')
|
|
||||||
->get(['transaction_journals.*'])->sum('amount');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$cache->store($sum);
|
$cache->store($sum);
|
||||||
|
Loading…
Reference in New Issue
Block a user