File reformatting.

This commit is contained in:
James Cole
2015-12-18 16:38:50 +01:00
parent 813fb679a7
commit ac61dfae6b
24 changed files with 149 additions and 140 deletions

View File

@@ -42,10 +42,10 @@ class ChartJsAccountChartGenerator implements AccountChartGenerator
public function expenseAccounts(Collection $accounts, Carbon $start, Carbon $end) public function expenseAccounts(Collection $accounts, Carbon $start, Carbon $end)
{ {
$data = [ $data = [
'count' => 1, 'count' => 1,
'labels' => [], 'datasets' => [[ 'labels' => [], 'datasets' => [[
'label' => trans('firefly.spent'), 'label' => trans('firefly.spent'),
'data' => []]]]; 'data' => []]]];
bcscale(2); bcscale(2);
$start->subDay(); $start->subDay();

View File

@@ -18,13 +18,6 @@ interface BudgetChartGenerator
*/ */
public function budget(Collection $entries); public function budget(Collection $entries);
/**
* @param Collection $entries
*
* @return array
*/
public function multiYear(Collection $entries);
/** /**
* @param Collection $entries * @param Collection $entries
* *
@@ -39,6 +32,13 @@ interface BudgetChartGenerator
*/ */
public function frontpage(Collection $entries); public function frontpage(Collection $entries);
/**
* @param Collection $entries
*
* @return array
*/
public function multiYear(Collection $entries);
/** /**
* @param Collection $budgets * @param Collection $budgets
* @param Collection $entries * @param Collection $entries

View File

@@ -20,11 +20,12 @@ interface CategoryChartGenerator
public function all(Collection $entries); public function all(Collection $entries);
/** /**
* @param Collection $categories
* @param Collection $entries * @param Collection $entries
* *
* @return array * @return array
*/ */
public function multiYear(Collection $entries); public function earnedInYear(Collection $categories, Collection $entries);
/** /**
* @param Collection $entries * @param Collection $entries
@@ -38,8 +39,14 @@ interface CategoryChartGenerator
* *
* @return array * @return array
*/ */
public function period(Collection $entries); public function multiYear(Collection $entries);
/**
* @param Collection $entries
*
* @return array
*/
public function period(Collection $entries);
/** /**
* @param Collection $categories * @param Collection $categories
@@ -48,12 +55,4 @@ interface CategoryChartGenerator
* @return array * @return array
*/ */
public function spentInYear(Collection $categories, Collection $entries); public function spentInYear(Collection $categories, Collection $entries);
/**
* @param Collection $categories
* @param Collection $entries
*
* @return array
*/
public function earnedInYear(Collection $categories, Collection $entries);
} }

View File

@@ -107,9 +107,9 @@ class ChartJsReportChartGenerator implements ReportChartGenerator
], ],
]; ];
$data['datasets'][0]['data'][] = round($income, 2); $data['datasets'][0]['data'][] = round($income, 2);
$data['datasets'][1]['data'][] = round( $expense, 2); $data['datasets'][1]['data'][] = round($expense, 2);
$data['datasets'][0]['data'][] = round(($income / $count), 2); $data['datasets'][0]['data'][] = round(($income / $count), 2);
$data['datasets'][1]['data'][] = round(( $expense / $count), 2); $data['datasets'][1]['data'][] = round(($expense / $count), 2);
return $data; return $data;
} }
@@ -138,9 +138,9 @@ class ChartJsReportChartGenerator implements ReportChartGenerator
], ],
]; ];
$data['datasets'][0]['data'][] = round($income, 2); $data['datasets'][0]['data'][] = round($income, 2);
$data['datasets'][1]['data'][] = round( $expense, 2); $data['datasets'][1]['data'][] = round($expense, 2);
$data['datasets'][0]['data'][] = round(($income / $count), 2); $data['datasets'][0]['data'][] = round(($income / $count), 2);
$data['datasets'][1]['data'][] = round(( $expense / $count), 2); $data['datasets'][1]['data'][] = round(($expense / $count), 2);
return $data; return $data;
} }

View File

