Merge branch 'release/3.5.6'

This commit is contained in:
James Cole 2015-12-28 08:07:43 +01:00
commit c2d444347d
56 changed files with 839 additions and 921 deletions

View File

@ -113,7 +113,7 @@ class ChartJsAccountChartGenerator implements AccountChartGenerator
'data' => [], 'data' => [],
]; ];
$current = clone $start; $current = clone $start;
$range = Steam::balanceInRange($account, $start, $end); $range = Steam::balanceInRange($account, $start, clone $end);
$previous = array_values($range)[0]; $previous = array_values($range)[0];
while ($current <= $end) { while ($current <= $end) {
$format = $current->format('Y-m-d'); $format = $current->format('Y-m-d');
@ -152,12 +152,17 @@ class ChartJsAccountChartGenerator implements AccountChartGenerator
] ]
], ],
]; ];
$range = Steam::balanceInRange($account, $start, $end);
$current = clone $start; $current = clone $start;
$previous = array_values($range)[0];
while ($end >= $current) { while ($end >= $current) {
$theDate = $current->format('Y-m-d');
$balance = isset($range[$theDate]) ? $range[$theDate] : $previous;
$data['labels'][] = $current->formatLocalized($format); $data['labels'][] = $current->formatLocalized($format);
$data['datasets'][0]['data'][] = Steam::balance($account, $current); $data['datasets'][0]['data'][] = $balance;
$previous = $balance;
$current->addDay(); $current->addDay();
} }

View File

@ -14,12 +14,12 @@ interface BillChartGenerator
{ {
/** /**
* @param Collection $paid * @param string $paid
* @param Collection $unpaid * @param string $unpaid
* *
* @return array * @return array
*/ */
public function frontpage(Collection $paid, Collection $unpaid); public function frontpage($paid, $unpaid);
/** /**
* @param Bill $bill * @param Bill $bill

View File

@ -2,11 +2,9 @@
namespace FireflyIII\Generator\Chart\Bill; namespace FireflyIII\Generator\Chart\Bill;
use Config;
use FireflyIII\Models\Bill; use FireflyIII\Models\Bill;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Preferences;
/** /**
* Class ChartJsBillChartGenerator * Class ChartJsBillChartGenerator
@ -17,42 +15,23 @@ class ChartJsBillChartGenerator implements BillChartGenerator
{ {
/** /**
* @param Collection $paid * @param string $paid
* @param Collection $unpaid * @param string $unpaid
* *
* @return array * @return array
*/ */
public function frontpage(Collection $paid, Collection $unpaid) public function frontpage($paid, $unpaid)
{ {
$paidDescriptions = [];
$paidAmount = 0;
$unpaidDescriptions = [];
$unpaidAmount = 0;
bcscale(2); bcscale(2);
/** @var TransactionJournal $entry */
foreach ($paid as $entry) { // loop paid and create single entry:
$paidDescriptions[] = $entry->description;
$paidAmount = bcadd($paidAmount, $entry->amount_positive);
}
/** @var Bill $entry */
foreach ($unpaid as $entry) { // loop unpaid:
$description = $entry[0]->name . ' (' . $entry[1]->format('jS M Y') . ')';
$amount = bcdiv(bcadd($entry[0]->amount_max, $entry[0]->amount_min), 2);
$unpaidDescriptions[] = $description;
$unpaidAmount = bcadd($unpaidAmount, $amount);
unset($amount, $description);
}
$data = [ $data = [
[ [
'value' => $unpaidAmount, 'value' => round($unpaid, 2),
'color' => 'rgba(53, 124, 165,0.7)', 'color' => 'rgba(53, 124, 165,0.7)',
'highlight' => 'rgba(53, 124, 165,0.9)', 'highlight' => 'rgba(53, 124, 165,0.9)',
'label' => trans('firefly.unpaid'), 'label' => trans('firefly.unpaid'),
], ],
[ [
'value' => $paidAmount, 'value' => round($paid * -1, 2), // paid is negative, must be positive.
'color' => 'rgba(0, 141, 76, 0.7)', 'color' => 'rgba(0, 141, 76, 0.7)',
'highlight' => 'rgba(0, 141, 76, 0.9)', 'highlight' => 'rgba(0, 141, 76, 0.9)',
'label' => trans('firefly.paid'), 'label' => trans('firefly.paid'),
@ -86,11 +65,15 @@ class ChartJsBillChartGenerator implements BillChartGenerator
$minAmount = []; $minAmount = [];
$maxAmount = []; $maxAmount = [];
$actualAmount = []; $actualAmount = [];
/** @var TransactionJournal $entry */
foreach ($entries as $entry) { foreach ($entries as $entry) {
$data['labels'][] = $entry->date->formatLocalized($format); $data['labels'][] = $entry->date->formatLocalized($format);
$minAmount[] = round($bill->amount_min, 2); $minAmount[] = round($bill->amount_min, 2);
$maxAmount[] = round($bill->amount_max, 2); $maxAmount[] = round($bill->amount_max, 2);
$actualAmount[] = round(($entry->amount * -1), 2); /*
* journalAmount has been collected in BillRepository::getJournals
*/
$actualAmount[] = round(($entry->journalAmount * -1), 2);
} }
$data['datasets'][] = [ $data['datasets'][] = [

View File

@ -83,8 +83,8 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator
if ($entry[1] != 0 || $entry[2] != 0 || $entry[3] != 0) { if ($entry[1] != 0 || $entry[2] != 0 || $entry[3] != 0) {
$data['labels'][] = $entry[0]; $data['labels'][] = $entry[0];
$left[] = round($entry[1], 2); $left[] = round($entry[1], 2);
$spent[] = round($entry[2], 2); $spent[] = round($entry[2] * -1, 2); // spent is coming in negative, must be positive
$overspent[] = round($entry[3], 2); $overspent[] = round($entry[3] * -1, 2); // same
} }
} }

View File

@ -54,5 +54,5 @@ interface CategoryChartGenerator
* *
* @return array * @return array
*/ */
public function spentInYear(Collection $categories, Collection $entries); public function spentInPeriod(Collection $categories, Collection $entries);
} }

View File

@ -49,79 +49,6 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator
return $data; return $data;
} }
/**
* @param Collection $entries
*
* @return array
*/
public function frontpage(Collection $entries)
{
$data = [
'count' => 1,
'labels' => [],
'datasets' => [
[
'label' => trans('firefly.spent'),
'data' => []
]
],
];
foreach ($entries as $entry) {
if ($entry['sum'] != 0) {
$data['labels'][] = $entry['name'];
$data['datasets'][0]['data'][] = round(($entry['sum'] * -1), 2);
}
}
return $data;
}
/**
* @codeCoverageIgnore
*
* @param Collection $entries
*
* @return array
*/
public function period(Collection $entries)
{
return $this->all($entries);
}
/**
* @param Collection $categories
* @param Collection $entries
*
* @return array
*/
public function spentInYear(Collection $categories, Collection $entries)
{
// language:
$format = trans('config.month');
$data = [
'count' => 0,
'labels' => [],
'datasets' => [],
];
foreach ($categories as $category) {
$data['labels'][] = $category->name;
}
foreach ($entries as $entry) {
$date = $entry[0]->formatLocalized($format);
array_shift($entry);
$data['count']++;
$data['datasets'][] = ['label' => $date, 'data' => $entry];
}
return $data;
}
/** /**
* @param Collection $categories * @param Collection $categories
* @param Collection $entries * @param Collection $entries
@ -156,36 +83,30 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator
} }
/** /**
* @param Collection $categories
* @param Collection $entries * @param Collection $entries
* *
* @return array * @return array
*/ */
public function spentInPeriod(Collection $categories, Collection $entries) public function frontpage(Collection $entries)
{ {
// language:
$format = trans('config.month');
$data = [ $data = [
'count' => 0, 'count' => 1,
'labels' => [], 'labels' => [],
'datasets' => [], 'datasets' => [
[
'label' => trans('firefly.spent'),
'data' => []
]
],
]; ];
foreach ($categories as $category) {
$data['labels'][] = $category->name;
}
foreach ($entries as $entry) { foreach ($entries as $entry) {
$date = $entry[0]->formatLocalized($format); if ($entry['sum'] != 0) {
array_shift($entry); $data['labels'][] = $entry['name'];
$data['count']++; $data['datasets'][0]['data'][] = round(($entry['sum'] * -1), 2);
$data['datasets'][] = ['label' => $date, 'data' => $entry]; }
} }
return $data; return $data;
} }
/** /**
@ -224,4 +145,50 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator
return $data; return $data;
} }
/**
* @codeCoverageIgnore
*
* @param Collection $entries
*
* @return array
*/
public function period(Collection $entries)
{
return $this->all($entries);
}
/**
* @param Collection $categories
* @param Collection $entries
*
* @return array
*/
public function spentInPeriod(Collection $categories, Collection $entries)
{
// language:
$format = trans('config.month');
$data = [
'count' => 0,
'labels' => [],
'datasets' => [],
];
foreach ($categories as $category) {
$data['labels'][] = $category->name;
}
foreach ($entries as $entry) {
$date = $entry[0]->formatLocalized($format);
array_shift($entry);
$data['count']++;
$data['datasets'][] = ['label' => $date, 'data' => $entry];
}
return $data;
}
} }

View File

@ -3,9 +3,7 @@
namespace FireflyIII\Generator\Chart\PiggyBank; namespace FireflyIII\Generator\Chart\PiggyBank;
use Carbon\Carbon; use Carbon\Carbon;
use Config;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Preferences;
/** /**

View File

@ -2,9 +2,7 @@
namespace FireflyIII\Generator\Chart\Report; namespace FireflyIII\Generator\Chart\Report;
use Config;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Preferences;
/** /**
* Class ChartJsReportChartGenerator * Class ChartJsReportChartGenerator
@ -14,40 +12,6 @@ use Preferences;
class ChartJsReportChartGenerator implements ReportChartGenerator class ChartJsReportChartGenerator implements ReportChartGenerator
{ {
/**
* @param Collection $entries
*
* @return array
*/
public function yearInOut(Collection $entries)
{
// language:
$format = trans('config.month');
$data = [
'count' => 2,
'labels' => [],
'datasets' => [
[
'label' => trans('firefly.income'),
'data' => []
],
[
'label' => trans('firefly.expenses'),
'data' => []
]
],
];
foreach ($entries as $entry) {
$data['labels'][] = $entry[0]->formatLocalized($format);
$data['datasets'][0]['data'][] = round($entry[1], 2);
$data['datasets'][1]['data'][] = round($entry[2], 2);
}
return $data;
}
/** /**
* Same as above but other translations. * Same as above but other translations.
* *
@ -81,6 +45,71 @@ class ChartJsReportChartGenerator implements ReportChartGenerator
return $data; return $data;
} }
/**
* @param string $income
* @param string $expense
* @param int $count
*
* @return array
*/
public function multiYearInOutSummarized($income, $expense, $count)
{
$data = [
'count' => 2,
'labels' => [trans('firefly.sum_of_years'), trans('firefly.average_of_years')],
'datasets' => [
[
'label' => trans('firefly.income'),
'data' => []
],
[
'label' => trans('firefly.expenses'),
'data' => []
]
],
];
$data['datasets'][0]['data'][] = round($income, 2);
$data['datasets'][1]['data'][] = round($expense, 2);
$data['datasets'][0]['data'][] = round(($income / $count), 2);
$data['datasets'][1]['data'][] = round(($expense / $count), 2);
return $data;
}
/**
* @param Collection $entries
*
* @return array
*/
public function yearInOut(Collection $entries)
{
// language:
$format = trans('config.month');
$data = [
'count' => 2,
'labels' => [],
'datasets' => [
[
'label' => trans('firefly.income'),
'data' => []
],
[
'label' => trans('firefly.expenses'),
'data' => []
]
],
];
foreach ($entries as $entry) {
$data['labels'][] = $entry[0]->formatLocalized($format);
$data['datasets'][0]['data'][] = round($entry[1], 2);
$data['datasets'][1]['data'][] = round($entry[2], 2);
}
return $data;
}
/** /**
* @param string $income * @param string $income
* @param string $expense * @param string $expense
@ -112,35 +141,4 @@ class ChartJsReportChartGenerator implements ReportChartGenerator
return $data; return $data;
} }
/**
* @param string $income
* @param string $expense
* @param int $count
*
* @return array
*/
public function multiYearInOutSummarized($income, $expense, $count)
{
$data = [
'count' => 2,
'labels' => [trans('firefly.sum_of_years'), trans('firefly.average_of_years')],
'datasets' => [
[
'label' => trans('firefly.income'),
'data' => []
],
[
'label' => trans('firefly.expenses'),
'data' => []
]
],
];
$data['datasets'][0]['data'][] = round($income, 2);
$data['datasets'][1]['data'][] = round($expense, 2);
$data['datasets'][0]['data'][] = round(($income / $count), 2);
$data['datasets'][1]['data'][] = round(($expense / $count), 2);
return $data;
}
} }

View File

@ -67,8 +67,10 @@ class AttachmentHelper implements AttachmentHelperInterface
} }
} }
} else { } else {
if (!is_null($files)) {
$this->processFile($files, $model); $this->processFile($files, $model);
} }
}
return true; return true;
} }

View File

@ -17,7 +17,8 @@ class Date extends BasicConverter implements ConverterInterface
{ {
/** /**
* @return Carbon * @return static
* @throws FireflyException
*/ */
public function convert() public function convert()
{ {

View File

@ -161,15 +161,6 @@ class ReportQuery implements ReportQueryInterface
} }
} }
); );
// $data = $data->filter(
// function (TransactionJournal $journal) {
// if ($journal->amount != 0) {
// return $journal;
// }
//
// return null;
// }
// );
return $data; return $data;
} }

View File

@ -56,6 +56,7 @@ class AccountController extends Controller
} }
/** /**
* @param AccountRepositoryInterface $repository
* @param Account $account * @param Account $account
* *
* @return \Illuminate\View\View * @return \Illuminate\View\View

View File

@ -91,6 +91,7 @@ class AttachmentController extends Controller
/** /**
* @param Attachment $attachment * @param Attachment $attachment
* @param AttachmentHelperInterface $helper
*/ */
public function download(Attachment $attachment, AttachmentHelperInterface $helper) public function download(Attachment $attachment, AttachmentHelperInterface $helper)
{ {

View File

@ -228,6 +228,11 @@ class AuthController extends Controller
return $domains; return $domains;
} }
/**
* @param $email
*
* @return bool
*/
protected function isBlockedDomain($email) protected function isBlockedDomain($email)
{ {
$parts = explode('@', $email); $parts = explode('@', $email);

View File

@ -77,6 +77,8 @@ class PasswordController extends Controller
return redirect()->back()->withErrors(['email' => trans($response)]); return redirect()->back()->withErrors(['email' => trans($response)]);
} }
abort(404);
return '';
} }
} }

