mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Code rearrange and optimise.
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
<?php namespace FireflyIII\Events;
|
<?php namespace FireflyIII\Events;
|
||||||
|
|
||||||
use FireflyIII\Events\Event;
|
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
@@ -10,7 +8,8 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
*
|
*
|
||||||
* @package FireflyIII\Events
|
* @package FireflyIII\Events
|
||||||
*/
|
*/
|
||||||
class JournalCreated extends Event {
|
class JournalCreated extends Event
|
||||||
|
{
|
||||||
|
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
<?php namespace FireflyIII\Events;
|
<?php namespace FireflyIII\Events;
|
||||||
|
|
||||||
use FireflyIII\Events\Event;
|
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class JournalSaved extends Event {
|
class JournalSaved extends Event
|
||||||
|
{
|
||||||
|
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
@@ -67,6 +67,7 @@ class ConnectJournalToPiggyBank
|
|||||||
$repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($journal->date)->first();
|
$repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($journal->date)->first();
|
||||||
if (is_null($repetition)) {
|
if (is_null($repetition)) {
|
||||||
Log::debug('Found no repetition for piggy bank for date ' . $journal->date->format('Y M d'));
|
Log::debug('Found no repetition for piggy bank for date ' . $journal->date->format('Y M d'));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php namespace FireflyIII\Handlers\Events;
|
<?php namespace FireflyIII\Handlers\Events;
|
||||||
|
|
||||||
|
use App;
|
||||||
use FireflyIII\Events\JournalSaved;
|
use FireflyIII\Events\JournalSaved;
|
||||||
use Log;
|
use Log;
|
||||||
use App;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RescanJournal
|
* Class RescanJournal
|
||||||
|
@@ -2,16 +2,17 @@
|
|||||||
|
|
||||||
namespace FireflyIII\Helpers\Reminders;
|
namespace FireflyIII\Helpers\Reminders;
|
||||||
|
|
||||||
use FireflyIII\Models\Reminder;
|
|
||||||
use FireflyIII\Models\PiggyBank;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Models\PiggyBank;
|
||||||
|
use FireflyIII\Models\Reminder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface ReminderHelperInterface
|
* Interface ReminderHelperInterface
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Helpers\Reminders
|
* @package FireflyIII\Helpers\Reminders
|
||||||
*/
|
*/
|
||||||
interface ReminderHelperInterface {
|
interface ReminderHelperInterface
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Takes a reminder, finds the piggy bank and tells you what to do now.
|
* Takes a reminder, finds the piggy bank and tells you what to do now.
|
||||||
* Aka how much money to put in.
|
* Aka how much money to put in.
|
||||||
|
@@ -170,6 +170,7 @@ class AccountController extends Controller
|
|||||||
$journals = $repository->getJournals($account, $page);
|
$journals = $repository->getJournals($account, $page);
|
||||||
$subTitle = 'Details for ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"';
|
$subTitle = 'Details for ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"';
|
||||||
$journals->setPath('accounts/show/' . $account->id);
|
$journals->setPath('accounts/show/' . $account->id);
|
||||||
|
|
||||||
return view('accounts.show', compact('account', 'what', 'subTitleIcon', 'journals', 'subTitle'));
|
return view('accounts.show', compact('account', 'what', 'subTitleIcon', 'journals', 'subTitle'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -136,11 +136,9 @@ class CategoryController extends Controller
|
|||||||
$page = intval(Input::get('page'));
|
$page = intval(Input::get('page'));
|
||||||
$offset = $page > 0 ? $page * 50 : 0;
|
$offset = $page > 0 ? $page * 50 : 0;
|
||||||
$set = $category->transactionJournals()->withRelevantData()->take(50)->offset($offset)
|
$set = $category->transactionJournals()->withRelevantData()->take(50)->offset($offset)
|
||||||
|
|
||||||
->orderBy('transaction_journals.date', 'DESC')
|
->orderBy('transaction_journals.date', 'DESC')
|
||||||
->orderBy('transaction_journals.order', 'ASC')
|
->orderBy('transaction_journals.order', 'ASC')
|
||||||
->orderBy('transaction_journals.id', 'DESC')
|
->orderBy('transaction_journals.id', 'DESC')
|
||||||
|
|
||||||
->get(
|
->get(
|
||||||
['transaction_journals.*']
|
['transaction_journals.*']
|
||||||
);
|
);
|
||||||
|
@@ -3,13 +3,13 @@ use Carbon\Carbon;
|
|||||||
use DaveJamesMiller\Breadcrumbs\Generator;
|
use DaveJamesMiller\Breadcrumbs\Generator;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\Budget;
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\Models\Category;
|
use FireflyIII\Models\Category;
|
||||||
use FireflyIII\Models\Reminder;
|
|
||||||
use FireflyIII\Models\LimitRepetition;
|
use FireflyIII\Models\LimitRepetition;
|
||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
|
use FireflyIII\Models\Reminder;
|
||||||
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Back home.
|
* Back home.
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
<?php namespace FireflyIII\Models;
|
<?php namespace FireflyIII\Models;
|
||||||
|
|
||||||
|
use Crypt;
|
||||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
use Crypt;
|
|
||||||
/**
|
/**
|
||||||
* Class Account
|
* Class Account
|
||||||
*
|
*
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
<?php namespace FireflyIII\Models;
|
<?php namespace FireflyIII\Models;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use App;
|
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PiggyBank
|
* Class PiggyBank
|
||||||
*
|
*
|
||||||
|
@@ -60,7 +60,6 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Account::deleted(
|
Account::deleted(
|
||||||
function (Account $account) {
|
function (Account $account) {
|
||||||
|
|
||||||
|
@@ -119,7 +119,6 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
return $paginator;
|
return $paginator;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
namespace FireflyIII\Repositories\Account;
|
namespace FireflyIII\Repositories\Account;
|
||||||
|
|
||||||
use FireflyIII\Models\Account;
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Models\Preference;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Models\Account;
|
||||||
|
use FireflyIII\Models\Preference;
|
||||||
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface AccountRepositoryInterface
|
* Interface AccountRepositoryInterface
|
||||||
*
|
*
|
||||||
|
@@ -11,7 +11,8 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
*
|
*
|
||||||
* @package FireflyIII\Repositories\Bill
|
* @package FireflyIII\Repositories\Bill
|
||||||
*/
|
*/
|
||||||
interface BillRepositoryInterface {
|
interface BillRepositoryInterface
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Bill $bill
|
* @param Bill $bill
|
||||||
|
@@ -57,6 +57,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
|
|
||||||
$set = $setQuery->get(['transaction_journals.*']);
|
$set = $setQuery->get(['transaction_journals.*']);
|
||||||
$count = $countQuery->count();
|
$count = $countQuery->count();
|
||||||
|
|
||||||
return new LengthAwarePaginator($set, $count, $take, $offset);
|
return new LengthAwarePaginator($set, $count, $take, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
namespace FireflyIII\Repositories\PiggyBank;
|
namespace FireflyIII\Repositories\PiggyBank;
|
||||||
|
|
||||||
use FireflyIII\Models\Reminder;
|
|
||||||
use FireflyIII\Models\PiggyBankRepetition;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Models\PiggyBankRepetition;
|
||||||
|
use FireflyIII\Models\Reminder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PiggyBankPart
|
* Class PiggyBankPart
|
||||||
|
@@ -344,6 +344,48 @@ class Navigation
|
|||||||
throw new FireflyException('Cannot do startOfPeriod for $repeat_freq ' . $repeatFreq);
|
throw new FireflyException('Cannot do startOfPeriod for $repeat_freq ' . $repeatFreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $theDate
|
||||||
|
* @param $repeatFreq
|
||||||
|
* @param int $subtract
|
||||||
|
*
|
||||||
|
* @return Carbon
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function subtractPeriod(Carbon $theDate, $repeatFreq, $subtract = 1)
|
||||||
|
{
|
||||||
|
$date = clone $theDate;
|
||||||
|
|
||||||
|
$functionMap = [
|
||||||
|
'daily' => 'subDays',
|
||||||
|
'week' => 'subWeeks',
|
||||||
|
'weekly' => 'subWeeks',
|
||||||
|
'month' => 'subMonths',
|
||||||
|
'monthly' => 'subMonths',
|
||||||
|
'year' => 'subYears',
|
||||||
|
'yearly' => 'subYears',
|
||||||
|
];
|
||||||
|
$modifierMap = [
|
||||||
|
'quarter' => 3,
|
||||||
|
'quarterly' => 3,
|
||||||
|
'half-year' => 6,
|
||||||
|
];
|
||||||
|
if (isset($functionMap[$repeatFreq])) {
|
||||||
|
$function = $functionMap[$repeatFreq];
|
||||||
|
$date->$function($subtract);
|
||||||
|
|
||||||
|
return $date;
|
||||||
|
}
|
||||||
|
if (isset($modifierMap[$repeatFreq])) {
|
||||||
|
$subtract = $subtract * $modifierMap[$repeatFreq];
|
||||||
|
$date->subMonths($subtract);
|
||||||
|
|
||||||
|
return $date;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new FireflyException('Cannot do subtractPeriod for $repeat_freq ' . $repeatFreq);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $range
|
* @param $range
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
@@ -414,47 +456,5 @@ class Navigation
|
|||||||
throw new FireflyException('updateStartDate cannot handle $range ' . $range);
|
throw new FireflyException('updateStartDate cannot handle $range ' . $range);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Carbon $theDate
|
|
||||||
* @param $repeatFreq
|
|
||||||
* @param int $subtract
|
|
||||||
*
|
|
||||||
* @return Carbon
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function subtractPeriod(Carbon $theDate, $repeatFreq, $subtract = 1)
|
|
||||||
{
|
|
||||||
$date = clone $theDate;
|
|
||||||
|
|
||||||
$functionMap = [
|
|
||||||
'daily' => 'subDays',
|
|
||||||
'week' => 'subWeeks',
|
|
||||||
'weekly' => 'subWeeks',
|
|
||||||
'month' => 'subMonths',
|
|
||||||
'monthly' => 'subMonths',
|
|
||||||
'year' => 'subYears',
|
|
||||||
'yearly' => 'subYears',
|
|
||||||
];
|
|
||||||
$modifierMap = [
|
|
||||||
'quarter' => 3,
|
|
||||||
'quarterly' => 3,
|
|
||||||
'half-year' => 6,
|
|
||||||
];
|
|
||||||
if (isset($functionMap[$repeatFreq])) {
|
|
||||||
$function = $functionMap[$repeatFreq];
|
|
||||||
$date->$function($subtract);
|
|
||||||
|
|
||||||
return $date;
|
|
||||||
}
|
|
||||||
if (isset($modifierMap[$repeatFreq])) {
|
|
||||||
$subtract = $subtract * $modifierMap[$repeatFreq];
|
|
||||||
$date->subMonths($subtract);
|
|
||||||
|
|
||||||
return $date;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new FireflyException('Cannot do subtractPeriod for $repeat_freq ' . $repeatFreq);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,8 @@ use Illuminate\Support\Collection;
|
|||||||
*
|
*
|
||||||
* @package FireflyIII\Support\Search
|
* @package FireflyIII\Support\Search
|
||||||
*/
|
*/
|
||||||
interface SearchInterface {
|
interface SearchInterface
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $words
|
* @param array $words
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user