mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 00:27:30 +00:00
Chart re-implemented and added coveralls and other instructions, which will probably not work at all.
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
namespace FireflyIII\Support;
|
||||
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use Preferences as Prefs;
|
||||
use Cache;
|
||||
/**
|
||||
* Class Amount
|
||||
*
|
||||
@@ -54,4 +57,29 @@ class Amount
|
||||
// €
|
||||
return $symbol . ' ' . $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrencyCode()
|
||||
{
|
||||
if (defined('FFCURRENCYCODE')) {
|
||||
return FFCURRENCYCODE;
|
||||
}
|
||||
if (Cache::has('FFCURRENCYCODE')) {
|
||||
define('FFCURRENCYCODE', Cache::get('FFCURRENCYCODE'));
|
||||
|
||||
return FFCURRENCYCODE;
|
||||
}
|
||||
|
||||
|
||||
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
|
||||
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
|
||||
|
||||
\Cache::forever('FFCURRENCYCODE', $currency->code);
|
||||
|
||||
define('FFCURRENCYCODE', $currency->code);
|
||||
|
||||
return $currency->code;
|
||||
}
|
||||
}
|
23
app/Support/Facades/Steam.php
Normal file
23
app/Support/Facades/Steam.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Support\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
/**
|
||||
* Class Steam
|
||||
*
|
||||
* @package FireflyIII\Support\Facades
|
||||
*/
|
||||
class Steam extends Facade
|
||||
{
|
||||
/**
|
||||
* Get the registered name of the component.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'steam';
|
||||
}
|
||||
|
||||
}
|
34
app/Support/Steam.php
Normal file
34
app/Support/Steam.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
|
||||
/**
|
||||
* Class Steam
|
||||
*
|
||||
* @package FireflyIII\Support
|
||||
*/
|
||||
class Steam
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function balance(Account $account, Carbon $date = null)
|
||||
{
|
||||
$date = is_null($date) ? Carbon::now() : $date;
|
||||
$balance = floatval(
|
||||
$account->transactions()->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
)->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')
|
||||
);
|
||||
|
||||
return $balance;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user