View File

@ -134,6 +134,8 @@ class BudgetController extends Controller
/** /**
* @param BudgetRepositoryInterface $repository * @param BudgetRepositoryInterface $repository
* *
* @param AccountRepositoryInterface $accountRepository
*
* @return \Illuminate\View\View * @return \Illuminate\View\View
*/ */
public function index(BudgetRepositoryInterface $repository, AccountRepositoryInterface $accountRepository) public function index(BudgetRepositoryInterface $repository, AccountRepositoryInterface $accountRepository)

View File

@ -146,6 +146,8 @@ class CategoryController extends Controller
* @param CategoryRepositoryInterface $repository * @param CategoryRepositoryInterface $repository
* @param Category $category * @param Category $category
* *
* @param $date
*
* @return \Illuminate\View\View * @return \Illuminate\View\View
*/ */
public function showWithDate(CategoryRepositoryInterface $repository, Category $category, $date) public function showWithDate(CategoryRepositoryInterface $repository, Category $category, $date)

View File

@ -37,13 +37,12 @@ class AccountController extends Controller
/** /**
* Shows the balances for a given set of dates and accounts. * Shows the balances for a given set of dates and accounts.
* *
* TODO fix parameters. * @param $report_type
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* *
* @param AccountRepositoryInterface $repository * @return \Illuminate\Http\JsonResponse
*
* @param $url
*
* @return \Symfony\Component\HttpFoundation\Response
*/ */
public function report($report_type, Carbon $start, Carbon $end, Collection $accounts) public function report($report_type, Carbon $start, Carbon $end, Collection $accounts)
{ {

View File

@ -33,7 +33,7 @@ class BillController extends Controller
} }
/** /**
* Shows all bills and whether or not theyve been paid this month (pie chart). * Shows all bills and whether or not they've been paid this month (pie chart).
* *
* @param BillRepositoryInterface $repository * @param BillRepositoryInterface $repository
* *
@ -43,26 +43,22 @@ class BillController extends Controller
{ {
$start = Session::get('start', Carbon::now()->startOfMonth()); $start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth());
$cache = new CacheProperties(); // chart properties for cache: $paid = $repository->getBillsPaidInRange($start, $end); // will be a negative amount.
$cache->addProperty($start); $unpaid = $repository->getBillsUnpaidInRange($start, $end); // will be a positive amount.
$cache->addProperty($end); $creditCardDue = $repository->getCreditCardBill($start, $end);
$cache->addProperty('bills');
$cache->addProperty('frontpage'); if ($creditCardDue < 0) {
if ($cache->has()) { // expenses are negative (bill not yet paid),
return Response::json($cache->get()); // @codeCoverageIgnore $creditCardDue = bcmul($creditCardDue, '-1');
$unpaid = bcadd($unpaid, $creditCardDue);
} else {
// if more than zero, the bill has been paid: (transfer = positive).
// amount must be negative to be added to $paid:
$paid = bcadd($paid, $creditCardDue);
} }
$set = $repository->getBillsForChart($start, $end);
// optionally expand this set with credit card data
$set = $repository->getCreditCardInfoForChart($set, $start, $end);
$paid = $set->get('paid');
$unpaid = $set->get('unpaid');
// build chart: // build chart:
$data = $this->generator->frontpage($paid, $unpaid); $data = $this->generator->frontpage($paid, $unpaid);
$cache->store($data);
return Response::json($data); return Response::json($data);
} }

View File

@ -43,6 +43,8 @@ class BudgetController extends Controller
* @param Carbon $end * @param Carbon $end
* @param Collection $accounts * @param Collection $accounts
* @param Collection $budgets * @param Collection $budgets
*
* @return \Illuminate\Http\JsonResponse
*/ */
public function multiYear(BudgetRepositoryInterface $repository, $report_type, Carbon $start, Carbon $end, Collection $accounts, Collection $budgets) public function multiYear(BudgetRepositoryInterface $repository, $report_type, Carbon $start, Carbon $end, Collection $accounts, Collection $budgets)
{ {
@ -111,6 +113,7 @@ class BudgetController extends Controller
/** /**
* @param BudgetRepositoryInterface $repository * @param BudgetRepositoryInterface $repository
* @param AccountRepositoryInterface $accountRepository
* @param Budget $budget * @param Budget $budget
* *
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
@ -207,15 +210,14 @@ class BudgetController extends Controller
* *
* @param BudgetRepositoryInterface $repository * @param BudgetRepositoryInterface $repository
* *
* @param AccountRepositoryInterface $accountRepository
*
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function frontpage(BudgetRepositoryInterface $repository, AccountRepositoryInterface $accountRepository) public function frontpage(BudgetRepositoryInterface $repository, AccountRepositoryInterface $accountRepository)
{ {
$budgets = $repository->getBudgets();
$start = Session::get('start', Carbon::now()->startOfMonth()); $start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth());
$allEntries = new Collection;
$accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']);
// chart properties for cache: // chart properties for cache:
$cache = new CacheProperties(); $cache = new CacheProperties();
@ -227,52 +229,57 @@ class BudgetController extends Controller
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get()); // @codeCoverageIgnore
} }
$budgets = $repository->getBudgetsAndLimitsInRange($start, $end);
$allEntries = new Collection;
$accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']);
bcscale(2); bcscale(2);
/** @var Budget $budget */ /** @var Budget $budget */
foreach ($budgets as $budget) { foreach ($budgets as $budget) {
$repetitions = $repository->getBudgetLimitRepetitions($budget, $start, $end); // we already have amount, startdate and enddate.
if ($repetitions->count() == 0) { // if this "is" a limit repetition (as opposed to a budget without one entirely)
$expenses = $repository->balanceInPeriod($budget, $start, $end, $accounts) * -1; // depends on whether startdate and enddate are null.
$allEntries->push([$budget->name, 0, 0, $expenses, 0, 0]);
continue;
}
/** @var LimitRepetition $repetition */
foreach ($repetitions as $repetition) {
$expenses = $repository->balanceInPeriod($budget, $repetition->startdate, $repetition->enddate, $accounts) * -1;
// $left can be less than zero.
// $overspent can be more than zero ( = overspending)
$left = max(bcsub($repetition->amount, $expenses), 0); // limited at zero.
$overspent = max(bcsub($expenses, $repetition->amount), 0); // limited at zero.
$name = $budget->name; $name = $budget->name;
if (is_null($budget->startdate) && is_null($budget->enddate)) {
// $spent is maxed to the repetition amount: $currentStart = clone $start;
$spent = $expenses > $repetition->amount ? $repetition->amount : $expenses; $currentEnd = clone $end;
$expenses = $repository->balanceInPeriod($budget, $currentStart, $currentEnd, $accounts);
$amount = 0;
$allEntries->push([$name, $left, $spent, $overspent, $repetition->amount, $expenses]); $left = 0;
} $spent = $expenses;
$overspent = 0;
} else {
$currentStart = clone $budget->startdate;
$currentEnd = clone $budget->enddate;
$expenses = $repository->balanceInPeriod($budget, $currentStart, $currentEnd, $accounts);
$amount = $budget->amount;
// smaller than 1 means spent MORE than budget allows.
$left = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? 0 : bcadd($budget->amount, $expenses);
$spent = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? ($amount * -1) : $expenses;
$overspent = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? bcadd($budget->amount, $expenses) : 0;
} }
$noBudgetExpenses = $repository->getWithoutBudgetSum($start, $end) * -1; $allEntries->push([$name, $left, $spent, $overspent, $amount, $expenses]);
}
$noBudgetExpenses = $repository->getWithoutBudgetSum($start, $end);
$allEntries->push([trans('firefly.noBudget'), 0, 0, $noBudgetExpenses, 0, 0]); $allEntries->push([trans('firefly.noBudget'), 0, 0, $noBudgetExpenses, 0, 0]);
$data = $this->generator->frontpage($allEntries); $data = $this->generator->frontpage($allEntries);
$cache->store($data); $cache->store($data);
return Response::json($data); return Response::json($data);
} }
/** /**
* Show a yearly overview for a budget.
*
* @param BudgetRepositoryInterface $repository * @param BudgetRepositoryInterface $repository
* @param $year * @param $report_type
* @param bool $shared * @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* *
* @return \Symfony\Component\HttpFoundation\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function year(BudgetRepositoryInterface $repository, $report_type, Carbon $start, Carbon $end, Collection $accounts) public function year(BudgetRepositoryInterface $repository, $report_type, Carbon $start, Carbon $end, Collection $accounts)
{ {

View File

@ -135,6 +135,8 @@ class CategoryController extends Controller
* @param Carbon $end * @param Carbon $end
* @param Collection $accounts * @param Collection $accounts
* @param Collection $categories * @param Collection $categories
*
* @return \Illuminate\Http\JsonResponse
*/ */
public function multiYear(CategoryRepositoryInterface $repository, $report_type, Carbon $start, Carbon $end, Collection $accounts, Collection $categories) public function multiYear(CategoryRepositoryInterface $repository, $report_type, Carbon $start, Carbon $end, Collection $accounts, Collection $categories)
{ {
@ -248,6 +250,8 @@ class CategoryController extends Controller
* @param CategoryRepositoryInterface $repository * @param CategoryRepositoryInterface $repository
* @param Category $category * @param Category $category
* *
* @param $date
*
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function specificPeriod(CategoryRepositoryInterface $repository, Category $category, $date) public function specificPeriod(CategoryRepositoryInterface $repository, Category $category, $date)
@ -287,66 +291,6 @@ class CategoryController extends Controller
} }
/**
* This chart will only show expenses.
*
* @param CategoryRepositoryInterface $repository
* @param $report_type
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return \Illuminate\Http\JsonResponse
*/
public function spentInYear(CategoryRepositoryInterface $repository, $report_type, Carbon $start, Carbon $end, Collection $accounts)
{
$cache = new CacheProperties; // chart properties for cache:
$cache->addProperty($start);
$cache->addProperty($report_type);
$cache->addProperty($end);
$cache->addProperty($accounts);
$cache->addProperty('category');
$cache->addProperty('spent-in-year');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
$allCategories = $repository->getCategories();
$entries = new Collection;
$categories = $allCategories->filter(
function (Category $category) use ($repository, $start, $end, $accounts) {
$spent = $repository->balanceInPeriod($category, $start, $end, $accounts);
if ($spent < 0) {
return $category;
}
return null;
}
);
while ($start < $end) {
$month = clone $start; // month is the current end of the period
$month->endOfMonth();
$row = [clone $start]; // make a row:
foreach ($categories as $category) { // each budget, fill the row
$spent = $repository->balanceInPeriod($category, $start, $month, $accounts);
if ($spent < 0) {
$row[] = $spent * -1;
} else {
$row[] = 0;
}
}
$entries->push($row);
$start->addMonth();
}
$data = $this->generator->spentInYear($categories, $entries);
$cache->store($data);
return Response::json($data);
}
/** /**
* Returns a chart of what has been earned in this period in each category * Returns a chart of what has been earned in this period in each category
* grouped by month. * grouped by month.
@ -389,7 +333,7 @@ class CategoryController extends Controller
$categories = $categories->merge($set); $categories = $categories->merge($set);
// save the set combined with the data that is in it: // save the set combined with the data that is in it:
// for example: // for example:
// [december 2015, salary:1000, bonus:200] // december 2015, salary:1000, bonus:200
$sets->push([$currentStart, $set]); $sets->push([$currentStart, $set]);
$start->addMonth(); $start->addMonth();
} }

View File

@ -1,7 +1,6 @@
<?php namespace FireflyIII\Http\Controllers; <?php namespace FireflyIII\Http\Controllers;
use Auth; use Auth;
use Config;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;

View File

@ -146,6 +146,8 @@ class CsvController extends Controller
* *
* STEP ONE * STEP ONE
* *
* @param AccountRepositoryInterface $repository
*
* @return \Illuminate\View\View * @return \Illuminate\View\View
*/ */
public function index(AccountRepositoryInterface $repository) public function index(AccountRepositoryInterface $repository)

View File

@ -1,15 +1,12 @@
<?php namespace FireflyIII\Http\Controllers; <?php namespace FireflyIII\Http\Controllers;
use Artisan; use Artisan;
use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use Config; use Config;
use FireflyIII\Models\Tag; use FireflyIII\Models\Tag;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Input; use Input;
use Log;
use Preferences; use Preferences;
use Route;
use Session; use Session;
use Steam; use Steam;

View File

