Various code cleanup.

This commit is contained in:
James Cole
2017-09-09 07:03:43 +02:00
parent f2cb675267
commit 66c13f35e7
5 changed files with 21 additions and 26 deletions

View File

@@ -251,15 +251,13 @@ class UpgradeDatabase extends Command
*/ */
public function updateTransferCurrencies() public function updateTransferCurrencies()
{ {
/** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class);
$set = TransactionJournal $set = TransactionJournal
::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id') ::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->where('transaction_types.type', TransactionType::TRANSFER) ->where('transaction_types.type', TransactionType::TRANSFER)
->get(['transaction_journals.*']); ->get(['transaction_journals.*']);
$set->each( $set->each(
function (TransactionJournal $transfer) use ($repository) { function (TransactionJournal $transfer) {
// select all "source" transactions: // select all "source" transactions:
/** @var Collection $transactions */ /** @var Collection $transactions */
$transactions = $transfer->transactions()->where('amount', '<', 0)->get(); $transactions = $transfer->transactions()->where('amount', '<', 0)->get();

View File

@@ -37,14 +37,13 @@ class TagFormRequest extends Request
*/ */
public function collectTagData(): array public function collectTagData(): array
{ {
$latitude = null;
$longitude = null;
$zoomLevel = null;
if ($this->get('setTag') === 'true') { if ($this->get('setTag') === 'true') {
$latitude = $this->string('latitude'); $latitude = $this->string('latitude');
$longitude = $this->string('longitude'); $longitude = $this->string('longitude');
$zoomLevel = $this->integer('zoomLevel'); $zoomLevel = $this->integer('zoomLevel');
} else {
$latitude = null;
$longitude = null;
$zoomLevel = null;
} }
$data = [ $data = [

View File

@@ -59,7 +59,8 @@ class RabobankDescription implements SpecificInterface
); );
$row[6] = $alternateName; $row[6] = $alternateName;
$row[10] = ''; $row[10] = '';
} else { }
if (!(strlen($oppositeAccount) < 1 && strlen($oppositeName) < 1)) {
Log::debug('Rabobank specific: either opposite account or name are filled.'); Log::debug('Rabobank specific: either opposite account or name are filled.');
} }

View File

@@ -137,10 +137,9 @@ class Amount
if ($amount > 0) { if ($amount > 0) {
return sprintf('<span class="text-success">%s</span>', $result); return sprintf('<span class="text-success">%s</span>', $result);
} else { }
if ($amount < 0) { if ($amount < 0) {
return sprintf('<span class="text-danger">%s</span>', $result); return sprintf('<span class="text-danger">%s</span>', $result);
}
} }
return sprintf('<span style="color:#999">%s</span>', $result); return sprintf('<span style="color:#999">%s</span>', $result);
@@ -194,14 +193,13 @@ class Amount
$cache->addProperty('getCurrencySymbol'); $cache->addProperty('getCurrencySymbol');
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore return $cache->get(); // @codeCoverageIgnore
} else {
$currencyPreference = Prefs::get('currencyPreference', config('firefly.default_currency', 'EUR'));
$currency = TransactionCurrency::where('code', $currencyPreference->data)->first();
$cache->store($currency->symbol);
return $currency->symbol;
} }
$currencyPreference = Prefs::get('currencyPreference', config('firefly.default_currency', 'EUR'));
$currency = TransactionCurrency::where('code', $currencyPreference->data)->first();
$cache->store($currency->symbol);
return $currency->symbol;
} }
/** /**

View File

@@ -100,14 +100,13 @@ class FireflyConfig
Cache::forget('ff-config-' . $name); Cache::forget('ff-config-' . $name);
return $item; return $item;
} else {
Log::debug('Exists already ', ['name' => $name]);
$config->data = $value;
$config->save();
Cache::forget('ff-config-' . $name);
return $config;
} }
Log::debug('Exists already ', ['name' => $name]);
$config->data = $value;
$config->save();
Cache::forget('ff-config-' . $name);
return $config;
} }