@@ -12,13 +12,6 @@ use Illuminate\Support\Collection;
interface ReportChartGenerator interface ReportChartGenerator
{ {
/**
* @param Collection $entries
*
* @return array
*/
public function yearInOut(Collection $entries);
/** /**
* @param Collection $entries * @param Collection $entries
* *
@@ -33,7 +26,14 @@ interface ReportChartGenerator
* *
* @return array * @return array
*/ */
public function yearInOutSummarized($income, $expense, $count); public function multiYearInOutSummarized($income, $expense, $count);
/**
* @param Collection $entries
*
* @return array
*/
public function yearInOut(Collection $entries);
/** /**
* @param string $income * @param string $income
@@ -42,6 +42,6 @@ interface ReportChartGenerator
* *
* @return array * @return array
*/ */
public function multiYearInOutSummarized($income, $expense, $count); public function yearInOutSummarized($income, $expense, $count);
} }

View File

@@ -237,7 +237,7 @@ class ReportHelper implements ReportHelperInterface
$budgetLine = new BudgetLine; $budgetLine = new BudgetLine;
$budgetLine->setBudget($budget); $budgetLine->setBudget($budget);
$budgetLine->setRepetition($repetition); $budgetLine->setRepetition($repetition);
$expenses = $repository->balanceInPeriodForList($budget, $start, $end, $accounts); $expenses = $repository->balanceInPeriodForList($budget, $start, $end, $accounts);
// 200 en -100 is 100, vergeleken met 0 === 1 // 200 en -100 is 100, vergeleken met 0 === 1
// 200 en -200 is 0, vergeleken met 0 === 0 // 200 en -200 is 0, vergeleken met 0 === 0

View File

@@ -134,7 +134,7 @@ class ReportQuery implements ReportQueryInterface
$query->orWhere( $query->orWhere(
function (Builder $q) use ($ids) { function (Builder $q) use ($ids) {
$q->where('transaction_types.type', TransactionType::TRANSFER); $q->where('transaction_types.type', TransactionType::TRANSFER);
$q->whereNotIn('ac_from.id',$ids); $q->whereNotIn('ac_from.id', $ids);
$q->whereIn('ac_to.id', $ids); $q->whereIn('ac_to.id', $ids);
} }
); );

View File

@@ -22,8 +22,8 @@ interface ReportQueryInterface
* and "ordinary" withdrawals. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does * and "ordinary" withdrawals. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does
* not group and returns different fields. * not group and returns different fields.
* *
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* @param Collection $accounts * @param Collection $accounts
* *
* @return Collection * @return Collection

View File

@@ -214,15 +214,17 @@ class AuthController extends Controller
/** /**
* @return array * @return array
*/ */
protected function getBlockedDomains() { protected function getBlockedDomains()
$set = Config::get('mail.blocked_domains'); {
$set = Config::get('mail.blocked_domains');
$domains = []; $domains = [];
foreach($set as $entry) { foreach ($set as $entry) {
$domain = trim($entry); $domain = trim($entry);
if(strlen($domain) > 0) { if (strlen($domain) > 0) {
$domains[] = $domain; $domains[] = $domain;
} }
} }
return $domains; return $domains;
} }
@@ -234,6 +236,7 @@ class AuthController extends Controller
if (isset($parts[1]) && in_array($parts[1], $blocked)) { if (isset($parts[1]) && in_array($parts[1], $blocked)) {
return true; return true;
} }
return false; return false;
} }

View File