@ -3,15 +3,12 @@
use Amount; use Amount;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Helpers\Report\ReportQueryInterface; use FireflyIII\Helpers\Report\ReportQueryInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\Bill;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface; use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
use Preferences; use Preferences;
use Response; use Response;
use Session; use Session;
@ -65,102 +62,50 @@ class JsonController extends Controller
/** /**
* @param BillRepositoryInterface $repository * @param BillRepositoryInterface $repository
* *
* @param AccountRepositoryInterface $accountRepository
*
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function boxBillsPaid(BillRepositoryInterface $repository, AccountRepositoryInterface $accountRepository) public function boxBillsPaid(BillRepositoryInterface $repository)
{ {
$start = Session::get('start', Carbon::now()->startOfMonth()); $start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth());
bcscale(2); bcscale(2);
// works for json too! /*
$cache = new CacheProperties; * Since both this method and the chart use the exact same data, we can suffice
$cache->addProperty($start); * with calling the one method in the bill repository that will get this amount.
$cache->addProperty($end); */
$cache->addProperty('box-bills-paid'); $amount = $repository->getBillsPaidInRange($start, $end); // will be a negative amount.
if ($cache->has()) { $creditCardDue = $repository->getCreditCardBill($start, $end);
return Response::json($cache->get()); // @codeCoverageIgnore if ($creditCardDue >= 0) {
$amount = bcadd($amount, $creditCardDue);
} }
// get amount from bills $amount = $amount * -1;
$amount = $repository->billsPaidInRange($start, $end)->sum('paid');
// add credit card bill.
$creditCards = $accountRepository->getCreditCards($end); // Find credit card accounts and possibly unpaid credit card bills.
/** @var Account $creditCard */
foreach ($creditCards as $creditCard) {
if ($creditCard->balance == 0) {
// find a transfer TO the credit card which should account for
// anything paid. If not, the CC is not yet used.
$amount = bcadd($amount, $accountRepository->getTransfersInRange($creditCard, $start, $end)->sum('amount'));
}
}
$data = ['box' => 'bills-paid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; $data = ['box' => 'bills-paid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
$cache->store($data);
return Response::json($data); return Response::json($data);
} }
/** /**
* @param BillRepositoryInterface $repository * @param BillRepositoryInterface $repository
* @param AccountRepositoryInterface $accountRepository
* *
* @return \Symfony\Component\HttpFoundation\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function boxBillsUnpaid(BillRepositoryInterface $repository, AccountRepositoryInterface $accountRepository) public function boxBillsUnpaid(BillRepositoryInterface $repository)
{ {
$amount = 0; bcscale(2);
$start = Session::get('start', Carbon::now()->startOfMonth()); $start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth());
bcscale(2); $amount = $repository->getBillsUnpaidInRange($start, $end); // will be a positive amount.
$creditCardDue = $repository->getCreditCardBill($start, $end);
// works for json too! if ($creditCardDue < 0) {
$cache = new CacheProperties; // expenses are negative (bill not yet paid),
$cache->addProperty($start); $creditCardDue = bcmul($creditCardDue, '-1');
$cache->addProperty($end); $amount = bcadd($amount, $creditCardDue);
$cache->addProperty('box-bills-unpaid');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
$bills = $repository->getActiveBills();
$unpaid = new Collection; // bills
/** @var Bill $bill */
foreach ($bills as $bill) {
$ranges = $repository->getRanges($bill, $start, $end);
foreach ($ranges as $range) {
$journals = $repository->getJournalsInRange($bill, $range['start'], $range['end']);
if ($journals->count() == 0) {
$unpaid->push([$bill, $range['start']]);
}
}
}
unset($bill, $bills, $range, $ranges);
$creditCards = $accountRepository->getCreditCards($end);
/** @var Account $creditCard */
foreach ($creditCards as $creditCard) {
$date = new Carbon($creditCard->getMeta('ccMonthlyPaymentDate'));
if ($creditCard->balance < 0) {
// unpaid! create a fake bill that matches the amount.
$description = $creditCard->name;
$fakeAmount = $creditCard->balance * -1;
$fakeBill = $repository->createFakeBill($description, $date, $fakeAmount);
$unpaid->push([$fakeBill, $date]);
}
}
/** @var Bill $entry */
foreach ($unpaid as $entry) {
$current = bcdiv(bcadd($entry[0]->amount_max, $entry[0]->amount_min), 2);
$amount = bcadd($amount, $current);
} }
$data = ['box' => 'bills-unpaid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; $data = ['box' => 'bills-unpaid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
$cache->store($data);
return Response::json($data); return Response::json($data);
} }
@ -168,6 +113,8 @@ class JsonController extends Controller
/** /**
* @param ReportQueryInterface $reportQuery * @param ReportQueryInterface $reportQuery
* *
* @param AccountRepositoryInterface $accountRepository
*
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function boxIn(ReportQueryInterface $reportQuery, AccountRepositoryInterface $accountRepository) public function boxIn(ReportQueryInterface $reportQuery, AccountRepositoryInterface $accountRepository)
@ -195,6 +142,8 @@ class JsonController extends Controller
/** /**
* @param ReportQueryInterface $reportQuery * @param ReportQueryInterface $reportQuery
* *
* @param AccountRepositoryInterface $accountRepository
*
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function boxOut(ReportQueryInterface $reportQuery, AccountRepositoryInterface $accountRepository) public function boxOut(ReportQueryInterface $reportQuery, AccountRepositoryInterface $accountRepository)

View File

@ -64,9 +64,12 @@ class ReportController extends Controller
$accountList = join(',', $accountIds); $accountList = join(',', $accountIds);
return view('reports.index', compact('months', 'accounts', 'start', 'accountList', return view(
'reports.index', compact(
'months', 'accounts', 'start', 'accountList',
'startOfMonth', 'endOfMonth', 'startOfYear', 'endOfYear' 'startOfMonth', 'endOfMonth', 'startOfYear', 'endOfYear'
)); )
);
} }
/** /**
@ -154,6 +157,14 @@ class ReportController extends Controller
); );
} }
/**
* @param $report_type
* @param $start
* @param $end
* @param $accounts
*
* @return View
*/
public function defaultMultiYear($report_type, $start, $end, $accounts) public function defaultMultiYear($report_type, $start, $end, $accounts)
{ {
@ -212,7 +223,6 @@ class ReportController extends Controller
// more than one year date difference means year report. // more than one year date difference means year report.
if ($start->diffInMonths($end) > 12) { if ($start->diffInMonths($end) > 12) {
// return view('error')->with('message', 'No report yet for this time period.');
return $this->defaultMultiYear($report_type, $start, $end, $accounts); return $this->defaultMultiYear($report_type, $start, $end, $accounts);
} }
// more than two months date difference means year report. // more than two months date difference means year report.
@ -221,7 +231,6 @@ class ReportController extends Controller
} }
return $this->defaultMonth($report_type, $start, $end, $accounts); return $this->defaultMonth($report_type, $start, $end, $accounts);
break;
} }

View File

