mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Moar updates.
This commit is contained in:
@@ -38,10 +38,10 @@ class HomeController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
Queue::push(function($job)
|
// Queue::push(function($job)
|
||||||
{
|
// {
|
||||||
Log::debug('This is a job!');
|
// Log::debug('This is a job!');
|
||||||
});
|
// });
|
||||||
|
|
||||||
\Event::fire('limits.check');
|
\Event::fire('limits.check');
|
||||||
\Event::fire('piggybanks.check');
|
\Event::fire('piggybanks.check');
|
||||||
|
@@ -28,8 +28,10 @@ class MigrateController extends BaseController
|
|||||||
if (is_writable($path)) {
|
if (is_writable($path)) {
|
||||||
Input::file('file')->move($path, $fileName);
|
Input::file('file')->move($path, $fileName);
|
||||||
// so now we push something in a queue and do something with it! Yay!
|
// so now we push something in a queue and do something with it! Yay!
|
||||||
Queue::push('Firefly\Queue\Import@start', ['file' => $fullName,'user' => \Auth::user()->id]);
|
\Log::debug('Pushed a job to start the import.');
|
||||||
exit;
|
Queue::push('Firefly\Queue\Import@start', ['file' => $fullName, 'user' => \Auth::user()->id]);
|
||||||
|
Session::flash('success', 'The import job has been queued. Please be patient. Data will appear');
|
||||||
|
return Redirect::route('index');
|
||||||
}
|
}
|
||||||
Session::flash('error', 'Could not save file to storage.');
|
Session::flash('error', 'Could not save file to storage.');
|
||||||
return Redirect::route('migrate.index');
|
return Redirect::route('migrate.index');
|
||||||
|
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
|
class CreateFailedJobsTable extends Migration
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::drop('failed_jobs');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->text('connection');
|
||||||
|
$table->text('queue');
|
||||||
|
$table->text('payload');
|
||||||
|
$table->timestamp('failed_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -3,8 +3,7 @@
|
|||||||
namespace Firefly\Queue;
|
namespace Firefly\Queue;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Firefly\Exception\FireflyException;
|
use Illuminate\Queue\Jobs\Job;
|
||||||
use Illuminate\Queue\Jobs\SyncJob;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Import
|
* Class Import
|
||||||
@@ -24,6 +23,18 @@ class Import
|
|||||||
/** @var \Firefly\Storage\Category\CategoryRepositoryInterface */
|
/** @var \Firefly\Storage\Category\CategoryRepositoryInterface */
|
||||||
protected $_categories;
|
protected $_categories;
|
||||||
|
|
||||||
|
/** @var \Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface */
|
||||||
|
protected $_journals;
|
||||||
|
|
||||||
|
/** @var \Firefly\Storage\Limit\LimitRepositoryInterface */
|
||||||
|
protected $_limits;
|
||||||
|
|
||||||
|
/** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface */
|
||||||
|
protected $_piggybanks;
|
||||||
|
|
||||||
|
/** @var \Firefly\Storage\RecurringTransaction\RecurringTransactionRepositoryInterface */
|
||||||
|
protected $_recurring;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -33,19 +44,59 @@ class Import
|
|||||||
$this->_repository = \App::make('Firefly\Storage\Import\ImportRepositoryInterface');
|
$this->_repository = \App::make('Firefly\Storage\Import\ImportRepositoryInterface');
|
||||||
$this->_budgets = \App::make('Firefly\Storage\Budget\BudgetRepositoryInterface');
|
$this->_budgets = \App::make('Firefly\Storage\Budget\BudgetRepositoryInterface');
|
||||||
$this->_categories = \App::make('Firefly\Storage\Category\CategoryRepositoryInterface');
|
$this->_categories = \App::make('Firefly\Storage\Category\CategoryRepositoryInterface');
|
||||||
|
$this->_journals = \App::make('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
|
||||||
|
$this->_limits = \App::make('Firefly\Storage\Limit\LimitRepositoryInterface');
|
||||||
|
$this->_piggybanks = \App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
||||||
|
$this->_recurring = \App::make('Firefly\Storage\RecurringTransaction\RecurringTransactionRepositoryInterface');
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Job $job
|
||||||
|
* @param array $payload
|
||||||
|
* @throws \Firefly\Exception\FireflyException
|
||||||
|
*/
|
||||||
|
public function importComponent(Job $job, array $payload)
|
||||||
|
{
|
||||||
|
|
||||||
|
\Log::debug('Going to import component "' . $payload['data']['name'] . '".');
|
||||||
|
switch ($payload['data']['type']['type']) {
|
||||||
|
case 'beneficiary':
|
||||||
|
$payload['class'] = 'Account';
|
||||||
|
$payload['data']['account_type'] = 'Beneficiary account';
|
||||||
|
$this->importAccount($job, $payload);
|
||||||
|
break;
|
||||||
|
case 'budget':
|
||||||
|
$this->importBudget($job, $payload);
|
||||||
|
break;
|
||||||
|
case 'category':
|
||||||
|
$this->importCategory($job, $payload);
|
||||||
|
break;
|
||||||
|
case 'payer':
|
||||||
|
$job->delete();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$job->delete();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import a personal account or beneficiary as a new account.
|
* Import a personal account or beneficiary as a new account.
|
||||||
*
|
*
|
||||||
* @param SyncJob $job
|
* @param Job $job
|
||||||
* @param array $payload
|
* @param array $payload
|
||||||
*/
|
*/
|
||||||
public function importAccount(SyncJob $job, array $payload)
|
public function importAccount(Job $job, array $payload)
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var \Importmap $importMap */
|
/** @var \Importmap $importMap */
|
||||||
$importMap = $this->_repository->findImportmap($payload['mapID']);
|
$importMap = $this->_repository->findImportmap($payload['mapID']);
|
||||||
|
$user = $importMap->user;
|
||||||
|
$this->overruleUser($user);
|
||||||
|
|
||||||
|
|
||||||
// maybe we've already imported this account:
|
// maybe we've already imported this account:
|
||||||
$importEntry = $this->_repository->findImportEntry($importMap, 'Account', intval($payload['data']['id']));
|
$importEntry = $this->_repository->findImportEntry($importMap, 'Account', intval($payload['data']['id']));
|
||||||
@@ -85,16 +136,33 @@ class Import
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
*/
|
||||||
|
protected function overruleUser(\User $user)
|
||||||
|
{
|
||||||
|
$this->_accounts->overruleUser($user);
|
||||||
|
$this->_budgets->overruleUser($user);
|
||||||
|
$this->_categories->overruleUser($user);
|
||||||
|
$this->_journals->overruleUser($user);
|
||||||
|
$this->_limits->overruleUser($user);
|
||||||
|
$this->_repository->overruleUser($user);
|
||||||
|
$this->_piggybanks->overruleUser($user);
|
||||||
|
$this->_recurring->overruleUser($user);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import a budget into Firefly.
|
* Import a budget into Firefly.
|
||||||
*
|
*
|
||||||
* @param SyncJob $job
|
* @param Job $job
|
||||||
* @param array $payload
|
* @param array $payload
|
||||||
*/
|
*/
|
||||||
public function importBudget(SyncJob $job, array $payload)
|
public function importBudget(Job $job, array $payload)
|
||||||
{
|
{
|
||||||
/** @var \Importmap $importMap */
|
/** @var \Importmap $importMap */
|
||||||
$importMap = $this->_repository->findImportmap($payload['mapID']);
|
$importMap = $this->_repository->findImportmap($payload['mapID']);
|
||||||
|
$user = $importMap->user;
|
||||||
|
$this->overruleUser($user);
|
||||||
|
|
||||||
// maybe we've already imported this budget:
|
// maybe we've already imported this budget:
|
||||||
$bdg = $this->_budgets->findByName($payload['data']['name']);
|
$bdg = $this->_budgets->findByName($payload['data']['name']);
|
||||||
@@ -117,14 +185,16 @@ class Import
|
|||||||
/**
|
/**
|
||||||
* Import a category into Firefly.
|
* Import a category into Firefly.
|
||||||
*
|
*
|
||||||
* @param SyncJob $job
|
* @param Job $job
|
||||||
* @param array $payload
|
* @param array $payload
|
||||||
*/
|
*/
|
||||||
public function importCategory(SyncJob $job, array $payload)
|
public function importCategory(Job $job, array $payload)
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var \Importmap $importMap */
|
/** @var \Importmap $importMap */
|
||||||
$importMap = $this->_repository->findImportmap($payload['mapID']);
|
$importMap = $this->_repository->findImportmap($payload['mapID']);
|
||||||
|
$user = $importMap->user;
|
||||||
|
$this->overruleUser($user);
|
||||||
|
|
||||||
// try to find budget:
|
// try to find budget:
|
||||||
$current = $this->_categories->findByName($payload['data']['name']);
|
$current = $this->_categories->findByName($payload['data']['name']);
|
||||||
@@ -141,85 +211,42 @@ class Import
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SyncJob $job
|
* @param Job $job
|
||||||
* @param array $payload
|
|
||||||
* @throws \Firefly\Exception\FireflyException
|
|
||||||
*/
|
|
||||||
public function importComponent(SyncJob $job, array $payload)
|
|
||||||
{
|
|
||||||
|
|
||||||
\Log::debug('Going to import component "' . $payload['data']['name'] . '".');
|
|
||||||
switch ($payload['data']['type']['type']) {
|
|
||||||
case 'beneficiary':
|
|
||||||
$jobFunction = 'Firefly\Queue\Import@importAccount';
|
|
||||||
$payload['class'] = 'Account';
|
|
||||||
$payload['data']['account_type'] = 'Beneficiary account';
|
|
||||||
\Log::debug('It is a beneficiary.');
|
|
||||||
break;
|
|
||||||
case 'budget':
|
|
||||||
$jobFunction = 'Firefly\Queue\Import@importBudget';
|
|
||||||
\Log::debug('It is a budget.');
|
|
||||||
break;
|
|
||||||
case 'category':
|
|
||||||
$jobFunction = 'Firefly\Queue\Import@importCategory';
|
|
||||||
\Log::debug('It is a category.');
|
|
||||||
break;
|
|
||||||
case 'payer':
|
|
||||||
// ignored!
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new FireflyException('No import case for "' . $payload['data']['type']['type'] . '"!');
|
|
||||||
}
|
|
||||||
if (isset($jobFunction)) {
|
|
||||||
\Queue::push($jobFunction, $payload);
|
|
||||||
}
|
|
||||||
$job->delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param SyncJob $job
|
|
||||||
* @param array $payload
|
* @param array $payload
|
||||||
*/
|
*/
|
||||||
public function importComponentTransaction(SyncJob $job, array $payload)
|
public function importComponentTransaction(Job $job, array $payload)
|
||||||
{
|
{
|
||||||
if ($job->attempts() > 1) {
|
if ($job->attempts() > 1) {
|
||||||
\Log::info('Job running for ' . $job->attempts() . 'th time!');
|
\Log::info('importComponentTransaction Job running for ' . $job->attempts() . 'th time!');
|
||||||
|
}
|
||||||
|
if ($job->attempts() > 30) {
|
||||||
|
\Log::error('importComponentTransaction Job running for ' . $job->attempts() . 'th time, so KILL!');
|
||||||
|
$job->delete();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldComponentId = intval($payload['data']['component_id']);
|
$oldComponentId = intval($payload['data']['component_id']);
|
||||||
$oldTransactionId = intval($payload['data']['transaction_id']);
|
$oldTransactionId = intval($payload['data']['transaction_id']);
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Import\ImportRepositoryInterface $repository */
|
|
||||||
$repository = \App::make('Firefly\Storage\Import\ImportRepositoryInterface');
|
|
||||||
|
|
||||||
|
|
||||||
/** @var \Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface $journals */
|
|
||||||
$journals = \App::make('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
|
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Category\CategoryRepositoryInterface $categories */
|
|
||||||
$categories = \App::make('Firefly\Storage\Category\CategoryRepositoryInterface');
|
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accounts */
|
|
||||||
$accounts = \App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
|
||||||
|
|
||||||
|
|
||||||
/** @var \Importmap $importMap */
|
/** @var \Importmap $importMap */
|
||||||
$importMap = $repository->findImportmap($payload['mapID']);
|
$importMap = $this->_repository->findImportmap($payload['mapID']);
|
||||||
|
$user = $importMap->user;
|
||||||
|
$this->overruleUser($user);
|
||||||
|
|
||||||
$oldTransactionMap = $repository->findImportEntry($importMap, 'Transaction', $oldTransactionId);
|
$oldTransactionMap = $this->_repository->findImportEntry($importMap, 'Transaction', $oldTransactionId);
|
||||||
|
|
||||||
// we don't know what the component is, so we need to search for it in a set
|
// we don't know what the component is, so we need to search for it in a set
|
||||||
// of possible types (Account / Beneficiary, Budget, Category)
|
// of possible types (Account / Beneficiary, Budget, Category)
|
||||||
/** @var \Importentry $oldComponentMap */
|
/** @var \Importentry $oldComponentMap */
|
||||||
$oldComponentMap = $repository->findImportComponentMap($importMap, $oldComponentId);
|
$oldComponentMap = $this->_repository->findImportComponentMap($importMap, $oldComponentId);
|
||||||
|
|
||||||
if (is_null($oldComponentMap)) {
|
if (is_null($oldComponentMap)) {
|
||||||
\Log::debug('Could not run this one, waiting for five seconds...');
|
\Log::debug('importComponentTransaction Could not run this one, waiting for five minutes...');
|
||||||
$job->release(5);
|
$job->release(300);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$journal = $journals->find($oldTransactionMap->new);
|
$journal = $this->_journals->find($oldTransactionMap->new);
|
||||||
\Log::debug('Going to update ' . $journal->description);
|
\Log::debug('Going to update ' . $journal->description);
|
||||||
|
|
||||||
// find the cash account:
|
// find the cash account:
|
||||||
@@ -237,8 +264,8 @@ class Import
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 'Category':
|
case 'Category':
|
||||||
$category = $categories->find($oldComponentMap->new);
|
$category = $this->_categories->find($oldComponentMap->new);
|
||||||
$journal = $journals->find($oldTransactionMap->new);
|
$journal = $this->_journals->find($oldTransactionMap->new);
|
||||||
\Log::info('Updating transactions Category.');
|
\Log::info('Updating transactions Category.');
|
||||||
$journal->categories()->save($category);
|
$journal->categories()->save($category);
|
||||||
$journal->save();
|
$journal->save();
|
||||||
@@ -246,11 +273,11 @@ class Import
|
|||||||
break;
|
break;
|
||||||
case 'Account':
|
case 'Account':
|
||||||
\Log::info('Updating transactions Account.');
|
\Log::info('Updating transactions Account.');
|
||||||
$account = $accounts->find($oldComponentMap->new);
|
$account = $this->_accounts->find($oldComponentMap->new);
|
||||||
$journal = $journals->find($oldTransactionMap->new);
|
$journal = $this->_journals->find($oldTransactionMap->new);
|
||||||
if (is_null($account)) {
|
if (is_null($account)) {
|
||||||
\Log::debug('Cash account is needed.');
|
\Log::debug('Cash account is needed.');
|
||||||
$account = $accounts->getCashAccount();
|
$account = $this->_accounts->getCashAccount();
|
||||||
\Log::info($account);
|
\Log::info($account);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,51 +296,51 @@ class Import
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SyncJob $job
|
* @param Job $job
|
||||||
* @param array $payload
|
* @param array $payload
|
||||||
*/
|
*/
|
||||||
public function importLimit(SyncJob $job, array $payload)
|
public function importLimit(Job $job, array $payload)
|
||||||
{
|
{
|
||||||
|
if ($job->attempts() > 30) {
|
||||||
/** @var \Firefly\Storage\Limit\LimitRepositoryInterface $limits */
|
\Log::error('importLimit Job running for ' . $job->attempts() . 'th time, so KILL!');
|
||||||
$limits = \App::make('Firefly\Storage\Limit\LimitRepositoryInterface');
|
$job->delete();
|
||||||
|
return;
|
||||||
/** @var \Firefly\Storage\Import\ImportRepositoryInterface $repository */
|
}
|
||||||
$repository = \App::make('Firefly\Storage\Import\ImportRepositoryInterface');
|
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Budget\BudgetRepositoryInterface $budgets */
|
|
||||||
$budgets = \App::make('Firefly\Storage\Budget\BudgetRepositoryInterface');
|
|
||||||
|
|
||||||
/** @var \Importmap $importMap */
|
/** @var \Importmap $importMap */
|
||||||
$importMap = $repository->findImportmap($payload['mapID']);
|
$importMap = $this->_repository->findImportmap($payload['mapID']);
|
||||||
|
$user = $importMap->user;
|
||||||
|
$this->overruleUser($user);
|
||||||
|
|
||||||
|
|
||||||
// find the budget this limit is part of:
|
// find the budget this limit is part of:
|
||||||
$importEntry = $repository->findImportEntry($importMap, 'Budget', intval($payload['data']['component_id']));
|
$importEntry = $this->_repository->findImportEntry($importMap, 'Budget',
|
||||||
|
intval($payload['data']['component_id']));
|
||||||
|
|
||||||
// budget is not yet imported:
|
// budget is not yet imported:
|
||||||
if (is_null($importEntry)) {
|
if (is_null($importEntry)) {
|
||||||
\Log::debug('Released job for work in five seconds...');
|
\Log::debug('importLimit Cannot import limit #' . $payload['data']['id'] .
|
||||||
$job->release(5);
|
' because the budget is not here yet. #' . $job->attempts());
|
||||||
|
$job->release(300);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// find similar limit:
|
// find similar limit:
|
||||||
\Log::debug('Trying to find budget with ID #' . $importEntry->new . ', based on entry #' . $importEntry->id);
|
\Log::debug('Trying to find budget with ID #' . $importEntry->new . ', based on entry #' . $importEntry->id);
|
||||||
$budget = $budgets->find($importEntry->new);
|
$budget = $this->_budgets->find($importEntry->new);
|
||||||
if (!is_null($budget)) {
|
if (!is_null($budget)) {
|
||||||
$current = $limits->findByBudgetAndDate($budget, new Carbon($payload['data']['date']));
|
$current = $this->_limits->findByBudgetAndDate($budget, new Carbon($payload['data']['date']));
|
||||||
if (is_null($current)) {
|
if (is_null($current)) {
|
||||||
// create it!
|
// create it!
|
||||||
$payload['data']['budget_id'] = $budget->id;
|
$payload['data']['budget_id'] = $budget->id;
|
||||||
$payload['data']['startdate'] = $payload['data']['date'];
|
$payload['data']['startdate'] = $payload['data']['date'];
|
||||||
$payload['data']['period'] = 'monthly';
|
$payload['data']['period'] = 'monthly';
|
||||||
$lim = $limits->store((array)$payload['data']);
|
$lim = $this->_limits->store((array)$payload['data']);
|
||||||
$repository->store($importMap, 'Limit', $payload['data']['id'], $lim->id);
|
$this->_repository->store($importMap, 'Limit', $payload['data']['id'], $lim->id);
|
||||||
\Event::fire('limits.store', [$lim]);
|
\Event::fire('limits.store', [$lim]);
|
||||||
\Log::debug('Imported ' . $payload['class'] . ', for ' . $budget->name . ' (' . $lim->startdate . ').');
|
\Log::debug('Imported ' . $payload['class'] . ', for ' . $budget->name . ' (' . $lim->startdate . ').');
|
||||||
} else {
|
} else {
|
||||||
// already has!
|
// already has!
|
||||||
$repository->store($importMap, 'Budget', $payload['data']['id'], $current->id);
|
$this->_repository->store($importMap, 'Budget', $payload['data']['id'], $current->id);
|
||||||
\Log::debug('Already had ' . $payload['class'] . ', for ' . $budget->name . ' (' . $current->startdate . ').');
|
\Log::debug('Already had ' . $payload['class'] . ', for ' . $budget->name . ' (' . $current->startdate . ').');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -324,34 +351,27 @@ class Import
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SyncJob $job
|
* @param Job $job
|
||||||
* @param array $payload
|
* @param array $payload
|
||||||
*/
|
*/
|
||||||
public function importPiggybank(SyncJob $job, array $payload)
|
public function importPiggybank(Job $job, array $payload)
|
||||||
{
|
{
|
||||||
/** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggybanks */
|
|
||||||
$piggybanks = \App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Import\ImportRepositoryInterface $repository */
|
|
||||||
$repository = \App::make('Firefly\Storage\Import\ImportRepositoryInterface');
|
|
||||||
|
|
||||||
/** @var \Importmap $importMap */
|
/** @var \Importmap $importMap */
|
||||||
$importMap = $repository->findImportmap($payload['mapID']);
|
$importMap = $this->_repository->findImportmap($payload['mapID']);
|
||||||
|
$user = $importMap->user;
|
||||||
|
$this->overruleUser($user);
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accounts */
|
// try to find related piggybank:
|
||||||
$accounts = \App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
$current = $this->_piggybanks->findByName($payload['data']['name']);
|
||||||
|
|
||||||
// try to find related piggybank:
|
|
||||||
$current = $piggybanks->findByName($payload['data']['name']);
|
|
||||||
|
|
||||||
// we need an account to go with this piggy bank:
|
// we need an account to go with this piggy bank:
|
||||||
$set = $accounts->getActiveDefault();
|
$set = $this->_accounts->getActiveDefault();
|
||||||
if (count($set) > 0) {
|
if (count($set) > 0) {
|
||||||
$account = $set[0];
|
$account = $set[0];
|
||||||
$payload['data']['account_id'] = $account->id;
|
$payload['data']['account_id'] = $account->id;
|
||||||
} else {
|
} else {
|
||||||
\Log::debug('Released job for work in five seconds...');
|
\Log::debug('Released job for work in five minutes...');
|
||||||
$job->release(5);
|
$job->release(300);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,35 +381,31 @@ class Import
|
|||||||
$payload['data']['rep_every'] = 1;
|
$payload['data']['rep_every'] = 1;
|
||||||
$payload['data']['reminder_skip'] = 1;
|
$payload['data']['reminder_skip'] = 1;
|
||||||
$payload['data']['rep_times'] = 1;
|
$payload['data']['rep_times'] = 1;
|
||||||
$piggy = $piggybanks->store((array)$payload['data']);
|
$piggy = $this->_piggybanks->store((array)$payload['data']);
|
||||||
$repository->store($importMap, 'Piggybank', $payload['data']['id'], $piggy->id);
|
$this->_repository->store($importMap, 'Piggybank', $payload['data']['id'], $piggy->id);
|
||||||
\Log::debug('Imported ' . $payload['class'] . ' "' . $payload['data']['name'] . '".');
|
\Log::debug('Imported ' . $payload['class'] . ' "' . $payload['data']['name'] . '".');
|
||||||
\Event::fire('piggybanks.store', [$piggy]);
|
\Event::fire('piggybanks.store', [$piggy]);
|
||||||
} else {
|
} else {
|
||||||
$repository->store($importMap, 'Piggybank', $payload['data']['id'], $current->id);
|
$this->_repository->store($importMap, 'Piggybank', $payload['data']['id'], $current->id);
|
||||||
\Log::debug('Already had ' . $payload['class'] . ' "' . $payload['data']['name'] . '".');
|
\Log::debug('Already had ' . $payload['class'] . ' "' . $payload['data']['name'] . '".');
|
||||||
}
|
}
|
||||||
$job->delete();
|
$job->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SyncJob $job
|
* @param Job $job
|
||||||
* @param array $payload
|
* @param array $payload
|
||||||
*/
|
*/
|
||||||
public function importPredictable(SyncJob $job, array $payload)
|
public function importPredictable(Job $job, array $payload)
|
||||||
{
|
{
|
||||||
/** @var \Firefly\Storage\RecurringTransaction\RecurringTransactionRepositoryInterface $piggybanks */
|
|
||||||
$recurring = \App::make('Firefly\Storage\RecurringTransaction\RecurringTransactionRepositoryInterface');
|
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Import\ImportRepositoryInterface $repository */
|
|
||||||
$repository = \App::make('Firefly\Storage\Import\ImportRepositoryInterface');
|
|
||||||
|
|
||||||
/** @var \Importmap $importMap */
|
/** @var \Importmap $importMap */
|
||||||
$importMap = $repository->findImportmap($payload['mapID']);
|
$importMap = $this->_repository->findImportmap($payload['mapID']);
|
||||||
|
$user = $importMap->user;
|
||||||
|
$this->overruleUser($user);
|
||||||
|
|
||||||
|
|
||||||
// try to find related recurring transaction:
|
// try to find related recurring transaction:
|
||||||
$current = $recurring->findByName($payload['data']['description']);
|
$current = $this->_recurring->findByName($payload['data']['description']);
|
||||||
if (is_null($current)) {
|
if (is_null($current)) {
|
||||||
|
|
||||||
$payload['data']['name'] = $payload['data']['description'];
|
$payload['data']['name'] = $payload['data']['description'];
|
||||||
@@ -402,12 +418,12 @@ class Import
|
|||||||
$payload['data']['active'] = intval($payload['data']['inactive']) == 1 ? 0 : 1;
|
$payload['data']['active'] = intval($payload['data']['inactive']) == 1 ? 0 : 1;
|
||||||
$payload['data']['automatch'] = 1;
|
$payload['data']['automatch'] = 1;
|
||||||
|
|
||||||
$recur = $recurring->store((array)$payload['data']);
|
$recur = $this->_recurring->store((array)$payload['data']);
|
||||||
|
|
||||||
$repository->store($importMap, 'RecurringTransaction', $payload['data']['id'], $recur->id);
|
$this->_repository->store($importMap, 'RecurringTransaction', $payload['data']['id'], $recur->id);
|
||||||
\Log::debug('Imported ' . $payload['class'] . ' "' . $payload['data']['name'] . '".');
|
\Log::debug('Imported ' . $payload['class'] . ' "' . $payload['data']['name'] . '".');
|
||||||
} else {
|
} else {
|
||||||
$repository->store($importMap, 'RecurringTransaction', $payload['data']['id'], $current->id);
|
$this->_repository->store($importMap, 'RecurringTransaction', $payload['data']['id'], $current->id);
|
||||||
\Log::debug('Already had ' . $payload['class'] . ' "' . $payload['data']['description'] . '".');
|
\Log::debug('Already had ' . $payload['class'] . ' "' . $payload['data']['description'] . '".');
|
||||||
}
|
}
|
||||||
$job->delete();
|
$job->delete();
|
||||||
@@ -415,10 +431,10 @@ class Import
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SyncJob $job
|
* @param Job $job
|
||||||
* @param array $payload
|
* @param array $payload
|
||||||
*/
|
*/
|
||||||
public function importSetting(SyncJob $job, array $payload)
|
public function importSetting(Job $job, array $payload)
|
||||||
{
|
{
|
||||||
switch ($payload['data']['name']) {
|
switch ($payload['data']['name']) {
|
||||||
default:
|
default:
|
||||||
@@ -429,23 +445,17 @@ class Import
|
|||||||
// if we have this account, update all piggy banks:
|
// if we have this account, update all piggy banks:
|
||||||
$accountID = intval($payload['data']['value']);
|
$accountID = intval($payload['data']['value']);
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Import\ImportRepositoryInterface $repository */
|
|
||||||
$repository = \App::make('Firefly\Storage\Import\ImportRepositoryInterface');
|
|
||||||
|
|
||||||
/** @var \Importmap $importMap */
|
/** @var \Importmap $importMap */
|
||||||
$importMap = $repository->findImportmap($payload['mapID']);
|
$importMap = $this->_repository->findImportmap($payload['mapID']);
|
||||||
|
$user = $importMap->user;
|
||||||
|
$this->overruleUser($user);
|
||||||
|
|
||||||
|
|
||||||
$importEntry = $repository->findImportEntry($importMap, 'Account', $accountID);
|
$importEntry = $this->_repository->findImportEntry($importMap, 'Account', $accountID);
|
||||||
if ($importEntry) {
|
if ($importEntry) {
|
||||||
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accounts */
|
|
||||||
$accounts = \App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggybanks */
|
$all = $this->_piggybanks->get();
|
||||||
$piggybanks = \App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
$account = $this->_accounts->find($importEntry->new);
|
||||||
|
|
||||||
$all = $piggybanks->get();
|
|
||||||
$account = $accounts->find($importEntry->new);
|
|
||||||
|
|
||||||
\Log::debug('Updating all piggybanks, found the right setting.');
|
\Log::debug('Updating all piggybanks, found the right setting.');
|
||||||
foreach ($all as $piggy) {
|
foreach ($all as $piggy) {
|
||||||
@@ -454,7 +464,8 @@ class Import
|
|||||||
$piggy->save();
|
$piggy->save();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$job->release(5);
|
\Log::debug('importSetting wait five minutes and try again...');
|
||||||
|
$job->release(300);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -463,35 +474,29 @@ class Import
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SyncJob $job
|
* @param Job $job
|
||||||
* @param array $payload
|
* @param array $payload
|
||||||
*/
|
*/
|
||||||
public function importTransaction(SyncJob $job, array $payload)
|
public function importTransaction(Job $job, array $payload)
|
||||||
{
|
{
|
||||||
/** @var \Firefly\Storage\Import\ImportRepositoryInterface $repository */
|
|
||||||
$repository = \App::make('Firefly\Storage\Import\ImportRepositoryInterface');
|
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accounts */
|
|
||||||
$accounts = \App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
|
||||||
|
|
||||||
/** @var \Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface $journals */
|
|
||||||
$journals = \App::make('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
|
|
||||||
|
|
||||||
|
|
||||||
/** @var \Importmap $importMap */
|
/** @var \Importmap $importMap */
|
||||||
$importMap = $repository->findImportmap($payload['mapID']);
|
$importMap = $this->_repository->findImportmap($payload['mapID']);
|
||||||
|
$user = $importMap->user;
|
||||||
|
$this->overruleUser($user);
|
||||||
|
|
||||||
// find or create the account type for the import account.
|
// find or create the account type for the import account.
|
||||||
// find or create the account for the import account.
|
// find or create the account for the import account.
|
||||||
$accountType = $accounts->findAccountType('Import account');
|
$accountType = $this->_accounts->findAccountType('Import account');
|
||||||
$importAccount = $accounts->createOrFind('Import account', $accountType);
|
$importAccount = $this->_accounts->createOrFind('Import account', $accountType);
|
||||||
|
|
||||||
|
|
||||||
// if amount is more than zero, move from $importAccount
|
// if amount is more than zero, move from $importAccount
|
||||||
$amount = floatval($payload['data']['amount']);
|
$amount = floatval($payload['data']['amount']);
|
||||||
|
|
||||||
$accountEntry = $repository->findImportEntry($importMap, 'Account', intval($payload['data']['account_id']));
|
$accountEntry = $this->_repository->findImportEntry($importMap, 'Account',
|
||||||
$personalAccount = $accounts->find($accountEntry->new);
|
intval($payload['data']['account_id']));
|
||||||
|
$personalAccount = $this->_accounts->find($accountEntry->new);
|
||||||
|
|
||||||
if ($amount < 0) {
|
if ($amount < 0) {
|
||||||
// if amount is less than zero, move to $importAccount
|
// if amount is less than zero, move to $importAccount
|
||||||
@@ -505,54 +510,49 @@ class Import
|
|||||||
$date = new Carbon($payload['data']['date']);
|
$date = new Carbon($payload['data']['date']);
|
||||||
|
|
||||||
// find a journal?
|
// find a journal?
|
||||||
$current = $repository->findImportEntry($importMap, 'Transaction', intval($payload['data']['id']));
|
$current = $this->_repository->findImportEntry($importMap, 'Transaction', intval($payload['data']['id']));
|
||||||
|
|
||||||
|
|
||||||
if (is_null($current)) {
|
if (is_null($current)) {
|
||||||
$journal = $journals->createSimpleJournal($accountFrom, $accountTo,
|
$journal = $this->_journals->createSimpleJournal($accountFrom, $accountTo,
|
||||||
$payload['data']['description'], $amount, $date);
|
$payload['data']['description'], $amount, $date);
|
||||||
$repository->store($importMap, 'Transaction', $payload['data']['id'], $journal->id);
|
$this->_repository->store($importMap, 'Transaction', $payload['data']['id'], $journal->id);
|
||||||
\Log::debug('Imported transaction "' . $payload['data']['description'] . '" (' . $journal->date->format('Y-m-d') . ').');
|
\Log::debug('Imported transaction "' . $payload['data']['description'] . '" (' . $journal->date->format('Y-m-d') . ').');
|
||||||
} else {
|
} else {
|
||||||
// do nothing.
|
// do nothing.
|
||||||
\Log::debug('ALREADY imported transaction "' . $payload['data']['description'] . '".');
|
\Log::debug('ALREADY imported transaction "' . $payload['data']['description'] . '".');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$job->delete();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SyncJob $job
|
* @param Job $job
|
||||||
* @param array $payload
|
* @param array $payload
|
||||||
*/
|
*/
|
||||||
public function importTransfer(SyncJob $job, array $payload)
|
public function importTransfer(Job $job, array $payload)
|
||||||
{
|
{
|
||||||
/** @var \Firefly\Storage\Import\ImportRepositoryInterface $repository */
|
|
||||||
$repository = \App::make('Firefly\Storage\Import\ImportRepositoryInterface');
|
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accounts */
|
|
||||||
$accounts = \App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
|
||||||
|
|
||||||
/** @var \Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface $journals */
|
|
||||||
$journals = \App::make('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
|
|
||||||
|
|
||||||
|
|
||||||
/** @var \Importmap $importMap */
|
/** @var \Importmap $importMap */
|
||||||
$importMap = $repository->findImportmap($payload['mapID']);
|
$importMap = $this->_repository->findImportmap($payload['mapID']);
|
||||||
|
$user = $importMap->user;
|
||||||
|
$this->overruleUser($user);
|
||||||
|
|
||||||
// from account:
|
// from account:
|
||||||
$oldFromAccountID = intval($payload['data']['accountfrom_id']);
|
$oldFromAccountID = intval($payload['data']['accountfrom_id']);
|
||||||
$oldFromAccountEntry = $repository->findImportEntry($importMap, 'Account', $oldFromAccountID);
|
$oldFromAccountEntry = $this->_repository->findImportEntry($importMap, 'Account', $oldFromAccountID);
|
||||||
$accountFrom = $accounts->find($oldFromAccountEntry->new);
|
$accountFrom = $this->_accounts->find($oldFromAccountEntry->new);
|
||||||
|
|
||||||
// to account:
|
// to account:
|
||||||
$oldToAccountID = intval($payload['data']['accountto_id']);
|
$oldToAccountID = intval($payload['data']['accountto_id']);
|
||||||
$oldToAccountEntry = $repository->findImportEntry($importMap, 'Account', $oldToAccountID);
|
$oldToAccountEntry = $this->_repository->findImportEntry($importMap, 'Account', $oldToAccountID);
|
||||||
$accountTo = $accounts->find($oldToAccountEntry->new);
|
$accountTo = $this->_accounts->find($oldToAccountEntry->new);
|
||||||
if (!is_null($accountFrom) && !is_null($accountTo)) {
|
if (!is_null($accountFrom) && !is_null($accountTo)) {
|
||||||
$amount = floatval($payload['data']['amount']);
|
$amount = floatval($payload['data']['amount']);
|
||||||
$date = new Carbon($payload['data']['date']);
|
$date = new Carbon($payload['data']['date']);
|
||||||
$journal = $journals->createSimpleJournal($accountFrom, $accountTo, $payload['data']['description'],
|
$journal = $this->_journals->createSimpleJournal($accountFrom, $accountTo, $payload['data']['description'],
|
||||||
$amount, $date);
|
$amount, $date);
|
||||||
\Log::debug('Imported transfer "' . $payload['data']['description'] . '".');
|
\Log::debug('Imported transfer "' . $payload['data']['description'] . '".');
|
||||||
$job->delete();
|
$job->delete();
|
||||||
@@ -563,10 +563,10 @@ class Import
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SyncJob $job
|
* @param Job $job
|
||||||
* @param $payload
|
* @param $payload
|
||||||
*/
|
*/
|
||||||
public function start(SyncJob $job, array $payload)
|
public function start(Job $job, array $payload)
|
||||||
{
|
{
|
||||||
\Log::debug('Start with job "start"');
|
\Log::debug('Start with job "start"');
|
||||||
$user = \User::find($payload['user']);
|
$user = \User::find($payload['user']);
|
||||||
@@ -591,19 +591,20 @@ class Import
|
|||||||
$class = ucfirst(\Str::singular($classes_plural));
|
$class = ucfirst(\Str::singular($classes_plural));
|
||||||
\Log::debug('Create job to import all ' . $classes_plural);
|
\Log::debug('Create job to import all ' . $classes_plural);
|
||||||
foreach ($JSON->$classes_plural as $entry) {
|
foreach ($JSON->$classes_plural as $entry) {
|
||||||
//\Log::debug('Create job to import single ' . $class);
|
\Log::debug('Create job to import single ' . $class);
|
||||||
$fn = 'import' . $class;
|
$fn = 'import' . $class;
|
||||||
$jobFunction = 'Firefly\Queue\Import@' . $fn;
|
$jobFunction = 'Firefly\Queue\Import@' . $fn;
|
||||||
\Queue::push($jobFunction, ['data' => $entry, 'class' => $class, 'mapID' => $importMap->id]);
|
\Queue::push($jobFunction, ['data' => $entry, 'class' => $class, 'mapID' => $importMap->id]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// accounts, components, limits, piggybanks, predictables, settings, transactions, transfers
|
// , components, limits, piggybanks, predictables, settings, transactions, transfers
|
||||||
// component_predictables, component_transactions, component_transfers
|
// component_predictables, component_transactions, component_transfers
|
||||||
|
|
||||||
$count = count($JSON->component_transaction);
|
$count = count($JSON->component_transaction);
|
||||||
foreach ($JSON->component_transaction as $index => $entry) {
|
foreach ($JSON->component_transaction as $index => $entry) {
|
||||||
//\Log::debug('Create job to import components_transaction! Yay! (' . $index . '/' . $count . ') ');
|
\Log::debug('Create job to import components_transaction! Yay! (' . $index . '/' . $count . ') ');
|
||||||
$fn = 'importComponentTransaction';
|
$fn = 'importComponentTransaction';
|
||||||
$jobFunction = 'Firefly\Queue\Import@' . $fn;
|
$jobFunction = 'Firefly\Queue\Import@' . $fn;
|
||||||
\Queue::push($jobFunction, ['data' => $entry, 'mapID' => $importMap->id]);
|
\Queue::push($jobFunction, ['data' => $entry, 'mapID' => $importMap->id]);
|
||||||
@@ -611,12 +612,7 @@ class Import
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
echo 'Done';
|
|
||||||
\Log::debug('Done with job "start"');
|
\Log::debug('Done with job "start"');
|
||||||
exit;
|
|
||||||
|
|
||||||
// this is it, close the job:
|
// this is it, close the job:
|
||||||
$job->delete();
|
$job->delete();
|
||||||
}
|
}
|
||||||
|
@@ -101,6 +101,12 @@ interface AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getDefault();
|
public function getDefault();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $data
|
* @param $data
|
||||||
*
|
*
|
||||||
|
@@ -12,11 +12,15 @@ use Carbon\Carbon;
|
|||||||
*/
|
*/
|
||||||
class EloquentAccountRepository implements AccountRepositoryInterface
|
class EloquentAccountRepository implements AccountRepositoryInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
protected $_user = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
$this->_user = \Auth::user();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,7 +28,7 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function count()
|
public function count()
|
||||||
{
|
{
|
||||||
return \Auth::user()->accounts()->count();
|
return $this->_user->accounts()->count();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +90,8 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
$accountIDs = array_unique($accountIDs);
|
$accountIDs = array_unique($accountIDs);
|
||||||
if (count($accountIDs) > 0) {
|
if (count($accountIDs) > 0) {
|
||||||
// find the "initial balance" type accounts in this list. Should be just 1.
|
// find the "initial balance" type accounts in this list. Should be just 1.
|
||||||
$query = \Auth::user()->accounts()->accountTypeIn(['Initial balance account'])
|
$query = $this->_user->accounts()->accountTypeIn(['Initial balance account'])
|
||||||
->whereIn('accounts.id', $accountIDs);
|
->whereIn('accounts.id', $accountIDs);
|
||||||
if ($query->count() == 1) {
|
if ($query->count() == 1) {
|
||||||
$iba = $query->first(['accounts.*']);
|
$iba = $query->first(['accounts.*']);
|
||||||
$iba->delete();
|
$iba->delete();
|
||||||
@@ -111,7 +115,16 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function find($accountId)
|
public function find($accountId)
|
||||||
{
|
{
|
||||||
return \Auth::user()->accounts()->where('id', $accountId)->first();
|
return $this->_user->accounts()->where('id', $accountId)->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $type
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function findAccountType($type)
|
||||||
|
{
|
||||||
|
return \AccountType::where('type', $type)->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -124,9 +137,23 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
{
|
{
|
||||||
$type = is_null($type) ? \AccountType::where('type', 'Default account')->first() : $type;
|
$type = is_null($type) ? \AccountType::where('type', 'Default account')->first() : $type;
|
||||||
|
|
||||||
return \Auth::user()->accounts()->where('account_type_id', $type->id)
|
return $this->_user->accounts()->where('account_type_id', $type->id)
|
||||||
->where('name', 'like', '%' . $name . '%')
|
->where('name', 'like', '%' . $name . '%')
|
||||||
->first();
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for import
|
||||||
|
*
|
||||||
|
* @param $name
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function findByNameAny($name)
|
||||||
|
{
|
||||||
|
return $this->_user->accounts()
|
||||||
|
->where('name', 'like', '%' . $name . '%')
|
||||||
|
->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +161,7 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function get()
|
public function get()
|
||||||
{
|
{
|
||||||
return \Auth::user()->accounts()->with('accounttype')->orderBy('name', 'ASC')->get();
|
return $this->_user->accounts()->with('accounttype')->orderBy('name', 'ASC')->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,18 +169,10 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getActiveDefault()
|
public function getActiveDefault()
|
||||||
{
|
{
|
||||||
return \Auth::user()->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
return $this->_user->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||||
->where('account_types.type', 'Default account')->where('accounts.active', 1)
|
->where('account_types.type', 'Default account')->where('accounts.active', 1)
|
||||||
|
|
||||||
->get(['accounts.*']);
|
->get(['accounts.*']);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $type
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function findAccountType($type) {
|
|
||||||
return \AccountType::where('type',$type)->first();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -161,12 +180,12 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getActiveDefaultAsSelectList()
|
public function getActiveDefaultAsSelectList()
|
||||||
{
|
{
|
||||||
$list = \Auth::user()->accounts()->leftJoin(
|
$list = $this->_user->accounts()->leftJoin(
|
||||||
'account_types', 'account_types.id', '=', 'accounts.account_type_id'
|
'account_types', 'account_types.id', '=', 'accounts.account_type_id'
|
||||||
)
|
)
|
||||||
->where('account_types.type', 'Default account')->where('accounts.active', 1)
|
->where('account_types.type', 'Default account')->where('accounts.active', 1)
|
||||||
|
|
||||||
->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
||||||
$return = [];
|
$return = [];
|
||||||
foreach ($list as $entry) {
|
foreach ($list as $entry) {
|
||||||
$return[intval($entry->id)] = $entry->name;
|
$return[intval($entry->id)] = $entry->name;
|
||||||
@@ -180,12 +199,12 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getBeneficiaries()
|
public function getBeneficiaries()
|
||||||
{
|
{
|
||||||
$list = \Auth::user()->accounts()->leftJoin(
|
$list = $this->_user->accounts()->leftJoin(
|
||||||
'account_types', 'account_types.id', '=', 'accounts.account_type_id'
|
'account_types', 'account_types.id', '=', 'accounts.account_type_id'
|
||||||
)
|
)
|
||||||
->where('account_types.type', 'Beneficiary account')->where('accounts.active', 1)
|
->where('account_types.type', 'Beneficiary account')->where('accounts.active', 1)
|
||||||
|
|
||||||
->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
||||||
|
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
@@ -198,7 +217,7 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
public function getByIds(array $ids)
|
public function getByIds(array $ids)
|
||||||
{
|
{
|
||||||
if (count($ids) > 0) {
|
if (count($ids) > 0) {
|
||||||
return \Auth::user()->accounts()->with('accounttype')->whereIn('id', $ids)->orderBy('name', 'ASC')->get();
|
return $this->_user->accounts()->with('accounttype')->whereIn('id', $ids)->orderBy('name', 'ASC')->get();
|
||||||
} else {
|
} else {
|
||||||
return $this->getActiveDefault();
|
return $this->getActiveDefault();
|
||||||
}
|
}
|
||||||
@@ -210,12 +229,12 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
public function getCashAccount()
|
public function getCashAccount()
|
||||||
{
|
{
|
||||||
$type = \AccountType::where('type', 'Cash account')->first();
|
$type = \AccountType::where('type', 'Cash account')->first();
|
||||||
$cash = \Auth::user()->accounts()->where('account_type_id', $type->id)->first();
|
$cash = $this->_user->accounts()->where('account_type_id', $type->id)->first();
|
||||||
if(is_null($cash)) {
|
if (is_null($cash)) {
|
||||||
$cash = new \Account;
|
$cash = new \Account;
|
||||||
$cash->accountType()->associate($type);
|
$cash->accountType()->associate($type);
|
||||||
$cash->user()->associate(\Auth::user());
|
$cash->user()->associate($this->_user);
|
||||||
$cash->name = 'Cash account';
|
$cash->name = 'Cash account';
|
||||||
$cash->active = 1;
|
$cash->active = 1;
|
||||||
$cash->save();
|
$cash->save();
|
||||||
}
|
}
|
||||||
@@ -229,10 +248,20 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getDefault()
|
public function getDefault()
|
||||||
{
|
{
|
||||||
return \Auth::user()->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
return $this->_user->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||||
->where('account_types.type', 'Default account')
|
->where('account_types.type', 'Default account')
|
||||||
|
|
||||||
->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user)
|
||||||
|
{
|
||||||
|
$this->_user = $user;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -262,11 +291,7 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
$account = new \Account;
|
$account = new \Account;
|
||||||
$account->accountType()->associate($accountType);
|
$account->accountType()->associate($accountType);
|
||||||
if (\Auth::check()) {
|
$account->user()->associate($this->_user);
|
||||||
$account->user()->associate(\Auth::user());
|
|
||||||
} else {
|
|
||||||
$account->user_id = $data['user_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$account->name = $data['name'];
|
$account->name = $data['name'];
|
||||||
$account->active
|
$account->active
|
||||||
@@ -328,20 +353,6 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
return $account;
|
return $account;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for import
|
|
||||||
*
|
|
||||||
* @param $name
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function findByNameAny($name)
|
|
||||||
{
|
|
||||||
return \Auth::user()->accounts()
|
|
||||||
->where('name', 'like', '%' . $name . '%')
|
|
||||||
->first();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Account $account
|
* @param \Account $account
|
||||||
* @param int $amount
|
* @param int $amount
|
||||||
@@ -358,7 +369,7 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
// create new account:
|
// create new account:
|
||||||
$initial = new \Account;
|
$initial = new \Account;
|
||||||
$initial->accountType()->associate($initialBalanceAT);
|
$initial->accountType()->associate($initialBalanceAT);
|
||||||
$initial->user()->associate(\Auth::user());
|
$initial->user()->associate($this->_user);
|
||||||
$initial->name = $account->name . ' initial balance';
|
$initial->name = $account->name . ' initial balance';
|
||||||
$initial->active = 0;
|
$initial->active = 0;
|
||||||
if ($initial->validate()) {
|
if ($initial->validate()) {
|
||||||
|
@@ -30,6 +30,12 @@ interface BudgetRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function findByName($budgetName);
|
public function findByName($budgetName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@@ -11,6 +11,15 @@ use Carbon\Carbon;
|
|||||||
*/
|
*/
|
||||||
class EloquentBudgetRepository implements BudgetRepositoryInterface
|
class EloquentBudgetRepository implements BudgetRepositoryInterface
|
||||||
{
|
{
|
||||||
|
protected $_user = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->_user = \Auth::user();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Budget $budget
|
* @param \Budget $budget
|
||||||
@@ -32,13 +41,13 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface
|
|||||||
public function find($budgetId)
|
public function find($budgetId)
|
||||||
{
|
{
|
||||||
|
|
||||||
return \Auth::user()->budgets()->find($budgetId);
|
return $this->_user->budgets()->find($budgetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findByName($budgetName)
|
public function findByName($budgetName)
|
||||||
{
|
{
|
||||||
|
|
||||||
return \Auth::user()->budgets()->whereName($budgetName)->first();
|
return $this->_user->budgets()->whereName($budgetName)->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,12 +55,12 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function get()
|
public function get()
|
||||||
{
|
{
|
||||||
$set = \Auth::user()->budgets()->with(
|
$set = $this->_user->budgets()->with(
|
||||||
['limits' => function ($q) {
|
['limits' => function ($q) {
|
||||||
$q->orderBy('limits.startdate', 'DESC');
|
$q->orderBy('limits.startdate', 'DESC');
|
||||||
}, 'limits.limitrepetitions' => function ($q) {
|
}, 'limits.limitrepetitions' => function ($q) {
|
||||||
$q->orderBy('limit_repetitions.startdate', 'ASC');
|
$q->orderBy('limit_repetitions.startdate', 'ASC');
|
||||||
}]
|
}]
|
||||||
)->orderBy('name', 'ASC')->get();
|
)->orderBy('name', 'ASC')->get();
|
||||||
foreach ($set as $budget) {
|
foreach ($set as $budget) {
|
||||||
foreach ($budget->limits as $limit) {
|
foreach ($budget->limits as $limit) {
|
||||||
@@ -69,8 +78,8 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getAsSelectList()
|
public function getAsSelectList()
|
||||||
{
|
{
|
||||||
$list = \Auth::user()->budgets()->with(
|
$list = $this->_user->budgets()->with(
|
||||||
['limits', 'limits.limitrepetitions']
|
['limits', 'limits.limitrepetitions']
|
||||||
)->orderBy('name', 'ASC')->get();
|
)->orderBy('name', 'ASC')->get();
|
||||||
$return = [];
|
$return = [];
|
||||||
foreach ($list as $entry) {
|
foreach ($list as $entry) {
|
||||||
@@ -88,9 +97,9 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function store($data)
|
public function store($data)
|
||||||
{
|
{
|
||||||
$budget = new \Budget;
|
$budget = new \Budget;
|
||||||
$budget->name = $data['name'];
|
$budget->name = $data['name'];
|
||||||
$budget->user()->associate(\Auth::user());
|
$budget->user()->associate($this->_user);
|
||||||
$budget->save();
|
$budget->save();
|
||||||
|
|
||||||
// if limit, create limit (repetition itself will be picked up elsewhere).
|
// if limit, create limit (repetition itself will be picked up elsewhere).
|
||||||
@@ -121,9 +130,9 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface
|
|||||||
$startDate->startOfYear();
|
$startDate->startOfYear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$limit->startdate = $startDate;
|
$limit->startdate = $startDate;
|
||||||
$limit->amount = $data['amount'];
|
$limit->amount = $data['amount'];
|
||||||
$limit->repeats = isset($data['repeats']) ? $data['repeats'] : 0;
|
$limit->repeats = isset($data['repeats']) ? $data['repeats'] : 0;
|
||||||
$limit->repeat_freq = $data['repeat_freq'];
|
$limit->repeat_freq = $data['repeat_freq'];
|
||||||
if ($limit->validate()) {
|
if ($limit->validate()) {
|
||||||
$limit->save();
|
$limit->save();
|
||||||
@@ -154,4 +163,14 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface
|
|||||||
return $budget;
|
return $budget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user)
|
||||||
|
{
|
||||||
|
$this->_user = $user;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -29,6 +29,12 @@ interface CategoryRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function createOrFind($name);
|
public function createOrFind($name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
*
|
*
|
||||||
|
@@ -9,6 +9,16 @@ namespace Firefly\Storage\Category;
|
|||||||
*/
|
*/
|
||||||
class EloquentCategoryRepository implements CategoryRepositoryInterface
|
class EloquentCategoryRepository implements CategoryRepositoryInterface
|
||||||
{
|
{
|
||||||
|
protected $_user = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->_user = \Auth::user();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
*
|
*
|
||||||
@@ -48,7 +58,7 @@ class EloquentCategoryRepository implements CategoryRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function find($categoryId)
|
public function find($categoryId)
|
||||||
{
|
{
|
||||||
return \Auth::user()->categories()->find($categoryId);
|
return $this->_user->categories()->find($categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,7 +72,7 @@ class EloquentCategoryRepository implements CategoryRepositoryInterface
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return \Auth::user()->categories()->where('name', 'LIKE', '%' . $name . '%')->first();
|
return $this->_user->categories()->where('name', 'LIKE', '%' . $name . '%')->first();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +81,7 @@ class EloquentCategoryRepository implements CategoryRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function get()
|
public function get()
|
||||||
{
|
{
|
||||||
return \Auth::user()->categories()->orderBy('name', 'ASC')->get();
|
return $this->_user->categories()->orderBy('name', 'ASC')->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,10 +91,10 @@ class EloquentCategoryRepository implements CategoryRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function store($data)
|
public function store($data)
|
||||||
{
|
{
|
||||||
$category = new \Category;
|
$category = new \Category;
|
||||||
$category->name = $data['name'];
|
$category->name = $data['name'];
|
||||||
|
|
||||||
$category->user()->associate(\Auth::user());
|
$category->user()->associate($this->_user);
|
||||||
$category->save();
|
$category->save();
|
||||||
|
|
||||||
return $category;
|
return $category;
|
||||||
@@ -106,4 +116,14 @@ class EloquentCategoryRepository implements CategoryRepositoryInterface
|
|||||||
|
|
||||||
return $category;
|
return $category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user)
|
||||||
|
{
|
||||||
|
$this->_user = $user;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -28,4 +28,10 @@ interface ComponentRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function store($data);
|
public function store($data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user);
|
||||||
|
|
||||||
}
|
}
|
@@ -14,12 +14,14 @@ use Illuminate\Database\QueryException;
|
|||||||
class EloquentComponentRepository implements ComponentRepositoryInterface
|
class EloquentComponentRepository implements ComponentRepositoryInterface
|
||||||
{
|
{
|
||||||
public $validator;
|
public $validator;
|
||||||
|
protected $_user = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
$this->_user = \Auth::user();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,7 +29,7 @@ class EloquentComponentRepository implements ComponentRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function count()
|
public function count()
|
||||||
{
|
{
|
||||||
return \Auth::user()->components()->count();
|
return $this->_user->components()->count();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,6 +42,16 @@ class EloquentComponentRepository implements ComponentRepositoryInterface
|
|||||||
throw new FireflyException('No implementation.');
|
throw new FireflyException('No implementation.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user)
|
||||||
|
{
|
||||||
|
$this->_user = $user;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $data
|
* @param $data
|
||||||
*
|
*
|
||||||
@@ -62,7 +74,7 @@ class EloquentComponentRepository implements ComponentRepositoryInterface
|
|||||||
|
|
||||||
}
|
}
|
||||||
$component->name = $data['name'];
|
$component->name = $data['name'];
|
||||||
$component->user()->associate(\Auth::user());
|
$component->user()->associate($this->_user);
|
||||||
try {
|
try {
|
||||||
$component->save();
|
$component->save();
|
||||||
} catch (QueryException $e) {
|
} catch (QueryException $e) {
|
||||||
|
@@ -5,6 +5,15 @@ namespace Firefly\Storage\Import;
|
|||||||
|
|
||||||
class EloquentImportRepository implements ImportRepositoryInterface
|
class EloquentImportRepository implements ImportRepositoryInterface
|
||||||
{
|
{
|
||||||
|
protected $_user = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->_user = \Auth::user();
|
||||||
|
}
|
||||||
|
|
||||||
public function findImportComponentMap(\Importmap $map, $oldComponentId)
|
public function findImportComponentMap(\Importmap $map, $oldComponentId)
|
||||||
{
|
{
|
||||||
@@ -26,6 +35,16 @@ class EloquentImportRepository implements ImportRepositoryInterface
|
|||||||
return \Importmap::find($id);
|
return \Importmap::find($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user)
|
||||||
|
{
|
||||||
|
$this->_user = $user;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function store(\Importmap $map, $class, $oldID, $newID)
|
public function store(\Importmap $map, $class, $oldID, $newID)
|
||||||
{
|
{
|
||||||
$entry = new \Importentry;
|
$entry = new \Importentry;
|
||||||
|
@@ -24,4 +24,10 @@ interface ImportRepositoryInterface
|
|||||||
public function findImportEntry(\Importmap $map, $class, $oldID);
|
public function findImportEntry(\Importmap $map, $class, $oldID);
|
||||||
|
|
||||||
public function findImportComponentMap(\Importmap $map, $oldComponentId);
|
public function findImportComponentMap(\Importmap $map, $oldComponentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user);
|
||||||
}
|
}
|
@@ -12,9 +12,14 @@ use Carbon\Carbon;
|
|||||||
*/
|
*/
|
||||||
class EloquentLimitRepository implements LimitRepositoryInterface
|
class EloquentLimitRepository implements LimitRepositoryInterface
|
||||||
{
|
{
|
||||||
|
protected $_user = null;
|
||||||
|
|
||||||
public function findByBudgetAndDate(\Budget $budget, Carbon $date) {
|
/**
|
||||||
return \Limit::whereComponentId($budget->id)->where('startdate',$date->format('Y-m-d'))->first();
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->_user = \Auth::user();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,24 +34,6 @@ class EloquentLimitRepository implements LimitRepositoryInterface
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \Limit $limit
|
|
||||||
* @param $data
|
|
||||||
*
|
|
||||||
* @return mixed|void
|
|
||||||
*/
|
|
||||||
public function update(\Limit $limit, $data)
|
|
||||||
{
|
|
||||||
$limit->startdate = new Carbon($data['startdate']);
|
|
||||||
$limit->repeat_freq = $data['period'];
|
|
||||||
$limit->repeats = isset($data['repeats']) && $data['repeats'] == '1' ? 1 : 0;
|
|
||||||
$limit->amount = floatval($data['amount']);
|
|
||||||
|
|
||||||
$limit->save();
|
|
||||||
|
|
||||||
return $limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $limitId
|
* @param $limitId
|
||||||
*
|
*
|
||||||
@@ -55,15 +42,20 @@ class EloquentLimitRepository implements LimitRepositoryInterface
|
|||||||
public function find($limitId)
|
public function find($limitId)
|
||||||
{
|
{
|
||||||
return \Limit::with('limitrepetitions')->where('limits.id', $limitId)->leftJoin(
|
return \Limit::with('limitrepetitions')->where('limits.id', $limitId)->leftJoin(
|
||||||
'components', 'components.id', '=', 'limits.component_id'
|
'components', 'components.id', '=', 'limits.component_id'
|
||||||
)
|
)
|
||||||
->where('components.user_id', \Auth::user()->id)->first(['limits.*']);
|
->where('components.user_id', $this->_user->id)->first(['limits.*']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findByBudgetAndDate(\Budget $budget, Carbon $date)
|
||||||
|
{
|
||||||
|
return \Limit::whereComponentId($budget->id)->where('startdate', $date->format('Y-m-d'))->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Budget $budget
|
* @param \Budget $budget
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
@@ -75,6 +67,16 @@ class EloquentLimitRepository implements LimitRepositoryInterface
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user)
|
||||||
|
{
|
||||||
|
$this->_user = $user;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $data
|
* @param $data
|
||||||
*
|
*
|
||||||
@@ -119,9 +121,9 @@ class EloquentLimitRepository implements LimitRepositoryInterface
|
|||||||
// find existing:
|
// find existing:
|
||||||
$count = \Limit::
|
$count = \Limit::
|
||||||
leftJoin('components', 'components.id', '=', 'limits.component_id')->where(
|
leftJoin('components', 'components.id', '=', 'limits.component_id')->where(
|
||||||
'components.user_id', \Auth::user()->id
|
'components.user_id', $this->_user->id
|
||||||
)->where('startdate', $date->format('Y-m-d'))->where('component_id', $data['budget_id'])->where(
|
)->where('startdate', $date->format('Y-m-d'))->where('component_id', $data['budget_id'])->where(
|
||||||
'repeat_freq', $data['period']
|
'repeat_freq', $data['period']
|
||||||
)->count();
|
)->count();
|
||||||
if ($count > 0) {
|
if ($count > 0) {
|
||||||
\Session::flash('error', 'There already is an entry for these parameters.');
|
\Session::flash('error', 'There already is an entry for these parameters.');
|
||||||
@@ -131,9 +133,9 @@ class EloquentLimitRepository implements LimitRepositoryInterface
|
|||||||
// create new limit:
|
// create new limit:
|
||||||
$limit = new \Limit;
|
$limit = new \Limit;
|
||||||
$limit->budget()->associate($budget);
|
$limit->budget()->associate($budget);
|
||||||
$limit->startdate = $date;
|
$limit->startdate = $date;
|
||||||
$limit->amount = floatval($data['amount']);
|
$limit->amount = floatval($data['amount']);
|
||||||
$limit->repeats = isset($data['repeats']) ? intval($data['repeats']) : 0;
|
$limit->repeats = isset($data['repeats']) ? intval($data['repeats']) : 0;
|
||||||
$limit->repeat_freq = $data['period'];
|
$limit->repeat_freq = $data['period'];
|
||||||
if (!$limit->save()) {
|
if (!$limit->save()) {
|
||||||
\Session::flash('error', 'Could not save: ' . $limit->errors()->first());
|
\Session::flash('error', 'Could not save: ' . $limit->errors()->first());
|
||||||
@@ -142,4 +144,22 @@ class EloquentLimitRepository implements LimitRepositoryInterface
|
|||||||
return $limit;
|
return $limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Limit $limit
|
||||||
|
* @param $data
|
||||||
|
*
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
|
public function update(\Limit $limit, $data)
|
||||||
|
{
|
||||||
|
$limit->startdate = new Carbon($data['startdate']);
|
||||||
|
$limit->repeat_freq = $data['period'];
|
||||||
|
$limit->repeats = isset($data['repeats']) && $data['repeats'] == '1' ? 1 : 0;
|
||||||
|
$limit->amount = floatval($data['amount']);
|
||||||
|
|
||||||
|
$limit->save();
|
||||||
|
|
||||||
|
return $limit;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -56,4 +56,10 @@ interface LimitRepositoryInterface
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function update(\Limit $limit, $data);
|
public function update(\Limit $limit, $data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user);
|
||||||
}
|
}
|
@@ -14,6 +14,15 @@ use Firefly\Exception\FireflyException;
|
|||||||
class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
protected $_user = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->_user = \Auth::user();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -21,14 +30,14 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
|||||||
public function count()
|
public function count()
|
||||||
{
|
{
|
||||||
return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where(
|
return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where(
|
||||||
'accounts.user_id', \Auth::user()->id
|
'accounts.user_id', $this->_user->id
|
||||||
)->count();
|
)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function countNonrepeating()
|
public function countNonrepeating()
|
||||||
{
|
{
|
||||||
return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where(
|
return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where(
|
||||||
'accounts.user_id', \Auth::user()->id
|
'accounts.user_id', $this->_user->id
|
||||||
)->where('repeats', 0)->count();
|
)->where('repeats', 0)->count();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,7 +45,7 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
|||||||
public function countRepeating()
|
public function countRepeating()
|
||||||
{
|
{
|
||||||
return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where(
|
return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where(
|
||||||
'accounts.user_id', \Auth::user()->id
|
'accounts.user_id', $this->_user->id
|
||||||
)->where('repeats', 1)->count();
|
)->where('repeats', 1)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,14 +69,14 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
|||||||
public function find($piggyBankId)
|
public function find($piggyBankId)
|
||||||
{
|
{
|
||||||
return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where(
|
return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where(
|
||||||
'accounts.user_id', \Auth::user()->id
|
'accounts.user_id', $this->_user->id
|
||||||
)->where('piggybanks.id', $piggyBankId)->first(['piggybanks.*']);
|
)->where('piggybanks.id', $piggyBankId)->first(['piggybanks.*']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findByName($piggyBankName)
|
public function findByName($piggyBankName)
|
||||||
{
|
{
|
||||||
return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where(
|
return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where(
|
||||||
'accounts.user_id', \Auth::user()->id
|
'accounts.user_id', $this->_user->id
|
||||||
)->where('piggybanks.name', $piggyBankName)->first(['piggybanks.*']);
|
)->where('piggybanks.name', $piggyBankName)->first(['piggybanks.*']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +85,7 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function get()
|
public function get()
|
||||||
{
|
{
|
||||||
$piggies = \Auth::user()->piggybanks()->with(['account', 'piggybankrepetitions'])->get();
|
$piggies = $this->_user->piggybanks()->with(['account', 'piggybankrepetitions'])->get();
|
||||||
|
|
||||||
foreach ($piggies as $pig) {
|
foreach ($piggies as $pig) {
|
||||||
$pig->leftInAccount = $this->leftOnAccount($pig->account);
|
$pig->leftInAccount = $this->leftOnAccount($pig->account);
|
||||||
@@ -102,7 +111,6 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Piggybank $piggyBank
|
* @param \Piggybank $piggyBank
|
||||||
* @param $amount
|
* @param $amount
|
||||||
@@ -122,6 +130,16 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user)
|
||||||
|
{
|
||||||
|
$this->_user = $user;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $data
|
* @param $data
|
||||||
*
|
*
|
||||||
@@ -141,6 +159,7 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
|||||||
|
|
||||||
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accounts */
|
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accounts */
|
||||||
$accounts = \App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
$accounts = \App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
||||||
|
$accounts->overruleUser($this->_user);
|
||||||
$account = isset($data['account_id']) ? $accounts->find($data['account_id']) : null;
|
$account = isset($data['account_id']) ? $accounts->find($data['account_id']) : null;
|
||||||
|
|
||||||
|
|
||||||
@@ -221,6 +240,7 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
|||||||
{
|
{
|
||||||
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accounts */
|
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accounts */
|
||||||
$accounts = \App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
$accounts = \App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
||||||
|
$accounts->overruleUser($this->_user);
|
||||||
$account = isset($data['account_id']) ? $accounts->find($data['account_id']) : null;
|
$account = isset($data['account_id']) ? $accounts->find($data['account_id']) : null;
|
||||||
|
|
||||||
if (!is_null($account)) {
|
if (!is_null($account)) {
|
||||||
|
@@ -39,7 +39,9 @@ interface PiggybankRepositoryInterface
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function find($piggyBankId);
|
public function find($piggyBankId);
|
||||||
|
|
||||||
public function findByName($piggyBankName);
|
public function findByName($piggyBankName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
@@ -77,5 +79,11 @@ interface PiggybankRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function update(\Piggybank $piggy, $data);
|
public function update(\Piggybank $piggy, $data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@@ -12,6 +12,27 @@ use Carbon\Carbon;
|
|||||||
*/
|
*/
|
||||||
class EloquentRecurringTransactionRepository implements RecurringTransactionRepositoryInterface
|
class EloquentRecurringTransactionRepository implements RecurringTransactionRepositoryInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user)
|
||||||
|
{
|
||||||
|
$this->_user = $user;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected $_user = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->_user = \Auth::user();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \RecurringTransaction $recurringTransaction
|
* @param \RecurringTransaction $recurringTransaction
|
||||||
*
|
*
|
||||||
@@ -26,7 +47,7 @@ class EloquentRecurringTransactionRepository implements RecurringTransactionRepo
|
|||||||
|
|
||||||
public function findByName($name)
|
public function findByName($name)
|
||||||
{
|
{
|
||||||
return \Auth::user()->recurringtransactions()->where('name', 'LIKE', '%' . $name . '%')->first();
|
return $this->_user->recurringtransactions()->where('name', 'LIKE', '%' . $name . '%')->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +55,7 @@ class EloquentRecurringTransactionRepository implements RecurringTransactionRepo
|
|||||||
*/
|
*/
|
||||||
public function get()
|
public function get()
|
||||||
{
|
{
|
||||||
return \Auth::user()->recurringtransactions()->get();
|
return $this->_user->recurringtransactions()->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,7 +66,7 @@ class EloquentRecurringTransactionRepository implements RecurringTransactionRepo
|
|||||||
public function store($data)
|
public function store($data)
|
||||||
{
|
{
|
||||||
$recurringTransaction = new \RecurringTransaction;
|
$recurringTransaction = new \RecurringTransaction;
|
||||||
$recurringTransaction->user()->associate(\Auth::user());
|
$recurringTransaction->user()->associate($this->_user);
|
||||||
$recurringTransaction->name = $data['name'];
|
$recurringTransaction->name = $data['name'];
|
||||||
$recurringTransaction->match = join(' ', explode(',', $data['match']));
|
$recurringTransaction->match = join(' ', explode(',', $data['match']));
|
||||||
$recurringTransaction->amount_max = floatval($data['amount_max']);
|
$recurringTransaction->amount_max = floatval($data['amount_max']);
|
||||||
|
@@ -44,5 +44,11 @@ interface RecurringTransactionRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function update(\RecurringTransaction $recurringTransaction, $data);
|
public function update(\RecurringTransaction $recurringTransaction, $data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@@ -12,6 +12,26 @@ use Carbon\Carbon;
|
|||||||
*/
|
*/
|
||||||
class EloquentReminderRepository implements ReminderRepositoryInterface
|
class EloquentReminderRepository implements ReminderRepositoryInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user)
|
||||||
|
{
|
||||||
|
$this->_user = $user;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected $_user = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->_user = \Auth::user();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Reminder $reminder
|
* @param \Reminder $reminder
|
||||||
*
|
*
|
||||||
@@ -42,7 +62,7 @@ class EloquentReminderRepository implements ReminderRepositoryInterface
|
|||||||
{
|
{
|
||||||
$today = new Carbon;
|
$today = new Carbon;
|
||||||
|
|
||||||
return \Auth::user()->reminders()->validOn($today)->get();
|
return $this->_user->reminders()->validOn($today)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,8 +72,8 @@ class EloquentReminderRepository implements ReminderRepositoryInterface
|
|||||||
{
|
{
|
||||||
$today = new Carbon;
|
$today = new Carbon;
|
||||||
|
|
||||||
return \Auth::user()->reminders()->with('recurringtransaction')->validOn($today)->where(
|
return $this->_user->reminders()->with('recurringtransaction')->validOn($today)->where(
|
||||||
'class', 'RecurringTransactionReminder'
|
'class', 'RecurringTransactionReminder'
|
||||||
)->get();
|
)->get();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -39,4 +39,10 @@ interface ReminderRepositoryInterface
|
|||||||
|
|
||||||
public function getCurrentRecurringReminders();
|
public function getCurrentRecurringReminders();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user);
|
||||||
|
|
||||||
}
|
}
|
@@ -9,5 +9,24 @@ namespace Firefly\Storage\Transaction;
|
|||||||
*/
|
*/
|
||||||
class EloquentTransactionRepository implements TransactionRepositoryInterface
|
class EloquentTransactionRepository implements TransactionRepositoryInterface
|
||||||
{
|
{
|
||||||
|
protected $_user = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->_user = \Auth::user();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user)
|
||||||
|
{
|
||||||
|
$this->_user = $user;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -9,6 +9,11 @@ namespace Firefly\Storage\Transaction;
|
|||||||
*/
|
*/
|
||||||
interface TransactionRepositoryInterface
|
interface TransactionRepositoryInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@@ -14,6 +14,16 @@ use Firefly\Exception\FireflyException;
|
|||||||
class EloquentTransactionJournalRepository implements TransactionJournalRepositoryInterface
|
class EloquentTransactionJournalRepository implements TransactionJournalRepositoryInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
protected $_user = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->_user = \Auth::user();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* We're building this thinking the money goes from A to B.
|
* We're building this thinking the money goes from A to B.
|
||||||
@@ -34,8 +44,8 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
* A gains 200 (200). * -1
|
* A gains 200 (200). * -1
|
||||||
* B loses 200 (-200). * 1
|
* B loses 200 (-200). * 1
|
||||||
*
|
*
|
||||||
* @param \Account $from
|
* @param \Account $from
|
||||||
* @param \Account $toAccount
|
* @param \Account $toAccount
|
||||||
* @param $description
|
* @param $description
|
||||||
* @param $amount
|
* @param $amount
|
||||||
* @param \Carbon\Carbon $date
|
* @param \Carbon\Carbon $date
|
||||||
@@ -48,7 +58,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
$journal = new \TransactionJournal;
|
$journal = new \TransactionJournal;
|
||||||
|
|
||||||
$amountFrom = $amount * -1;
|
$amountFrom = $amount * -1;
|
||||||
$amountTo = $amount;
|
$amountTo = $amount;
|
||||||
|
|
||||||
if (round(floatval($amount), 2) == 0.00) {
|
if (round(floatval($amount), 2) == 0.00) {
|
||||||
$journal->errors()->add('amount', 'Amount must not be zero.');
|
$journal->errors()->add('amount', 'Amount must not be zero.');
|
||||||
@@ -64,7 +74,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
}
|
}
|
||||||
|
|
||||||
// account types for both:
|
// account types for both:
|
||||||
$toAT = $toAccount->accountType->type;
|
$toAT = $toAccount->accountType->type;
|
||||||
$fromAT = $from->accountType->type;
|
$fromAT = $from->accountType->type;
|
||||||
|
|
||||||
$journalType = null;
|
$journalType = null;
|
||||||
@@ -105,10 +115,10 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
|
|
||||||
$journal->transactionType()->associate($journalType);
|
$journal->transactionType()->associate($journalType);
|
||||||
$journal->transactionCurrency()->associate($currency);
|
$journal->transactionCurrency()->associate($currency);
|
||||||
$journal->user()->associate(\Auth::user());
|
$journal->user()->associate($this->_user);
|
||||||
$journal->completed = false;
|
$journal->completed = false;
|
||||||
$journal->description = $description;
|
$journal->description = $description;
|
||||||
$journal->date = $date;
|
$journal->date = $date;
|
||||||
if (!$journal->validate()) {
|
if (!$journal->validate()) {
|
||||||
return $journal;
|
return $journal;
|
||||||
}
|
}
|
||||||
@@ -119,10 +129,10 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
$fromTransaction->account()->associate($from);
|
$fromTransaction->account()->associate($from);
|
||||||
$fromTransaction->transactionJournal()->associate($journal);
|
$fromTransaction->transactionJournal()->associate($journal);
|
||||||
$fromTransaction->description = null;
|
$fromTransaction->description = null;
|
||||||
$fromTransaction->amount = $amountFrom;
|
$fromTransaction->amount = $amountFrom;
|
||||||
if (!$fromTransaction->validate()) {
|
if (!$fromTransaction->validate()) {
|
||||||
throw new FireflyException('Cannot create valid transaction (from): ' . $fromTransaction->errors()->first(
|
throw new FireflyException('Cannot create valid transaction (from): ' . $fromTransaction->errors()
|
||||||
));
|
->first());
|
||||||
}
|
}
|
||||||
$fromTransaction->save();
|
$fromTransaction->save();
|
||||||
|
|
||||||
@@ -130,7 +140,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
$toTransaction->account()->associate($toAccount);
|
$toTransaction->account()->associate($toAccount);
|
||||||
$toTransaction->transactionJournal()->associate($journal);
|
$toTransaction->transactionJournal()->associate($journal);
|
||||||
$toTransaction->description = null;
|
$toTransaction->description = null;
|
||||||
$toTransaction->amount = $amountTo;
|
$toTransaction->amount = $amountTo;
|
||||||
if (!$toTransaction->validate()) {
|
if (!$toTransaction->validate()) {
|
||||||
throw new FireflyException('Cannot create valid transaction (to): ' . $toTransaction->errors()->first());
|
throw new FireflyException('Cannot create valid transaction (to): ' . $toTransaction->errors()->first());
|
||||||
}
|
}
|
||||||
@@ -149,13 +159,13 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
*/
|
*/
|
||||||
public function find($journalId)
|
public function find($journalId)
|
||||||
{
|
{
|
||||||
return \Auth::user()->transactionjournals()->with(
|
return $this->_user->transactionjournals()->with(
|
||||||
['transactions' => function ($q) {
|
['transactions' => function ($q) {
|
||||||
return $q->orderBy('amount', 'ASC');
|
return $q->orderBy('amount', 'ASC');
|
||||||
}, 'transactioncurrency', 'transactiontype', 'components', 'transactions.account',
|
}, 'transactioncurrency', 'transactiontype', 'components', 'transactions.account',
|
||||||
'transactions.account.accounttype']
|
'transactions.account.accounttype']
|
||||||
)
|
)
|
||||||
->where('id', $journalId)->first();
|
->where('id', $journalId)->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -168,64 +178,76 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Account $account
|
* @param \Account $account
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getByAccountAndDate(\Account $account, Carbon $date)
|
public function getByAccountAndDate(\Account $account, Carbon $date)
|
||||||
{
|
{
|
||||||
$accountID = $account->id;
|
$accountID = $account->id;
|
||||||
$query = \Auth::user()->transactionjournals()->with(
|
$query = $this->_user->transactionjournals()->with(
|
||||||
[
|
[
|
||||||
'transactions',
|
'transactions',
|
||||||
'transactions.account',
|
'transactions.account',
|
||||||
'transactioncurrency',
|
'transactioncurrency',
|
||||||
'transactiontype'
|
'transactiontype'
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
->distinct()
|
->distinct()
|
||||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
->leftJoin('transactions', 'transactions.transaction_journal_id', '=',
|
||||||
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
'transaction_journals.id')
|
||||||
->where('transactions.account_id', $accountID)
|
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
||||||
->where('transaction_journals.date', $date->format('Y-m-d'))
|
->where('transactions.account_id', $accountID)
|
||||||
->orderBy('transaction_journals.date', 'DESC')
|
->where('transaction_journals.date', $date->format('Y-m-d'))
|
||||||
->orderBy('transaction_journals.id', 'DESC')
|
->orderBy('transaction_journals.date', 'DESC')
|
||||||
->get(['transaction_journals.*']);
|
->orderBy('transaction_journals.id', 'DESC')
|
||||||
|
->get(['transaction_journals.*']);
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Account $account
|
* @param \Account $account
|
||||||
* @param int $count
|
* @param int $count
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getByAccountInDateRange(\Account $account, $count = 25, Carbon $start, Carbon $end)
|
public function getByAccountInDateRange(\Account $account, $count = 25, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
$accountID = $account->id;
|
$accountID = $account->id;
|
||||||
$query = \Auth::user()->transactionjournals()->with(
|
$query = $this->_user->transactionjournals()->with(
|
||||||
[
|
[
|
||||||
'transactions',
|
'transactions',
|
||||||
'transactioncurrency',
|
'transactioncurrency',
|
||||||
'transactiontype'
|
'transactiontype'
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
->leftJoin('transactions', 'transactions.transaction_journal_id', '=',
|
||||||
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
'transaction_journals.id')
|
||||||
->where('accounts.id', $accountID)
|
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
||||||
->where('date', '>=', $start->format('Y-m-d'))
|
->where('accounts.id', $accountID)
|
||||||
->where('date', '<=', $end->format('Y-m-d'))
|
->where('date', '>=', $start->format('Y-m-d'))
|
||||||
->orderBy('transaction_journals.date', 'DESC')
|
->where('date', '<=', $end->format('Y-m-d'))
|
||||||
->orderBy('transaction_journals.id', 'DESC')
|
->orderBy('transaction_journals.date', 'DESC')
|
||||||
->take($count)
|
->orderBy('transaction_journals.id', 'DESC')
|
||||||
->get(['transaction_journals.*']);
|
->take($count)
|
||||||
|
->get(['transaction_journals.*']);
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user)
|
||||||
|
{
|
||||||
|
$this->_user = $user;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $count
|
* @param int $count
|
||||||
*
|
*
|
||||||
@@ -233,19 +255,19 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
*/
|
*/
|
||||||
public function paginate($count = 25, Carbon $start = null, Carbon $end = null)
|
public function paginate($count = 25, Carbon $start = null, Carbon $end = null)
|
||||||
{
|
{
|
||||||
$query = \Auth::user()->transactionjournals()->with(
|
$query = $this->_user->transactionjournals()->with(
|
||||||
[
|
[
|
||||||
'transactions' => function ($q) {
|
'transactions' => function ($q) {
|
||||||
return $q->orderBy('amount', 'ASC');
|
return $q->orderBy('amount', 'ASC');
|
||||||
},
|
},
|
||||||
'transactions.account',
|
'transactions.account',
|
||||||
'transactions.account.accounttype',
|
'transactions.account.accounttype',
|
||||||
'transactioncurrency',
|
'transactioncurrency',
|
||||||
'transactiontype'
|
'transactiontype'
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
->orderBy('transaction_journals.date', 'DESC')
|
->orderBy('transaction_journals.date', 'DESC')
|
||||||
->orderBy('transaction_journals.id', 'DESC');
|
->orderBy('transaction_journals.id', 'DESC');
|
||||||
if (!is_null($start)) {
|
if (!is_null($start)) {
|
||||||
$query->where('transaction_journals.date', '>=', $start->format('Y-m-d'));
|
$query->where('transaction_journals.date', '>=', $start->format('Y-m-d'));
|
||||||
}
|
}
|
||||||
@@ -270,37 +292,40 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
// depending on the $what
|
// depending on the $what
|
||||||
|
|
||||||
$fromAccount = null;
|
$fromAccount = null;
|
||||||
$toAccount = null;
|
$toAccount = null;
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accountRepository */
|
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accountRepository */
|
||||||
$accountRepository = \App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
$accountRepository = \App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
||||||
|
$accountRepository->overruleUser($this->_user);
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Category\CategoryRepositoryInterface $catRepository */
|
/** @var \Firefly\Storage\Category\CategoryRepositoryInterface $catRepository */
|
||||||
$catRepository = \App::make('Firefly\Storage\Category\CategoryRepositoryInterface');
|
$catRepository = \App::make('Firefly\Storage\Category\CategoryRepositoryInterface');
|
||||||
|
$catRepository->overruleUser($this->_user);
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Budget\BudgetRepositoryInterface $budRepository */
|
/** @var \Firefly\Storage\Budget\BudgetRepositoryInterface $budRepository */
|
||||||
$budRepository = \App::make('Firefly\Storage\Budget\BudgetRepositoryInterface');
|
$budRepository = \App::make('Firefly\Storage\Budget\BudgetRepositoryInterface');
|
||||||
|
$budRepository->overruleUser($this->_user);
|
||||||
|
|
||||||
|
|
||||||
switch ($what) {
|
switch ($what) {
|
||||||
case 'withdrawal':
|
case 'withdrawal':
|
||||||
$fromAccount = $accountRepository->find(intval($data['account_id']));
|
$fromAccount = $accountRepository->find(intval($data['account_id']));
|
||||||
$toAccount = $accountRepository->createOrFindBeneficiary($data['beneficiary']);
|
$toAccount = $accountRepository->createOrFindBeneficiary($data['beneficiary']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'deposit':
|
case 'deposit':
|
||||||
$fromAccount = $accountRepository->createOrFindBeneficiary($data['beneficiary']);
|
$fromAccount = $accountRepository->createOrFindBeneficiary($data['beneficiary']);
|
||||||
$toAccount = $accountRepository->find(intval($data['account_id']));
|
$toAccount = $accountRepository->find(intval($data['account_id']));
|
||||||
break;
|
break;
|
||||||
case 'transfer':
|
case 'transfer':
|
||||||
$fromAccount = $accountRepository->find(intval($data['account_from_id']));
|
$fromAccount = $accountRepository->find(intval($data['account_from_id']));
|
||||||
$toAccount = $accountRepository->find(intval($data['account_to_id']));
|
$toAccount = $accountRepository->find(intval($data['account_to_id']));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// fall back to cash if necessary:
|
// fall back to cash if necessary:
|
||||||
$fromAccount = is_null($fromAccount) ? $fromAccount = $accountRepository->getCashAccount() : $fromAccount;
|
$fromAccount = is_null($fromAccount) ? $fromAccount = $accountRepository->getCashAccount() : $fromAccount;
|
||||||
$toAccount = is_null($toAccount) ? $toAccount = $accountRepository->getCashAccount() : $toAccount;
|
$toAccount = is_null($toAccount) ? $toAccount = $accountRepository->getCashAccount() : $toAccount;
|
||||||
|
|
||||||
// create or find category:
|
// create or find category:
|
||||||
$category = isset($data['category']) ? $catRepository->createOrFind($data['category']) : null;
|
$category = isset($data['category']) ? $catRepository->createOrFind($data['category']) : null;
|
||||||
@@ -309,8 +334,8 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
$budget = isset($data['budget_id']) ? $budRepository->find(intval($data['budget_id'])) : null;
|
$budget = isset($data['budget_id']) ? $budRepository->find(intval($data['budget_id'])) : null;
|
||||||
// find amount & description:
|
// find amount & description:
|
||||||
$description = trim($data['description']);
|
$description = trim($data['description']);
|
||||||
$amount = floatval($data['amount']);
|
$amount = floatval($data['amount']);
|
||||||
$date = new Carbon($data['date']);
|
$date = new Carbon($data['date']);
|
||||||
|
|
||||||
// try to create a journal:
|
// try to create a journal:
|
||||||
$transactionJournal = $this->createSimpleJournal($fromAccount, $toAccount, $description, $amount, $date);
|
$transactionJournal = $this->createSimpleJournal($fromAccount, $toAccount, $description, $amount, $date);
|
||||||
@@ -323,6 +348,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
if ($what == 'transfer') {
|
if ($what == 'transfer') {
|
||||||
/** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
|
/** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
|
||||||
$piggyRepository = \App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
$piggyRepository = \App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
||||||
|
$piggyRepository->overruleUser($this->_user);
|
||||||
|
|
||||||
if (isset($data['piggybank_id'])) {
|
if (isset($data['piggybank_id'])) {
|
||||||
/** @var \Piggybank $piggyBank */
|
/** @var \Piggybank $piggyBank */
|
||||||
@@ -337,15 +363,15 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
$transaction->piggybank()->associate($piggyBank);
|
$transaction->piggybank()->associate($piggyBank);
|
||||||
$transaction->save();
|
$transaction->save();
|
||||||
\Event::fire(
|
\Event::fire(
|
||||||
'piggybanks.createRelatedTransfer', [$piggyBank, $transactionJournal, $transaction]
|
'piggybanks.createRelatedTransfer', [$piggyBank, $transactionJournal, $transaction]
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($connected === false) {
|
if ($connected === false) {
|
||||||
\Session::flash(
|
\Session::flash(
|
||||||
'warning', 'Piggy bank "' . e($piggyBank->name)
|
'warning', 'Piggy bank "' . e($piggyBank->name)
|
||||||
. '" is not set to draw money from any of the accounts in this transfer'
|
. '" is not set to draw money from any of the accounts in this transfer'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -375,18 +401,21 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
{
|
{
|
||||||
/** @var \Firefly\Storage\Category\CategoryRepositoryInterface $catRepository */
|
/** @var \Firefly\Storage\Category\CategoryRepositoryInterface $catRepository */
|
||||||
$catRepository = \App::make('Firefly\Storage\Category\CategoryRepositoryInterface');
|
$catRepository = \App::make('Firefly\Storage\Category\CategoryRepositoryInterface');
|
||||||
|
$catRepository->overruleUser($this->_user);
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Budget\BudgetRepositoryInterface $budgetRepository */
|
/** @var \Firefly\Storage\Budget\BudgetRepositoryInterface $budgetRepository */
|
||||||
$budRepository = \App::make('Firefly\Storage\Budget\BudgetRepositoryInterface');
|
$budRepository = \App::make('Firefly\Storage\Budget\BudgetRepositoryInterface');
|
||||||
|
$budRepository->overruleUser($this->_user);
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accountRepository */
|
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accountRepository */
|
||||||
$accountRepository = \App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
$accountRepository = \App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
||||||
|
$accountRepository->overruleUser($this->_user);
|
||||||
|
|
||||||
|
|
||||||
// update basics first:
|
// update basics first:
|
||||||
$journal->description = $data['description'];
|
$journal->description = $data['description'];
|
||||||
$journal->date = $data['date'];
|
$journal->date = $data['date'];
|
||||||
$amount = floatval($data['amount']);
|
$amount = floatval($data['amount']);
|
||||||
|
|
||||||
// remove previous category, if any:
|
// remove previous category, if any:
|
||||||
if (!is_null($journal->categories()->first())) {
|
if (!is_null($journal->categories()->first())) {
|
||||||
@@ -424,7 +453,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
switch ($journal->transactiontype->type) {
|
switch ($journal->transactiontype->type) {
|
||||||
case 'Withdrawal':
|
case 'Withdrawal':
|
||||||
// means transaction[0] is the users account.
|
// means transaction[0] is the users account.
|
||||||
$account = $accountRepository->find($data['account_id']);
|
$account = $accountRepository->find($data['account_id']);
|
||||||
$beneficiary = $accountRepository->createOrFindBeneficiary($data['beneficiary']);
|
$beneficiary = $accountRepository->createOrFindBeneficiary($data['beneficiary']);
|
||||||
$transactions[0]->account()->associate($account);
|
$transactions[0]->account()->associate($account);
|
||||||
$transactions[1]->account()->associate($beneficiary);
|
$transactions[1]->account()->associate($beneficiary);
|
||||||
@@ -438,7 +467,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
break;
|
break;
|
||||||
case 'Deposit':
|
case 'Deposit':
|
||||||
// means transaction[0] is the beneficiary.
|
// means transaction[0] is the beneficiary.
|
||||||
$account = $accountRepository->find($data['account_id']);
|
$account = $accountRepository->find($data['account_id']);
|
||||||
$beneficiary = $accountRepository->createOrFindBeneficiary($data['beneficiary']);
|
$beneficiary = $accountRepository->createOrFindBeneficiary($data['beneficiary']);
|
||||||
$journal->transactions[0]->account()->associate($beneficiary);
|
$journal->transactions[0]->account()->associate($beneficiary);
|
||||||
$journal->transactions[1]->account()->associate($account);
|
$journal->transactions[1]->account()->associate($account);
|
||||||
@@ -455,6 +484,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
// attach the new piggy bank, if valid:
|
// attach the new piggy bank, if valid:
|
||||||
/** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
|
/** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
|
||||||
$piggyRepository = \App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
$piggyRepository = \App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
||||||
|
$piggyRepository->overruleUser($this->_user);
|
||||||
|
|
||||||
if (isset($data['piggybank_id'])) {
|
if (isset($data['piggybank_id'])) {
|
||||||
/** @var \Piggybank $piggyBank */
|
/** @var \Piggybank $piggyBank */
|
||||||
@@ -476,8 +506,8 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
}
|
}
|
||||||
if ($connected === false) {
|
if ($connected === false) {
|
||||||
\Session::flash(
|
\Session::flash(
|
||||||
'warning', 'Piggy bank "' . e($piggyBank->name)
|
'warning', 'Piggy bank "' . e($piggyBank->name)
|
||||||
. '" is not set to draw money from any of the accounts in this transfer'
|
. '" is not set to draw money from any of the accounts in this transfer'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@ interface TransactionJournalRepositoryInterface
|
|||||||
* @param \Account $toAccount
|
* @param \Account $toAccount
|
||||||
* @param $description
|
* @param $description
|
||||||
* @param $amount
|
* @param $amount
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
@@ -27,6 +27,12 @@ interface TransactionJournalRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function get();
|
public function get();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \User $user
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function overruleUser(\User $user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $what
|
* @param $what
|
||||||
* @param $data
|
* @param $data
|
||||||
@@ -52,9 +58,9 @@ interface TransactionJournalRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Account $account
|
* @param \Account $account
|
||||||
* @param int $count
|
* @param int $count
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
@@ -62,7 +68,7 @@ interface TransactionJournalRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Account $account
|
* @param \Account $account
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@@ -60,10 +60,10 @@ class EloquentUserRepository implements UserRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function register($array)
|
public function register($array)
|
||||||
{
|
{
|
||||||
$user = new \User;
|
$user = new \User;
|
||||||
$user->email = isset($array['email']) ? $array['email'] : null;
|
$user->email = isset($array['email']) ? $array['email'] : null;
|
||||||
$user->migrated = 0;
|
$user->migrated = 0;
|
||||||
$user->reset = \Str::random(32);
|
$user->reset = \Str::random(32);
|
||||||
$user->password = \Hash::make(\Str::random(12));
|
$user->password = \Hash::make(\Str::random(12));
|
||||||
|
|
||||||
if (!$user->save()) {
|
if (!$user->save()) {
|
||||||
|
@@ -1,5 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Importentry
|
||||||
|
*
|
||||||
|
* @property-read \Importmap $importmap
|
||||||
|
* @property integer $id
|
||||||
|
* @property \Carbon\Carbon $created_at
|
||||||
|
* @property \Carbon\Carbon $updated_at
|
||||||
|
* @property string $class
|
||||||
|
* @property integer $importmap_id
|
||||||
|
* @property integer $old
|
||||||
|
* @property integer $new
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Importentry whereId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Importentry whereCreatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Importentry whereUpdatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Importentry whereClass($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Importentry whereImportmapId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Importentry whereOld($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Importentry whereNew($value)
|
||||||
|
*/
|
||||||
class Importentry extends Eloquent {
|
class Importentry extends Eloquent {
|
||||||
public function importmap()
|
public function importmap()
|
||||||
{
|
{
|
||||||
|
@@ -2,6 +2,18 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Importmap
|
* Class Importmap
|
||||||
|
*
|
||||||
|
* @property-read \User $user
|
||||||
|
* @property integer $id
|
||||||
|
* @property \Carbon\Carbon $created_at
|
||||||
|
* @property \Carbon\Carbon $updated_at
|
||||||
|
* @property integer $user_id
|
||||||
|
* @property string $file
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Importmap whereId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Importmap whereCreatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Importmap whereUpdatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Importmap whereUserId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Importmap whereFile($value)
|
||||||
*/
|
*/
|
||||||
class Importmap extends Eloquent
|
class Importmap extends Eloquent
|
||||||
{
|
{
|
||||||
|
@@ -47,6 +47,22 @@ use LaravelBook\Ardent\Builder;
|
|||||||
* 'Budget[] $budgets
|
* 'Budget[] $budgets
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||||
* 'Category[] $categories
|
* 'Category[] $categories
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||||
|
* 'Budget[] $budgets
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||||
|
* 'Category[] $categories
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||||
|
* 'Budget[] $budgets
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||||
|
* 'Category[] $categories
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||||
|
* 'Budget[] $budgets
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||||
|
* 'Category[] $categories
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||||
|
* 'Budget[] $budgets
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||||
|
* 'Category[] $categories
|
||||||
*/
|
*/
|
||||||
class TransactionJournal extends Ardent
|
class TransactionJournal extends Ardent
|
||||||
{
|
{
|
||||||
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
BIN
public/assets/highslide/highslide/loader.white.gif
Executable file
BIN
public/assets/highslide/highslide/loader.white.gif
Executable file
Binary file not shown.
After Width: | Height: | Size: 673 B |
1
public/assets/jquery-1.10.2.min.map
Normal file
1
public/assets/jquery-1.10.2.min.map
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user