mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-27 03:10:32 -06:00
Various code cleanup things inspired by Code Climate [skip ci]
This commit is contained in:
parent
916d85c3fe
commit
dde09f9f89
@ -77,11 +77,7 @@ class HomeController extends BaseController
|
||||
$preferences->set('viewRange', $range);
|
||||
Session::forget('range');
|
||||
}
|
||||
if (isset($_SERVER['HTTP_REFERER']) && (!strpos($_SERVER['HTTP_REFERER'], Config::get('app.url')) === false)) {
|
||||
return Redirect::back();
|
||||
} else {
|
||||
return Redirect::intended();
|
||||
}
|
||||
Redirect::to(URL::previous());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,14 +86,7 @@ class HomeController extends BaseController
|
||||
public function sessionNext()
|
||||
{
|
||||
Navigation::next();
|
||||
|
||||
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], Config::get('app.url')) === 0) {
|
||||
Log::debug('Redirect back');
|
||||
return Redirect::back();
|
||||
} else {
|
||||
Log::debug('Redirect intended');
|
||||
return Redirect::intended();
|
||||
}
|
||||
Redirect::to(URL::previous());
|
||||
|
||||
}
|
||||
|
||||
@ -107,13 +96,6 @@ class HomeController extends BaseController
|
||||
public function sessionPrev()
|
||||
{
|
||||
Navigation::prev();
|
||||
|
||||
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], Config::get('app.url')) === 0) {
|
||||
Log::debug('Redirect back');
|
||||
return Redirect::back();
|
||||
} else {
|
||||
Log::debug('Redirect intended');
|
||||
return Redirect::intended();
|
||||
}
|
||||
Redirect::to(URL::previous());
|
||||
}
|
||||
}
|
||||
|
@ -41,31 +41,24 @@ class TestDataSeeder extends Seeder
|
||||
protected $_yearAgoStartOfMonth;
|
||||
|
||||
/**
|
||||
*
|
||||
* A whole bunch of times and dates.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_startOfMonth = Carbon::now()->startOfMonth();
|
||||
$this->som = $this->_startOfMonth->format('Y-m-d');
|
||||
|
||||
$this->_endOfMonth = Carbon::now()->endOfMonth();
|
||||
$this->eom = $this->_endOfMonth->format('Y-m-d');
|
||||
|
||||
$this->_nextStartOfMonth = Carbon::now()->addMonth()->startOfMonth();
|
||||
$this->nsom = $this->_nextStartOfMonth->format('Y-m-d');
|
||||
|
||||
$this->_nextEndOfMonth = Carbon::now()->addMonth()->endOfMonth();
|
||||
$this->neom = $this->_nextEndOfMonth->format('Y-m-d');
|
||||
|
||||
$this->_startOfMonth = Carbon::now()->startOfMonth();
|
||||
$this->som = $this->_startOfMonth->format('Y-m-d');
|
||||
$this->_endOfMonth = Carbon::now()->endOfMonth();
|
||||
$this->eom = $this->_endOfMonth->format('Y-m-d');
|
||||
$this->_nextStartOfMonth = Carbon::now()->addMonth()->startOfMonth();
|
||||
$this->nsom = $this->_nextStartOfMonth->format('Y-m-d');
|
||||
$this->_nextEndOfMonth = Carbon::now()->addMonth()->endOfMonth();
|
||||
$this->neom = $this->_nextEndOfMonth->format('Y-m-d');
|
||||
$this->_yearAgoStartOfMonth = Carbon::now()->subYear()->startOfMonth();
|
||||
$this->yasom = $this->_yearAgoStartOfMonth->format('Y-m-d');
|
||||
|
||||
$this->_yearAgoEndOfMonth = Carbon::now()->subYear()->startOfMonth();
|
||||
$this->yaeom = $this->_yearAgoEndOfMonth->format('Y-m-d');
|
||||
|
||||
|
||||
$this->_today = Carbon::now();
|
||||
$this->today = $this->_today->format('Y-m-d');
|
||||
$this->_yearAgoEndOfMonth = Carbon::now()->subYear()->startOfMonth();
|
||||
$this->yaeom = $this->_yearAgoEndOfMonth->format('Y-m-d');
|
||||
$this->_today = Carbon::now();
|
||||
$this->today = $this->_today->format('Y-m-d');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,67 +69,42 @@ class TestDataSeeder extends Seeder
|
||||
User::create(['email' => 'reset@example.com', 'password' => 'functional', 'reset' => 'okokokokokokokokokokokokokokokok', 'remember_token' => null]);
|
||||
User::create(['email' => 'functional@example.com', 'password' => 'functional', 'reset' => null, 'remember_token' => null]);
|
||||
|
||||
|
||||
$user = User::create(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james', 'reset' => null, 'remember_token' => null]);
|
||||
Log::debug('Created users.');
|
||||
// create initial accounts and various other stuff:
|
||||
$this->createAssetAccounts($user);
|
||||
Log::debug('Created asset accounts.');
|
||||
$this->createBudgets($user);
|
||||
Log::debug('Created budgets.');
|
||||
$this->createCategories($user);
|
||||
Log::debug('Created categories.');
|
||||
$this->createPiggyBanks($user);
|
||||
Log::debug('Created piggy banks.');
|
||||
$this->createReminders($user);
|
||||
Log::debug('Created reminders.');
|
||||
$this->createRecurringTransactions($user);
|
||||
Log::debug('Created recurring transactions.');
|
||||
$this->createBills($user);
|
||||
Log::debug('Created bills.');
|
||||
$this->createExpenseAccounts($user);
|
||||
Log::debug('Created expense accounts.');
|
||||
$this->createRevenueAccounts($user);
|
||||
Log::debug('Created revenue accounts.');
|
||||
|
||||
// get some objects from the database:
|
||||
$checking = Account::whereName('Checking account')->orderBy('id', 'DESC')->first();
|
||||
Log::debug('Found checking: ' . json_encode($checking));
|
||||
$savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();
|
||||
Log::debug('Found savings: ' . json_encode($savings));
|
||||
$landLord = Account::whereName('Land lord')->orderBy('id', 'DESC')->first();
|
||||
Log::debug('Found landlord: ' . json_encode($landLord));
|
||||
$utilities = Account::whereName('Utilities company')->orderBy('id', 'DESC')->first();
|
||||
Log::debug('Found utilities: ' . json_encode($utilities));
|
||||
$checking = Account::whereName('Checking account')->orderBy('id', 'DESC')->first();
|
||||
$savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();
|
||||
$landLord = Account::whereName('Land lord')->orderBy('id', 'DESC')->first();
|
||||
$utilities = Account::whereName('Utilities company')->orderBy('id', 'DESC')->first();
|
||||
$television = Account::whereName('TV company')->orderBy('id', 'DESC')->first();
|
||||
Log::debug('Found tv company: ' . json_encode($television));
|
||||
$phone = Account::whereName('Phone agency')->orderBy('id', 'DESC')->first();
|
||||
Log::debug('Found phone company: ' . json_encode($phone));
|
||||
$employer = Account::whereName('Employer')->orderBy('id', 'DESC')->first();
|
||||
Log::debug('Found employer: ' . json_encode($employer));
|
||||
$phone = Account::whereName('Phone agency')->orderBy('id', 'DESC')->first();
|
||||
$employer = Account::whereName('Employer')->orderBy('id', 'DESC')->first();
|
||||
|
||||
|
||||
$bills = Budget::whereName('Bills')->orderBy('id', 'DESC')->first();
|
||||
Log::debug('Found bills budget: ' . json_encode($bills));
|
||||
$bills = Budget::whereName('Bills')->orderBy('id', 'DESC')->first();
|
||||
$groceries = Budget::whereName('Groceries')->orderBy('id', 'DESC')->first();
|
||||
Log::debug('Found groceries budget: ' . json_encode($groceries));
|
||||
|
||||
$house = Category::whereName('House')->orderBy('id', 'DESC')->first();
|
||||
Log::debug('Found house category: ' . json_encode($checking));
|
||||
|
||||
|
||||
$withdrawal = TransactionType::whereType('Withdrawal')->first();
|
||||
Log::debug('Found withdrawal: ' . json_encode($withdrawal));
|
||||
$deposit = TransactionType::whereType('Deposit')->first();
|
||||
Log::debug('Found deposit: ' . json_encode($deposit));
|
||||
$transfer = TransactionType::whereType('Transfer')->first();
|
||||
Log::debug('Found transfer: ' . json_encode($transfer));
|
||||
$deposit = TransactionType::whereType('Deposit')->first();
|
||||
$transfer = TransactionType::whereType('Transfer')->first();
|
||||
|
||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
||||
Log::debug('Found euro: ' . json_encode($euro));
|
||||
|
||||
$rentBill = Bill::where('name', 'Rent')->first();
|
||||
Log::debug('Found bill "rent": ' . json_encode($rentBill));
|
||||
|
||||
|
||||
$current = clone $this->_yearAgoStartOfMonth;
|
||||
@ -146,31 +114,22 @@ class TestDataSeeder extends Seeder
|
||||
Log::debug('Now at: ' . $cur);
|
||||
|
||||
// create expenses for rent, utilities, TV, phone on the 1st of the month.
|
||||
|
||||
$this->createTransaction($checking, $landLord, 800, $withdrawal, 'Rent for ' . $formatted, $cur, $euro, $bills, $house, $rentBill);
|
||||
Log::debug('Created rent.');
|
||||
$this->createTransaction($checking, $utilities, 150, $withdrawal, 'Utilities for ' . $formatted, $cur, $euro, $bills, $house);
|
||||
Log::debug('Created utilities.');
|
||||
$this->createTransaction($checking, $television, 50, $withdrawal, 'TV for ' . $formatted, $cur, $euro, $bills, $house);
|
||||
Log::debug('Created TV.');
|
||||
$this->createTransaction($checking, $phone, 50, $withdrawal, 'Phone bill for ' . $formatted, $cur, $euro, $bills, $house);
|
||||
Log::debug('Created phone bill.');
|
||||
|
||||
// two transactions. One without a budget, one without a category.
|
||||
$this->createTransaction($checking, $phone, 10, $withdrawal, 'Extra charges on phone bill for ' . $formatted, $cur, $euro, null, $house);
|
||||
Log::debug('Created extra charges no budget.');
|
||||
$this->createTransaction($checking, $television, 5, $withdrawal, 'Extra charges on TV bill for ' . $formatted, $cur, $euro, $bills, null);
|
||||
Log::debug('Created extra charges no category.');
|
||||
|
||||
// income from job:
|
||||
$this->createTransaction($employer, $checking, rand(3500, 4000), $deposit, 'Salary for ' . $formatted, $cur, $euro);
|
||||
Log::debug('Created income.');
|
||||
$this->createTransaction($checking, $savings, 2000, $transfer, 'Salary to savings account in ' . $formatted, $cur, $euro);
|
||||
Log::debug('Created savings.');
|
||||
|
||||
$this->createGroceries($current);
|
||||
Log::debug('Created groceries range.');
|
||||
$this->createBigExpense(clone $current);
|
||||
Log::debug('Created big expense.');
|
||||
|
||||
echo 'Created test-content for ' . $current->format('F Y') . "\n";
|
||||
$current->addMonth();
|
||||
@ -242,7 +201,7 @@ class TestDataSeeder extends Seeder
|
||||
$user = User::whereEmail('thegrumpydictator@gmail.com')->first();
|
||||
|
||||
$billID = is_null($bill) ? null : $bill->id;
|
||||
Log::debug('String length of encrypted description ("'.$description.'") is: ' . strlen(Crypt::encrypt($description)));
|
||||
Log::debug('String length of encrypted description ("' . $description . '") is: ' . strlen(Crypt::encrypt($description)));
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = TransactionJournal::create(
|
||||
|
@ -1,6 +1,6 @@
|
||||
$(function () {
|
||||
|
||||
if (typeof(googleLineChart) == "function" && typeof accountID != 'undefined' && typeof view != 'undefined') {
|
||||
if (typeof(googleLineChart) === "function" && typeof accountID !== 'undefined' && typeof view !== 'undefined') {
|
||||
googleLineChart('chart/account/' + accountID + '/' + view, 'overview-chart');
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
$(document).ready(function () {
|
||||
|
||||
if (typeof(googleComboChart) == 'function' && typeof(billID) != 'undefined') {
|
||||
if (typeof(googleComboChart) === 'function' && typeof(billID) !== 'undefined') {
|
||||
googleComboChart('chart/bills/' + billID, 'bill-overview');
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ $(function () {
|
||||
$('.updateIncome').on('click', updateIncome);
|
||||
|
||||
|
||||
if (typeof budgetID != 'undefined' && typeof repetitionID == 'undefined') {
|
||||
if (typeof budgetID !== 'undefined' && typeof repetitionID === 'undefined') {
|
||||
googleColumnChart('chart/budget/' + budgetID + '/spending', 'budgetOverview');
|
||||
}
|
||||
if (typeof budgetID != 'undefined' && typeof repetitionID != 'undefined') {
|
||||
if (typeof budgetID !== 'undefined' && typeof repetitionID !== 'undefined') {
|
||||
googleLineChart('chart/budget/' + budgetID + '/' + repetitionID, 'budgetOverview');
|
||||
}
|
||||
|
||||
@ -24,7 +24,6 @@ function updateSingleRange(e) {
|
||||
var value = parseInt(input.val());
|
||||
|
||||
var spent = parseFloat($('#spent-' + id).data('value'));
|
||||
console.log('Spent vs budgeted: ' + spent + ' vs ' + value)
|
||||
|
||||
// update small display:
|
||||
if (value > 0) {
|
||||
@ -41,7 +40,6 @@ function updateSingleRange(e) {
|
||||
// $('#budgeted-' + id).html('Budgeted: <span class="text-success">\u20AC ' + value.toFixed(2) + '</span>');
|
||||
//}
|
||||
} else {
|
||||
console.log('Set to zero!');
|
||||
// hide the input:
|
||||
$('#budget-info-' + id + ' span').hide();
|
||||
$('#budget-info-' + id + ' input').hide();
|
||||
@ -55,10 +53,7 @@ function updateSingleRange(e) {
|
||||
$('#budget-range-display-' + id).text('\u20AC ' + value.toFixed(2));
|
||||
|
||||
// send a post to Firefly to update the amount:
|
||||
console.log('Value is: ' + value);
|
||||
console.log('POST! with ID ' + id + ' AND value ' + value);
|
||||
$.post('budgets/amount/' + id, {amount: value}).success(function (data) {
|
||||
console.log('Budget ' + data.name + ' updated!');
|
||||
// update the link if relevant:
|
||||
$('#budget-link-' + id).attr('href', 'budgets/show/' + id + '/' + data.repetition);
|
||||
});
|
||||
@ -97,7 +92,6 @@ function updateTotal() {
|
||||
// we gaan er X overheen,
|
||||
|
||||
var pct = totalAmount / sum * 100;
|
||||
console.log(pct)
|
||||
var danger = 100 - pct;
|
||||
var err = 100 - danger;
|
||||
$('#progress-bar-default').css('width', 0);
|
||||
@ -134,14 +128,9 @@ function updateRanges() {
|
||||
// update progress bar (if relevant)
|
||||
var barHolder = $('#budget-progress-' + id);
|
||||
var spent = parseFloat(barHolder.data('spent'));
|
||||
if (value > 0 && spent > 0) {
|
||||
console.log('Add bar')
|
||||
//barHolder.append($('<div class="progress-bar" id="progress-bar-something-' + id + '" role="progressbar" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100" style="width: 10%;"></div>'));
|
||||
}
|
||||
|
||||
// send a post to Firefly to update the amount:
|
||||
$.post('budgets/amount/' + id, {amount: value}).success(function (data) {
|
||||
console.log('Budget ' + data.name + ' updated!');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
$(function () {
|
||||
|
||||
if (typeof componentID != 'undefined' && typeof repetitionID == 'undefined') {
|
||||
if (typeof componentID !== 'undefined' && typeof repetitionID === 'undefined') {
|
||||
googleColumnChart('chart/category/' + componentID + '/spending/' + year, 'componentOverview');
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ $(function () {
|
||||
$('.addMoney').on('click', addMoney);
|
||||
$('.removeMoney').on('click', removeMoney);
|
||||
|
||||
if (typeof(googleLineChart) == 'function' && typeof(piggyBankID) != 'undefined') {
|
||||
if (typeof(googleLineChart) === 'function' && typeof(piggyBankID) !== 'undefined') {
|
||||
googleLineChart('chart/piggy_history/' + piggyBankID, 'piggy-bank-history');
|
||||
}
|
||||
});
|
||||
|
@ -22,7 +22,6 @@ function relateTransaction(e) {
|
||||
var ID = target.data('id');
|
||||
|
||||
|
||||
console.log($('#searchRelated').length);
|
||||
$('#relationModal').empty().load('related/related/' + ID, function () {
|
||||
|
||||
$('#relationModal').modal('show');
|
||||
|
Loading…
Reference in New Issue
Block a user