@ -10,11 +10,13 @@ use FireflyIII\Events\JournalSaved;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Requests\JournalFormRequest; use FireflyIII\Http\Requests\JournalFormRequest;
use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Support\Collection;
use Input; use Input;
use Preferences; use Preferences;
use Response; use Response;
@ -264,6 +266,15 @@ class TransactionController extends Controller
*/ */
public function show(JournalRepositoryInterface $repository, TransactionJournal $journal) public function show(JournalRepositoryInterface $repository, TransactionJournal $journal)
{ {
/** @var Collection $set */
$events = $journal->piggyBankEvents()->get();
$events->each(
function (PiggyBankEvent $event) {
$event->piggyBank = $event->piggyBank()->withTrashed()->first();
}
);
bcscale(2); bcscale(2);
$journal->transactions->each( $journal->transactions->each(
function (Transaction $t) use ($journal, $repository) { function (Transaction $t) use ($journal, $repository) {
@ -274,13 +285,15 @@ class TransactionController extends Controller
$what = strtolower($journal->getTransactionType()); $what = strtolower($journal->getTransactionType());
$subTitle = trans('firefly.' . $journal->getTransactionType()) . ' "' . e($journal->description) . '"'; $subTitle = trans('firefly.' . $journal->getTransactionType()) . ' "' . e($journal->description) . '"';
return view('transactions.show', compact('journal', 'subTitle', 'what')); return view('transactions.show', compact('journal','events', 'subTitle', 'what'));
} }
/** /**
* @param JournalFormRequest $request * @param JournalFormRequest $request
* @param JournalRepositoryInterface $repository * @param JournalRepositoryInterface $repository
* *
* @param AttachmentHelperInterface $att
*
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
*/ */
public function store(JournalFormRequest $request, JournalRepositoryInterface $repository, AttachmentHelperInterface $att) public function store(JournalFormRequest $request, JournalRepositoryInterface $repository, AttachmentHelperInterface $att)

View File

@ -4,7 +4,7 @@ use App;
use Auth; use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use Closure; use Closure;
use Config; use FireflyIII\User;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Preferences; use Preferences;
@ -46,6 +46,7 @@ class Authenticate
*/ */
public function handle(Request $request, Closure $next) public function handle(Request $request, Closure $next)
{ {
if ($this->auth->guest()) { if ($this->auth->guest()) {
if ($request->ajax()) { if ($request->ajax()) {
return response('Unauthorized.', 401); return response('Unauthorized.', 401);
@ -54,7 +55,7 @@ class Authenticate
} }
} }
if (intval($this->auth->user()->blocked) == 1) { if ($this->auth->user() instanceof User && intval($this->auth->user()->blocked) == 1) {
Auth::logout(); Auth::logout();
return redirect()->route('index'); return redirect()->route('index');

View File

@ -1,6 +1,6 @@
<?php <?php
use Carbon\Carbon; use Carbon\Carbon;
use DaveJamesMiller\Breadcrumbs\Generator; use DaveJamesMiller\Breadcrumbs\Generator as BreadCrumbGenerator;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Bill; use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
@ -16,7 +16,7 @@ use FireflyIII\Models\TransactionJournal;
*/ */
Breadcrumbs::register( Breadcrumbs::register(
'home', 'home',
function (Generator $breadcrumbs) { function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->push(trans('breadcrumbs.home'), route('index')); $breadcrumbs->push(trans('breadcrumbs.home'), route('index'));
} }
@ -24,7 +24,7 @@ Breadcrumbs::register(
Breadcrumbs::register( Breadcrumbs::register(
'index', 'index',
function (Generator $breadcrumbs) { function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->push(trans('breadcrumbs.home'), route('index')); $breadcrumbs->push(trans('breadcrumbs.home'), route('index'));
} }
@ -33,21 +33,21 @@ Breadcrumbs::register(
// accounts // accounts
Breadcrumbs::register( Breadcrumbs::register(
'accounts.index', function (Generator $breadcrumbs, $what) { 'accounts.index', function (BreadCrumbGenerator $breadcrumbs, $what) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('firefly.' . strtolower(e($what)) . '_accounts'), route('accounts.index', [$what])); $breadcrumbs->push(trans('firefly.' . strtolower(e($what)) . '_accounts'), route('accounts.index', [$what]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'accounts.create', function (Generator $breadcrumbs, $what) { 'accounts.create', function (BreadCrumbGenerator $breadcrumbs, $what) {
$breadcrumbs->parent('accounts.index', $what); $breadcrumbs->parent('accounts.index', $what);
$breadcrumbs->push(trans('firefly.new_' . strtolower(e($what)) . '_account'), route('accounts.create', [$what])); $breadcrumbs->push(trans('firefly.new_' . strtolower(e($what)) . '_account'), route('accounts.create', [$what]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'accounts.show', function (Generator $breadcrumbs, Account $account) { 'accounts.show', function (BreadCrumbGenerator $breadcrumbs, Account $account) {
$what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type); $what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type);
@ -57,7 +57,7 @@ Breadcrumbs::register(
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'accounts.delete', function (Generator $breadcrumbs, Account $account) { 'accounts.delete', function (BreadCrumbGenerator $breadcrumbs, Account $account) {
$breadcrumbs->parent('accounts.show', $account); $breadcrumbs->parent('accounts.show', $account);
$breadcrumbs->push(trans('firefly.delete_account', ['name' => e($account->name)]), route('accounts.delete', [$account->id])); $breadcrumbs->push(trans('firefly.delete_account', ['name' => e($account->name)]), route('accounts.delete', [$account->id]));
} }
@ -65,7 +65,7 @@ Breadcrumbs::register(
Breadcrumbs::register( Breadcrumbs::register(
'accounts.edit', function (Generator $breadcrumbs, Account $account) { 'accounts.edit', function (BreadCrumbGenerator $breadcrumbs, Account $account) {
$breadcrumbs->parent('accounts.show', $account); $breadcrumbs->parent('accounts.show', $account);
$what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type); $what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type);
@ -75,40 +75,40 @@ Breadcrumbs::register(
// budgets. // budgets.
Breadcrumbs::register( Breadcrumbs::register(
'budgets.index', function (Generator $breadcrumbs) { 'budgets.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('firefly.budgets'), route('budgets.index')); $breadcrumbs->push(trans('firefly.budgets'), route('budgets.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'budgets.create', function (Generator $breadcrumbs) { 'budgets.create', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('budgets.index'); $breadcrumbs->parent('budgets.index');
$breadcrumbs->push(trans('firefly.create_new_budget'), route('budgets.create')); $breadcrumbs->push(trans('firefly.create_new_budget'), route('budgets.create'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'budgets.edit', function (Generator $breadcrumbs, Budget $budget) { 'budgets.edit', function (BreadCrumbGenerator $breadcrumbs, Budget $budget) {
$breadcrumbs->parent('budgets.show', $budget); $breadcrumbs->parent('budgets.show', $budget);
$breadcrumbs->push(trans('firefly.edit_budget', ['name' => e($budget->name)]), route('budgets.edit', [$budget->id])); $breadcrumbs->push(trans('firefly.edit_budget', ['name' => e($budget->name)]), route('budgets.edit', [$budget->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'budgets.delete', function (Generator $breadcrumbs, Budget $budget) { 'budgets.delete', function (BreadCrumbGenerator $breadcrumbs, Budget $budget) {
$breadcrumbs->parent('budgets.show', $budget); $breadcrumbs->parent('budgets.show', $budget);
$breadcrumbs->push(trans('firefly.delete_budget', ['name' => e($budget->name)]), route('budgets.delete', [$budget->id])); $breadcrumbs->push(trans('firefly.delete_budget', ['name' => e($budget->name)]), route('budgets.delete', [$budget->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'budgets.noBudget', function (Generator $breadcrumbs, $subTitle) { 'budgets.noBudget', function (BreadCrumbGenerator $breadcrumbs, $subTitle) {
$breadcrumbs->parent('budgets.index'); $breadcrumbs->parent('budgets.index');
$breadcrumbs->push($subTitle, route('budgets.noBudget')); $breadcrumbs->push($subTitle, route('budgets.noBudget'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'budgets.show', function (Generator $breadcrumbs, Budget $budget, LimitRepetition $repetition = null) { 'budgets.show', function (BreadCrumbGenerator $breadcrumbs, Budget $budget, LimitRepetition $repetition = null) {
$breadcrumbs->parent('budgets.index'); $breadcrumbs->parent('budgets.index');
$breadcrumbs->push(e($budget->name), route('budgets.show', [$budget->id])); $breadcrumbs->push(e($budget->name), route('budgets.show', [$budget->id]));
if (!is_null($repetition) && !is_null($repetition->id)) { if (!is_null($repetition) && !is_null($repetition->id)) {
@ -121,33 +121,33 @@ Breadcrumbs::register(
// categories // categories
Breadcrumbs::register( Breadcrumbs::register(
'categories.index', function (Generator $breadcrumbs) { 'categories.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('firefly.categories'), route('categories.index')); $breadcrumbs->push(trans('firefly.categories'), route('categories.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'categories.create', function (Generator $breadcrumbs) { 'categories.create', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('categories.index'); $breadcrumbs->parent('categories.index');
$breadcrumbs->push(trans('firefly.new_category'), route('categories.create')); $breadcrumbs->push(trans('firefly.new_category'), route('categories.create'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'categories.edit', function (Generator $breadcrumbs, Category $category) { 'categories.edit', function (BreadCrumbGenerator $breadcrumbs, Category $category) {
$breadcrumbs->parent('categories.show', $category); $breadcrumbs->parent('categories.show', $category);
$breadcrumbs->push(trans('firefly.edit_category', ['name' => e($category->name)]), route('categories.edit', [$category->id])); $breadcrumbs->push(trans('firefly.edit_category', ['name' => e($category->name)]), route('categories.edit', [$category->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'categories.delete', function (Generator $breadcrumbs, Category $category) { 'categories.delete', function (BreadCrumbGenerator $breadcrumbs, Category $category) {
$breadcrumbs->parent('categories.show', $category); $breadcrumbs->parent('categories.show', $category);
$breadcrumbs->push(trans('firefly.delete_category', ['name' => e($category->name)]), route('categories.delete', [$category->id])); $breadcrumbs->push(trans('firefly.delete_category', ['name' => e($category->name)]), route('categories.delete', [$category->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'categories.show', function (Generator $breadcrumbs, Category $category) { 'categories.show', function (BreadCrumbGenerator $breadcrumbs, Category $category) {
$breadcrumbs->parent('categories.index'); $breadcrumbs->parent('categories.index');
$breadcrumbs->push(e($category->name), route('categories.show', [$category->id])); $breadcrumbs->push(e($category->name), route('categories.show', [$category->id]));
@ -155,7 +155,7 @@ Breadcrumbs::register(
); );
Breadcrumbs::register( Breadcrumbs::register(
'categories.show.date', function (Generator $breadcrumbs, Category $category, Carbon $date) { 'categories.show.date', function (BreadCrumbGenerator $breadcrumbs, Category $category, Carbon $date) {
// get current period preference. // get current period preference.
$range = Preferences::get('viewRange', '1M')->data; $range = Preferences::get('viewRange', '1M')->data;
@ -168,7 +168,7 @@ Breadcrumbs::register(
); );
Breadcrumbs::register( Breadcrumbs::register(
'categories.noCategory', function (Generator $breadcrumbs, $subTitle) { 'categories.noCategory', function (BreadCrumbGenerator $breadcrumbs, $subTitle) {
$breadcrumbs->parent('categories.index'); $breadcrumbs->parent('categories.index');
$breadcrumbs->push($subTitle, route('categories.noCategory')); $breadcrumbs->push($subTitle, route('categories.noCategory'));
} }
@ -176,35 +176,35 @@ Breadcrumbs::register(
// CSV: // CSV:
Breadcrumbs::register( Breadcrumbs::register(
'csv.index', function (Generator $breadcrumbs) { 'csv.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('firefly.csv_index_title'), route('csv.index')); $breadcrumbs->push(trans('firefly.csv_index_title'), route('csv.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'csv.column-roles', function (Generator $breadcrumbs) { 'csv.column-roles', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('csv.index'); $breadcrumbs->parent('csv.index');
$breadcrumbs->push(trans('firefly.csv_define_column_roles'), route('csv.column-roles')); $breadcrumbs->push(trans('firefly.csv_define_column_roles'), route('csv.column-roles'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'csv.map', function (Generator $breadcrumbs) { 'csv.map', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('csv.index'); $breadcrumbs->parent('csv.index');
$breadcrumbs->push(trans('firefly.csv_map_values'), route('csv.map')); $breadcrumbs->push(trans('firefly.csv_map_values'), route('csv.map'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'csv.download-config-page', function (Generator $breadcrumbs) { 'csv.download-config-page', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('csv.index'); $breadcrumbs->parent('csv.index');
$breadcrumbs->push(trans('firefly.csv_download_config'), route('csv.download-config-page')); $breadcrumbs->push(trans('firefly.csv_download_config'), route('csv.download-config-page'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'csv.process', function (Generator $breadcrumbs) { 'csv.process', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('csv.index'); $breadcrumbs->parent('csv.index');
$breadcrumbs->push(trans('firefly.csv_process_title'), route('csv.process')); $breadcrumbs->push(trans('firefly.csv_process_title'), route('csv.process'));
} }
@ -213,27 +213,27 @@ Breadcrumbs::register(
// currencies. // currencies.
Breadcrumbs::register( Breadcrumbs::register(
'currency.index', function (Generator $breadcrumbs) { 'currency.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('firefly.currencies'), route('currency.index')); $breadcrumbs->push(trans('firefly.currencies'), route('currency.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'currency.create', function (Generator $breadcrumbs) { 'currency.create', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('currency.index'); $breadcrumbs->parent('currency.index');
$breadcrumbs->push(trans('firefly.create_currency'), route('currency.create')); $breadcrumbs->push(trans('firefly.create_currency'), route('currency.create'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'currency.edit', function (Generator $breadcrumbs, TransactionCurrency $currency) { 'currency.edit', function (BreadCrumbGenerator $breadcrumbs, TransactionCurrency $currency) {
$breadcrumbs->parent('currency.index'); $breadcrumbs->parent('currency.index');
$breadcrumbs->push(trans('breadcrumbs.edit_currency', ['name' => e($currency->name)]), route('currency.edit', [$currency->id])); $breadcrumbs->push(trans('breadcrumbs.edit_currency', ['name' => e($currency->name)]), route('currency.edit', [$currency->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'currency.delete', function (Generator $breadcrumbs, TransactionCurrency $currency) { 'currency.delete', function (BreadCrumbGenerator $breadcrumbs, TransactionCurrency $currency) {
$breadcrumbs->parent('currency.index'); $breadcrumbs->parent('currency.index');
$breadcrumbs->push(trans('breadcrumbs.delete_currency', ['name' => e($currency->name)]), route('currency.delete', [$currency->id])); $breadcrumbs->push(trans('breadcrumbs.delete_currency', ['name' => e($currency->name)]), route('currency.delete', [$currency->id]));
} }
@ -242,33 +242,33 @@ Breadcrumbs::register(
// piggy banks // piggy banks
Breadcrumbs::register( Breadcrumbs::register(
'piggy-banks.index', function (Generator $breadcrumbs) { 'piggy-banks.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('firefly.piggyBanks'), route('piggy-banks.index')); $breadcrumbs->push(trans('firefly.piggyBanks'), route('piggy-banks.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'piggy-banks.create', function (Generator $breadcrumbs) { 'piggy-banks.create', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('piggy-banks.index'); $breadcrumbs->parent('piggy-banks.index');
$breadcrumbs->push(trans('breadcrumbs.newPiggyBank'), route('piggy-banks.create')); $breadcrumbs->push(trans('breadcrumbs.newPiggyBank'), route('piggy-banks.create'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'piggy-banks.edit', function (Generator $breadcrumbs, PiggyBank $piggyBank) { 'piggy-banks.edit', function (BreadCrumbGenerator $breadcrumbs, PiggyBank $piggyBank) {
$breadcrumbs->parent('piggy-banks.show', $piggyBank); $breadcrumbs->parent('piggy-banks.show', $piggyBank);
$breadcrumbs->push(trans('breadcrumbs.edit_piggyBank', ['name' => e($piggyBank->name)]), route('piggy-banks.edit', [$piggyBank->id])); $breadcrumbs->push(trans('breadcrumbs.edit_piggyBank', ['name' => e($piggyBank->name)]), route('piggy-banks.edit', [$piggyBank->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'piggy-banks.delete', function (Generator $breadcrumbs, PiggyBank $piggyBank) { 'piggy-banks.delete', function (BreadCrumbGenerator $breadcrumbs, PiggyBank $piggyBank) {
$breadcrumbs->parent('piggy-banks.show', $piggyBank); $breadcrumbs->parent('piggy-banks.show', $piggyBank);
$breadcrumbs->push(trans('firefly.delete_piggy_bank', ['name' => e($piggyBank->name)]), route('piggy-banks.delete', [$piggyBank->id])); $breadcrumbs->push(trans('firefly.delete_piggy_bank', ['name' => e($piggyBank->name)]), route('piggy-banks.delete', [$piggyBank->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'piggy-banks.show', function (Generator $breadcrumbs, PiggyBank $piggyBank) { 'piggy-banks.show', function (BreadCrumbGenerator $breadcrumbs, PiggyBank $piggyBank) {
$breadcrumbs->parent('piggy-banks.index'); $breadcrumbs->parent('piggy-banks.index');
$breadcrumbs->push(e($piggyBank->name), route('piggy-banks.show', [$piggyBank->id])); $breadcrumbs->push(e($piggyBank->name), route('piggy-banks.show', [$piggyBank->id]));
@ -277,7 +277,7 @@ Breadcrumbs::register(
// preferences // preferences
Breadcrumbs::register( Breadcrumbs::register(
'preferences', function (Generator $breadcrumbs) { 'preferences', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.preferences'), route('preferences')); $breadcrumbs->push(trans('breadcrumbs.preferences'), route('preferences'));
@ -286,21 +286,21 @@ Breadcrumbs::register(
// profile // profile
Breadcrumbs::register( Breadcrumbs::register(
'profile', function (Generator $breadcrumbs) { 'profile', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.profile'), route('profile')); $breadcrumbs->push(trans('breadcrumbs.profile'), route('profile'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'profile.change-password', function (Generator $breadcrumbs) { 'profile.change-password', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('profile'); $breadcrumbs->parent('profile');
$breadcrumbs->push(trans('breadcrumbs.changePassword'), route('profile.change-password')); $breadcrumbs->push(trans('breadcrumbs.changePassword'), route('profile.change-password'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'profile.delete-account', function (Generator $breadcrumbs) { 'profile.delete-account', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('profile'); $breadcrumbs->parent('profile');
$breadcrumbs->push(trans('firefly.delete_account'), route('profile.delete-account')); $breadcrumbs->push(trans('firefly.delete_account'), route('profile.delete-account'));
@ -309,33 +309,33 @@ Breadcrumbs::register(
// bills // bills
Breadcrumbs::register( Breadcrumbs::register(
'bills.index', function (Generator $breadcrumbs) { 'bills.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.bills'), route('bills.index')); $breadcrumbs->push(trans('breadcrumbs.bills'), route('bills.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'bills.create', function (Generator $breadcrumbs) { 'bills.create', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('bills.index'); $breadcrumbs->parent('bills.index');
$breadcrumbs->push(trans('breadcrumbs.newBill'), route('bills.create')); $breadcrumbs->push(trans('breadcrumbs.newBill'), route('bills.create'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'bills.edit', function (Generator $breadcrumbs, Bill $bill) { 'bills.edit', function (BreadCrumbGenerator $breadcrumbs, Bill $bill) {
$breadcrumbs->parent('bills.show', $bill); $breadcrumbs->parent('bills.show', $bill);
$breadcrumbs->push(trans('breadcrumbs.edit_bill', ['name' => e($bill->name)]), route('bills.edit', [$bill->id])); $breadcrumbs->push(trans('breadcrumbs.edit_bill', ['name' => e($bill->name)]), route('bills.edit', [$bill->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'bills.delete', function (Generator $breadcrumbs, Bill $bill) { 'bills.delete', function (BreadCrumbGenerator $breadcrumbs, Bill $bill) {
$breadcrumbs->parent('bills.show', $bill); $breadcrumbs->parent('bills.show', $bill);
$breadcrumbs->push(trans('breadcrumbs.delete_bill', ['name' => e($bill->name)]), route('bills.delete', [$bill->id])); $breadcrumbs->push(trans('breadcrumbs.delete_bill', ['name' => e($bill->name)]), route('bills.delete', [$bill->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'bills.show', function (Generator $breadcrumbs, Bill $bill) { 'bills.show', function (BreadCrumbGenerator $breadcrumbs, Bill $bill) {
$breadcrumbs->parent('bills.index'); $breadcrumbs->parent('bills.index');
$breadcrumbs->push(e($bill->name), route('bills.show', [$bill->id])); $breadcrumbs->push(e($bill->name), route('bills.show', [$bill->id]));
@ -344,14 +344,14 @@ Breadcrumbs::register(
// reports // reports
Breadcrumbs::register( Breadcrumbs::register(
'reports.index', function (Generator $breadcrumbs) { 'reports.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.reports'), route('reports.index')); $breadcrumbs->push(trans('breadcrumbs.reports'), route('reports.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'reports.report', function (Generator $breadcrumbs, Carbon $start, Carbon $end, $reportType, $accountIds) { 'reports.report', function (BreadCrumbGenerator $breadcrumbs, Carbon $start, Carbon $end, $reportType, $accountIds) {
$breadcrumbs->parent('reports.index'); $breadcrumbs->parent('reports.index');
$monthFormat = trans('config.month_and_day'); $monthFormat = trans('config.month_and_day');
@ -363,7 +363,7 @@ Breadcrumbs::register(
// search // search
Breadcrumbs::register( Breadcrumbs::register(
'search', function (Generator $breadcrumbs, $query) { 'search', function (BreadCrumbGenerator $breadcrumbs, $query) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.searchResult', ['query' => e($query)]), route('search')); $breadcrumbs->push(trans('breadcrumbs.searchResult', ['query' => e($query)]), route('search'));
} }
@ -371,33 +371,33 @@ Breadcrumbs::register(
// transactions // transactions
Breadcrumbs::register( Breadcrumbs::register(
'transactions.index', function (Generator $breadcrumbs, $what) { 'transactions.index', function (BreadCrumbGenerator $breadcrumbs, $what) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.' . $what . '_list'), route('transactions.index', [$what])); $breadcrumbs->push(trans('breadcrumbs.' . $what . '_list'), route('transactions.index', [$what]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'transactions.create', function (Generator $breadcrumbs, $what) { 'transactions.create', function (BreadCrumbGenerator $breadcrumbs, $what) {
$breadcrumbs->parent('transactions.index', $what); $breadcrumbs->parent('transactions.index', $what);
$breadcrumbs->push(trans('breadcrumbs.create_' . e($what)), route('transactions.create', [$what])); $breadcrumbs->push(trans('breadcrumbs.create_' . e($what)), route('transactions.create', [$what]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'transactions.edit', function (Generator $breadcrumbs, TransactionJournal $journal) { 'transactions.edit', function (BreadCrumbGenerator $breadcrumbs, TransactionJournal $journal) {
$breadcrumbs->parent('transactions.show', $journal); $breadcrumbs->parent('transactions.show', $journal);
$breadcrumbs->push(trans('breadcrumbs.edit_journal', ['description' => $journal->description]), route('transactions.edit', [$journal->id])); $breadcrumbs->push(trans('breadcrumbs.edit_journal', ['description' => $journal->description]), route('transactions.edit', [$journal->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'transactions.delete', function (Generator $breadcrumbs, TransactionJournal $journal) { 'transactions.delete', function (BreadCrumbGenerator $breadcrumbs, TransactionJournal $journal) {
$breadcrumbs->parent('transactions.show', $journal); $breadcrumbs->parent('transactions.show', $journal);
$breadcrumbs->push(trans('breadcrumbs.delete_journal', ['description' => e($journal->description)]), route('transactions.delete', [$journal->id])); $breadcrumbs->push(trans('breadcrumbs.delete_journal', ['description' => e($journal->description)]), route('transactions.delete', [$journal->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'transactions.show', function (Generator $breadcrumbs, TransactionJournal $journal) { 'transactions.show', function (BreadCrumbGenerator $breadcrumbs, TransactionJournal $journal) {
$breadcrumbs->parent('transactions.index', strtolower($journal->getTransactionType())); $breadcrumbs->parent('transactions.index', strtolower($journal->getTransactionType()));
$breadcrumbs->push($journal->description, route('transactions.show', [$journal->id])); $breadcrumbs->push($journal->description, route('transactions.show', [$journal->id]));
@ -407,28 +407,28 @@ Breadcrumbs::register(
// tags // tags
Breadcrumbs::register( Breadcrumbs::register(
'tags.index', function (Generator $breadcrumbs) { 'tags.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.tags'), route('tags.index')); $breadcrumbs->push(trans('breadcrumbs.tags'), route('tags.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'tags.create', function (Generator $breadcrumbs) { 'tags.create', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('tags.index'); $breadcrumbs->parent('tags.index');
$breadcrumbs->push(trans('breadcrumbs.createTag'), route('tags.create')); $breadcrumbs->push(trans('breadcrumbs.createTag'), route('tags.create'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'tags.edit', function (Generator $breadcrumbs, Tag $tag) { 'tags.edit', function (BreadCrumbGenerator $breadcrumbs, Tag $tag) {
$breadcrumbs->parent('tags.show', $tag); $breadcrumbs->parent('tags.show', $tag);
$breadcrumbs->push(trans('breadcrumbs.edit_tag', ['tag' => e($tag->tag)]), route('tags.edit', [$tag->id])); $breadcrumbs->push(trans('breadcrumbs.edit_tag', ['tag' => e($tag->tag)]), route('tags.edit', [$tag->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'tags.delete', function (Generator $breadcrumbs, Tag $tag) { 'tags.delete', function (BreadCrumbGenerator $breadcrumbs, Tag $tag) {
$breadcrumbs->parent('tags.show', $tag); $breadcrumbs->parent('tags.show', $tag);
$breadcrumbs->push(trans('breadcrumbs.delete_tag', ['tag' => e($tag->tag)]), route('tags.delete', [$tag->id])); $breadcrumbs->push(trans('breadcrumbs.delete_tag', ['tag' => e($tag->tag)]), route('tags.delete', [$tag->id]));
} }
@ -436,7 +436,7 @@ Breadcrumbs::register(
Breadcrumbs::register( Breadcrumbs::register(
'tags.show', function (Generator $breadcrumbs, Tag $tag) { 'tags.show', function (BreadCrumbGenerator $breadcrumbs, Tag $tag) {
$breadcrumbs->parent('tags.index'); $breadcrumbs->parent('tags.index');
$breadcrumbs->push(e($tag->tag), route('tags.show', [$tag->id])); $breadcrumbs->push(e($tag->tag), route('tags.show', [$tag->id]));
} }

View File

@ -30,7 +30,7 @@ Route::bind(
throw new NotFoundHttpException; throw new NotFoundHttpException;
} }
); );
// account list! Yay! // accounts
Route::bind( Route::bind(
'accountList', 'accountList',
function ($value) { function ($value) {

View File

@ -41,6 +41,7 @@ use Illuminate\Database\Eloquent\Model;
* @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
* @property-read string $expectedAmount
*/ */
class Bill extends Model class Bill extends Model
{ {

View File

@ -78,7 +78,7 @@ class Budget extends Model
*/ */
public function getDates() public function getDates()
{ {
return ['created_at', 'updated_at', 'deleted_at']; return ['created_at', 'updated_at', 'deleted_at', 'startdate', 'enddate'];
} }
/** /**

View File

@ -13,7 +13,7 @@ use Illuminate\Database\Eloquent\Model;
* @property integer $transaction_journal_id * @property integer $transaction_journal_id
* @property \Carbon\Carbon $date * @property \Carbon\Carbon $date
* @property float $amount * @property float $amount
* @property-read \FireflyIII\Models\PiggyBank $piggyBank * @property \FireflyIII\Models\PiggyBank $piggyBank
* @property-read \FireflyIII\Models\TransactionJournal $transactionJournal * @property-read \FireflyIII\Models\TransactionJournal $transactionJournal
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankEvent whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankEvent whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankEvent whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankEvent whereCreatedAt($value)

View File

@ -16,7 +16,6 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Query\Builder;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
@ -118,7 +117,13 @@ class AccountRepository implements AccountRepositoryInterface
*/ */
public function getCreditCards(Carbon $date) public function getCreditCards(Carbon $date)
{ {
return Auth::user()->accounts() $cache = new CacheProperties();
$cache->addProperty('user-credit-cards');
if ($cache->has()) {
return $cache->get();
}
$set = Auth::user()->accounts()
->hasMetaValue('accountRole', 'ccAsset') ->hasMetaValue('accountRole', 'ccAsset')
->hasMetaValue('ccType', 'monthlyFull') ->hasMetaValue('ccType', 'monthlyFull')
->leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id') ->leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
@ -134,6 +139,9 @@ class AccountRepository implements AccountRepositoryInterface
DB::Raw('SUM(`transactions`.`amount`) AS `balance`') DB::Raw('SUM(`transactions`.`amount`) AS `balance`')
] ]
); );
$cache->store($set);
return $set;
} }
/** /**
@ -353,36 +361,6 @@ class AccountRepository implements AccountRepositoryInterface
return $accounts; return $accounts;
} }
/**
* Get all transfers TO this account in this range.
*
* @param Account $account
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function getTransfersInRange(Account $account, Carbon $start, Carbon $end)
{
$set = TransactionJournal::whereIn(
'id', function (Builder $q) use ($account, $start, $end) {
$q->select('transaction_journals.id')
->from('transactions')
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->where('transactions.account_id', $account->id)
->where('transactions.amount', '>', 0)// this makes the filter unnecessary.
->where('transaction_journals.user_id', Auth::user()->id)
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->where('transaction_types.type', TransactionType::TRANSFER);
}
)->get();
return $set;
}
/** /**
* @param Account $account * @param Account $account
* @param Carbon $date * @param Carbon $date

View File

@ -76,18 +76,6 @@ interface AccountRepositoryInterface
*/ */
public function getPiggyBankAccounts(); public function getPiggyBankAccounts();
/**
* Get all transfers TO this account in this range.
*
* @param Account $account
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function getTransfersInRange(Account $account, Carbon $start, Carbon $end);
/** /**
* @param Preference $preference * @param Preference $preference
* *

View File

@ -9,11 +9,14 @@ use FireflyIII\Models\Account;
use FireflyIII\Models\Bill; use FireflyIII\Models\Bill;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\JoinClause; use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
use Navigation; use Navigation;
use Steam;
/** /**
* Class BillRepository * Class BillRepository
@ -22,53 +25,6 @@ use Steam;
*/ */
class BillRepository implements BillRepositoryInterface class BillRepository implements BillRepositoryInterface
{ {
/**
* @deprecated
* Returns the sum of all payments connected to this bill between the dates.
*
* @param Bill $bill
* @param Carbon $start
* @param Carbon $end
*
* @return integer
*/
public function billPaymentsInRange(Bill $bill, Carbon $start, Carbon $end)
{
$amount = 0;
$journals = $bill->transactionjournals()->before($end)->after($start)->get();
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
$amount += $journal->amount;
}
return $amount;
}
/**
* Create a fake bill to help the chart controller.
*
* @param string $description
* @param Carbon $date
* @param float $amount
*
* @return Bill
*/
public function createFakeBill($description, Carbon $date, $amount)
{
$bill = new Bill;
$bill->name = $description;
$bill->match = $description;
$bill->amount_min = $amount;
$bill->amount_max = $amount;
$bill->date = $date;
$bill->repeat_freq = 'monthly';
$bill->skip = 0;
$bill->automatch = false;
$bill->active = false;
return $bill;
}
/** /**
* @param Bill $bill * @param Bill $bill
@ -80,16 +36,6 @@ class BillRepository implements BillRepositoryInterface
return $bill->delete(); return $bill->delete();
} }
/**
* @return Collection
*/
public function getActiveBills()
{
/** @var Collection $set */
$set = Auth::user()->bills()->where('active', 1)->get()->sortBy('name');
return $set;
}
/** /**
* @return Collection * @return Collection
@ -130,7 +76,7 @@ class BillRepository implements BillRepositoryInterface
$set = $set->filter( $set = $set->filter(
function (Bill $bill) use ($ids) { function (Bill $bill) use ($ids) {
// get transaction journals from or to any of the mentioned accounts. // get transaction journals from or to any of the mentioned accounts.
// if zero, return null. // when zero, return null.
$journals = $bill->transactionjournals()->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') $journals = $bill->transactionjournals()->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->whereIn('transactions.account_id', $ids)->count(); ->whereIn('transactions.account_id', $ids)->count();
@ -152,22 +98,43 @@ class BillRepository implements BillRepositoryInterface
} }
/** /**
* This method also returns the amount of the journal in "journalAmount"
* for easy access.
*
* @param Bill $bill * @param Bill $bill
* *
* @return Collection * @return Collection
*/ */
public function getJournals(Bill $bill) public function getJournals(Bill $bill)
{ {
return $bill->transactionjournals()->withRelevantData() $cache = new CacheProperties;
$cache->addProperty($bill->id);
$cache->addProperty('journals-for-bill');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$set = $bill->transactionjournals()
->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('amount', '<', 0);
}
)
->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.*', 'transactions.amount as journalAmount']);
$cache->store($set);
return $set;
} }
/** /**
* Get all journals that were recorded on this bill between these dates. * Get all journals that were recorded on this bill between these dates.
* *
* @deprecated
*
* @param Bill $bill * @param Bill $bill
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
@ -448,109 +415,166 @@ class BillRepository implements BillRepositoryInterface
} }
/** /**
* Gets a collection of paid bills and a collection of unpaid bills to be used * Get the total amount of money paid for the users active bills in the date range given.
* in the pie chart on the front page. * This amount will be negative (they're expenses).
* *
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* *
* @return Collection * @return string
*/ */
public function getBillsForChart(Carbon $start, Carbon $end) public function getBillsPaidInRange(Carbon $start, Carbon $end)
{ {
$paid = new Collection; $cache = new CacheProperties;
$unpaid = new Collection; $cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('bills-paid-in-range');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$amount = '0';
$bills = $this->getActiveBills(); $bills = $this->getActiveBills();
/** @var Bill $bill */ /** @var Bill $bill */
foreach ($bills as $bill) { foreach ($bills as $bill) {
$ranges = $this->getRanges($bill, $start, $end); $ranges = $this->getRanges($bill, $start, $end);
foreach ($ranges as $range) { foreach ($ranges as $range) {
// paid a bill in this range? $paid = $bill->transactionjournals()
$journals = $this->getJournalsInRange($bill, $range['start'], $range['end']); ->before($range['end'])
if ($journals->count() == 0) { ->after($range['start'])
$unpaid->push([$bill, $range['start']]); ->leftJoin(
} else { 'transactions', function (JoinClause $join) {
$paid = $paid->merge($journals); $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '<', 0);
} }
)
->first([DB::Raw('SUM(`transactions`.`amount`) as `sum_amount`')]);
$amount = bcadd($amount, $paid->sum_amount);
}
}
$cache->store($amount);
} return $amount;
}
$set = new Collection;
$set->put('paid', $paid);
$set->put('unpaid', $unpaid);
return $set;
} }
/** /**
* Takes the paid/unpaid bills collection set up before and expands it using
* credit cards the user might have.
*
* @param Collection $set
* @param Carbon $start
* @param Carbon $end
*
* @return Collection * @return Collection
*/ */
public function getCreditCardInfoForChart(Collection $set, Carbon $start, Carbon $end) public function getActiveBills()
{
$accounts = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$creditCards = $accounts->getCreditCards($end);
$paid = $set->get('paid');
$unpaid = $set->get('unpaid');
foreach ($creditCards as $creditCard) {
$date = new Carbon($creditCard->getMeta('ccMonthlyPaymentDate'));
if ($creditCard->balance < 0) {
// unpaid! create a fake bill that matches the amount.
$description = $creditCard->name;
$amount = $creditCard->balance * -1;
$fakeBill = $this->createFakeBill($description, $date, $amount);
unset($description, $amount);
$unpaid->push([$fakeBill, $date]);
}
if ($creditCard->balance == 0) {
// find transfer(s) TO the credit card which should account for
// anything paid. If not, the CC is not yet used.
$journals = $accounts->getTransfersInRange($creditCard, $start, $end);
$paid = $paid->merge($journals);
}
}
$set = new Collection;
$set->put('paid', $paid);
$set->put('unpaid', $unpaid);
return $set;
}
/**
* This method returns all active bills which have been paid for in the given range,
* with the field "paid" indicating how much the bill was for.
*
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function billsPaidInRange(Carbon $start, Carbon $end)
{ {
/** @var Collection $set */
$set = Auth::user()->bills() $set = Auth::user()->bills()
->leftJoin('transaction_journals', 'transaction_journals.bill_id', '=', 'bills.id') ->where('active', 1)
->get(
[
'bills.*',
DB::Raw('(`bills`.`amount_min` + `bills`.`amount_max` / 2) as `expectedAmount`')
]
)->sortBy('name');
return $set;
}
/**
* Get the total amount of money due for the users active bills in the date range given. This amount will be positive.
*
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
public function getBillsUnpaidInRange(Carbon $start, Carbon $end)
{
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('bills-unpaid-in-range');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$amount = '0';
$bills = $this->getActiveBills();
/** @var Bill $bill */
foreach ($bills as $bill) {
$ranges = $this->getRanges($bill, $start, $end);
$paidBill = '0';
foreach ($ranges as $range) {
$paid = $bill->transactionjournals()
->before($range['end'])
->after($range['start'])
->leftJoin( ->leftJoin(
'transactions', function (JoinClause $join) { 'transactions', function (JoinClause $join) {
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '>', 0); $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '>', 0);
} }
) )
->first([DB::Raw('SUM(`transactions`.`amount`) as `sum_amount`')]);
$paidBill = bcadd($paid->sum_amount, $paidBill);
}
if ($paidBill == 0) {
$amount = bcadd($amount, $bill->expectedAmount);
}
}
$cache->store($amount);
return $amount;
}
/**
* This method will tell you if you still have a CC bill to pay. Amount will be positive if the amount
* has been paid, otherwise it will be negative.
*
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
public function getCreditCardBill(Carbon $start, Carbon $end)
{
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('credit-card-bill');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
/** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$amount = '0';
$creditCards = $accountRepository->getCreditCards($end); // Find credit card accounts and possibly unpaid credit card bills.
/** @var Account $creditCard */
foreach ($creditCards as $creditCard) {
if ($creditCard->balance == 0) {
// find a transfer TO the credit card which should account for
// anything paid. If not, the CC is not yet used.
$set = TransactionJournal::whereIn(
'transaction_journals.id', function (Builder $q) use ($creditCard, $start, $end) {
$q->select('transaction_journals.id')
->from('transactions')
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->where('transactions.account_id', $creditCard->id)
->where('transactions.amount', '>', 0)// this makes the filter unnecessary.
->where('transaction_journals.user_id', Auth::user()->id)
->where('transaction_journals.date', '>=', $start->format('Y-m-d')) ->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d')) ->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->where('bills.active', 1) ->where('transaction_types.type', TransactionType::TRANSFER);
->groupBy('bills.id')->get( }
['bills.*', DB::Raw('SUM(`transactions`.`amount`) as `paid`')] )->leftJoin(
); 'transactions', function (JoinClause $join) {
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '>', 0);
}
)->first([DB::Raw('SUM(`transactions`.`amount`) as `sum_amount`')]);
$amount = bcadd($amount, $set->sum_amount);
} else {
$amount = bcadd($amount, $creditCard->balance);
}
}
return $amount;
return $set;
} }
} }

View File

@ -16,61 +16,41 @@ interface BillRepositoryInterface
{ {
/** /**
* Takes the paid/unpaid bills collection set up before and expands it using * This method will tell you if you still have a CC bill to pay. Amount will be negative if the amount
* credit cards the user might have. * has been paid
* *
* @param Collection $set
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* *
* @return string
*/
public function getCreditCardBill(Carbon $start, Carbon $end);
/**
* Get the total amount of money paid for the users active bills in the date range given.
*
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
public function getBillsPaidInRange(Carbon $start, Carbon $end);
/**
* Get the total amount of money due for the users active bills in the date range given.
*
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
public function getBillsUnpaidInRange(Carbon $start, Carbon $end);
/**
* @return Collection * @return Collection
*/ */
public function getCreditCardInfoForChart(Collection $set, Carbon $start, Carbon $end); public function getActiveBills();
/**
* Gets a collection of paid bills and a collection of unpaid bills to be used
* in the pie chart on the front page.
*
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function getBillsForChart(Carbon $start, Carbon $end);
/**
* @deprecated
* Returns the sum of all payments connected to this bill between the dates.
*
* @param Bill $bill
* @param Carbon $start
* @param Carbon $end
*
* @return float
*/
public function billPaymentsInRange(Bill $bill, Carbon $start, Carbon $end);
/**
* This method returns all active bills which have been paid for in the given range,
* with the field "paid" indicating how much the bill was for.
*
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function billsPaidInRange(Carbon $start, Carbon $end);
/**
* Create a fake bill to help the chart controller.
*
* @param string $description
* @param Carbon $date
* @param float $amount
*
* @return Bill
*/
public function createFakeBill($description, Carbon $date, $amount);
/** /**
* @param Bill $bill * @param Bill $bill
@ -79,11 +59,6 @@ interface BillRepositoryInterface
*/ */
public function destroy(Bill $bill); public function destroy(Bill $bill);
/**
* @return Collection
*/
public function getActiveBills();
/** /**
* @return Collection * @return Collection
*/ */
@ -126,7 +101,7 @@ interface BillRepositoryInterface
/** /**
* Every bill repeats itself weekly, monthly or yearly (or whatever). This method takes a date-range (usually the view-range of Firefly itself) * Every bill repeats itself weekly, monthly or yearly (or whatever). This method takes a date-range (usually the view-range of Firefly itself)
* 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 * 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. * you give 1st and the 31st of that month as argument, you'll get one response, matching the range of your bill (from the 14th to the 31th).
* *
* @param Bill $bill * @param Bill $bill
* @param Carbon $start * @param Carbon $start

View File

@ -4,13 +4,16 @@ namespace FireflyIII\Repositories\Budget;
use Auth; use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use DB;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\LimitRepetition; use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Shared\ComponentRepository; use FireflyIII\Repositories\Shared\ComponentRepository;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Input; use Input;
@ -76,6 +79,50 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
return $set; return $set;
} }
/**
* Returns a list of budgets, budget limits and limit repetitions
* (doubling any of them in a left join)
*
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function getBudgetsAndLimitsInRange(Carbon $start, Carbon $end)
{
/** @var Collection $set */
$set = Auth::user()
->budgets()
->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budgets.id')
->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
->where(
function (Builder $query) use ($start, $end) {
$query->where(
function (Builder $query) use ($start, $end) {
$query->where('limit_repetitions.startdate', '>=', $start->format('Y-m-d'));
$query->where('limit_repetitions.startdate', '<=', $end->format('Y-m-d'));
}
);
$query->orWhere(
function (Builder $query) {
$query->whereNull('limit_repetitions.startdate');
$query->whereNull('limit_repetitions.enddate');
}
);
}
)
->get(['budgets.*', 'limit_repetitions.startdate', 'limit_repetitions.enddate', 'limit_repetitions.amount']);
$set = $set->sortBy(
function (Budget $budget) {
return strtolower($budget->name);
}
);
return $set;
}
/** /**
* @param Budget $budget * @param Budget $budget
* @param Carbon $start * @param Carbon $start
@ -143,8 +190,6 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
->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(DB::getQueryLog())
$cache->store($data); $cache->store($data);
return $data; return $data;
@ -247,6 +292,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
/** /**
* @deprecated * @deprecated
*
* @param Budget $budget * @param Budget $budget
* @param Carbon $date * @param Carbon $date
* *
@ -294,7 +340,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
*/ */
public function getWithoutBudgetSum(Carbon $start, Carbon $end) public function getWithoutBudgetSum(Carbon $start, Carbon $end)
{ {
$noBudgetSet = Auth::user() $entry = Auth::user()
->transactionjournals() ->transactionjournals()
->whereNotIn( ->whereNotIn(
'transaction_journals.id', function (QueryBuilder $query) use ($start, $end) { 'transaction_journals.id', function (QueryBuilder $query) use ($start, $end) {
@ -309,10 +355,15 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
) )
->after($start) ->after($start)
->before($end) ->before($end)
->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '<', 0);
}
)
->transactionTypes([TransactionType::WITHDRAWAL]) ->transactionTypes([TransactionType::WITHDRAWAL])
->get(['transaction_journals.*'])->sum('amount'); ->first([DB::Raw('SUM(`transactions`.`amount`) as `journalAmount`')]);
return $noBudgetSet; return $entry->journalAmount;
} }
/** /**

View File

@ -63,6 +63,17 @@ interface BudgetRepositoryInterface
*/ */
public function getBudgets(); public function getBudgets();
/**
* Returns a list of budgets, budget limits and limit repetitions
* (doubling any of them in a left join)
*
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function getBudgetsAndLimitsInRange(Carbon $start, Carbon $end);
/** /**
* @param Budget $budget * @param Budget $budget
* @param Carbon $start * @param Carbon $start
@ -97,6 +108,7 @@ interface BudgetRepositoryInterface
/** /**
* @deprecated * @deprecated
*
* @param Budget $budget * @param Budget $budget
* *
* @return Carbon * @return Carbon
@ -105,6 +117,7 @@ interface BudgetRepositoryInterface
/** /**
* @deprecated * @deprecated
*
* @param Budget $budget * @param Budget $budget
* @param Carbon $date * @param Carbon $date
* *

View File

@ -346,8 +346,6 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
* @param \Carbon\Carbon $start * @param \Carbon\Carbon $start
* @param \Carbon\Carbon $end * @param \Carbon\Carbon $end
* *
* @param bool $shared
*
* @return string * @return string
*/ */
public function spentInPeriod(Category $category, Carbon $start, Carbon $end) public function spentInPeriod(Category $category, Carbon $start, Carbon $end)
@ -377,8 +375,6 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
* @param \Carbon\Carbon $start * @param \Carbon\Carbon $start
* @param \Carbon\Carbon $end * @param \Carbon\Carbon $end
* *
* @param bool $shared
*
* @return string * @return string
*/ */
public function earnedInPeriod(Category $category, Carbon $start, Carbon $end) public function earnedInPeriod(Category $category, Carbon $start, Carbon $end)
@ -403,11 +399,14 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
return $sum; return $sum;
} }
/** /**
* @param Category $category * @param Category $category
* @param int $page * @param int $page
* @param Carbon $start
* @param Carbon $end
* *
* @return Collection * @return mixed
*/ */
public function getJournalsInRange(Category $category, $page, Carbon $start, Carbon $end) public function getJournalsInRange(Category $category, $page, Carbon $start, Carbon $end)
{ {
@ -428,6 +427,9 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
/** /**
* @param Category $category * @param Category $category
* *
* @param Carbon $start
* @param Carbon $end
*
* @return int * @return int
*/ */
public function countJournalsInRange(Category $category, Carbon $start, Carbon $end) public function countJournalsInRange(Category $category, Carbon $start, Carbon $end)

View File

@ -23,6 +23,9 @@ interface CategoryRepositoryInterface
/** /**
* @param Category $category * @param Category $category
* *
* @param Carbon $start
* @param Carbon $end
*
* @return int * @return int
*/ */
public function countJournalsInRange(Category $category, Carbon $start, Carbon $end); public function countJournalsInRange(Category $category, Carbon $start, Carbon $end);
@ -141,6 +144,9 @@ interface CategoryRepositoryInterface
* @param Category $category * @param Category $category
* @param int $page * @param int $page
* *
* @param Carbon $start
* @param Carbon $end
*
* @return Collection * @return Collection
*/ */
public function getJournalsInRange(Category $category, $page, Carbon $start, Carbon $end); public function getJournalsInRange(Category $category, $page, Carbon $start, Carbon $end);
@ -190,8 +196,6 @@ interface CategoryRepositoryInterface
* @param \Carbon\Carbon $start * @param \Carbon\Carbon $start
* @param \Carbon\Carbon $end * @param \Carbon\Carbon $end
* *
* @param bool $shared
*
* @return string * @return string
*/ */
public function spentInPeriod(Category $category, Carbon $start, Carbon $end); public function spentInPeriod(Category $category, Carbon $start, Carbon $end);
@ -201,8 +205,6 @@ interface CategoryRepositoryInterface
* @param \Carbon\Carbon $start * @param \Carbon\Carbon $start
* @param \Carbon\Carbon $end * @param \Carbon\Carbon $end
* *
* @param bool $shared
*
* @return string * @return string
*/ */
public function earnedInPeriod(Category $category, Carbon $start, Carbon $end); public function earnedInPeriod(Category $category, Carbon $start, Carbon $end);

View File

@ -174,7 +174,7 @@ class JournalRepository implements JournalRepositoryInterface
[ [
'user_id' => $data['user'], 'user_id' => $data['user'],
'transaction_type_id' => $transactionType->id, 'transaction_type_id' => $transactionType->id,
'transaction_currency_id' => $data['amount_currency_id_amount'], 'amount_currency_id_amount' => $data['amount_currency_id_amount'],
'description' => $data['description'], 'description' => $data['description'],
'completed' => 0, 'completed' => 0,
'date' => $data['date'], 'date' => $data['date'],
@ -236,7 +236,7 @@ class JournalRepository implements JournalRepositoryInterface
public function update(TransactionJournal $journal, array $data) public function update(TransactionJournal $journal, array $data)
{ {
// update actual journal. // update actual journal.
$journal->transaction_currency_id = $data['amount_currency_id']; $journal->transaction_currency_id = $data['amount_currency_id_amount'];
$journal->description = $data['description']; $journal->description = $data['description'];
$journal->date = $data['date']; $journal->date = $data['date'];

View File

@ -3,10 +3,10 @@
namespace FireflyIII\Repositories\Shared; namespace FireflyIII\Repositories\Shared;
use Carbon\Carbon; use Carbon\Carbon;
use DB;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@ -35,27 +35,29 @@ class ComponentRepository
$cache->addProperty($accounts); $cache->addProperty($accounts);
$cache->addProperty('balanceInPeriodList'); $cache->addProperty('balanceInPeriodList');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$ids = []; $ids = [];
/** @var Account $account */ /** @var Account $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
$ids[] = $account->id; $ids[] = $account->id;
} }
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$sum = $object->transactionjournals() $entry = $object->transactionjournals()
->transactionTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::OPENING_BALANCE]) ->transactionTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::OPENING_BALANCE])
->before($end) ->before($end)
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->whereIn('accounts.id', $ids) ->whereIn('accounts.id', $ids)
->after($start) ->after($start)
->get(['transaction_journals.*'])->sum('amount'); ->first([DB::Raw('SUM(`transactions`.`amount`) as `journalAmount`')]);
$amount = $entry->journalAmount;
$cache->store($sum); $cache->store($amount);
return $sum; return $amount;
} }
} }

View File

@ -76,10 +76,11 @@ class Steam
* Gets the balance for the given account during the whole range, using this format: * Gets the balance for the given account during the whole range, using this format:
* *
* [yyyy-mm-dd] => 123,2 * [yyyy-mm-dd] => 123,2
*
* @param Account $account * @param Account $account
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
*
* @return array
*/ */
public function balanceInRange(Account $account, Carbon $start, Carbon $end) public function balanceInRange(Account $account, Carbon $start, Carbon $end)
{ {

View File

@ -27,7 +27,7 @@
"doctrine/dbal": "~2.5", "doctrine/dbal": "~2.5",
"illuminate/html": "~5.0", "illuminate/html": "~5.0",
"league/commonmark": "~0.7", "league/commonmark": "~0.7",
"rcrowe/twigbridge": "0.7.x@dev", "rcrowe/twigbridge": "~0.9",
"zizaco/entrust": "dev-laravel-5", "zizaco/entrust": "dev-laravel-5",
"league/csv": "^7.1" "league/csv": "^7.1"
}, },

264
composer.lock generated
View File

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "79e0f94d7571803d13e30aa48111b1ab", "hash": "4fc3975430321d76dd859916a9dcbfb0",
"content-hash": "968497c3098b5a38109e66c170c8becd", "content-hash": "ad9d33604e0a88fabea148474769942d",
"packages": [ "packages": [
{ {
"name": "classpreloader/classpreloader", "name": "classpreloader/classpreloader",
@ -269,16 +269,16 @@
}, },
{ {
"name": "doctrine/cache", "name": "doctrine/cache",
"version": "v1.5.2", "version": "v1.5.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/cache.git", "url": "https://github.com/doctrine/cache.git",
"reference": "47c7128262da274f590ae6f86eb137a7a64e82af" "reference": "47cdc76ceb95cc591d9c79a36dc3794975b5d136"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/47c7128262da274f590ae6f86eb137a7a64e82af", "url": "https://api.github.com/repos/doctrine/cache/zipball/47cdc76ceb95cc591d9c79a36dc3794975b5d136",
"reference": "47c7128262da274f590ae6f86eb137a7a64e82af", "reference": "47cdc76ceb95cc591d9c79a36dc3794975b5d136",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -335,7 +335,7 @@
"cache", "cache",
"caching" "caching"
], ],
"time": "2015-12-03 10:50:37" "time": "2015-12-19 05:03:47"
}, },
{ {
"name": "doctrine/collections", "name": "doctrine/collections",
@ -405,16 +405,16 @@
}, },
{ {
"name": "doctrine/common", "name": "doctrine/common",
"version": "v2.5.2", "version": "v2.6.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/common.git", "url": "https://github.com/doctrine/common.git",
"reference": "311001fd9865a4d0d59efff4eac6d7dcb3f5270c" "reference": "a579557bc689580c19fee4e27487a67fe60defc0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/common/zipball/311001fd9865a4d0d59efff4eac6d7dcb3f5270c", "url": "https://api.github.com/repos/doctrine/common/zipball/a579557bc689580c19fee4e27487a67fe60defc0",
"reference": "311001fd9865a4d0d59efff4eac6d7dcb3f5270c", "reference": "a579557bc689580c19fee4e27487a67fe60defc0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -423,20 +423,20 @@
"doctrine/collections": "1.*", "doctrine/collections": "1.*",
"doctrine/inflector": "1.*", "doctrine/inflector": "1.*",
"doctrine/lexer": "1.*", "doctrine/lexer": "1.*",
"php": ">=5.3.2" "php": "~5.5|~7.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~3.7" "phpunit/phpunit": "~4.8|~5.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.5.x-dev" "dev-master": "2.7.x-dev"
} }
}, },
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"Doctrine\\Common\\": "lib/" "Doctrine\\Common\\": "lib/Doctrine/Common"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -474,24 +474,24 @@
"persistence", "persistence",
"spl" "spl"
], ],
"time": "2015-12-04 12:49:42" "time": "2015-12-25 13:18:31"
}, },
{ {
"name": "doctrine/dbal", "name": "doctrine/dbal",
"version": "v2.5.2", "version": "v2.5.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/dbal.git", "url": "https://github.com/doctrine/dbal.git",
"reference": "01dbcbc5cd0a913d751418e635434a18a2f2a75c" "reference": "2fbcea96eae34a53183377cdbb0b9bec33974648"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/01dbcbc5cd0a913d751418e635434a18a2f2a75c", "url": "https://api.github.com/repos/doctrine/dbal/zipball/2fbcea96eae34a53183377cdbb0b9bec33974648",
"reference": "01dbcbc5cd0a913d751418e635434a18a2f2a75c", "reference": "2fbcea96eae34a53183377cdbb0b9bec33974648",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/common": ">=2.4,<2.6-dev", "doctrine/common": ">=2.4,<2.7-dev",
"php": ">=5.3.2" "php": ">=5.3.2"
}, },
"require-dev": { "require-dev": {
@ -545,7 +545,7 @@
"persistence", "persistence",
"queryobject" "queryobject"
], ],
"time": "2015-09-16 16:29:33" "time": "2015-12-25 16:28:24"
}, },
{ {
"name": "doctrine/inflector", "name": "doctrine/inflector",
@ -1148,16 +1148,16 @@
}, },
{ {
"name": "league/flysystem", "name": "league/flysystem",
"version": "1.0.15", "version": "1.0.16",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/flysystem.git", "url": "https://github.com/thephpleague/flysystem.git",
"reference": "31525caf9e8772683672fefd8a1ca0c0736020f4" "reference": "183e1a610664baf6dcd6fceda415baf43cbdc031"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/31525caf9e8772683672fefd8a1ca0c0736020f4", "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/183e1a610664baf6dcd6fceda415baf43cbdc031",
"reference": "31525caf9e8772683672fefd8a1ca0c0736020f4", "reference": "183e1a610664baf6dcd6fceda415baf43cbdc031",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1171,7 +1171,7 @@
"mockery/mockery": "~0.9", "mockery/mockery": "~0.9",
"phpspec/phpspec": "^2.2", "phpspec/phpspec": "^2.2",
"phpspec/prophecy-phpunit": "~1.0", "phpspec/prophecy-phpunit": "~1.0",
"phpunit/phpunit": "~4.1" "phpunit/phpunit": "~4.8"
}, },
"suggest": { "suggest": {
"ext-fileinfo": "Required for MimeType", "ext-fileinfo": "Required for MimeType",
@ -1228,7 +1228,7 @@
"sftp", "sftp",
"storage" "storage"
], ],
"time": "2015-09-30 22:26:59" "time": "2015-12-19 20:16:43"
}, },
{ {
"name": "monolog/monolog", "name": "monolog/monolog",
@ -1609,21 +1609,21 @@
}, },
{ {
"name": "rcrowe/twigbridge", "name": "rcrowe/twigbridge",
"version": "dev-master", "version": "v0.9.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/rcrowe/TwigBridge.git", "url": "https://github.com/rcrowe/TwigBridge.git",
"reference": "0e2693d99745eb8bbd01a80e841951c0738e1d15" "reference": "634c4d12fc3dc633d202341b7a29a107f77a67da"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/rcrowe/TwigBridge/zipball/0e2693d99745eb8bbd01a80e841951c0738e1d15", "url": "https://api.github.com/repos/rcrowe/TwigBridge/zipball/634c4d12fc3dc633d202341b7a29a107f77a67da",
"reference": "0e2693d99745eb8bbd01a80e841951c0738e1d15", "reference": "634c4d12fc3dc633d202341b7a29a107f77a67da",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"illuminate/support": "5.0.*|5.1.*", "illuminate/support": "5.0.*|5.1.*|5.2.*",
"illuminate/view": "5.0.*|5.1.*", "illuminate/view": "5.0.*|5.1.*|5.2.*",
"php": ">=5.4.0", "php": ">=5.4.0",
"twig/twig": "~1.15|~2.0" "twig/twig": "~1.15|~2.0"
}, },
@ -1641,7 +1641,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "0.7-dev" "dev-master": "0.10-dev"
} }
}, },
"autoload": { "autoload": {
@ -1669,7 +1669,7 @@
"laravel", "laravel",
"twig" "twig"
], ],
"time": "2015-05-21 13:46:00" "time": "2015-12-21 22:03:34"
}, },
{ {
"name": "swiftmailer/swiftmailer", "name": "swiftmailer/swiftmailer",
@ -1726,16 +1726,16 @@
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v2.7.7", "version": "v2.7.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
"reference": "16bb1cb86df43c90931df65f529e7ebd79636750" "reference": "4e35a78f932a4c07bd349efea647ac741c1419b6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/16bb1cb86df43c90931df65f529e7ebd79636750", "url": "https://api.github.com/repos/symfony/console/zipball/4e35a78f932a4c07bd349efea647ac741c1419b6",
"reference": "16bb1cb86df43c90931df65f529e7ebd79636750", "reference": "4e35a78f932a4c07bd349efea647ac741c1419b6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1781,20 +1781,20 @@
], ],
"description": "Symfony Console Component", "description": "Symfony Console Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-18 09:54:26" "time": "2015-12-23 11:17:38"
}, },
{ {
"name": "symfony/css-selector", "name": "symfony/css-selector",
"version": "v2.7.7", "version": "v2.7.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/css-selector.git", "url": "https://github.com/symfony/css-selector.git",
"reference": "abb47717fb88aebd9437da2fc8bb01a50a36679f" "reference": "35bebec48d3d08e3138257419e3ca84070152012"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/abb47717fb88aebd9437da2fc8bb01a50a36679f", "url": "https://api.github.com/repos/symfony/css-selector/zipball/35bebec48d3d08e3138257419e3ca84070152012",
"reference": "abb47717fb88aebd9437da2fc8bb01a50a36679f", "reference": "35bebec48d3d08e3138257419e3ca84070152012",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1834,20 +1834,20 @@
], ],
"description": "Symfony CssSelector Component", "description": "Symfony CssSelector Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-10-30 20:10:21" "time": "2015-12-05 17:37:09"
}, },
{ {
"name": "symfony/debug", "name": "symfony/debug",
"version": "v2.7.7", "version": "v2.7.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/debug.git", "url": "https://github.com/symfony/debug.git",
"reference": "0dbc119596f4afc82d9b2eb2a7e6a4af1ee763fa" "reference": "08589346bd2ec9a8eb3d935e3b1fedba9bb6463f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/0dbc119596f4afc82d9b2eb2a7e6a4af1ee763fa", "url": "https://api.github.com/repos/symfony/debug/zipball/08589346bd2ec9a8eb3d935e3b1fedba9bb6463f",
"reference": "0dbc119596f4afc82d9b2eb2a7e6a4af1ee763fa", "reference": "08589346bd2ec9a8eb3d935e3b1fedba9bb6463f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1891,11 +1891,11 @@
], ],
"description": "Symfony Debug Component", "description": "Symfony Debug Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-10-30 20:10:21" "time": "2015-12-26 14:05:15"
}, },
{ {
"name": "symfony/dom-crawler", "name": "symfony/dom-crawler",
"version": "v2.7.7", "version": "v2.7.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/dom-crawler.git", "url": "https://github.com/symfony/dom-crawler.git",
@ -1950,7 +1950,7 @@
}, },
{ {
"name": "symfony/event-dispatcher", "name": "symfony/event-dispatcher",
"version": "v2.8.0", "version": "v2.8.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/event-dispatcher.git", "url": "https://github.com/symfony/event-dispatcher.git",
@ -2010,16 +2010,16 @@
}, },
{ {
"name": "symfony/finder", "name": "symfony/finder",
"version": "v2.7.7", "version": "v2.7.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/finder.git", "url": "https://github.com/symfony/finder.git",
"reference": "a06a0c0ff7db3736a50d530c908cca547bf13da9" "reference": "937edcbac3f2dd3187c56cf90368867d55dee991"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/a06a0c0ff7db3736a50d530c908cca547bf13da9", "url": "https://api.github.com/repos/symfony/finder/zipball/937edcbac3f2dd3187c56cf90368867d55dee991",
"reference": "a06a0c0ff7db3736a50d530c908cca547bf13da9", "reference": "937edcbac3f2dd3187c56cf90368867d55dee991",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2055,20 +2055,20 @@
], ],
"description": "Symfony Finder Component", "description": "Symfony Finder Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-10-30 20:10:21" "time": "2015-12-05 11:06:38"
}, },
{ {
"name": "symfony/http-foundation", "name": "symfony/http-foundation",
"version": "v2.7.7", "version": "v2.7.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-foundation.git", "url": "https://github.com/symfony/http-foundation.git",
"reference": "e83a3d105ddaf5a113e803c904fdec552d1f1c35" "reference": "cf11faac7df5384bb14774ad7266add227e10ec1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/e83a3d105ddaf5a113e803c904fdec552d1f1c35", "url": "https://api.github.com/repos/symfony/http-foundation/zipball/cf11faac7df5384bb14774ad7266add227e10ec1",
"reference": "e83a3d105ddaf5a113e803c904fdec552d1f1c35", "reference": "cf11faac7df5384bb14774ad7266add227e10ec1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2110,20 +2110,20 @@
], ],
"description": "Symfony HttpFoundation Component", "description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-20 17:41:18" "time": "2015-12-18 15:35:58"
}, },
{ {
"name": "symfony/http-kernel", "name": "symfony/http-kernel",
"version": "v2.7.7", "version": "v2.7.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-kernel.git", "url": "https://github.com/symfony/http-kernel.git",
"reference": "5570de31e8fbc03777a8c61eb24f9b626e5e5941" "reference": "2dea13800e1a48710cf23a2c60c804c88e72ed57"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/5570de31e8fbc03777a8c61eb24f9b626e5e5941", "url": "https://api.github.com/repos/symfony/http-kernel/zipball/2dea13800e1a48710cf23a2c60c804c88e72ed57",
"reference": "5570de31e8fbc03777a8c61eb24f9b626e5e5941", "reference": "2dea13800e1a48710cf23a2c60c804c88e72ed57",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2192,20 +2192,20 @@
], ],
"description": "Symfony HttpKernel Component", "description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-23 11:57:49" "time": "2015-12-26 15:01:55"
}, },
{ {
"name": "symfony/polyfill-php56", "name": "symfony/polyfill-php56",
"version": "v1.0.0", "version": "v1.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php56.git", "url": "https://github.com/symfony/polyfill-php56.git",
"reference": "a6bd4770a6967517e6610529e14afaa3111094a3" "reference": "e2e77609a9e2328eb370fbb0e0d8b2000ebb488f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/a6bd4770a6967517e6610529e14afaa3111094a3", "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/e2e77609a9e2328eb370fbb0e0d8b2000ebb488f",
"reference": "a6bd4770a6967517e6610529e14afaa3111094a3", "reference": "e2e77609a9e2328eb370fbb0e0d8b2000ebb488f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2248,11 +2248,11 @@
"portable", "portable",
"shim" "shim"
], ],
"time": "2015-11-04 20:28:58" "time": "2015-12-18 15:10:25"
}, },
{ {
"name": "symfony/polyfill-util", "name": "symfony/polyfill-util",
"version": "v1.0.0", "version": "v1.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-util.git", "url": "https://github.com/symfony/polyfill-util.git",
@ -2304,16 +2304,16 @@
}, },
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v2.7.7", "version": "v2.7.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/process.git", "url": "https://github.com/symfony/process.git",
"reference": "f6290983c8725d0afa29bdc3e5295879de3e58f5" "reference": "a3fb8f4c4afc4f1b285de5df07e568602934f525"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/f6290983c8725d0afa29bdc3e5295879de3e58f5", "url": "https://api.github.com/repos/symfony/process/zipball/a3fb8f4c4afc4f1b285de5df07e568602934f525",
"reference": "f6290983c8725d0afa29bdc3e5295879de3e58f5", "reference": "a3fb8f4c4afc4f1b285de5df07e568602934f525",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2349,20 +2349,20 @@
], ],
"description": "Symfony Process Component", "description": "Symfony Process Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-19 16:11:24" "time": "2015-12-23 11:03:39"
}, },
{ {
"name": "symfony/routing", "name": "symfony/routing",
"version": "v2.7.7", "version": "v2.7.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/routing.git", "url": "https://github.com/symfony/routing.git",
"reference": "7450f6196711b124fb8b04a12286d01a0401ddfe" "reference": "2c100bd94be50e2a1fce7fe1ac534e28776c24ff"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/7450f6196711b124fb8b04a12286d01a0401ddfe", "url": "https://api.github.com/repos/symfony/routing/zipball/2c100bd94be50e2a1fce7fe1ac534e28776c24ff",
"reference": "7450f6196711b124fb8b04a12286d01a0401ddfe", "reference": "2c100bd94be50e2a1fce7fe1ac534e28776c24ff",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2422,20 +2422,20 @@
"uri", "uri",
"url" "url"
], ],
"time": "2015-11-18 13:41:01" "time": "2015-12-23 06:54:35"
}, },
{ {
"name": "symfony/translation", "name": "symfony/translation",
"version": "v2.7.7", "version": "v2.7.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/translation.git", "url": "https://github.com/symfony/translation.git",
"reference": "e4ecb9c3ba1304eaf24de15c2d7a428101c1982f" "reference": "e7e95debf0465f7886d2994cd808f9382adb423c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/e4ecb9c3ba1304eaf24de15c2d7a428101c1982f", "url": "https://api.github.com/repos/symfony/translation/zipball/e7e95debf0465f7886d2994cd808f9382adb423c",
"reference": "e4ecb9c3ba1304eaf24de15c2d7a428101c1982f", "reference": "e7e95debf0465f7886d2994cd808f9382adb423c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2485,20 +2485,20 @@
], ],
"description": "Symfony Translation Component", "description": "Symfony Translation Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-18 13:41:01" "time": "2015-12-05 17:37:09"
}, },
{ {
"name": "symfony/var-dumper", "name": "symfony/var-dumper",
"version": "v2.7.7", "version": "v2.7.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/var-dumper.git", "url": "https://github.com/symfony/var-dumper.git",
"reference": "72bcb27411780eaee9469729aace73c0d46fb2b8" "reference": "ec3233d755578c56612c13d81d4ef141f8f94e9e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/72bcb27411780eaee9469729aace73c0d46fb2b8", "url": "https://api.github.com/repos/symfony/var-dumper/zipball/ec3233d755578c56612c13d81d4ef141f8f94e9e",
"reference": "72bcb27411780eaee9469729aace73c0d46fb2b8", "reference": "ec3233d755578c56612c13d81d4ef141f8f94e9e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2544,7 +2544,7 @@
"debug", "debug",
"dump" "dump"
], ],
"time": "2015-11-18 13:41:01" "time": "2015-12-05 10:02:55"
}, },
{ {
"name": "twig/twig", "name": "twig/twig",
@ -2779,28 +2779,28 @@
"packages-dev": [ "packages-dev": [
{ {
"name": "barryvdh/laravel-debugbar", "name": "barryvdh/laravel-debugbar",
"version": "v2.0.6", "version": "v2.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/barryvdh/laravel-debugbar.git", "url": "https://github.com/barryvdh/laravel-debugbar.git",
"reference": "23672cbbe78278ff1fdb258caa0b1de7b5d0bc0c" "reference": "974fd16e328ca851a081449100d9509af59cf0ff"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/23672cbbe78278ff1fdb258caa0b1de7b5d0bc0c", "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/974fd16e328ca851a081449100d9509af59cf0ff",
"reference": "23672cbbe78278ff1fdb258caa0b1de7b5d0bc0c", "reference": "974fd16e328ca851a081449100d9509af59cf0ff",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"illuminate/support": "~5.0.17|5.1.*", "illuminate/support": "~5.0.17|5.1.*|5.2.*",
"maximebf/debugbar": "~1.10.2", "maximebf/debugbar": "~1.11.0",
"php": ">=5.4.0", "php": ">=5.4.0",
"symfony/finder": "~2.6" "symfony/finder": "~2.6|~3.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.1-dev" "dev-master": "2.2-dev"
} }
}, },
"autoload": { "autoload": {
@ -2829,26 +2829,26 @@
"profiler", "profiler",
"webprofiler" "webprofiler"
], ],
"time": "2015-09-09 11:39:27" "time": "2015-12-22 06:22:38"
}, },
{ {
"name": "barryvdh/laravel-ide-helper", "name": "barryvdh/laravel-ide-helper",
"version": "v2.1.0", "version": "v2.1.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/barryvdh/laravel-ide-helper.git", "url": "https://github.com/barryvdh/laravel-ide-helper.git",
"reference": "83999f8467374adcb8893f566c9171c9d9691f50" "reference": "d82e8f191fb043a0f8cbf2de64fd3027bfa4f772"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-ide-helper/zipball/83999f8467374adcb8893f566c9171c9d9691f50", "url": "https://api.github.com/repos/barryvdh/laravel-ide-helper/zipball/d82e8f191fb043a0f8cbf2de64fd3027bfa4f772",
"reference": "83999f8467374adcb8893f566c9171c9d9691f50", "reference": "d82e8f191fb043a0f8cbf2de64fd3027bfa4f772",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"illuminate/console": "5.0.x|5.1.x", "illuminate/console": "5.0.x|5.1.x|5.2.x",
"illuminate/filesystem": "5.0.x|5.1.x", "illuminate/filesystem": "5.0.x|5.1.x|5.2.x",
"illuminate/support": "5.0.x|5.1.x", "illuminate/support": "5.0.x|5.1.x|5.2.x",
"php": ">=5.4.0", "php": ">=5.4.0",
"phpdocumentor/reflection-docblock": "2.0.4", "phpdocumentor/reflection-docblock": "2.0.4",
"symfony/class-loader": "~2.3" "symfony/class-loader": "~2.3"
@ -2892,29 +2892,29 @@
"phpstorm", "phpstorm",
"sublime" "sublime"
], ],
"time": "2015-08-13 11:40:00" "time": "2015-12-21 19:48:06"
}, },
{ {
"name": "maximebf/debugbar", "name": "maximebf/debugbar",
"version": "v1.10.5", "version": "v1.11.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/maximebf/php-debugbar.git", "url": "https://github.com/maximebf/php-debugbar.git",
"reference": "30e53e8a28284b69dd223c9f5ee8957befd72636" "reference": "07741d84d39d10f00551c94284cdefcc69703e77"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/30e53e8a28284b69dd223c9f5ee8957befd72636", "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/07741d84d39d10f00551c94284cdefcc69703e77",
"reference": "30e53e8a28284b69dd223c9f5ee8957befd72636", "reference": "07741d84d39d10f00551c94284cdefcc69703e77",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.0", "php": ">=5.3.0",
"psr/log": "~1.0", "psr/log": "^1.0",
"symfony/var-dumper": "~2.6" "symfony/var-dumper": "^2.6|^3.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.0" "phpunit/phpunit": "^4.0|^5.0"
}, },
"suggest": { "suggest": {
"kriswallsmith/assetic": "The best way to manage assets", "kriswallsmith/assetic": "The best way to manage assets",
@ -2924,12 +2924,12 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.10-dev" "dev-master": "1.11-dev"
} }
}, },
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"DebugBar": "src/" "DebugBar\\": "src/DebugBar/"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -2941,14 +2941,19 @@
"name": "Maxime Bouroumeau-Fuseau", "name": "Maxime Bouroumeau-Fuseau",
"email": "maxime.bouroumeau@gmail.com", "email": "maxime.bouroumeau@gmail.com",
"homepage": "http://maximebf.com" "homepage": "http://maximebf.com"
},
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
} }
], ],
"description": "Debug bar in the browser for php application", "description": "Debug bar in the browser for php application",
"homepage": "https://github.com/maximebf/php-debugbar", "homepage": "https://github.com/maximebf/php-debugbar",
"keywords": [ "keywords": [
"debug" "debug",
"debugbar"
], ],
"time": "2015-10-19 20:35:12" "time": "2015-12-10 09:50:24"
}, },
{ {
"name": "phpdocumentor/reflection-docblock", "name": "phpdocumentor/reflection-docblock",
@ -3001,16 +3006,16 @@
}, },
{ {
"name": "symfony/class-loader", "name": "symfony/class-loader",
"version": "v2.8.0", "version": "v2.8.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/class-loader.git", "url": "https://github.com/symfony/class-loader.git",
"reference": "51f83451bf0ddfc696e47e4642d6cd10fcfce160" "reference": "ec74b0a279cf3a9bd36172b3e3061591d380ce6c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/class-loader/zipball/51f83451bf0ddfc696e47e4642d6cd10fcfce160", "url": "https://api.github.com/repos/symfony/class-loader/zipball/ec74b0a279cf3a9bd36172b3e3061591d380ce6c",
"reference": "51f83451bf0ddfc696e47e4642d6cd10fcfce160", "reference": "ec74b0a279cf3a9bd36172b3e3061591d380ce6c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3049,13 +3054,12 @@
], ],
"description": "Symfony ClassLoader Component", "description": "Symfony ClassLoader Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-26 07:00:59" "time": "2015-12-05 17:37:59"
} }
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": { "stability-flags": {
"rcrowe/twigbridge": 20,
"zizaco/entrust": 20, "zizaco/entrust": 20,
"barryvdh/laravel-debugbar": 0 "barryvdh/laravel-debugbar": 0
}, },

View File

@ -2,7 +2,7 @@
return [ return [
'chart' => 'chartjs', 'chart' => 'chartjs',
'version' => '3.5.5', 'version' => '3.5.6',
'index_periods' => ['1D', '1W', '1M', '3M', '6M', '1Y', 'custom'], 'index_periods' => ['1D', '1W', '1M', '3M', '6M', '1Y', 'custom'],
'budget_periods' => ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'], 'budget_periods' => ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'],
'csv_import_enabled' => true, 'csv_import_enabled' => true,

View File

@ -60,6 +60,7 @@
</script> </script>
</body> </body>

View File

@ -5,7 +5,8 @@
<div class="input-group"> <div class="input-group">
<div class="input-group-btn"> <div class="input-group-btn">
<button type="button" <button type="button"
class="btn btn-default dropdown-toggle currency-dropdown" id="currency_dropdown_{{ name }}" data-toggle="dropdown" aria-expanded="false"> class="btn btn-default dropdown-toggle currency-dropdown" id="currency_dropdown_{{ name }}" data-toggle="dropdown"
aria-expanded="false">
<span id="currency_select_symbol_{{ name }}">{{ defaultCurrency.symbol|raw }}</span> <span class="caret"></span> <span id="currency_select_symbol_{{ name }}">{{ defaultCurrency.symbol|raw }}</span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu currency-dropdown-menu" role="menu"> <ul class="dropdown-menu currency-dropdown-menu" role="menu">

View File

@ -5,7 +5,8 @@
<div class="input-group"> <div class="input-group">
<div class="input-group-btn"> <div class="input-group-btn">
<button type="button" <button type="button"
class="btn btn-default dropdown-toggle currency-dropdown" id="currency_dropdown_{{ name }}" data-toggle="dropdown" aria-expanded="false"> class="btn btn-default dropdown-toggle currency-dropdown" id="currency_dropdown_{{ name }}" data-toggle="dropdown"
aria-expanded="false">
<span id="currency_select_symbol_{{ name }}">{{ defaultCurrency.symbol|raw }}</span> <span class="caret"></span> <span id="currency_select_symbol_{{ name }}">{{ defaultCurrency.symbol|raw }}</span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu currency-dropdown-menu" role="menu"> <ul class="dropdown-menu currency-dropdown-menu" role="menu">

View File

@ -10,7 +10,7 @@
<tr> <tr>
{% if showPiggyBank %} {% if showPiggyBank %}
<td> <td>
<a href="{{ route('piggy-banks.show',event.piggyBank_id) }}">{{ event.piggyBank.name }}</a> <a href="{{ route('piggy-banks.show',event.piggyBank.id) }}">{{ event.piggyBank.name }}</a>
</td> </td>
{% endif %} {% endif %}
<td> <td>

View File

@ -126,10 +126,10 @@
{% if journal.piggyBankEvents|length > 0 %} {% if journal.piggyBankEvents|length > 0 %}
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
{{ 'piggyBanks'|_ }} <h3 class="box-title">{{ 'piggyBanks'|_ }}</h3>
</div> </div>
<div class="box-body"> <div class="box-body">
{% include 'list/piggy-bank-events' with {'events': journal.piggyBankEvents, 'showPiggyBank':true} %} {% include 'list/piggy-bank-events' with {'events': events, 'showPiggyBank':true} %}
</div> </div>
</div> </div>
{% endif %} {% endif %}