mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Small updates.
This commit is contained in:
parent
8b4f656d90
commit
f572445a65
@ -5,6 +5,7 @@ namespace FireflyIII\Support;
|
|||||||
use Cache;
|
use Cache;
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use Preferences as Prefs;
|
use Preferences as Prefs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,19 +31,27 @@ class Amount
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Transaction|\Transaction $transaction
|
|
||||||
* @param bool $coloured
|
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function formatTransaction(Transaction $transaction, $coloured = true)
|
public function getCurrencySymbol()
|
||||||
{
|
{
|
||||||
$symbol = $transaction->transactionJournal->transactionCurrency->symbol;
|
if (defined('FFCURRENCYSYMBOL')) {
|
||||||
$amount = floatval($transaction->amount);
|
return FFCURRENCYSYMBOL;
|
||||||
|
}
|
||||||
|
if (\Cache::has('FFCURRENCYSYMBOL')) {
|
||||||
|
define('FFCURRENCYSYMBOL', \Cache::get('FFCURRENCYSYMBOL'));
|
||||||
|
|
||||||
return $this->formatWithSymbol($symbol, $amount, $coloured);
|
return FFCURRENCYSYMBOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
|
||||||
|
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
|
||||||
|
|
||||||
|
\Cache::forever('FFCURRENCYSYMBOL', $currency->symbol);
|
||||||
|
|
||||||
|
define('FFCURRENCYSYMBOL', $currency->symbol);
|
||||||
|
|
||||||
|
return $currency->symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,29 +82,45 @@ class Amount
|
|||||||
return $symbol . ' ' . $string;
|
return $symbol . ' ' . $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
*
|
||||||
|
* @param TransactionJournal $journal
|
||||||
*/
|
*/
|
||||||
public function getCurrencySymbol()
|
public function formatJournal(TransactionJournal $journal, $coloured = true)
|
||||||
{
|
{
|
||||||
if (defined('FFCURRENCYSYMBOL')) {
|
$showPositive = true;
|
||||||
return FFCURRENCYSYMBOL;
|
$symbol = $journal->transactionCurrency->symbol;
|
||||||
|
$amount = 0;
|
||||||
|
switch ($journal->transactionType->type) {
|
||||||
|
case 'Withdrawal':
|
||||||
|
$showPositive = false;
|
||||||
}
|
}
|
||||||
if (\Cache::has('FFCURRENCYSYMBOL')) {
|
foreach ($journal->transactions as $t) {
|
||||||
define('FFCURRENCYSYMBOL', \Cache::get('FFCURRENCYSYMBOL'));
|
if (floatval($t->amount) > 0 && $showPositive === true) {
|
||||||
|
$amount = floatval($t->amount);
|
||||||
return FFCURRENCYSYMBOL;
|
break;
|
||||||
|
}
|
||||||
|
if (floatval($t->amount) < 0 && $showPositive === false) {
|
||||||
|
$amount = floatval($t->amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
|
return $this->formatWithSymbol($symbol, $amount, $coloured);
|
||||||
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
|
}
|
||||||
|
|
||||||
\Cache::forever('FFCURRENCYSYMBOL', $currency->symbol);
|
/**
|
||||||
|
* @param Transaction $transaction
|
||||||
|
* @param bool $coloured
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function formatTransaction(Transaction $transaction, $coloured = true)
|
||||||
|
{
|
||||||
|
$symbol = $transaction->transactionJournal->transactionCurrency->symbol;
|
||||||
|
$amount = floatval($transaction->amount);
|
||||||
|
|
||||||
define('FFCURRENCYSYMBOL', $currency->symbol);
|
return $this->formatWithSymbol($symbol, $amount, $coloured);
|
||||||
|
|
||||||
return $currency->symbol;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +24,7 @@ function googleChart(chartType, URL, container, options) {
|
|||||||
/*
|
/*
|
||||||
Create a new google charts object.
|
Create a new google charts object.
|
||||||
*/
|
*/
|
||||||
var chart = false
|
var chart = false;
|
||||||
var options = false;
|
var options = false;
|
||||||
var isMaterialDesign = false;
|
var isMaterialDesign = false;
|
||||||
if (chartType === 'line') {
|
if (chartType === 'line') {
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<i class="fa fa-money fa-fw"></i>
|
<i class="fa fa-money fa-fw"></i>
|
||||||
<a href="{{route('accounts.show',$data[1]->id)}}">{{{$data[1]->name}}}</a>
|
<a href="{{route('accounts.show',$data[1]->id)}}">{{{$data[1]->name}}}</a> ({!! Amount::format(Steam::balance($data[1])) !!})
|
||||||
|
|
||||||
|
|
||||||
<!-- ACTIONS MENU -->
|
<!-- ACTIONS MENU -->
|
||||||
|
@ -15,19 +15,7 @@
|
|||||||
{{{$journal->description}}}
|
{{{$journal->description}}}
|
||||||
|
|
||||||
<span class="pull-right small">
|
<span class="pull-right small">
|
||||||
@if(isset($account))
|
{!! Amount::formatJournal($journal) !!}
|
||||||
@foreach($journal->transactions as $index => $t)
|
|
||||||
@if($t->account_id == $account->id)
|
|
||||||
{!! Amount::formatTransaction($t) !!}
|
|
||||||
@endif
|
|
||||||
@endforeach
|
|
||||||
@else
|
|
||||||
@foreach($journal->transactions as $index => $t)
|
|
||||||
@if($index == 0)
|
|
||||||
{!! Amount::formatTransaction($t) !!}
|
|
||||||
@endif
|
|
||||||
@endforeach
|
|
||||||
@endif
|
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user