mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code rearrange and optimise.
This commit is contained in:
parent
210f84b6ea
commit
bea321939e
@ -1,7 +1,5 @@
|
||||
<?php namespace FireflyIII\Events;
|
||||
|
||||
use FireflyIII\Events\Event;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
@ -10,24 +8,25 @@ use Illuminate\Queue\SerializesModels;
|
||||
*
|
||||
* @package FireflyIII\Events
|
||||
*/
|
||||
class JournalCreated extends Event {
|
||||
class JournalCreated extends Event
|
||||
{
|
||||
|
||||
use SerializesModels;
|
||||
use SerializesModels;
|
||||
|
||||
public $journal;
|
||||
public $piggyBankId;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TransactionJournal $journal, $piggyBankId)
|
||||
{
|
||||
//
|
||||
$this->journal = $journal;
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TransactionJournal $journal, $piggyBankId)
|
||||
{
|
||||
//
|
||||
$this->journal = $journal;
|
||||
$this->piggyBankId = $piggyBankId;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,24 @@
|
||||
<?php namespace FireflyIII\Events;
|
||||
|
||||
use FireflyIII\Events\Event;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class JournalSaved extends Event {
|
||||
class JournalSaved extends Event
|
||||
{
|
||||
|
||||
use SerializesModels;
|
||||
use SerializesModels;
|
||||
|
||||
public $journal;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TransactionJournal $journal)
|
||||
{
|
||||
//
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TransactionJournal $journal)
|
||||
{
|
||||
//
|
||||
$this->journal = $journal;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class ConnectJournalToPiggyBank
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $event->journal;
|
||||
$piggyBankId = $event->piggyBankId;
|
||||
if(intval($piggyBankId) < 1) {
|
||||
if (intval($piggyBankId) < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -66,7 +66,8 @@ class ConnectJournalToPiggyBank
|
||||
// update piggy bank rep for date of transaction journal.
|
||||
$repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($journal->date)->first();
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php namespace FireflyIII\Handlers\Events;
|
||||
|
||||
use App;
|
||||
use FireflyIII\Events\JournalSaved;
|
||||
use Log;
|
||||
use App;
|
||||
|
||||
/**
|
||||
* Class RescanJournal
|
||||
|
@ -35,8 +35,8 @@ class UpdateJournalConnection
|
||||
|
||||
// get the event connected to this journal:
|
||||
/** @var PiggyBankEvent $event */
|
||||
$event = PiggyBankEvent::where('transaction_journal_id', $journal->id)->first();
|
||||
if(is_null($event)) {
|
||||
$event = PiggyBankEvent::where('transaction_journal_id', $journal->id)->first();
|
||||
if (is_null($event)) {
|
||||
return;
|
||||
}
|
||||
$piggyBank = $event->piggyBank()->first();
|
||||
|
@ -2,16 +2,17 @@
|
||||
|
||||
namespace FireflyIII\Helpers\Reminders;
|
||||
|
||||
use FireflyIII\Models\Reminder;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\Reminder;
|
||||
|
||||
/**
|
||||
* Interface ReminderHelperInterface
|
||||
*
|
||||
* @package FireflyIII\Helpers\Reminders
|
||||
*/
|
||||
interface ReminderHelperInterface {
|
||||
interface ReminderHelperInterface
|
||||
{
|
||||
/**
|
||||
* Takes a reminder, finds the piggy bank and tells you what to do now.
|
||||
* Aka how much money to put in.
|
||||
|
@ -169,7 +169,8 @@ class AccountController extends Controller
|
||||
$what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type);
|
||||
$journals = $repository->getJournals($account, $page);
|
||||
$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'));
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ class AuthController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
$data =$request->all();
|
||||
$data = $request->all();
|
||||
$data['password'] = bcrypt($data['password']);
|
||||
|
||||
$this->auth->login($this->registrar->create($data));
|
||||
|
@ -98,8 +98,8 @@ class BudgetController extends Controller
|
||||
*/
|
||||
public function index(BudgetRepositoryInterface $repository)
|
||||
{
|
||||
$budgets = Auth::user()->budgets()->where('active',1)->get();
|
||||
$inactive = Auth::user()->budgets()->where('active',0)->get();
|
||||
$budgets = Auth::user()->budgets()->where('active', 1)->get();
|
||||
$inactive = Auth::user()->budgets()->where('active', 0)->get();
|
||||
|
||||
// loop the budgets:
|
||||
$budgets->each(
|
||||
@ -118,7 +118,7 @@ class BudgetController extends Controller
|
||||
$budgetMax = Preferences::get('budgetMaximum', 1000);
|
||||
$budgetMaximum = $budgetMax->data;
|
||||
|
||||
return view('budgets.index', compact('budgetMaximum','inactive', 'budgets', 'spent', 'spentPCT', 'overspent', 'amount'));
|
||||
return view('budgets.index', compact('budgetMaximum', 'inactive', 'budgets', 'spent', 'spentPCT', 'overspent', 'amount'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,9 +134,9 @@ class BudgetController extends Controller
|
||||
->whereNull('budget_transaction_journal.id')
|
||||
->before($end)
|
||||
->after($start)
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order','ASC')
|
||||
->orderBy('transaction_journals.id','DESC')
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
->orderBy('transaction_journals.id', 'DESC')
|
||||
->get(['transaction_journals.*']);
|
||||
$subTitle = 'Transactions without a budget in ' . $start->format('F Y');
|
||||
|
||||
@ -210,7 +210,7 @@ class BudgetController extends Controller
|
||||
public function update(Budget $budget, BudgetFormRequest $request, BudgetRepositoryInterface $repository)
|
||||
{
|
||||
$budgetData = [
|
||||
'name' => $request->input('name'),
|
||||
'name' => $request->input('name'),
|
||||
'active' => intval($request->input('active')) == 1
|
||||
];
|
||||
|
||||
|
@ -89,10 +89,10 @@ class CategoryController extends Controller
|
||||
$categories->each(
|
||||
function (Category $category) {
|
||||
$latest = $category->transactionjournals()
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order','ASC')
|
||||
->orderBy('transaction_journals.id','DESC')
|
||||
->first();
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
->orderBy('transaction_journals.id', 'DESC')
|
||||
->first();
|
||||
if ($latest) {
|
||||
$category->lastActivity = $latest->date;
|
||||
}
|
||||
@ -115,9 +115,9 @@ class CategoryController extends Controller
|
||||
->whereNull('category_transaction_journal.id')
|
||||
->before($end)
|
||||
->after($start)
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order','ASC')
|
||||
->orderBy('transaction_journals.id','DESC')
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
->orderBy('transaction_journals.id', 'DESC')
|
||||
->get(['transaction_journals.*']);
|
||||
|
||||
$subTitle = 'Transactions without a category between ' . $start->format('jS F Y') . ' and ' . $end->format('jS F Y');
|
||||
@ -136,14 +136,12 @@ class CategoryController extends Controller
|
||||
$page = intval(Input::get('page'));
|
||||
$offset = $page > 0 ? $page * 50 : 0;
|
||||
$set = $category->transactionJournals()->withRelevantData()->take(50)->offset($offset)
|
||||
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order','ASC')
|
||||
->orderBy('transaction_journals.id','DESC')
|
||||
|
||||
->get(
|
||||
['transaction_journals.*']
|
||||
);
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
->orderBy('transaction_journals.id', 'DESC')
|
||||
->get(
|
||||
['transaction_journals.*']
|
||||
);
|
||||
$count = $category->transactionJournals()->count();
|
||||
|
||||
$journals = new LengthAwarePaginator($set, $count, 50, $page);
|
||||
@ -166,7 +164,7 @@ class CategoryController extends Controller
|
||||
$category = $repository->store($categoryData);
|
||||
|
||||
Session::flash('success', 'New category "' . $category->name . '" stored!');
|
||||
|
||||
|
||||
if (intval(Input::get('create_another')) === 1) {
|
||||
return Redirect::route('categories.create')->withInput();
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class GoogleChartController extends Controller
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$current = clone $start;
|
||||
$today = new Carbon;
|
||||
$today = new Carbon;
|
||||
|
||||
while ($end >= $current) {
|
||||
$certain = $current < $today;
|
||||
@ -237,20 +237,20 @@ class GoogleChartController extends Controller
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$set = TransactionJournal::
|
||||
where('transaction_journals.user_id',Auth::user()->id)
|
||||
->leftJoin(
|
||||
'transactions',
|
||||
function (JoinClause $join) {
|
||||
$join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('amount', '>', 0);
|
||||
}
|
||||
)
|
||||
where('transaction_journals.user_id', Auth::user()->id)
|
||||
->leftJoin(
|
||||
'transactions',
|
||||
function (JoinClause $join) {
|
||||
$join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('amount', '>', 0);
|
||||
}
|
||||
)
|
||||
->leftJoin(
|
||||
'category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
|
||||
)
|
||||
->leftJoin('categories', 'categories.id', '=', 'category_transaction_journal.category_id')
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->before($end)
|
||||
->where('categories.user_id',Auth::user()->id)
|
||||
->where('categories.user_id', Auth::user()->id)
|
||||
->after($start)
|
||||
->where('transaction_types.type', 'Withdrawal')
|
||||
->groupBy('categories.id')
|
||||
|
@ -89,8 +89,8 @@ class JsonController extends Controller
|
||||
// paid a bill in this range?
|
||||
$count = $bill->transactionjournals()->before($range['end'])->after($range['start'])->count();
|
||||
if ($count != 0) {
|
||||
$journal = $bill->transactionjournals()->with('transactions')->before($range['end'])->after($range['start'])->first();
|
||||
$currentAmount = 0;
|
||||
$journal = $bill->transactionjournals()->with('transactions')->before($range['end'])->after($range['start'])->first();
|
||||
$currentAmount = 0;
|
||||
foreach ($journal->transactions as $t) {
|
||||
if (floatval($t->amount) > 0) {
|
||||
$currentAmount = floatval($t->amount);
|
||||
|
@ -98,10 +98,10 @@ class PiggyBanks
|
||||
// first loop fixes this date. or should fix it.
|
||||
$max = new Carbon;
|
||||
|
||||
echo '[#'.$piggyBank->id.', from: '.$start->format('Y-m-d.').' to '.$end->format('Y-m-d.').']';
|
||||
echo '[#' . $piggyBank->id . ', from: ' . $start->format('Y-m-d.') . ' to ' . $end->format('Y-m-d.') . ']';
|
||||
// create stuff. Or at least, try:
|
||||
$repetition = $piggyBank->piggyBankRepetitions()->onDates($start, $end)->first();
|
||||
if(!$repetition) {
|
||||
if (!$repetition) {
|
||||
$repetition = new PiggyBankRepetition;
|
||||
$repetition->piggyBank()->associate($piggyBank);
|
||||
$repetition->startdate = $start;
|
||||
|
@ -46,7 +46,7 @@ class ReplaceTestVars
|
||||
$input = $request->all();
|
||||
$input['_token'] = $request->session()->token();
|
||||
// we need to update _token value to make sure we get the POST / PUT tests passed.
|
||||
Log::debug('Input token replaced ('.$input['_token'].').');
|
||||
Log::debug('Input token replaced (' . $input['_token'] . ').');
|
||||
$request->replace($input);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ class AccountFormRequest extends Request
|
||||
|
||||
$nameRule = 'required|between:1,100|uniqueAccountForUser';
|
||||
if (Account::find(Input::get('id'))) {
|
||||
$nameRule = 'required|between:1,100|belongsToUser:accounts|uniqueForUser:'.Input::get('id');
|
||||
$nameRule = 'required|between:1,100|belongsToUser:accounts|uniqueForUser:' . Input::get('id');
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -26,7 +26,7 @@ class ProfileFormRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'current_password' => 'required',
|
||||
'current_password' => 'required',
|
||||
'new_password' => 'required|confirmed',
|
||||
'new_password_confirmation' => 'required',
|
||||
];
|
||||
|
@ -3,13 +3,13 @@ use Carbon\Carbon;
|
||||
use DaveJamesMiller\Breadcrumbs\Generator;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Reminder;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\Reminder;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
|
||||
/*
|
||||
* Back home.
|
||||
|
@ -132,7 +132,7 @@ Route::get('/register', ['uses' => 'Auth\AuthController@getRegister', 'as' => 'r
|
||||
|
||||
Route::controllers(
|
||||
[
|
||||
'auth' => 'Auth\AuthController',
|
||||
'auth' => 'Auth\AuthController',
|
||||
'password' => 'Auth\PasswordController',
|
||||
]
|
||||
);
|
||||
@ -142,7 +142,7 @@ Route::controllers(
|
||||
* Home Controller
|
||||
*/
|
||||
Route::group(
|
||||
['middleware' => ['auth', 'range', 'reminders','piggybanks']], function () {
|
||||
['middleware' => ['auth', 'range', 'reminders', 'piggybanks']], function () {
|
||||
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
|
||||
Route::get('/home', ['uses' => 'HomeController@index', 'as' => 'home']);
|
||||
Route::post('/daterange', ['uses' => 'HomeController@dateRange', 'as' => 'daterange']);
|
||||
|
@ -1,10 +1,11 @@
|
||||
<?php namespace FireflyIII\Models;
|
||||
|
||||
use Crypt;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use Crypt;
|
||||
|
||||
/**
|
||||
* Class Account
|
||||
*
|
||||
|
@ -14,12 +14,12 @@ class AccountMeta extends Model
|
||||
use ValidatingTrait;
|
||||
protected $fillable = ['account_id', 'name', 'data'];
|
||||
protected $rules
|
||||
= [
|
||||
= [
|
||||
'account_id' => 'required|exists:accounts,id',
|
||||
'name' => 'required|between:1,100',
|
||||
'data' => 'required'
|
||||
];
|
||||
protected $table = 'account_meta';
|
||||
protected $table = 'account_meta';
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
|
@ -10,7 +10,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class Bill extends Model
|
||||
{
|
||||
|
||||
protected $fillable = ['name', 'match', 'amount_min','user_id', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active',];
|
||||
protected $fillable = ['name', 'match', 'amount_min', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active',];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
|
@ -12,7 +12,7 @@ class Component extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = ['user_id', 'name','class'];
|
||||
protected $fillable = ['user_id', 'name', 'class'];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
|
@ -1,11 +1,10 @@
|
||||
<?php namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class PiggyBank
|
||||
*
|
||||
@ -44,7 +43,7 @@ class PiggyBank extends Model
|
||||
|
||||
return $rep;
|
||||
} else {
|
||||
Log::error('Tried to work with a piggy bank with a repeats=1 value! (id is '.$this->id.')');
|
||||
Log::error('Tried to work with a piggy bank with a repeats=1 value! (id is ' . $this->id . ')');
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
*/
|
||||
protected $listen
|
||||
= [
|
||||
'FireflyIII\Events\JournalSaved' => [
|
||||
'FireflyIII\Events\JournalSaved' => [
|
||||
'FireflyIII\Handlers\Events\RescanJournal',
|
||||
'FireflyIII\Handlers\Events\UpdateJournalConnection',
|
||||
|
||||
@ -60,7 +60,6 @@ class EventServiceProvider extends ServiceProvider
|
||||
);
|
||||
|
||||
|
||||
|
||||
Account::deleted(
|
||||
function (Account $account) {
|
||||
|
||||
|
@ -106,9 +106,9 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
->withRelevantData()
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->where('transactions.account_id', $account->id)
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order','ASC')
|
||||
->orderBy('transaction_journals.id','DESC');
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
->orderBy('transaction_journals.id', 'DESC');
|
||||
|
||||
$query->before(Session::get('end', Carbon::now()->endOfMonth()));
|
||||
$query->after(Session::get('start', Carbon::now()->startOfMonth()));
|
||||
@ -119,7 +119,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
return $paginator;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,11 +2,12 @@
|
||||
|
||||
namespace FireflyIII\Repositories\Account;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\Preference;
|
||||
use Illuminate\Support\Collection;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface AccountRepositoryInterface
|
||||
*
|
||||
|
@ -11,7 +11,8 @@ use FireflyIII\Models\TransactionJournal;
|
||||
*
|
||||
* @package FireflyIII\Repositories\Bill
|
||||
*/
|
||||
interface BillRepositoryInterface {
|
||||
interface BillRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Bill $bill
|
||||
@ -25,7 +26,7 @@ interface BillRepositoryInterface {
|
||||
* and returns date ranges that fall within the given range; those ranges are the bills expected. When a bill is due on the 14th of the month and
|
||||
* you give 1st and the 31st of that month as argument, you'll get one response, matching the range of your bill.
|
||||
*
|
||||
* @param Bill $bill
|
||||
* @param Bill $bill
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
|
@ -43,9 +43,9 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
|
||||
|
||||
$setQuery = $budget->transactionJournals()->withRelevantData()->take($take)->offset($offset)
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order','ASC')
|
||||
->orderBy('transaction_journals.id','DESC');
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
->orderBy('transaction_journals.id', 'DESC');
|
||||
$countQuery = $budget->transactionJournals();
|
||||
|
||||
|
||||
@ -57,6 +57,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
|
||||
$set = $setQuery->get(['transaction_journals.*']);
|
||||
$count = $countQuery->count();
|
||||
|
||||
return new LengthAwarePaginator($set, $count, $take, $offset);
|
||||
}
|
||||
|
||||
@ -103,7 +104,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
public function update(Budget $budget, array $data)
|
||||
{
|
||||
// update the account:
|
||||
$budget->name = $data['name'];
|
||||
$budget->name = $data['name'];
|
||||
$budget->active = $data['active'];
|
||||
$budget->save();
|
||||
|
||||
|
@ -111,7 +111,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
public function setOrder($id, $order)
|
||||
{
|
||||
$piggyBank = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id)
|
||||
->where('piggy_banks.id',$id)->first(['piggy_banks.*']);
|
||||
->where('piggy_banks.id', $id)->first(['piggy_banks.*']);
|
||||
if ($piggyBank) {
|
||||
$piggyBank->order = $order;
|
||||
$piggyBank->save();
|
||||
|
@ -2,10 +2,9 @@
|
||||
|
||||
namespace FireflyIII\Repositories\PiggyBank;
|
||||
|
||||
use FireflyIII\Models\Reminder;
|
||||
use FireflyIII\Models\PiggyBankRepetition;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\PiggyBankRepetition;
|
||||
use FireflyIII\Models\Reminder;
|
||||
|
||||
/**
|
||||
* Class PiggyBankPart
|
||||
|
@ -344,6 +344,48 @@ class Navigation
|
||||
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 Carbon $start
|
||||
@ -414,47 +456,5 @@ class Navigation
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -112,8 +112,8 @@ class Search implements SearchInterface
|
||||
)->get();
|
||||
|
||||
// encrypted
|
||||
$all = Auth::user()->transactionjournals()->withRelevantData()->where('encrypted', 1)->get();
|
||||
$set = $all->filter(
|
||||
$all = Auth::user()->transactionjournals()->withRelevantData()->where('encrypted', 1)->get();
|
||||
$set = $all->filter(
|
||||
function (TransactionJournal $journal) use ($words) {
|
||||
foreach ($words as $word) {
|
||||
$haystack = strtolower($journal->description);
|
||||
|
@ -9,7 +9,8 @@ use Illuminate\Support\Collection;
|
||||
*
|
||||
* @package FireflyIII\Support\Search
|
||||
*/
|
||||
interface SearchInterface {
|
||||
interface SearchInterface
|
||||
{
|
||||
/**
|
||||
* @param array $words
|
||||
*
|
||||
|
@ -152,7 +152,7 @@ class FireflyValidator extends Validator
|
||||
*/
|
||||
public function validateUniquePiggyBankForUser($attribute, $value, $parameters)
|
||||
{
|
||||
$query = DB::table($parameters[0])->where('piggy_banks.'.$parameters[1], $value);
|
||||
$query = DB::table($parameters[0])->where('piggy_banks.' . $parameters[1], $value);
|
||||
$query->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id');
|
||||
$query->where('accounts.user_id', Auth::user()->id);
|
||||
if (isset($paramers[2])) {
|
||||
|
Loading…
Reference in New Issue
Block a user