@@ -1,13 +1,12 @@
<?php namespace FireflyIII\Http\Controllers\Auth; <?php namespace FireflyIII\Http\Controllers\Auth;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Mail\Message; use Illuminate\Mail\Message;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Password; use Illuminate\Support\Facades\Password;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* Class PasswordController * Class PasswordController
* *
@@ -50,6 +49,7 @@ class PasswordController extends Controller
* Send a reset link to the given user. * Send a reset link to the given user.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function postEmail(Request $request) public function postEmail(Request $request)
@@ -61,9 +61,11 @@ class PasswordController extends Controller
if (!is_null($user) && intval($user->blocked) === 1) { if (!is_null($user) && intval($user->blocked) === 1) {
$response = 'passwords.blocked'; $response = 'passwords.blocked';
} else { } else {
$response = Password::sendResetLink($request->only('email'), function (Message $message) { $response = Password::sendResetLink(
$request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject()); $message->subject($this->getEmailSubject());
}); }
);
} }
switch ($response) { switch ($response) {

View File

@@ -147,7 +147,7 @@ class CurrencyController extends Controller
public function index(CurrencyRepositoryInterface $repository) public function index(CurrencyRepositoryInterface $repository)
{ {
$currencies = $repository->get(); $currencies = $repository->get();
$defaultCurrency = $repository->getCurrencyByPreference(Preferences::get('currencyPreference', env('DEFAULT_CURRENCY','EUR'))); $defaultCurrency = $repository->getCurrencyByPreference(Preferences::get('currencyPreference', env('DEFAULT_CURRENCY', 'EUR')));
if (!Auth::user()->hasRole('owner')) { if (!Auth::user()->hasRole('owner')) {

View File

@@ -192,7 +192,7 @@ class JsonController extends Controller
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get()); // @codeCoverageIgnore
} }
$accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']); $accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']);
$amount = $reportQuery->incomeInPeriod($start, $end, $accounts)->sum('amount'); $amount = $reportQuery->incomeInPeriod($start, $end, $accounts)->sum('amount');
$data = ['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; $data = ['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
$cache->store($data); $cache->store($data);

View File

@@ -46,17 +46,17 @@ class ReportController extends Controller
$months = $this->helper->listOfMonths($start); $months = $this->helper->listOfMonths($start);
// does the user have shared accounts? // does the user have shared accounts?
$accounts = $repository->getAccounts(['Default account', 'Asset account']); $accounts = $repository->getAccounts(['Default account', 'Asset account']);
// get id's for quick links: // get id's for quick links:
$accountIds = []; $accountIds = [];
/** @var Account $account */ /** @var Account $account */
foreach($accounts as $account) { foreach ($accounts as $account) {
$accountIds [] = $account->id; $accountIds [] = $account->id;
} }
$accountList = join(',',$accountIds); $accountList = join(',', $accountIds);
return view('reports.index', compact('months', 'accounts', 'start','accountList')); return view('reports.index', compact('months', 'accounts', 'start', 'accountList'));
} }
/** /**

View File

@@ -48,7 +48,7 @@ class TransactionController extends Controller
*/ */
public function create(AccountRepositoryInterface $repository, $what = TransactionType::DEPOSIT) public function create(AccountRepositoryInterface $repository, $what = TransactionType::DEPOSIT)
{ {
$what = strtolower($what); $what = strtolower($what);
$maxFileSize = Steam::phpBytes(ini_get('upload_max_filesize')); $maxFileSize = Steam::phpBytes(ini_get('upload_max_filesize'));
$maxPostSize = Steam::phpBytes(ini_get('post_max_size')); $maxPostSize = Steam::phpBytes(ini_get('post_max_size'));
$uploadSize = min($maxFileSize, $maxPostSize); $uploadSize = min($maxFileSize, $maxPostSize);

View File

@@ -1,13 +1,14 @@
<?php namespace FireflyIII\Http\Middleware; <?php namespace FireflyIII\Http\Middleware;
use App; use App;
use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use Closure; use Closure;
use Config; use Config;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Preferences; use Preferences;
use Auth;
/** /**
* Class Authenticate * Class Authenticate
* *
@@ -55,6 +56,7 @@ class Authenticate
if (intval($this->auth->user()->blocked) == 1) { if (intval($this->auth->user()->blocked) == 1) {
Auth::logout(); Auth::logout();
return redirect()->route('index'); return redirect()->route('index');
} }

View File

@@ -268,7 +268,7 @@ Route::get('/cron/sendgrid', ['uses' => 'CronController@sendgrid']);
Route::controllers( Route::controllers(
[ [
'auth' => 'Auth\AuthController', 'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController', 'password' => 'Auth\PasswordController',
] ]
); );

View File

@@ -39,8 +39,8 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereSkip($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereSkip($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereNameEncrypted($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereNameEncrypted($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereMatchEncrypted($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereMatchEncrypted($value)
* @property \Carbon\Carbon $nextExpectedMatch * @property \Carbon\Carbon $nextExpectedMatch
* @property \Carbon\Carbon $lastFoundMatch * @property \Carbon\Carbon $lastFoundMatch
*/ */
class Bill extends Model class Bill extends Model
{ {

View File

@@ -25,7 +25,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereUserId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereUserId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereEncrypted($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereEncrypted($value)
* @property-read float $spent * @property-read float $spent
* @property \Carbon\Carbon $lastActivity * @property \Carbon\Carbon $lastActivity
*/ */
class Category extends Model class Category extends Model
{ {

View File

@@ -23,9 +23,9 @@ class TransactionType extends Model
{ {
use SoftDeletes; use SoftDeletes;
const WITHDRAWAL = 'Withdrawal'; const WITHDRAWAL = 'Withdrawal';
const DEPOSIT = 'Deposit'; const DEPOSIT = 'Deposit';
const TRANSFER = 'Transfer'; const TRANSFER = 'Transfer';
const OPENING_BALANCE = 'Opening balance'; const OPENING_BALANCE = 'Opening balance';
/** /**
@@ -36,22 +36,6 @@ class TransactionType extends Model
return ['created_at', 'updated_at', 'deleted_at']; return ['created_at', 'updated_at', 'deleted_at'];
} }
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function transactionJournals()
{
return $this->hasMany('FireflyIII\Models\TransactionJournal');
}
/**
* @return bool
*/
public function isWithdrawal()
{
return $this->type === TransactionType::WITHDRAWAL;
}
/** /**
* @return bool * @return bool
*/ */
@@ -60,6 +44,14 @@ class TransactionType extends Model
return $this->type === TransactionType::DEPOSIT; return $this->type === TransactionType::DEPOSIT;
} }
/**
* @return bool
*/
public function isOpeningBalance()
{
return $this->type === TransactionType::OPENING_BALANCE;
}
/** /**
* @return bool * @return bool
*/ */
@@ -71,8 +63,16 @@ class TransactionType extends Model
/** /**
* @return bool * @return bool
*/ */
public function isOpeningBalance() public function isWithdrawal()
{ {
return $this->type === TransactionType::OPENING_BALANCE; return $this->type === TransactionType::WITHDRAWAL;
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function transactionJournals()
{
return $this->hasMany('FireflyIII\Models\TransactionJournal');
} }
} }

View File

@@ -14,7 +14,6 @@ use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Input; use Input;
use Log;
/** /**
* Class BudgetRepository * Class BudgetRepository
@@ -89,10 +88,10 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
/** @var Collection $repetitions */ /** @var Collection $repetitions */
return LimitRepetition:: return LimitRepetition::
leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id') leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
->where('limit_repetitions.startdate', '<=', $end->format('Y-m-d 00:00:00')) ->where('limit_repetitions.startdate', '<=', $end->format('Y-m-d 00:00:00'))
->where('limit_repetitions.startdate', '>=', $start->format('Y-m-d 00:00:00')) ->where('limit_repetitions.startdate', '>=', $start->format('Y-m-d 00:00:00'))
->where('budget_limits.budget_id', $budget->id) ->where('budget_limits.budget_id', $budget->id)
->get(['limit_repetitions.*']); ->get(['limit_repetitions.*']);
} }
/** /**
@@ -141,9 +140,9 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
return $cache->get(); // @codeCoverageIgnore return $cache->get(); // @codeCoverageIgnore
} }
$data = $budget->limitrepetitions() $data = $budget->limitrepetitions()
->where('limit_repetitions.startdate', $start->format('Y-m-d 00:00:00')) ->where('limit_repetitions.startdate', $start->format('Y-m-d 00:00:00'))
->where('limit_repetitions.enddate', $end->format('Y-m-d 00:00:00')) ->where('limit_repetitions.enddate', $end->format('Y-m-d 00:00:00'))
->first(['limit_repetitions.*']); ->first(['limit_repetitions.*']);
//Log::debug('Looking for limit reps for budget #' . $budget->id . ' start [' . $start . '] and end [' . $end . '].'); //Log::debug('Looking for limit reps for budget #' . $budget->id . ' start [' . $start . '] and end [' . $end . '].');
//Log::debug(DB::getQueryLog()) //Log::debug(DB::getQueryLog())
$cache->store($data); $cache->store($data);
@@ -186,9 +185,9 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
/** /**
* Returns all the transaction journals for a limit, possibly limited by a limit repetition. * Returns all the transaction journals for a limit, possibly limited by a limit repetition.
* *
* @param Budget $budget * @param Budget $budget
* @param LimitRepetition $repetition * @param LimitRepetition $repetition
* @param int $take * @param int $take
* *
* @return LengthAwarePaginator * @return LengthAwarePaginator
*/ */
@@ -205,11 +204,11 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
return $cache->get(); // @codeCoverageIgnore return $cache->get(); // @codeCoverageIgnore
} }
$offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0; $offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0;
$setQuery = $budget->transactionJournals()->withRelevantData()->take($take)->offset($offset) $setQuery = $budget->transactionJournals()->withRelevantData()->take($take)->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');
$countQuery = $budget->transactionJournals(); $countQuery = $budget->transactionJournals();
@@ -219,7 +218,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
} }
$set = $setQuery->get(['transaction_journals.*']); $set = $setQuery->get(['transaction_journals.*']);
$count = $countQuery->count(); $count = $countQuery->count();
@@ -253,9 +252,9 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
public function getLimitAmountOnDate(Budget $budget, Carbon $date) public function getLimitAmountOnDate(Budget $budget, Carbon $date)
{ {
$repetition = LimitRepetition::leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id') $repetition = LimitRepetition::leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
->where('limit_repetitions.startdate', $date->format('Y-m-d 00:00:00')) ->where('limit_repetitions.startdate', $date->format('Y-m-d 00:00:00'))
->where('budget_limits.budget_id', $budget->id) ->where('budget_limits.budget_id', $budget->id)
->first(['limit_repetitions.*']); ->first(['limit_repetitions.*']);
if ($repetition) { if ($repetition) {
return $repetition->amount; return $repetition->amount;
@@ -273,15 +272,15 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
public function getWithoutBudget(Carbon $start, Carbon $end) public function getWithoutBudget(Carbon $start, Carbon $end)
{ {
return Auth::user() return Auth::user()
->transactionjournals() ->transactionjournals()
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->whereNull('budget_transaction_journal.id') ->whereNull('budget_transaction_journal.id')
->before($end) ->before($end)
->after($start) ->after($start)
->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(['transaction_journals.*']); ->get(['transaction_journals.*']);
} }
/** /**
@@ -293,30 +292,30 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
public function getWithoutBudgetSum(Carbon $start, Carbon $end) public function getWithoutBudgetSum(Carbon $start, Carbon $end)
{ {
$noBudgetSet = Auth::user() $noBudgetSet = Auth::user()
->transactionjournals() ->transactionjournals()
->whereNotIn( ->whereNotIn(
'transaction_journals.id', function (QueryBuilder $query) use ($start, $end) { 'transaction_journals.id', function (QueryBuilder $query) use ($start, $end) {
$query $query
->select('transaction_journals.id') ->select('transaction_journals.id')
->from('transaction_journals') ->from('transaction_journals')
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00')) ->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00')) ->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00'))
->whereNotNull('budget_transaction_journal.budget_id'); ->whereNotNull('budget_transaction_journal.budget_id');
} }
) )
->after($start) ->after($start)
->before($end) ->before($end)
->transactionTypes([TransactionType::WITHDRAWAL]) ->transactionTypes([TransactionType::WITHDRAWAL])
->get(['transaction_journals.*'])->sum('amount'); ->get(['transaction_journals.*'])->sum('amount');
return $noBudgetSet; return $noBudgetSet;
} }
/** /**
* @param Budget $budget * @param Budget $budget
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* @param Collection $accounts * @param Collection $accounts
* *
* @return string * @return string
@@ -330,7 +329,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
* @param Budget $budget * @param Budget $budget
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* @param bool $shared * @param bool $shared
* *
* @return string * @return string
*/ */
@@ -349,7 +348,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
$newBudget = new Budget( $newBudget = new Budget(
[ [
'user_id' => $data['user'], 'user_id' => $data['user'],
'name' => $data['name'], 'name' => $data['name'],
] ]
); );
$newBudget->save(); $newBudget->save();
@@ -360,14 +359,14 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
/** /**
* @param Budget $budget * @param Budget $budget
* @param array $data * @param array $data
* *
* @return Budget * @return Budget
*/ */
public function update(Budget $budget, array $data) public function update(Budget $budget, array $data)
{ {
// update the account: // update the account:
$budget->name = $data['name']; $budget->name = $data['name'];
$budget->active = $data['active']; $budget->active = $data['active'];
$budget->save(); $budget->save();
@@ -391,10 +390,10 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
// if not, create one! // if not, create one!
$limit = new BudgetLimit; $limit = new BudgetLimit;
$limit->budget()->associate($budget); $limit->budget()->associate($budget);
$limit->startdate = $date; $limit->startdate = $date;
$limit->amount = $amount; $limit->amount = $amount;
$limit->repeat_freq = 'monthly'; $limit->repeat_freq = 'monthly';
$limit->repeats = 0; $limit->repeats = 0;
$limit->save(); $limit->save();
// likewise, there should be a limit repetition to match the end date // likewise, there should be a limit repetition to match the end date

View File

@@ -478,6 +478,7 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
->transactionTypes([TransactionType::WITHDRAWAL]) ->transactionTypes([TransactionType::WITHDRAWAL])
->get(['transaction_journals.*']) ->get(['transaction_journals.*'])
->sum('amount'); ->sum('amount');
return $sum; return $sum;
} }
@@ -508,6 +509,7 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
->after($start) ->after($start)
->get(['transaction_journals.*']) ->get(['transaction_journals.*'])
->sum('amount'); ->sum('amount');
return $sum; return $sum;
} }

View File

@@ -77,7 +77,9 @@ class TagRepository implements TagRepositoryInterface
/** @var Tag $tag */ /** @var Tag $tag */
foreach ($tags as $tag) { foreach ($tags as $tag) {
$journals = $tag->transactionjournals()->after($start)->before($end)->transactionTypes([TransactionType::TRANSFER])->get(['transaction_journals.*']); $journals = $tag->transactionjournals()->after($start)->before($end)->transactionTypes([TransactionType::TRANSFER])->get(
['transaction_journals.*']
);
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
foreach ($journals as $journal) { foreach ($journals as $journal) {

View File

@@ -40,7 +40,7 @@ class Amount
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); return $cache->get();
} else { } else {
$currencyPreference = Prefs::get('currencyPreference', env('DEFAULT_CURRENCY','EUR')); $currencyPreference = Prefs::get('currencyPreference', env('DEFAULT_CURRENCY', 'EUR'));
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first(); $currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
$cache->store($currency->symbol); $cache->store($currency->symbol);
@@ -152,7 +152,7 @@ class Amount
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); return $cache->get();
} else { } else {
$currencyPreference = Prefs::get('currencyPreference', env('DEFAULT_CURRENCY','EUR')); $currencyPreference = Prefs::get('currencyPreference', env('DEFAULT_CURRENCY', 'EUR'));
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first(); $currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
if ($currency) { if ($currency) {
@@ -161,9 +161,9 @@ class Amount
return $currency->code; return $currency->code;
} }
$cache->store(env('DEFAULT_CURRENCY','EUR')); $cache->store(env('DEFAULT_CURRENCY', 'EUR'));
return env('DEFAULT_CURRENCY','EUR'); // @codeCoverageIgnore return env('DEFAULT_CURRENCY', 'EUR'); // @codeCoverageIgnore
} }
} }

View File

@@ -273,7 +273,7 @@ class FireflyValidator extends Validator
// get entries from table // get entries from table
$set = DB::table($table)->where('user_id', Auth::user()->id) $set = DB::table($table)->where('user_id', Auth::user()->id)
->where('id', '!=', $exclude)->get([$field]); ->where('id', '!=', $exclude)->get([$field]);
foreach ($set as $entry) { foreach ($set as $entry) {
$fieldValue = $this->tryDecrypt($entry->$field); $fieldValue = $this->tryDecrypt($entry->$field);