mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-03 12:45:20 +00:00
Made big headway in preference management, accounts, importing stuff, etc. etc.
This commit is contained in:
@@ -1,10 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sander
|
||||
* Date: 04/07/14
|
||||
* Time: 13:58
|
||||
*/
|
||||
|
||||
namespace Firefly\Exception;
|
||||
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sander
|
||||
* Date: 04/07/14
|
||||
* Time: 13:55
|
||||
*/
|
||||
|
||||
namespace Firefly\Helper;
|
||||
|
||||
|
||||
@@ -21,6 +21,12 @@ class HelperServiceProvider extends ServiceProvider
|
||||
'Firefly\Helper\Migration\MigrationHelperInterface',
|
||||
'Firefly\Helper\Migration\MigrationHelper'
|
||||
);
|
||||
|
||||
// settings:
|
||||
$this->app->bind(
|
||||
'Firefly\Helper\Preferences\PreferencesHelperInterface',
|
||||
'Firefly\Helper\Preferences\PreferencesHelper'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sander
|
||||
* Date: 03/07/14
|
||||
* Time: 21:34
|
||||
*/
|
||||
|
||||
namespace Firefly\Helper\Migration;
|
||||
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sander
|
||||
* Date: 03/07/14
|
||||
* Time: 21:33
|
||||
*/
|
||||
|
||||
namespace Firefly\Helper\Migration;
|
||||
|
||||
|
||||
39
app/lib/Firefly/Helper/Preferences/PreferencesHelper.php
Normal file
39
app/lib/Firefly/Helper/Preferences/PreferencesHelper.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace Firefly\Helper\Preferences;
|
||||
class PreferencesHelper implements PreferencesHelperInterface
|
||||
{
|
||||
|
||||
public function get($name, $default = null)
|
||||
{
|
||||
$pref = \Preference::where('user_id', \Auth::user()->id)->where('name', $name)->first();
|
||||
if (is_null($default) && is_null($pref)) {
|
||||
// return NULL
|
||||
return null;
|
||||
}
|
||||
if (!is_null($pref)) {
|
||||
return $pref;
|
||||
}
|
||||
if (!is_null($default) && is_null($pref)) {
|
||||
// create preference, return that:
|
||||
return $this->set($name, $default);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function set($name, $value)
|
||||
{
|
||||
$pref = \Preference::where('user_id', \Auth::user()->id)->where('name', $name)->first();
|
||||
if (is_null($pref)) {
|
||||
$pref = new \Preference;
|
||||
$pref->name = $name;
|
||||
$pref->user()->associate(\Auth::user());
|
||||
|
||||
}
|
||||
$pref->data = $value;
|
||||
$pref->save();
|
||||
|
||||
|
||||
return $pref;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace Firefly\Helper\Preferences;
|
||||
interface PreferencesHelperInterface
|
||||
{
|
||||
|
||||
public function set($name,$value);
|
||||
public function get($name,$default = null);
|
||||
|
||||
}
|
||||
@@ -10,6 +10,9 @@ interface AccountRepositoryInterface
|
||||
public function count();
|
||||
|
||||
public function get();
|
||||
public function getByIds($ids);
|
||||
public function getDefault();
|
||||
public function getActiveDefault();
|
||||
|
||||
public function store($data);
|
||||
public function storeWithInitialBalance($data,\Carbon\Carbon $date, $amount = 0);
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
namespace Firefly\Storage\Account;
|
||||
|
||||
use Firefly\Helper\MigrationException;
|
||||
|
||||
class EloquentAccountRepository implements AccountRepositoryInterface
|
||||
{
|
||||
public $validator;
|
||||
@@ -13,8 +11,30 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
||||
{
|
||||
}
|
||||
|
||||
public function get() {
|
||||
return \Auth::user()->accounts()->get();
|
||||
public function get()
|
||||
{
|
||||
return \Auth::user()->accounts()->with('accounttype')->get();
|
||||
}
|
||||
|
||||
public function getByIds($ids)
|
||||
{
|
||||
return \Auth::user()->accounts()->with('accounttype')->whereIn('id', $ids)->get();
|
||||
}
|
||||
|
||||
public function getDefault()
|
||||
{
|
||||
return \Auth::user()->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->where('account_types.description', 'Default account')
|
||||
|
||||
->get(['accounts.*']);
|
||||
}
|
||||
|
||||
public function getActiveDefault()
|
||||
{
|
||||
return \Auth::user()->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->where('account_types.description', 'Default account')->where('accounts.active', 1)
|
||||
|
||||
->get(['accounts.*']);
|
||||
}
|
||||
|
||||
public function count()
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sander
|
||||
* Date: 03/07/14
|
||||
* Time: 15:24
|
||||
*/
|
||||
|
||||
|
||||
namespace Firefly\Storage\TransactionJournal;
|
||||
|
||||
@@ -15,7 +10,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
||||
public function createSimpleJournal(\Account $from, \Account $to, $description, $amount, \Carbon\Carbon $date)
|
||||
{
|
||||
|
||||
\Log::debug('Creating tranaction "'.$description.'".');
|
||||
\Log::debug('Creating tranaction "' . $description . '".');
|
||||
/*
|
||||
* We're building this thinking the money goes from A to B.
|
||||
* If the amount is negative however, the money still goes
|
||||
@@ -69,7 +64,10 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
||||
}
|
||||
|
||||
// some debug information:
|
||||
\Log::debug($journalType->type.': AccountFrom "'.$from->name.'" will gain/lose '.$amountFrom.' and AccountTo "'.$to->name.'" will gain/lose '.$amountTo);
|
||||
\Log::debug(
|
||||
$journalType->type . ': AccountFrom "' . $from->name . '" will gain/lose ' . $amountFrom
|
||||
. ' and AccountTo "' . $to->name . '" will gain/lose ' . $amountTo
|
||||
);
|
||||
|
||||
if (is_null($journalType)) {
|
||||
\Log::error('Could not figure out transacion type!');
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sander
|
||||
* Date: 03/07/14
|
||||
* Time: 15:22
|
||||
*/
|
||||
|
||||
namespace Firefly\Storage\TransactionJournal;
|
||||
|
||||
|
||||
interface TransactionJournalRepositoryInterface {
|
||||
interface TransactionJournalRepositoryInterface
|
||||
{
|
||||
|
||||
public function createSimpleJournal(\Account $from, \Account $to, $description, $amount, \Carbon\Carbon $date);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user