Compare commits

...

87 Commits

Author SHA1 Message Date
James Cole
f43b026162 Merge branch 'release/3.4.2' 2015-05-25 23:18:32 +02:00
James Cole
b806c70f52 New read me. 2015-05-25 22:58:49 +02:00
James Cole
10bff3c0b8 Fix tests. 2015-05-25 22:56:00 +02:00
James Cole
65c12fd0b2 Merge branch 'release/3.4.1' 2015-05-25 22:24:28 +02:00
James Cole
50f71c4130 Merge branch 'release/3.4.1' into develop 2015-05-25 22:24:28 +02:00
James Cole
8e401a53dc New version. 2015-05-25 22:24:21 +02:00
James Cole
64a289a47c Cleanup some code [skip ci] 2015-05-25 22:17:41 +02:00
James Cole
8f2c37061b Update translations [skip ci] 2015-05-25 22:16:00 +02:00
James Cole
39f2de6b90 Cleanup code [skip ci] 2015-05-25 22:04:24 +02:00
James Cole
855ba8d4f3 Cleanup [skip ci] 2015-05-25 22:01:48 +02:00
James Cole
74f098e718 Some new translations [skip ci] 2015-05-25 21:39:05 +02:00
James Cole
56c8a84691 Update translations [skip ci] 2015-05-25 21:26:34 +02:00
James Cole
8bbf319032 Some translations and a new test. 2015-05-25 21:17:36 +02:00
James Cole
afbca4ae65 Newline in travis.ml [skip ci] 2015-05-25 20:08:31 +02:00
James Cole
0ef6d2f91a Code cleanup. 2015-05-25 19:58:13 +02:00
James Cole
fbe4435599 Fix translation [skip ci] 2015-05-25 19:19:27 +02:00
James Cole
34be565dd1 New translations [skip ci] 2015-05-25 19:18:16 +02:00
James Cole
af838e4ed1 New translations. 2015-05-25 09:23:45 +02:00
James Cole
60fe8ce011 New GA events [skip ci] 2015-05-25 08:12:31 +02:00
James Cole
8ece341467 Add GA events [skip ci] 2015-05-25 08:01:06 +02:00
James Cole
dfa6bdbcb8 Fixed menu for mobile screens [skip ci] 2015-05-25 07:53:13 +02:00
James Cole
fb2481ebaa Add some GA events. 2015-05-25 07:26:19 +02:00
James Cole
4874c116cf Add GA to 503 page. [skip ci] 2015-05-25 07:23:35 +02:00
James Cole
e19c44efbd Some code cleanup. 2015-05-25 07:14:04 +02:00
James Cole
4b687b9bdc Clean up config 2015-05-25 07:03:26 +02:00
James Cole
6af79ef601 Fixed tests 2015-05-24 23:08:55 +02:00
James Cole
352b996ad2 Cleanup some code. 2015-05-24 22:59:48 +02:00
James Cole
4a93bb35f8 Cleanup budget view. 2015-05-24 22:54:59 +02:00
James Cole
8e1f493daf Another build routine. 2015-05-24 21:45:10 +02:00
James Cole
59ee153375 Fixed test. 2015-05-24 21:11:37 +02:00
James Cole
60f7f1fc16 New build routine. 2015-05-24 21:07:22 +02:00
James Cole
b7433683d8 Cleanup cleanup [skip ci] 2015-05-24 20:57:27 +02:00
James Cole
42799b9273 Some JS cleanup. 2015-05-24 20:48:31 +02:00
James Cole
860a0f790e Update js [skip ci] 2015-05-24 20:41:14 +02:00
James Cole
8daccbfbb4 Add JSHint stuff. [skip ci] 2015-05-24 18:22:41 +02:00
James Cole
285b77dcb7 Merge branch 'release/3.4.0.10' into develop 2015-05-24 15:56:05 +02:00
James Cole
6e48827d3f Merge branch 'release/3.4.0.10' 2015-05-24 15:56:04 +02:00
James Cole
f0c20cc706 New release. 2015-05-24 15:55:59 +02:00
James Cole
8916c0a3de Clean code [skip ci] 2015-05-24 15:18:19 +02:00
James Cole
7193a77840 Some translations and cleanup [skip ci] 2015-05-24 15:13:07 +02:00
James Cole
61930b5b51 Code cleanup [skip ci] 2015-05-24 15:03:45 +02:00
James Cole
11a494cacf Remove some middleware, fix cleanup [skip ci] 2015-05-24 12:53:47 +02:00
James Cole
17f9bf0339 Merge branch 'release/3.4.0.9' into develop 2015-05-24 11:53:44 +02:00
James Cole
3d9755ca8c Merge branch 'release/3.4.0.9' 2015-05-24 11:53:43 +02:00
James Cole
b5cf2d03e6 New version. 2015-05-24 11:53:34 +02:00
James Cole
e3b35b8f35 Add code climate file [skip ci] 2015-05-24 11:46:41 +02:00
James Cole
1c1fe672bd Some code cleanup [skip ci] 2015-05-24 11:41:52 +02:00
James Cole
6c71f68ed8 Should cover models. 2015-05-24 11:13:46 +02:00
James Cole
8f2f912cdf New (empty) tests for models. 2015-05-24 10:01:00 +02:00
James Cole
bf6ea16acb Fixed test. 2015-05-24 09:29:44 +02:00
James Cole
288546c2b9 Fixed some math. 2015-05-24 08:00:40 +02:00
James Cole
724db6c34c Built some new tests 2015-05-24 07:43:48 +02:00
James Cole
067c451c1d Fixed tests 2015-05-23 21:41:04 +02:00
James Cole
11e3696191 Cleanup tests. 2015-05-23 21:23:51 +02:00
James Cole
41e20664de Fixed coverage. 2015-05-23 21:18:20 +02:00
James Cole
d8de90d6f3 Ignore constructors. 2015-05-23 20:49:57 +02:00
James Cole
b01e8299d3 Fixed tests 2015-05-23 20:47:31 +02:00
James Cole
1ec11e3e2e Compartmentalised all tests. 2015-05-23 19:41:54 +02:00
James Cole
422f429725 Experimental count thing. 2015-05-23 17:38:16 +02:00
James Cole
5c55fa5fbb Remove encrypted amounts because it stinks. 2015-05-23 17:33:04 +02:00
James Cole
80d845fdf2 Save but don't use. 2015-05-23 17:18:23 +02:00
James Cole
601fe68346 Don't multiply transactions. 2015-05-23 17:14:36 +02:00
James Cole
9e050fb059 Updated some tests. 2015-05-23 17:11:16 +02:00
James Cole
99d4adf5e6 Translations [skip ci] 2015-05-23 15:57:38 +02:00
James Cole
85f8d1e8e9 Math is hard [skip ci] 2015-05-23 15:45:01 +02:00
James Cole
8334d3d99f Translation error [skip ci] 2015-05-23 15:43:48 +02:00
James Cole
cff08d19eb Slowly move away from using the raw 'transactions.amount' field. 2015-05-23 15:42:19 +02:00
James Cole
2d86390bc1 Experimental query.Code cleanup [skip ci] 2015-05-23 09:11:59 +02:00
James Cole
7a20835571 Code cleanup [skip ci] 2015-05-23 09:09:25 +02:00
James Cole
ff3c9676b5 Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 09:05:08 +02:00
James Cole
055f97dab1 Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 09:03:52 +02:00
James Cole
8a867e71a1 Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 09:02:27 +02:00
James Cole
b8275b4734 Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 09:01:38 +02:00
James Cole
36b951b146 Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 09:01:07 +02:00
James Cole
c5a5f17643 Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 09:00:11 +02:00
James Cole
16b909c4df Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 08:59:23 +02:00
James Cole
92b7648e03 Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 08:58:21 +02:00
James Cole
ca46ebe3b2 Encrypt bill amounts [skip ci] 2015-05-23 08:57:02 +02:00
James Cole
676e48254a Whoops [skip ci] 2015-05-23 08:55:16 +02:00
James Cole
b15b55227d Add another cleanup routine. [skip ci] 2015-05-23 08:54:25 +02:00
James Cole
3c3b723913 Some code cleanup [skip ci] 2015-05-23 08:51:24 +02:00
James Cole
f05002c729 Updated models for encryption. 2015-05-23 08:46:46 +02:00
James Cole
1c2cbd5b40 New stuff for encrypted amounts. 2015-05-23 07:47:36 +02:00
James Cole
54c6ca9f45 Expanded some tests. 2015-05-22 20:25:12 +02:00
James Cole
c10efbb170 Also encrypt meta data for reminders. 2015-05-22 19:19:18 +02:00
James Cole
a496ad5814 Simple routine to encrypt entries which were not encrypted yet. 2015-05-22 19:18:00 +02:00
James Cole
f946f10afd Merge branch 'release/3.4.0.8' into develop 2015-05-22 18:55:13 +02:00
163 changed files with 4145 additions and 1545 deletions

25
.codeclimate.yml Normal file
View File

@@ -0,0 +1,25 @@
# Save as .codeclimate.yml (note leading .) in project root directory
languages:
JavaScript: true
PHP: true
exclude_paths:
- "public/packages/maximebf/php-debugbar/debugbar.js"
- "public/packages/maximebf/php-debugbar/widgets.js"
- "public/packages/maximebf/php-debugbar/openhandler.js"
- "public/packages/maximebf/php-debugbar/widgets/sqlqueries/widget.js"
- "public/js/bootstrap3-typeahead.min.js"
- "public/js/bootstrap-sortable.js"
- "public/js/bootstrap-tagsinput.min.js"
- "public/js/bootstrap-tagsinput.min.js.map"
- "public/js/daterangepicker.js"
- "public/js/jquery-2.1.3.min.js"
- "public/js/jquery-2.1.3.min.js.map"
- "public/js/jquery-ui.min.js"
- "public/js/metisMenu.js"
- "public/js/moment.min.js"
- "public/js/sb-admin-2.js"
- "public/bootstrap/*"
- "resources/lang/*"
- "tests/*"
- "database/*"
- "storage/*"

View File

@@ -1,3 +1,3 @@
src_dir: .
coverage_clover: storage/coverage/clover.xml
json_path: storage/coverage/coveralls-upload.json
coverage_clover: build/logs/clover.xml
json_path: build/logs/coveralls-upload.json

View File

@@ -16,4 +16,5 @@ EMAIL_DRIVER=smtp
EMAIL_USERNAME=
EMAIL_PASSWORD=
ANALYTICS_ID=
EMAIL_PRETEND=false
EMAIL_PRETEND=false
RUNCLEANUP=true

22
.jshintrc Normal file
View File

@@ -0,0 +1,22 @@
{
"undef": true,
"unused": false,
"strict": true,
"browser": true,
"jquery": true,
"devel": true,
"globals": [
"language",
"token",
"currencyCode",
"$",
"token",
"accountID",
"billID",
"currentMonthName",
"previousMonthName",
"nextMonthName",
"everything",
"moment"
]
}

View File

@@ -6,10 +6,6 @@ php:
- 5.5
- 5.6
addons:
code_climate:
repo_token: 26489f9e854fcdf7e7660ba29c1455694685465b1f90329a79f7d2bf448acb61
install:
- composer update
- php artisan env
@@ -20,3 +16,5 @@ script:
after_script:
- php vendor/bin/coveralls
- CODECLIMATE_REPO_TOKEN=26489f9e854fcdf7e7660ba29c1455694685465b1f90329a79f7d2bf448acb61 ./vendor/bin/test-reporter --stdout > codeclimate.json
- "curl -X POST -d @codeclimate.json -H 'Content-Type: application/json' -H 'User-Agent: Code Climate (PHP Test Reporter v0.1.1)' https://codeclimate.com/test_reports"

View File

@@ -1,5 +1,5 @@
# Firefly III
#### v3.4.0.8
#### 3.4.2
[![Build Status](https://travis-ci.org/JC5/firefly-iii.svg?branch=develop)](https://travis-ci.org/JC5/firefly-iii)
[![Project Status](http://stillmaintained.com/JC5/firefly-iii.png?a=b)](http://stillmaintained.com/JC5/firefly-iii)

View File

@@ -18,6 +18,8 @@ class ConnectJournalToPiggyBank
/**
* Create the event handler.
*
* @codeCoverageIgnore
*
*/
public function __construct()
{

View File

@@ -3,7 +3,6 @@
namespace FireflyIII\Helpers\Collection;
use FireflyIII\Models\Bill as BillModel;
use Illuminate\Support\Collection;
/**

View File

@@ -15,14 +15,14 @@ class Budget
{
/** @var Collection */
protected $budgetLines;
/** @var float */
protected $budgeted = 0;
/** @var float */
protected $left = 0;
/** @var float */
protected $overspent = 0;
/** @var float */
protected $spent = 0;
/** @var string */
protected $budgeted = '0';
/** @var string */
protected $left = '0';
/** @var string */
protected $overspent = '0';
/** @var string */
protected $spent = '0';
/**
*
@@ -45,7 +45,9 @@ class Budget
*/
public function addBudgeted($add)
{
$this->budgeted += floatval($add);
$add = strval(round($add, 2));
bcscale(2);
$this->budgeted = bcadd($this->budgeted, $add);
}
/**
@@ -53,7 +55,9 @@ class Budget
*/
public function addLeft($add)
{
$this->left += floatval($add);
$add = strval(round($add, 2));
bcscale(2);
$this->left = bcadd($this->left, $add);
}
/**
@@ -61,7 +65,9 @@ class Budget
*/
public function addOverspent($add)
{
$this->overspent += floatval($add);
$add = strval(round($add, 2));
bcscale(2);
$this->overspent = bcadd($this->overspent, $add);
}
/**
@@ -69,7 +75,9 @@ class Budget
*/
public function addSpent($add)
{
$this->spent += floatval($add);
$add = strval(round($add, 2));
bcscale(2);
$this->spent = bcadd($this->spent, $add);
}
/**
@@ -81,7 +89,7 @@ class Budget
}
/**
* @return float
* @return string
*/
public function getBudgeted()
{
@@ -89,7 +97,7 @@ class Budget
}
/**
* @param float $budgeted
* @param string $budgeted
*/
public function setBudgeted($budgeted)
{
@@ -97,7 +105,7 @@ class Budget
}
/**
* @return float
* @return string
*/
public function getLeft()
{
@@ -105,7 +113,7 @@ class Budget
}
/**
* @param float $left
* @param string $left
*/
public function setLeft($left)
{
@@ -113,7 +121,7 @@ class Budget
}
/**
* @return float
* @return string
*/
public function getOverspent()
{
@@ -121,15 +129,15 @@ class Budget
}
/**
* @param float $overspent
* @param string $overspent
*/
public function setOverspent($overspent)
{
$this->overspent = $overspent;
$this->overspent = strval(round($overspent, 2));
}
/**
* @return float
* @return string
*/
public function getSpent()
{
@@ -137,11 +145,11 @@ class Budget
}
/**
* @param float $spent
* @param string $spent
*/
public function setSpent($spent)
{
$this->spent = $spent;
$this->spent = strval(round($spent, 2));
}

View File

@@ -17,16 +17,14 @@ class BudgetLine
/** @var BudgetModel */
protected $budget;
/** @var LimitRepetition */
protected $repetition;
/** @var float */
protected $budgeted = 0;
/** @var float */
protected $left = 0;
/** @var float */
protected $overspent = 0;
/** @var LimitRepetition */
protected $repetition;
/** @var float */
protected $spent = 0;
@@ -94,22 +92,6 @@ class BudgetLine
$this->overspent = $overspent;
}
/**
* @return float
*/
public function getSpent()
{
return $this->spent;
}
/**
* @param float $spent
*/
public function setSpent($spent)
{
$this->spent = $spent;
}
/**
* @return LimitRepetition
*/
@@ -126,5 +108,21 @@ class BudgetLine
$this->repetition = $repetition;
}
/**
* @return float
*/
public function getSpent()
{
return $this->spent;
}
/**
* @param float $spent
*/
public function setSpent($spent)
{
$this->spent = $spent;
}
}

View File

@@ -1,10 +1,4 @@
<?php
/**
* Created by PhpStorm.
* User: sander
* Date: 16/05/15
* Time: 13:09
*/
namespace FireflyIII\Helpers\Collection;
@@ -24,8 +18,8 @@ class Category
/** @var Collection */
protected $categories;
/** @var float */
protected $total = 0;
/** @var string */
protected $total = '0';
/**
*
@@ -50,7 +44,9 @@ class Category
*/
public function addTotal($add)
{
$this->total += floatval($add);
$add = strval(round($add, 2));
bcscale(2);
$this->total = bcadd($this->total, $add);
}
/**
@@ -69,11 +65,11 @@ class Category
}
/**
* @return float
* @return string
*/
public function getTotal()
{
return $this->total;
return strval(round($this->total, 2));
}

View File

@@ -17,8 +17,8 @@ class Expense
{
/** @var Collection */
protected $expenses;
/** @var float */
protected $total;
/** @var string */
protected $total = '0';
/**
*
@@ -37,14 +37,15 @@ class Expense
$accountId = $entry->account_id;
if (!$this->expenses->has($accountId)) {
$newObject = new stdClass;
$newObject->amount = floatval($entry->amount);
$newObject->amount = strval(round($entry->amount, 2));
$newObject->name = $entry->name;
$newObject->count = 1;
$newObject->id = $accountId;
$this->expenses->put($accountId, $newObject);
} else {
$existing = $this->expenses->get($accountId);
$existing->amount += floatval($entry->amount);
bcscale(2);
$existing = $this->expenses->get($accountId);
$existing->amount = bcadd($existing->amount, $entry->amount);
$existing->count++;
$this->expenses->put($accountId, $existing);
}
@@ -55,7 +56,9 @@ class Expense
*/
public function addToTotal($add)
{
$this->total += floatval($add);
$add = strval(round($add, 2));
bcscale(2);
$this->total = bcadd($this->total, $add);
}
/**
@@ -73,10 +76,10 @@ class Expense
}
/**
* @return float
* @return string
*/
public function getTotal()
{
return $this->total;
return strval(round($this->total, 2));
}
}

View File

@@ -38,14 +38,15 @@ class Income
$accountId = $entry->account_id;
if (!$this->incomes->has($accountId)) {
$newObject = new stdClass;
$newObject->amount = floatval($entry->amount);
$newObject->amount = strval(round($entry->amount, 2));
$newObject->name = $entry->name;
$newObject->count = 1;
$newObject->id = $accountId;
$this->incomes->put($accountId, $newObject);
} else {
$existing = $this->incomes->get($accountId);
$existing->amount += floatval($entry->amount);
bcscale(2);
$existing = $this->incomes->get($accountId);
$existing->amount = bcadd($existing->amount, $entry->amount);
$existing->count++;
$this->incomes->put($accountId, $existing);
}
@@ -56,7 +57,9 @@ class Income
*/
public function addToTotal($add)
{
$this->total += floatval($add);
$add = strval(round($add, 2));
bcscale(2);
$this->total = bcadd($this->total, $add);
}
/**
@@ -78,7 +81,7 @@ class Income
*/
public function getTotal()
{
return $this->total;
return strval(round($this->total, 2));
}

View File

@@ -5,9 +5,11 @@ namespace FireflyIII\Helpers\Reminders;
use Amount;
use Auth;
use Carbon\Carbon;
use Config;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\Reminder;
use Navigation;
use Preferences;
/**
* Class ReminderHelper
@@ -154,14 +156,21 @@ class ReminderHelper implements ReminderHelperInterface
$piggyBank = $reminder->remindersable;
if (is_null($piggyBank)) {
return 'Piggy bank no longer exists.';
return trans('firefly.piggy_bank_not_exists');
}
if (is_null($piggyBank->targetdate)) {
return 'Add money to this piggy bank to reach your target of ' . Amount::format($piggyBank->targetamount);
return trans('firefly.add_any_amount_to_piggy', ['amount' => Amount::format($piggyBank->targetamount)]);
}
return 'Add ' . Amount::format($reminder->metadata->perReminder) . ' to fill this piggy bank on ' . $piggyBank->targetdate->format('jS F Y');
$lang = Preferences::get('language', 'en')->data;
return trans(
'firefly.add_set_amount_to_piggy',
[
'amount' => Amount::format($reminder->metadata->perReminder),
'date' => $piggyBank->targetdate->formatLocalized(Config::get('firefly.monthAndDay.' . $lang))
]
);
}
}

View File

@@ -4,7 +4,6 @@ namespace FireflyIII\Helpers\Reminders;
use Carbon\Carbon;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankRepetition;
use FireflyIII\Models\Reminder;
/**

View File

@@ -34,6 +34,7 @@ class ReportHelper implements ReportHelperInterface
/**
* @codeCoverageIgnore
*
* @param ReportQueryInterface $query
*
*/
@@ -64,11 +65,13 @@ class ReportHelper implements ReportHelperInterface
$diff = 0;
// remove cash account, if any:
$accounts =$accounts->filter(function(Account $account) {
if($account->accountType->type != 'Cash account') {
return $account;
}
});
$accounts = $accounts->filter(
function (Account $account) {
if ($account->accountType->type != 'Cash account') {
return $account;
}
} // @codeCoverageIgnore
);
// summarize:
foreach ($accounts as $account) {

View File

@@ -5,12 +5,10 @@ namespace FireflyIII\Helpers\Report;
use Auth;
use Carbon\Carbon;
use Crypt;
use DB;
use FireflyIII\Models\Account;
use FireflyIII\Models\Budget;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection;
use Steam;
@@ -74,7 +72,7 @@ class ReportQuery implements ReportQueryInterface
if ($journal->amount != 0) {
return $journal;
}
}
} // @codeCoverageIgnore
);
return $data;
@@ -138,7 +136,6 @@ class ReportQuery implements ReportQueryInterface
* This method returns all "income" journals in a certain period, which are both transfers from a shared account
* and "ordinary" deposits. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does
* not group and returns different fields.
*
* @param Carbon $start
* @param Carbon $end
@@ -191,7 +188,7 @@ class ReportQuery implements ReportQueryInterface
if ($journal->amount != 0) {
return $journal;
}
}
} // @codeCoverageIgnore
);
return $data;
@@ -237,13 +234,11 @@ class ReportQuery implements ReportQueryInterface
Auth::user()->transactionjournals()
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.amount', '<', 0)
->transactionTypes(['Withdrawal'])
->where('transactions.account_id', $account->id)
->before($end)
->after($start)
->whereNull('budget_transaction_journal.budget_id')
->sum('transactions.amount')
->whereNull('budget_transaction_journal.budget_id')->get(['transaction_journals.*'])->sum('amount')
);
}

View File

@@ -22,7 +22,7 @@ use View;
class AccountController extends Controller
{
/**
*
* @codeCoverageIgnore
*/
public function __construct()
{
@@ -39,13 +39,15 @@ class AccountController extends Controller
public function create($what = 'asset')
{
$subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what);
$subTitle = 'Create a new ' . e($what) . ' account';
$subTitle = trans('firefly.make_new_' . $what . '_account');
// put previous url in session if not redirect from store (not "create another").
if (Session::get('accounts.create.fromStore') !== true) {
Session::put('accounts.create.url', URL::previous());
}
Session::forget('accounts.create.fromStore');
Session::flash('gaEventCategory', 'accounts');
Session::flash('gaEventAction', 'create-' . $what);
return view('accounts.create', compact('subTitleIcon', 'what', 'subTitle'));
@@ -58,10 +60,13 @@ class AccountController extends Controller
*/
public function delete(Account $account)
{
$subTitle = 'Delete ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"';
$typeName = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type);
$subTitle = trans('firefly.delete_' . $typeName . '_account', ['name' => $account->name]);
// put previous url in session
Session::put('accounts.delete.url', URL::previous());
Session::flash('gaEventCategory', 'accounts');
Session::flash('gaEventAction', 'delete-' . $typeName);
return view('accounts.delete', compact('account', 'subTitle'));
}
@@ -81,7 +86,7 @@ class AccountController extends Controller
$repository->destroy($account);
Session::flash('success', 'The ' . e($typeName) . ' account "' . e($name) . '" was deleted.');
Session::flash('success', trans('firefly.' . $typeName . '_deleted', ['name' => $name]));
return Redirect::to(Session::get('accounts.delete.url'));
}
@@ -125,6 +130,8 @@ class AccountController extends Controller
'virtualBalance' => floatval($account->virtual_balance)
];
Session::flash('preFilled', $preFilled);
Session::flash('gaEventCategory', 'accounts');
Session::flash('gaEventAction', 'edit-' . $what);
return view('accounts.edit', compact('account', 'subTitle', 'subTitleIcon', 'openingBalance', 'what'));
}

View File

@@ -36,6 +36,8 @@ class PasswordController extends Controller
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
*
* @codeCoverageIgnore
*
*/
public function __construct(Guard $auth, PasswordBroker $passwords)
{

View File

@@ -3,7 +3,6 @@
use Config;
use FireflyIII\Http\Requests;
use FireflyIII\Http\Requests\BillFormRequest;
use FireflyIII\Models\Account;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
@@ -23,7 +22,7 @@ class BillController extends Controller
{
/**
*
* @codeCoverageIgnore
*/
public function __construct()
{
@@ -44,6 +43,8 @@ class BillController extends Controller
Session::put('bills.create.url', URL::previous());
}
Session::forget('bills.create.fromStore');
Session::flash('gaEventCategory', 'bills');
Session::flash('gaEventAction', 'create');
$subTitle = 'Create new bill';
return view('bills.create', compact('periods', 'subTitle'));
@@ -58,7 +59,9 @@ class BillController extends Controller
{
// put previous url in session
Session::put('bills.delete.url', URL::previous());
$subTitle = 'Delete "' . e($bill->name) . '"';
Session::flash('gaEventCategory', 'bills');
Session::flash('gaEventAction', 'delete');
$subTitle = trans('firefly.delete_bill', ['name' => $bill->name]);
return view('bills.delete', compact('bill', 'subTitle'));
}
@@ -94,6 +97,8 @@ class BillController extends Controller
Session::put('bills.edit.url', URL::previous());
}
Session::forget('bills.edit.fromUpdate');
Session::flash('gaEventCategory', 'bills');
Session::flash('gaEventAction', 'edit');
return view('bills.edit', compact('subTitle', 'periods', 'bill'));
}

View File

@@ -1,5 +1,6 @@
<?php namespace FireflyIII\Http\Controllers;
use Amount;
use Auth;
use Carbon\Carbon;
use FireflyIII\Http\Requests;
@@ -24,7 +25,7 @@ class BudgetController extends Controller
{
/**
*
* @codeCoverageIgnore
*/
public function __construct()
{
@@ -45,6 +46,9 @@ class BudgetController extends Controller
$amount = intval(Input::get('amount'));
$date = Session::get('start', Carbon::now()->startOfMonth());
$limitRepetition = $repository->updateLimitAmount($budget, $date, $amount);
if ($amount == 0) {
$limitRepetition = null;
}
return Response::json(['name' => $budget->name, 'repetition' => $limitRepetition ? $limitRepetition->id : 0]);
@@ -60,6 +64,8 @@ class BudgetController extends Controller
Session::put('budgets.create.url', URL::previous());
}
Session::forget('budgets.create.fromStore');
Session::flash('gaEventCategory', 'budgets');
Session::flash('gaEventAction', 'create');
$subTitle = trans('firefly.create_new_budget');
return view('budgets.create', compact('subTitle'));
@@ -72,10 +78,12 @@ class BudgetController extends Controller
*/
public function delete(Budget $budget)
{
$subTitle = 'Delete budget' . e($budget->name) . '"';
$subTitle = trans('firefly.delete_budget', ['name' => $budget->name]);
// put previous url in session
Session::put('budgets.delete.url', URL::previous());
Session::flash('gaEventCategory', 'budgets');
Session::flash('gaEventAction', 'delete');
return view('budgets.delete', compact('budget', 'subTitle'));
}
@@ -95,6 +103,7 @@ class BudgetController extends Controller
Session::flash('success', 'The budget "' . e($name) . '" was deleted.');
return Redirect::to(Session::get('budgets.delete.url'));
}
@@ -112,6 +121,8 @@ class BudgetController extends Controller
Session::put('budgets.edit.url', URL::previous());
}
Session::forget('budgets.edit.fromUpdate');
Session::flash('gaEventCategory', 'budgets');
Session::flash('gaEventAction', 'edit');
return view('budgets.edit', compact('budget', 'subTitle'));
@@ -126,7 +137,9 @@ class BudgetController extends Controller
{
$budgets = $repository->getActiveBudgets();
$inactive = $repository->getInactiveBudgets();
$spent = '0';
$budgeted = '0';
bcscale(2);
/**
* Do some cleanup:
*/
@@ -134,24 +147,27 @@ class BudgetController extends Controller
// loop the budgets:
$budgets->each(
function (Budget $budget) use ($repository) {
$date = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth());
$budget->spent = $repository->spentInPeriodCorrected($budget, $date, $end);
$budget->currentRep = $repository->getCurrentRepetition($budget, $date);
/** @var Budget $budget */
foreach ($budgets as $budget) {
$date = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth());
$budget->spent = $repository->spentInPeriodCorrected($budget, $date, $end);
$budget->currentRep = $repository->getCurrentRepetition($budget, $date);
if ($budget->currentRep) {
$budgeted = bcadd($budgeted, $budget->currentRep->amount);
}
$spent = bcadd($spent, $budget->spent);
}
$dateAsString = Session::get('start', Carbon::now()->startOfMonth())->format('FY');
$budgetIncomeTotal = Preferences::get('budgetIncomeTotal' . $dateAsString, 1000)->data;
$budgetMaximum = Preferences::get('budgetMaximum', 1000)->data;
$defaultCurrency = Amount::getDefaultCurrency();
return view(
'budgets.index', compact('budgetMaximum', 'budgetIncomeTotal', 'defaultCurrency', 'inactive', 'budgets', 'spent', 'budgeted')
);
$dateAsString = Session::get('start', Carbon::now()->startOfMonth())->format('FY');
$spent = $budgets->sum('spent');
$amount = Preferences::get('budgetIncomeTotal' . $dateAsString, 1000)->data;
$overspent = $spent > $amount;
$spentPCT = $overspent ? ceil($amount / $spent * 100) : ceil($spent / $amount * 100);
$budgetMax = Preferences::get('budgetMaximum', 1000);
$budgetMaximum = $budgetMax->data;
return view('budgets.index', compact('budgetMaximum', 'inactive', 'budgets', 'spent', 'spentPCT', 'overspent', 'amount'));
}
/**
@@ -164,7 +180,10 @@ class BudgetController extends Controller
$start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->startOfMonth());
$list = $repository->getWithoutBudget($start, $end);
$subTitle = 'Transactions without a budget between ' . $start->format('jS F Y') . ' and ' . $end->format('jS F Y');
$subTitle = trans(
'firefly.without_budget_between',
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
);
return view('budgets.noBudget', compact('list', 'subTitle'));
}
@@ -198,7 +217,11 @@ class BudgetController extends Controller
$journals = $repository->getJournals($budget, $repetition);
$limits = !is_null($repetition->id) ? [$repetition->budgetLimit] : $repository->getBudgetLimits($budget);
$subTitle = !is_null($repetition->id) ? e($budget->name) . ' in ' . $repetition->startdate->format('F Y') : e($budget->name);
$subTitle = !is_null($repetition->id)
?
trans('firefly.budget_in_month', ['name' => $budget->name, 'month' => $repetition->startdate->formatLocalized($this->monthFormat)])
:
e($budget->name);
$journals->setPath('/budgets/show/' . $budget->id);
return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle'));

View File

@@ -21,7 +21,7 @@ class CategoryController extends Controller
{
/**
*
* @codeCoverageIgnore
*/
public function __construct()
{
@@ -40,6 +40,8 @@ class CategoryController extends Controller
Session::put('categories.create.url', URL::previous());
}
Session::forget('categories.create.fromStore');
Session::flash('gaEventCategory', 'categories');
Session::flash('gaEventAction', 'create');
$subTitle = 'Create a new category';
return view('categories.create', compact('subTitle'));
@@ -52,10 +54,12 @@ class CategoryController extends Controller
*/
public function delete(Category $category)
{
$subTitle = 'Delete category "' . e($category->name) . '"';
$subTitle = trans('firefly.delete_category', ['name' => $category->name]);
// put previous url in session
Session::put('categories.delete.url', URL::previous());
Session::flash('gaEventCategory', 'categories');
Session::flash('gaEventAction', 'delete');
return view('categories.delete', compact('category', 'subTitle'));
}
@@ -91,6 +95,8 @@ class CategoryController extends Controller
Session::put('categories.edit.url', URL::previous());
}
Session::forget('categories.edit.fromUpdate');
Session::flash('gaEventCategory', 'categories');
Session::flash('gaEventAction', 'edit');
return view('categories.edit', compact('category', 'subTitle'));

View File

@@ -4,7 +4,6 @@ namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Models\Bill;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;

View File

@@ -33,7 +33,7 @@ class BudgetController extends Controller
$first = $repository->getFirstBudgetLimitDate($budget);
$range = $viewRange = Preferences::get('viewRange', '1M')->data;
$range = Preferences::get('viewRange', '1M')->data;
$last = Session::get('end', new Carbon);
$final = clone $last;
$final->addYears(2);

View File

@@ -6,8 +6,6 @@ namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Category;
use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\Preference;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use Grumpydictator\Gchart\GChart;
use Navigation;

View File

@@ -1,19 +1,10 @@
<?php
/**
* Created by PhpStorm.
* User: sander
* Date: 16/05/15
* Time: 09:36
*/
namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Models\Bill;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use Grumpydictator\Gchart\GChart;
use Illuminate\Support\Collection;

View File

@@ -24,7 +24,7 @@ abstract class Controller extends BaseController
protected $monthFormat;
/**
*
* @codeCoverageIgnore
*/
public function __construct()
{

View File

@@ -23,7 +23,7 @@ class CurrencyController extends Controller
/**
*
* @codeCoverageIgnore
*/
public function __construct()
{
@@ -45,6 +45,8 @@ class CurrencyController extends Controller
Session::put('currency.create.url', URL::previous());
}
Session::forget('currency.create.fromStore');
Session::flash('gaEventCategory', 'currency');
Session::flash('gaEventAction', 'create');
return view('currency.create', compact('subTitleIcon', 'subTitle'));
}
@@ -84,6 +86,8 @@ class CurrencyController extends Controller
// put previous url in session
Session::put('currency.delete.url', URL::previous());
Session::flash('gaEventCategory', 'currency');
Session::flash('gaEventAction', 'delete');
return view('currency.delete', compact('currency'));
@@ -127,6 +131,8 @@ class CurrencyController extends Controller
Session::put('currency.edit.url', URL::previous());
}
Session::forget('currency.edit.fromUpdate');
Session::flash('gaEventCategory', 'currency');
Session::flash('gaEventAction', 'edit');
return view('currency.edit', compact('currency', 'subTitle', 'subTitleIcon'));

View File

@@ -6,6 +6,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Input;
use Preferences;
use Redirect;
use Route;
use Session;
use Steam;
@@ -87,5 +88,78 @@ class HomeController extends Controller
return view('index', compact('count', 'title', 'savings', 'subTitle', 'mainTitleIcon', 'transactions', 'savingsTotal', 'piggyBankAccounts'));
}
/**
* @codeCoverageIgnore
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function routes()
{
$directory = '/vagrant_data/Sites/firefly-iii-help';
$languages = array_keys(Config::get('firefly.lang'));
$routes = [];
$ignored = [
'debugbar.openhandler', 'debugbar.assets.css', 'debugbar.assets.js', 'register', 'routes', 'daterange',
'flush', 'delete-account-post', 'change-password-post', 'logout', 'login', 'tags.hideTagHelp',
'budgets.postIncome', 'flush'
];
$ignoreMatch = ['.store', '.update', '.destroy', 'json.'];
$routeCollection = Route::getRoutes();
/** @var \Illuminate\Routing\Route $object */
foreach ($routeCollection as $object) {
// get name:
$name = $object->getName();
// has name and not in ignore list?
if (strlen($name) > 0 && !in_array($name, $ignored)) {
// not in ignoreMatch?
$continue = true;
foreach ($ignoreMatch as $ignore) {
$match = strpos($name, $ignore);
if (!($match === false)) {
$continue = false;
}
}
unset($ignore, $match);
if ($continue) {
$routes[] = $name;
// check all languages:
foreach ($languages as $lang) {
$file = $directory . '/' . $lang . '/' . $name . '.md';
if (!file_exists($file)) {
touch($file);
echo $name . '<br />';
}
}
}
}
}
// loop directories with language file.
// tag the ones not in the list of approved routes.
foreach ($languages as $lang) {
$dir = $directory . '/' . $lang;
$set = scandir($dir);
foreach ($set as $entry) {
if ($entry != '.' && $entry != '..') {
$name = str_replace('.md', '', $entry);
if (!in_array($name, $routes)) {
$file = $dir . '/' . $entry;
unlink($file);
}
}
}
}
echo 'Done!';
}
}

View File

@@ -5,7 +5,6 @@ use Carbon\Carbon;
use FireflyIII\Helpers\Report\ReportQueryInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Preference;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
@@ -123,11 +122,6 @@ class JsonController extends Controller
$start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth());
$amount = $reportQuery->incomeInPeriodCorrected($start, $end, true)->sum('amount');
// $amount = 0;
// foreach($set as $entry) {
// //echo $entry->description.' ('.$entry->tags->count().'): ' . $entry->amount."\n";
// $amount += $entry->amount;
// }
return Response::json(['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]);
}

View File

@@ -26,7 +26,7 @@ class PiggyBankController extends Controller
{
/**
*
* @codeCoverageIgnore
*/
public function __construct()
{
@@ -72,6 +72,8 @@ class PiggyBankController extends Controller
Session::put('piggy-banks.create.url', URL::previous());
}
Session::forget('piggy-banks.create.fromStore');
Session::flash('gaEventCategory', 'piggy-banks');
Session::flash('gaEventAction', 'create');
return view('piggy-banks.create', compact('accounts', 'periods', 'subTitle', 'subTitleIcon'));
}
@@ -83,10 +85,12 @@ class PiggyBankController extends Controller
*/
public function delete(PiggyBank $piggyBank)
{
$subTitle = 'Delete "' . e($piggyBank->name) . '"';
$subTitle = trans('firefly.delete_piggy_bank', ['name' => $piggyBank->name]);
// put previous url in session
Session::put('piggy-banks.delete.url', URL::previous());
Session::flash('gaEventCategory', 'piggy-banks');
Session::flash('gaEventAction', 'delete');
return view('piggy-banks.delete', compact('piggyBank', 'subTitle'));
}
@@ -118,7 +122,7 @@ class PiggyBankController extends Controller
$periods = Config::get('firefly.piggy_bank_periods');
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
$subTitle = 'Edit piggy bank "' . e($piggyBank->name) . '"';
$subTitle = trans('firefly.update_piggy_title', ['name' => $piggyBank->name]);
$subTitleIcon = 'fa-pencil';
/*
@@ -138,6 +142,8 @@ class PiggyBankController extends Controller
'remind_me' => intval($piggyBank->remind_me) == 1 && !is_null($piggyBank->reminder) ? true : false
];
Session::flash('preFilled', $preFilled);
Session::flash('gaEventCategory', 'piggy-banks');
Session::flash('gaEventAction', 'edit');
// put previous url in session if not redirect from store (not "return_to_edit").
if (Session::get('piggy-banks.edit.fromUpdate') !== true) {

View File

@@ -17,7 +17,7 @@ class PreferencesController extends Controller
{
/**
*
* @codeCoverageIgnore
*/
public function __construct()
{
@@ -38,8 +38,7 @@ class PreferencesController extends Controller
$viewRange = $viewRangePref->data;
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
$budgetMax = Preferences::get('budgetMaximum', 1000);
$languagePref = Preferences::get('language', 'en');
$language = $languagePref->data;
$language = Preferences::get('language', 'en')->data;
$budgetMaximum = $budgetMax->data;
return view('preferences.index', compact('budgetMaximum', 'language', 'accounts', 'frontPageAccounts', 'viewRange'));

View File

@@ -109,6 +109,8 @@ class ProfileController extends Controller
// DELETE!
Auth::user()->delete();
Session::flush();
Session::flash('gaEventCategory', 'user');
Session::flash('gaEventAction', 'delete-account');
return Redirect::route('index');
}

View File

@@ -3,10 +3,6 @@
use Carbon\Carbon;
use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\Budget;
use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Session;
use View;
@@ -23,6 +19,8 @@ class ReportController extends Controller
protected $helper;
/**
* @codeCoverageIgnore
*
* @param ReportHelperInterface $helper
*/
public function __construct(ReportHelperInterface $helper)
@@ -92,6 +90,10 @@ class ReportController extends Controller
$balance = $this->helper->getBalanceReport($start, $end, $shared);
$bills = $this->helper->getBillReport($start, $end, $shared);
Session::flash('gaEventCategory', 'report');
Session::flash('gaEventAction', 'month');
Session::flash('gaEventLabel', $start->format('F Y'));
return view(
'reports.month',
@@ -135,6 +137,10 @@ class ReportController extends Controller
$incomes = $this->helper->getIncomeReport($start, $end, $shared);
$expenses = $this->helper->getExpenseReport($start, $end, $shared);
Session::flash('gaEventCategory', 'report');
Session::flash('gaEventAction', 'year');
Session::flash('gaEventLabel', $start->format('Y'));
return view(
'reports.year',

View File

@@ -31,8 +31,11 @@ use View;
*/
class TagController extends Controller
{
public $tagOptions = [];
/**
*
* @codeCoverageIgnore
*/
public function __construct()
{
@@ -40,12 +43,12 @@ class TagController extends Controller
View::share('title', 'Tags');
View::share('mainTitleIcon', 'fa-tags');
View::share('hideTags', true);
$tagOptions = [
$this->tagOptions = [
'nothing' => 'Just a regular tag.',
'balancingAct' => 'The tag takes at most two transactions; an expense and a transfer. They\'ll balance each other out.',
'advancePayment' => 'The tag accepts one expense and any number of deposits aimed to repay the original expense.',
];
View::share('tagOptions', $tagOptions);
View::share('tagOptions', $this->tagOptions);
}
/**
@@ -67,6 +70,8 @@ class TagController extends Controller
Session::put('tags.create.url', URL::previous());
}
Session::forget('tags.create.fromStore');
Session::flash('gaEventCategory', 'tags');
Session::flash('gaEventAction', 'create');
return view('tags.create', compact('subTitle', 'subTitleIcon'));
}
@@ -78,10 +83,12 @@ class TagController extends Controller
*/
public function delete(Tag $tag)
{
$subTitle = 'Delete "' . e($tag->tag) . '"';
$subTitle = trans('firefly.delete_tag', ['name' => $tag->tag]);
// put previous url in session
Session::put('tags.delete.url', URL::previous());
Session::flash('gaEventCategory', 'tags');
Session::flash('gaEventAction', 'delete');
return view('tags.delete', compact('tag', 'subTitle'));
}
@@ -108,7 +115,7 @@ class TagController extends Controller
*
* @return View
*/
public function edit(Tag $tag)
public function edit(Tag $tag, TagRepositoryInterface $repository)
{
$subTitle = 'Edit tag "' . e($tag->tag) . '"';
$subTitleIcon = 'fa-tag';
@@ -116,67 +123,16 @@ class TagController extends Controller
/*
* Default tag options (again)
*/
$tagOptions = [
'nothing' => 'Just a regular tag.',
'balancingAct' => 'The tag takes at most two transactions; an expense and a transfer. They\'ll balance each other out.',
'advancePayment' => 'The tag accepts one expense and any number of deposits aimed to repay the original expense.',
];
$tagOptions = $this->tagOptions;
/*
* Can this tag become another type?
*/
$allowToAdvancePayment = true;
$allowToBalancingAct = true;
/*
* If this tag is a balancing act, and it contains transfers, it cannot be
* changes to an advancePayment.
*/
if ($tag->tagMode == 'balancingAct' || $tag->tagMode == 'nothing') {
foreach ($tag->transactionjournals as $journal) {
if ($journal->transactionType->type == 'Transfer') {
$allowToAdvancePayment = false;
}
}
}
/*
* If this tag contains more than one expenses, it cannot become an advance payment.
*/
$count = 0;
foreach ($tag->transactionjournals as $journal) {
if ($journal->transactionType->type == 'Withdrawal') {
$count++;
}
}
if ($count > 1) {
$allowToAdvancePayment = false;
}
/*
* If has more than two transactions already, cannot become a balancing act:
*/
if ($tag->transactionjournals->count() > 2) {
$allowToBalancingAct = false;
}
/*
* If any transaction is a deposit, cannot become a balancing act.
*/
$count = 0;
foreach ($tag->transactionjournals as $journal) {
if ($journal->transactionType->type == 'Deposit') {
$count++;
}
}
if ($count > 0) {
$allowToBalancingAct = false;
}
$allowAdvance = $repository->tagAllowAdvance($tag);
$allowToBalancingAct = $repository->tagAllowBalancing($tag);
// edit tag options:
if ($allowToAdvancePayment === false) {
if ($allowAdvance === false) {
unset($tagOptions['advancePayment']);
}
if ($allowToBalancingAct === false) {
@@ -189,6 +145,8 @@ class TagController extends Controller
Session::put('tags.edit.url', URL::previous());
}
Session::forget('tags.edit.fromUpdate');
Session::flash('gaEventCategory', 'tags');
Session::flash('gaEventAction', 'edit');
return view('tags.edit', compact('tag', 'subTitle', 'subTitleIcon', 'tagOptions'));
}

View File

@@ -26,6 +26,7 @@ use View;
class TransactionController extends Controller
{
/**
* @codeCoverageIgnore
*/
public function __construct()
{
@@ -61,6 +62,8 @@ class TransactionController extends Controller
Session::put('transactions.create.url', URL::previous());
}
Session::forget('transactions.create.fromStore');
Session::flash('gaEventCategory', 'transactions');
Session::flash('gaEventAction', 'create-' . $what);
asort($piggies);
@@ -78,10 +81,12 @@ class TransactionController extends Controller
public function delete(TransactionJournal $journal)
{
$type = strtolower($journal->transactionType->type);
$subTitle = 'Delete ' . e($type) . ' "' . e($journal->description) . '"';
$subTitle = trans('firefly.delete_' . $type, ['description' => $journal->description]);
// put previous url in session
Session::put('transactions.delete.url', URL::previous());
Session::flash('gaEventCategory', 'transactions');
Session::flash('gaEventAction', 'delete-' . $type);
return view('transactions.delete', compact('journal', 'subTitle'));
@@ -157,6 +162,8 @@ class TransactionController extends Controller
$preFilled['account_to_id'] = $transactions[0]->account->id;
Session::flash('preFilled', $preFilled);
Session::flash('gaEventCategory', 'transactions');
Session::flash('gaEventAction', 'edit-' . $what);
// put previous url in session if not redirect from store (not "return_to_edit").
if (Session::get('transactions.edit.fromUpdate') !== true) {

View File

@@ -37,8 +37,8 @@ class Kernel extends HttpKernel
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'FireflyIII\Http\Middleware\RedirectIfAuthenticated',
'range' => 'FireflyIII\Http\Middleware\Range',
'cleanup' => 'FireflyIII\Http\Middleware\Cleanup',
'reminders' => 'FireflyIII\Http\Middleware\Reminders',
'piggybanks' => 'FireflyIII\Http\Middleware\PiggyBanks',
];

View File

@@ -3,11 +3,10 @@
use App;
use Closure;
use Config;
use FireflyIII\Models\Preference;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request;
use Preferences;
use Carbon\Carbon;
/**
* Class Authenticate
*
@@ -55,6 +54,7 @@ class Authenticate
// if logged in, set user language:
$pref = Preferences::get('language', 'en');
App::setLocale($pref->data);
Carbon::setLocale($pref->data);
setlocale(LC_TIME, Config::get('firefly.locales.' . $pref->data));

View File

@@ -0,0 +1,224 @@
<?php namespace FireflyIII\Http\Middleware;
use Closure;
use FireflyIII\Models\Account;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\Preference;
use FireflyIII\Models\Reminder;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request;
use Session;
/**
* Class Cleanup
*
* @codeCoverageIgnore
* @package FireflyIII\Http\Middleware
*/
class Cleanup
{
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
*
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if ($this->auth->guest()) {
return response('Unauthorized.', 401);
}
$count = -1;
bcscale(0);
if (env('RUNCLEANUP') == 'true') {
$count = 0;
$count = bcadd($count, $this->encryptAccountAndBills());
$count = bcadd($count, $this->encryptBudgetsAndCategories());
$count = bcadd($count, $this->encryptPiggiesAndJournals());
$count = bcadd($count, $this->encryptRemindersAndPreferences());
}
if ($count == 0) {
Session::flash('warning', 'Please open the .env file and change RUNCLEANUP=true to RUNCLEANUP=false');
}
return $next($request);
}
/**
* @return int
*/
protected function encryptAccountAndBills()
{
$count = 0;
// encrypt account name
$set = Account::where('encrypted', 0)->take(5)->get();
/** @var Account $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
// encrypt bill name
$set = Bill::where('name_encrypted', 0)->take(5)->get();
/** @var Bill $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
// encrypt bill match
$set = Bill::where('match_encrypted', 0)->take(5)->get();
/** @var Bill $entry */
foreach ($set as $entry) {
$match = $entry->match;
$entry->match = $match;
$entry->save();
}
unset($set, $entry, $match);
return $count;
}
/**
* @return int
*/
protected function encryptBudgetsAndCategories()
{
$count = 0;
// encrypt budget name
$set = Budget::where('encrypted', 0)->take(5)->get();
/** @var Budget $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
// encrypt category name
$set = Category::where('encrypted', 0)->take(5)->get();
/** @var Category $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
return $count;
}
/**
* @return int
*/
protected function encryptPiggiesAndJournals()
{
$count = 0;
// encrypt piggy bank name
$set = PiggyBank::where('encrypted', 0)->take(5)->get();
/** @var PiggyBank $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
// encrypt transaction journal description
$set = TransactionJournal::where('encrypted', 0)->take(5)->get();
/** @var TransactionJournal $entry */
foreach ($set as $entry) {
$count++;
$description = $entry->description;
$entry->description = $description;
$entry->save();
}
unset($set, $entry, $description);
return $count;
}
/**
* @return int
*/
protected function encryptRemindersAndPreferences()
{
$count = 0;
// encrypt reminder metadata
$set = Reminder::where('encrypted', 0)->take(5)->get();
/** @var Reminder $entry */
foreach ($set as $entry) {
$count++;
$metadata = $entry->metadata;
$entry->metadata = $metadata;
$entry->save();
}
unset($set, $entry, $metadata);
//encrypt preference name
$set = Preference::whereNull('name_encrypted')->take(5)->get();
/** @var Preference $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
//encrypt preference data
$set = Preference::whereNull('data_encrypted')->take(5)->get();
/** @var Preference $entry */
foreach ($set as $entry) {
$count++;
$data = $entry->data;
$entry->data = $data;
$entry->save();
}
unset($set, $entry, $data);
return $count;
}
}

View File

@@ -1,70 +0,0 @@
<?php
namespace FireflyIII\Http\Middleware;
use Closure;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankRepetition;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
/**
* Class PiggyBanks
*
* @package FireflyIII\Http\Middleware
*/
class PiggyBanks
{
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
*
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if ($this->auth->check() && !$request->isXmlHttpRequest()) {
// get piggy banks without a repetition:
/** @var Collection $set */
$set = $this->auth->user()->piggybanks()
->leftJoin('piggy_bank_repetitions', 'piggy_banks.id', '=', 'piggy_bank_repetitions.piggy_bank_id')
->whereNull('piggy_bank_repetitions.id')
->get(['piggy_banks.id', 'piggy_banks.startdate', 'piggy_banks.targetdate']);
/** @var PiggyBank $partialPiggy */
foreach ($set as $partialPiggy) {
$repetition = new PiggyBankRepetition;
$repetition->piggyBank()->associate($partialPiggy);
$repetition->startdate = $partialPiggy->startdate;
$repetition->targetdate = $partialPiggy->targetdate;
$repetition->currentamount = 0;
$repetition->save();
}
unset($partialPiggy, $set, $repetition);
}
return $next($request);
}
}

View File

@@ -1,11 +1,4 @@
<?php
/**
* Created by PhpStorm.
* User: sander
* Date: 27/04/15
* Time: 12:50
*/
namespace FireflyIII\Http\Requests;
use Auth;

View File

@@ -1,7 +1,6 @@
<?php
use Carbon\Carbon;
use DaveJamesMiller\Breadcrumbs\Generator;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget;
@@ -71,7 +70,7 @@ Breadcrumbs::register(
$breadcrumbs->parent('accounts.show', $account);
$what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type);
$breadcrumbs->push(trans('breadcrumbs.edit_'.$what.'_account', ['name' => e($account->name)]), route('accounts.edit', $account->id));
$breadcrumbs->push(trans('breadcrumbs.edit_' . $what . '_account', ['name' => e($account->name)]), route('accounts.edit', $account->id));
}
);

View File

@@ -193,13 +193,14 @@ Route::controllers(
]
);
Route::get('/routes', ['uses' => 'HomeController@routes', 'as' => 'routes']);
/**
* Home Controller
*/
Route::group(
['middleware' => ['auth', 'range', 'reminders', 'piggybanks']], function () {
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
['middleware' => ['auth', 'range', 'reminders']], function () {
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index', 'middleware' => 'cleanup']);
Route::get('/home', ['uses' => 'HomeController@index', 'as' => 'home']);
Route::post('/daterange', ['uses' => 'HomeController@dateRange', 'as' => 'daterange']);
Route::get('/flush', ['uses' => 'HomeController@flush', 'as' => 'flush']);
@@ -370,7 +371,6 @@ Route::group(
* Report Controller
*/
Route::get('/reports', ['uses' => 'ReportController@index', 'as' => 'reports.index']);
//Route::get('/reports/{year}', ['uses' => 'ReportController@year', 'as' => 'reports.year'])->where(['year' => '[0-9]{4}']);
Route::get('/reports/{year}/{shared?}', ['uses' => 'ReportController@year', 'as' => 'reports.year'])->where(['year' => '[0-9]{4}', 'shared' => 'shared']);
Route::get('/reports/{year}/{month}/{shared?}', ['uses' => 'ReportController@month', 'as' => 'reports.month'])->where(
['year' => '[0-9]{4}', 'month' => '[0-9]{1,2}', 'shared' => 'shared']

View File

@@ -1,6 +1,5 @@
<?php namespace FireflyIII\Models;
use App;
use Crypt;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
@@ -18,6 +17,7 @@ class Account extends Model
use SoftDeletes, ValidatingTrait;
protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance'];
protected $hidden = ['virtual_balance_encrypted', 'encrypted'];
protected $rules
= [
'user_id' => 'required|exists:users,id',
@@ -50,12 +50,6 @@ class Account extends Model
}
// create it!
$account = Account::create($fields);
if (is_null($account->id)) {
// could not create account:
App::abort(500, 'Could not create new account with data: ' . json_encode($fields) . ' because ' . json_encode($account->getErrors()));
}
return $account;
@@ -117,6 +111,8 @@ class Account extends Model
*
* @param $fieldName
*
* @codeCoverageIgnore
*
* @return string|null
*/
public function getMeta($fieldName)
@@ -145,9 +141,7 @@ class Account extends Model
return Crypt::decrypt($value);
}
// @codeCoverageIgnoreStart
return $value;
// @codeCoverageIgnoreEnd
}
/**
@@ -203,6 +197,16 @@ class Account extends Model
$this->attributes['encrypted'] = true;
}
/**
* @param $value
*
* @codeCoverageIgnore
*/
public function setVirtualBalanceAttribute($value)
{
$this->attributes['virtual_balance'] = strval(round($value, 2));
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany

View File

@@ -4,6 +4,7 @@ use Crypt;
use Illuminate\Database\Eloquent\Model;
/**
* @codeCoverageIgnore
* Class Bill
*
* @package FireflyIII\Models
@@ -14,6 +15,8 @@ class Bill extends Model
protected $fillable
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active',];
protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];
/**
* @return array
*/
@@ -34,9 +37,7 @@ class Bill extends Model
return Crypt::decrypt($value);
}
// @codeCoverageIgnoreStart
return $value;
// @codeCoverageIgnoreEnd
}
/**
@@ -51,9 +52,23 @@ class Bill extends Model
return Crypt::decrypt($value);
}
// @codeCoverageIgnoreStart
return $value;
// @codeCoverageIgnoreEnd
}
/**
* @param $value
*/
public function setAmountMaxAttribute($value)
{
$this->attributes['amount_max'] = strval(round($value, 2));
}
/**
* @param $value
*/
public function setAmountMinAttribute($value)
{
$this->attributes['amount_min'] = strval(round($value, 2));
}
/**

View File

@@ -15,7 +15,8 @@ class Budget extends Model
use SoftDeletes;
protected $fillable = ['user_id', 'name'];
protected $fillable = ['user_id', 'name', 'active'];
protected $hidden = ['encrypted'];
/**
*
@@ -46,9 +47,7 @@ class Budget extends Model
return Crypt::decrypt($value);
}
// @codeCoverageIgnoreStart
return $value;
// @codeCoverageIgnoreEnd
}
/**

View File

@@ -11,6 +11,8 @@ use Illuminate\Database\Eloquent\Model;
class BudgetLimit extends Model
{
protected $hidden = ['amount_encrypted'];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
@@ -35,4 +37,12 @@ class BudgetLimit extends Model
return $this->hasMany('FireflyIII\Models\LimitRepetition');
}
/**
* @param $value
*/
public function setAmountAttribute($value)
{
$this->attributes['amount'] = strval(round($value, 2));
}
}

View File

@@ -1,6 +1,5 @@
<?php namespace FireflyIII\Models;
use App;
use Crypt;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -16,24 +15,7 @@ class Category extends Model
use SoftDeletes;
protected $fillable = ['user_id', 'name'];
/**
* @codeCoverageIgnore
* @return array
*/
public function getDates()
{
return ['created_at', 'updated_at', 'deleted_at'];
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function transactionjournals()
{
return $this->belongsToMany('FireflyIII\Models\TransactionJournal', 'category_transaction_journal', 'category_id');
}
protected $hidden = ['encrypted'];
/**
* @param array $fields
@@ -59,11 +41,6 @@ class Category extends Model
}
// create it!
$category = Category::create($fields);
if (is_null($category->id)) {
// could not create account:
App::abort(500, 'Could not create new category with data: ' . json_encode($fields));
}
return $category;
@@ -71,22 +48,11 @@ class Category extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return array
*/
public function user()
public function getDates()
{
return $this->belongsTo('FireflyIII\User');
}
/**
* @codeCoverageIgnore
*
* @param $value
*/
public function setNameAttribute($value)
{
$this->attributes['name'] = Crypt::encrypt($value);
$this->attributes['encrypted'] = true;
return ['created_at', 'updated_at', 'deleted_at'];
}
/**
@@ -106,4 +72,33 @@ class Category extends Model
return $value;
}
/**
* @codeCoverageIgnore
*
* @param $value
*/
public function setNameAttribute($value)
{
$this->attributes['name'] = Crypt::encrypt($value);
$this->attributes['encrypted'] = true;
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function transactionjournals()
{
return $this->belongsToMany('FireflyIII\Models\TransactionJournal', 'category_transaction_journal', 'category_id');
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('FireflyIII\User');
}
}

View File

@@ -1,19 +1,20 @@
<?php namespace FireflyIII\Models;
use Auth;
use DB;
use Illuminate\Database\Eloquent\Model;
/**
* Class LimitRepetition
*
* @codeCoverageIgnore
*
* @package FireflyIII\Models
*/
class LimitRepetition extends Model
{
protected $hidden = ['amount_encrypted'];
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function budgetLimit()
@@ -22,7 +23,6 @@ class LimitRepetition extends Model
}
/**
* @codeCoverageIgnore
* @return array
*/
public function getDates()
@@ -31,24 +31,11 @@ class LimitRepetition extends Model
}
/**
* @return float
* @param $value
*/
public function spentInRepetition()
public function setAmountAttribute($value)
{
$sum = DB::table('transactions')
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budget_transaction_journal.budget_id')
->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
->where('transaction_journals.date', '>=', $this->startdate->format('Y-m-d'))
->where('transaction_journals.date', '<=', $this->enddate->format('Y-m-d'))
->where('transaction_journals.user_id', Auth::user()->id)
->whereNull('transactions.deleted_at')
->where('transactions.amount', '>', 0)
->where('limit_repetitions.id', '=', $this->id)
->sum('transactions.amount');
return floatval($sum);
$this->attributes['amount'] = strval(round($value, 2));
}
}

View File

@@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class PiggyBank
*
* @codeCoverageIgnore
*
* @package FireflyIII\Models
*/
class PiggyBank extends Model
@@ -14,10 +16,10 @@ class PiggyBank extends Model
use SoftDeletes;
protected $fillable
= ['name', 'account_id', 'order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me'];
= ['name', 'account_id', 'order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me'];
protected $hidden = ['targetamount_encrypted', 'encrypted'];
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function account()
@@ -45,7 +47,6 @@ class PiggyBank extends Model
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggyBankRepetitions()
@@ -54,7 +55,6 @@ class PiggyBank extends Model
}
/**
* @codeCoverageIgnore
* @return array
*/
public function getDates()
@@ -63,48 +63,6 @@ class PiggyBank extends Model
}
/**
* @codeCoverageIgnore
*
* @param $value
*
* @return int
*/
public function getRemindMeAttribute($value)
{
return intval($value) == 1;
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggyBankEvents()
{
return $this->hasMany('FireflyIII\Models\PiggyBankEvent');
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
*/
public function reminders()
{
return $this->morphMany('FireflyIII\Models\Reminder', 'remindersable');
}
/**
* @codeCoverageIgnore
*
* @param $value
*/
public function setNameAttribute($value)
{
$this->attributes['name'] = Crypt::encrypt($value);
$this->attributes['encrypted'] = true;
}
/**
* @codeCoverageIgnore
*
* @param $value
*
@@ -117,8 +75,51 @@ class PiggyBank extends Model
return Crypt::decrypt($value);
}
// @codeCoverageIgnoreStart
return $value;
// @codeCoverageIgnoreEnd
}
/**
*
* @param $value
*
* @return int
*/
public function getRemindMeAttribute($value)
{
return intval($value) == 1;
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggyBankEvents()
{
return $this->hasMany('FireflyIII\Models\PiggyBankEvent');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
*/
public function reminders()
{
return $this->morphMany('FireflyIII\Models\Reminder', 'remindersable');
}
/**
*
* @param $value
*/
public function setNameAttribute($value)
{
$this->attributes['name'] = Crypt::encrypt($value);
$this->attributes['encrypted'] = true;
}
/**
* @param $value
*/
public function setTargetamountAttribute($value)
{
$this->attributes['targetamount'] = strval(round($value, 2));
}
}

View File

@@ -6,12 +6,14 @@ use Illuminate\Database\Eloquent\Model;
* Class PiggyBankEvent
*
* @codeCoverageIgnore
*
* @package FireflyIII\Models
*/
class PiggyBankEvent extends Model
{
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount'];
protected $hidden = ['amount_encrypted'];
/**
* @return array
@@ -29,6 +31,14 @@ class PiggyBankEvent extends Model
return $this->belongsTo('FireflyIII\Models\PiggyBank');
}
/**
* @param $value
*/
public function setAmountAttribute($value)
{
$this->attributes['amount'] = strval(round($value, 2));
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/

View File

@@ -14,6 +14,7 @@ class PiggyBankRepetition extends Model
{
protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount'];
protected $hidden = ['currentamount_encrypted'];
/**
* @return array
@@ -66,4 +67,12 @@ class PiggyBankRepetition extends Model
);
}
/**
* @param $value
*/
public function setCurrentamountAttribute($value)
{
$this->attributes['currentamount'] = strval(round($value, 2));
}
}

View File

@@ -1,5 +1,6 @@
<?php namespace FireflyIII\Models;
use Crypt;
use Illuminate\Database\Eloquent\Model;
/**
@@ -12,6 +13,7 @@ class Preference extends Model
{
protected $fillable = ['user_id', 'data', 'name'];
protected $hidden = ['data_encrypted', 'name_encrypted'];
/**
* @param $value
@@ -20,7 +22,12 @@ class Preference extends Model
*/
public function getDataAttribute($value)
{
return json_decode($value);
if (is_null($this->data_encrypted)) {
return json_decode($value);
}
$data = Crypt::decrypt($this->data_encrypted);
return json_decode($data);
}
/**
@@ -31,12 +38,37 @@ class Preference extends Model
return ['created_at', 'updated_at'];
}
/**
* @param $value
*
* @return float|int
*/
public function getNameAttribute($value)
{
if (is_null($this->name_encrypted)) {
return $value;
}
$value = Crypt::decrypt($this->name_encrypted);
return $value;
}
/**
* @param $value
*/
public function setDataAttribute($value)
{
$this->attributes['data'] = json_encode($value);
$this->attributes['data'] = '';
$this->attributes['data_encrypted'] = Crypt::encrypt(json_encode($value));
}
/**
* @param $value
*/
public function setNameAttribute($value)
{
$this->attributes['name_encrypted'] = Crypt::encrypt($value);
$this->attributes['name'] = $value;
}
/**

View File

@@ -8,6 +8,8 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class Reminder
*
* @codeCoverageIgnore
*
* @package FireflyIII\Models
*/
class Reminder extends Model
@@ -15,9 +17,9 @@ class Reminder extends Model
protected $fillable = ['user_id', 'startdate', 'metadata', 'enddate', 'active', 'notnow', 'remindersable_id', 'remindersable_type',];
protected $hidden = ['encrypted'];
/**
* @codeCoverageIgnore
*
* @param $value
*
@@ -29,7 +31,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
* @return array
*/
public function getDates()
@@ -38,7 +39,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
*
* @param $value
*
@@ -54,7 +54,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
*
* @param $value
*
@@ -66,7 +65,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
public function remindersable()
@@ -75,7 +73,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
*
* @param EloquentBuilder $query
* @param Carbon $start
@@ -89,7 +86,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
*
* @param EloquentBuilder $query
*
@@ -104,7 +100,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
*
* @param $value
*/
@@ -115,7 +110,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()

View File

@@ -2,7 +2,6 @@
namespace FireflyIII\Models;
use App;
use Crypt;
use Illuminate\Database\Eloquent\Model;
use Watson\Validating\ValidatingTrait;
@@ -57,12 +56,6 @@ class Tag extends Model
$fields['tagMode'] = 'nothing';
$fields['description'] = isset($fields['description']) && !is_null($fields['description']) ? $fields['description'] : '';
$tag = Tag::create($fields);
if (is_null($tag->id)) {
// could not create account:
App::abort(500, 'Could not create new tag with data: ' . json_encode($fields) . ' because ' . json_encode($tag->getErrors()));
}
return $tag;

View File

@@ -16,6 +16,7 @@ class Transaction extends Model
{
protected $fillable = ['account_id', 'transaction_journal_id', 'description', 'amount'];
protected $hidden = ['encrypted'];
protected $rules
= [
'account_id' => 'required|exists:accounts,id',
@@ -33,6 +34,24 @@ class Transaction extends Model
return $this->belongsTo('FireflyIII\Models\Account');
}
/**
* @param $value
*
* @return float|int
*/
public function getAmountAttribute($value)
{
return $value;
}
/**
* @return array
*/
public function getDates()
{
return ['created_at', 'updated_at', 'deleted_at'];
}
/**
* @param EloquentBuilder $query
* @param Carbon $date
@@ -56,11 +75,11 @@ class Transaction extends Model
}
/**
* @return array
* @param $value
*/
public function getDates()
public function setAmountAttribute($value)
{
return ['created_at', 'updated_at', 'deleted_at'];
$this->attributes['amount'] = strval(round($value, 2));
}
/**

View File

@@ -6,7 +6,6 @@ use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\JoinClause;
use Watson\Validating\ValidatingTrait;
/**
@@ -19,9 +18,9 @@ class TransactionJournal extends Model
use SoftDeletes, ValidatingTrait;
protected $fillable = ['user_id', 'transaction_type_id', 'bill_id', 'transaction_currency_id', 'description', 'completed', 'date', 'encrypted'];
protected $hidden = ['encrypted'];
protected $rules
= [
= [
'user_id' => 'required|exists:users,id',
'transaction_type_id' => 'required|exists:transaction_types,id',
'bill_id' => 'exists:bills,id',
@@ -60,15 +59,15 @@ class TransactionJournal extends Model
}
/**
* @return float
* @return string
*/
public function getActualAmountAttribute()
{
$amount = 0;
$amount = '0';
/** @var Transaction $t */
foreach ($this->transactions as $t) {
if ($t->amount > 0) {
$amount = floatval($t->amount);
$amount = $t->amount;
}
}
@@ -80,11 +79,12 @@ class TransactionJournal extends Model
*/
public function getAmountAttribute()
{
$amount = 0;
$amount = '0';
bcscale(2);
/** @var Transaction $t */
foreach ($this->transactions as $t) {
if ($t->amount > 0) {
$amount = floatval($t->amount);
$amount = $t->amount;
}
}
@@ -94,16 +94,16 @@ class TransactionJournal extends Model
if ($this->tags->count() == 0) {
return $amount;
}
// if journal is part of advancePayment AND journal is a withdrawal,
// then journal is being repaid by other journals, so the actual amount will lower:
/** @var Tag $advancePayment */
$advancePayment = $this->tags()->where('tagMode', 'advancePayment')->first();
if ($advancePayment && $this->transactionType->type == 'Withdrawal') {
// loop other deposits, remove from our amount.
$others = $advancePayment->transactionJournals()->transactionTypes(['Deposit'])->get();
foreach ($others as $other) {
$amount -= $other->actualAmount;
$amount = bcsub($amount, $other->actualAmount);
}
return $amount;
@@ -112,25 +112,24 @@ class TransactionJournal extends Model
// if this journal is part of an advancePayment AND the journal is a deposit,
// then the journal amount is correcting a withdrawal, and the amount is zero:
if ($advancePayment && $this->transactionType->type == 'Deposit') {
return 0;
return '0';
}
// is balancing act?
$balancingAct = $this->tags()->where('tagMode', 'balancingAct')->first();
if ($balancingAct) {
// this is the transfer
if ($balancingAct) {
// this is the expense:
if ($this->transactionType->type == 'Withdrawal') {
$transfer = $balancingAct->transactionJournals()->transactionTypes(['Transfer'])->first();
if ($transfer) {
$amount -= $transfer->actualAmount;
$amount = bcsub($amount, $transfer->actualAmount);
return $amount;
}
}
}
} // @codeCoverageIgnore
} // @codeCoverageIgnore
return $amount;
}
@@ -181,16 +180,16 @@ class TransactionJournal extends Model
*/
public function getCorrectedActualAmountAttribute()
{
$amount = 0;
$amount = '0';
$type = $this->transactionType->type;
/** @var Transaction $t */
foreach ($this->transactions as $t) {
if ($t->amount > 0 && $type != 'Withdrawal') {
$amount = floatval($t->amount);
$amount = $t->amount;
break;
}
if ($t->amount < 0 && $type == 'Withdrawal') {
$amount = floatval($t->amount);
$amount = $t->amount;
break;
}
}
@@ -223,6 +222,21 @@ class TransactionJournal extends Model
return $value;
}
/**
* @return Account
*/
public function getDestinationAccountAttribute()
{
/** @var Transaction $transaction */
foreach ($this->transactions()->get() as $transaction) {
if (floatval($transaction->amount) > 0) {
return $transaction->account;
}
}
return $this->transactions()->first()->account;
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
@@ -273,24 +287,6 @@ class TransactionJournal extends Model
return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
}
/**
* @codeCoverageIgnore
*
* @param EloquentBuilder $query
* @param $amount
*/
public function scopeLessThan(EloquentBuilder $query, $amount)
{
if (is_null($this->joinedTransactions)) {
$query->leftJoin(
'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
);
$this->joinedTransactions = true;
}
$query->where('transactions.amount', '<=', $amount);
}
/**
* @codeCoverageIgnore
*
@@ -304,24 +300,6 @@ class TransactionJournal extends Model
return $query->where('date', '=', $date->format('Y-m-d'));
}
/**
* Returns the account to which the money was moved.
*
* @codeCoverageIgnore
*
* @param EloquentBuilder $query
* @param Account $account
*/
public function scopeToAccountIs(EloquentBuilder $query, Account $account)
{
$query->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '>', 0);
}
);
$query->where('transactions.account_id', $account->id);
}
/**
* @codeCoverageIgnore
*

View File

@@ -6,6 +6,8 @@ use Illuminate\Support\ServiceProvider;
* Class AppServiceProvider
*
* @package FireflyIII\Providers
*
* @codeCoverageIgnore
*/
class AppServiceProvider extends ServiceProvider
{

View File

@@ -6,6 +6,8 @@ use Illuminate\Support\ServiceProvider;
/**
* Class BusServiceProvider
*
* @codeCoverageIgnore
*
* @package FireflyIII\Providers
*/
class BusServiceProvider extends ServiceProvider

View File

@@ -6,6 +6,8 @@ use Illuminate\Support\ServiceProvider;
* Class ConfigServiceProvider
*
* @package FireflyIII\Providers
* @codeCoverageIgnore
*
*/
class ConfigServiceProvider extends ServiceProvider
{
@@ -23,232 +25,7 @@ class ConfigServiceProvider extends ServiceProvider
*/
public function register()
{
config(
[
'twigbridge' => [
'twig' => [
/*
|--------------------------------------------------------------------------
| Extension
|--------------------------------------------------------------------------
|
| File extension for Twig view files.
|
*/
'extension' => 'twig',
/*
|--------------------------------------------------------------------------
| Accepts all Twig environment configuration options
|--------------------------------------------------------------------------
|
| http://twig.sensiolabs.org/doc/api.html#environment-options
|
*/
'environment' => [
// When set to true, the generated templates have a __toString() method
// that you can use to display the generated nodes.
// default: false
'debug' => config('app.debug', false),
// The charset used by the templates.
// default: utf-8
'charset' => 'utf-8',
// The base template class to use for generated templates.
// default: TwigBridge\Twig\Template
'base_template_class' => 'TwigBridge\Twig\Template',
// An absolute path where to store the compiled templates, or false to disable caching. If null
// then the cache file path is used.
// default: cache file storage path
'cache' => null,
// When developing with Twig, it's useful to recompile the template
// whenever the source code changes. If you don't provide a value
// for the auto_reload option, it will be determined automatically based on the debug value.
'auto_reload' => true,
// If set to false, Twig will silently ignore invalid variables
// (variables and or attributes/methods that do not exist) and
// replace them with a null value. When set to true, Twig throws an exception instead.
// default: false
'strict_variables' => false,
// If set to true, auto-escaping will be enabled by default for all templates.
// default: true
'autoescape' => true,
// A flag that indicates which optimizations to apply
// (default to -1 -- all optimizations are enabled; set it to 0 to disable)
'optimizations' => -1,
],
/*
|--------------------------------------------------------------------------
| Global variables
|--------------------------------------------------------------------------
|
| These will always be passed in and can be accessed as Twig variables.
| NOTE: these will be overwritten if you pass data into the view with the same key.
|
*/
'globals' => [],
],
'extensions' => [
/*
|--------------------------------------------------------------------------
| Extensions
|--------------------------------------------------------------------------
|
| Enabled extensions.
|
| `Twig_Extension_Debug` is enabled automatically if twig.debug is TRUE.
|
*/
'enabled' => [
'TwigBridge\Extension\Loader\Facades',
'TwigBridge\Extension\Loader\Filters',
'TwigBridge\Extension\Loader\Functions',
'TwigBridge\Extension\Laravel\Auth',
'TwigBridge\Extension\Laravel\Config',
'TwigBridge\Extension\Laravel\Dump',
'TwigBridge\Extension\Laravel\Input',
'TwigBridge\Extension\Laravel\Session',
'TwigBridge\Extension\Laravel\String',
'TwigBridge\Extension\Laravel\Translator',
'TwigBridge\Extension\Laravel\Url',
// 'TwigBridge\Extension\Laravel\Form',
// 'TwigBridge\Extension\Laravel\Html',
// 'TwigBridge\Extension\Laravel\Legacy\Facades',
],
/*
|--------------------------------------------------------------------------
| Facades
|--------------------------------------------------------------------------
|
| Available facades. Access like `{{ Config.get('foo.bar') }}`.
|
| Each facade can take an optional array of options. To mark the whole facade
| as safe you can set the option `'is_safe' => true`. Setting the facade as
| safe means that any HTML returned will not be escaped.
|
| It is advisable to not set the whole facade as safe and instead mark the
| each appropriate method as safe for security reasons. You can do that with
| the following syntax:
|
| <code>
| 'Form' => [
| 'is_safe' => [
| 'open'
| ]
| ]
| </code>
|
| The values of the `is_safe` array must match the called method on the facade
| in order to be marked as safe.
|
*/
'facades' => [
'Breadcrumbs' => [
'is_safe' => [
'renderIfExists'
]
],
'Session',
'Route',
'Auth',
'Lang',
'URL',
'Config',
'ExpandedForm' => [
'is_safe' => [
'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location',
'multiRadio'
]
],
'Form' => [
'is_safe' => [
'input', 'select', 'checkbox', 'model', 'open', 'radio', 'textarea'
]
],
],
/*
|--------------------------------------------------------------------------
| Functions
|--------------------------------------------------------------------------
|
| Available functions. Access like `{{ secure_url(...) }}`.
|
| Each function can take an optional array of options. These options are
| passed directly to `Twig_SimpleFunction`.
|
| So for example, to mark a function as safe you can do the following:
|
| <code>
| 'link_to' => [
| 'is_safe' => ['html']
| ]
| </code>
|
| The options array also takes a `callback` that allows you to name the
| function differently in your Twig templates than what it's actually called.
|
| <code>
| 'link' => [
| 'callback' => 'link_to'
| ]
| </code>
|
*/
'functions' => [
'elixir',
'head',
'last',
'old'
],
/*
|--------------------------------------------------------------------------
| Filters
|--------------------------------------------------------------------------
|
| Available filters. Access like `{{ variable|filter }}`.
|
| Each filter can take an optional array of options. These options are
| passed directly to `Twig_SimpleFilter`.
|
| So for example, to mark a filter as safe you can do the following:
|
| <code>
| 'studly_case' => [
| 'is_safe' => ['html']
| ]
| </code>
|
| The options array also takes a `callback` that allows you to name the
| filter differently in your Twig templates than what is actually called.
|
| <code>
| 'snake' => [
| 'callback' => 'snake_case'
| ]
| </code>
|
*/
'filters' => [],
],
]
]
);
}
}

View File

@@ -23,6 +23,7 @@ use Validator;
* Class FireflyServiceProvider
*
* @package FireflyIII\Providers
* @codeCoverageIgnore
*/
class FireflyServiceProvider extends ServiceProvider
{

View File

@@ -7,6 +7,7 @@ use Illuminate\Routing\Router;
* Class RouteServiceProvider
*
* @package FireflyIII\Providers
* @codeCoverageIgnore
*/
class RouteServiceProvider extends ServiceProvider
{

View File

@@ -8,6 +8,7 @@ use Illuminate\Support\ServiceProvider;
/**
* Class TestingServiceProvider
*
* @codeCoverageIgnore
* @package FireflyIII\Providers
*/
class TestingServiceProvider extends ServiceProvider

View File

@@ -287,7 +287,7 @@ class AccountRepository implements AccountRepositoryInterface
*/
public function getTransfersInRange(Account $account, Carbon $start, Carbon $end)
{
return TransactionJournal::whereIn(
$set = TransactionJournal::whereIn(
'id', function (Builder $q) use ($account, $start, $end) {
$q->select('transaction_journals.id')
->from('transactions')
@@ -297,11 +297,19 @@ class AccountRepository implements AccountRepositoryInterface
->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('transactions.amount', '>', 0)
->where('transaction_types.type', 'Transfer');
}
)->get();
$filtered = $set->filter(
function (TransactionJournal $journal) use ($account) {
if ($journal->destination_account->id == $account->id) {
return $journal;
}
} // @codeCoverageIgnore
);
return $filtered;
}
/**

View File

@@ -10,7 +10,6 @@ use FireflyIII\Models\AccountType;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection;
use Log;
use Navigation;
@@ -108,16 +107,10 @@ class BillRepository implements BillRepositoryInterface
public function getJournals(Bill $bill)
{
return $bill->transactionjournals()->withRelevantData()
->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.amount', '>', 0);
}
)
->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.order', 'ASC')
->orderBy('transaction_journals.id', 'DESC')
->get(['transaction_journals.*', 'transactions.amount']);
->get(['transaction_journals.*']);
}
/**

View File

@@ -250,9 +250,8 @@ class BudgetRepository implements BudgetRepositoryInterface
)
->after($start)
->before($end)
->lessThan(0)
->transactionTypes(['Withdrawal'])
->sum('transactions.amount');
->get(['transaction_journals.*'])->sum('amount');
return floatval($noBudgetSet) * -1;
}
@@ -269,13 +268,13 @@ class BudgetRepository implements BudgetRepositoryInterface
{
if ($shared === true) {
// get everything:
$sum = floatval($budget->transactionjournals()->before($end)->after($start)->lessThan(0)->get(['transaction_journals.*'])->sum('amount'));
$sum = floatval($budget->transactionjournals()->before($end)->after($start)->get(['transaction_journals.*'])->sum('amount'));
} else {
// get all journals in this month where the asset account is NOT shared.
$sum = $budget->transactionjournals()
->before($end)
->after($start)
->lessThan(0)
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin(
'account_meta', function (JoinClause $join) {
@@ -310,7 +309,6 @@ class BudgetRepository implements BudgetRepositoryInterface
}
/**
* @param Budget $budget
* @param array $data

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Repositories\Category;
use Auth;
use Carbon\Carbon;
use Crypt;
use DB;
use FireflyIII\Models\Category;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Database\Query\JoinClause;
@@ -86,7 +85,7 @@ class CategoryRepository implements CategoryRepositoryInterface
$result[$categoryId]['sum'] += floatval($entry->amount);
} else {
$isEncrypted = intval($entry->category_encrypted) == 1 ? true : false;
$name = strlen($entry->name) == 0 ? trans('firefly.noCategory') : $entry->name;
$name = strlen($entry->name) == 0 ? trans('firefly.no_category') : $entry->name;
$name = $isEncrypted ? Crypt::decrypt($name) : $name;
$result[$categoryId] = [
'name' => $name,
@@ -202,7 +201,7 @@ class CategoryRepository implements CategoryRepositoryInterface
->before($end)
->after($start)
->transactionTypes(['Withdrawal'])
->lessThan(0)
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin(
'account_meta', function (JoinClause $join) {

View File

@@ -76,15 +76,20 @@ class JournalRepository implements JournalRepositoryInterface
*/
public function getAmountBefore(TransactionJournal $journal, Transaction $transaction)
{
return floatval(
$transaction->account->transactions()->leftJoin(
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
)
->where('transaction_journals.date', '<=', $journal->date->format('Y-m-d'))
->where('transaction_journals.order', '>=', $journal->order)
->where('transaction_journals.id', '!=', $journal->id)
->sum('transactions.amount')
);
$set = $transaction->account->transactions()->leftJoin(
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
)
->where('transaction_journals.date', '<=', $journal->date->format('Y-m-d'))
->where('transaction_journals.order', '>=', $journal->order)
->where('transaction_journals.id', '!=', $journal->id)
->get(['transactions.*']);
$sum = 0;
foreach ($set as $entry) {
$sum += $entry->amount;
}
return $sum;
}
/**

View File

@@ -7,7 +7,6 @@ use Carbon\Carbon;
use DB;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\Models\PiggyBankRepetition;
use Illuminate\Support\Collection;
/**

View File

@@ -3,7 +3,6 @@
namespace FireflyIII\Repositories\PiggyBank;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankRepetition;
use Illuminate\Support\Collection;
/**
@@ -14,18 +13,6 @@ use Illuminate\Support\Collection;
interface PiggyBankRepositoryInterface
{
/**
* @return Collection
*/
public function getPiggyBanks();
/**
* @param PiggyBank $piggyBank
*
* @return Collection
*/
public function getEvents(PiggyBank $piggyBank);
/**
* @param PiggyBank $piggyBank
* @param $amount
@@ -34,6 +21,13 @@ interface PiggyBankRepositoryInterface
*/
public function createEvent(PiggyBank $piggyBank, $amount);
/**
* @param PiggyBank $piggyBank
*
* @return bool
*/
public function destroy(PiggyBank $piggyBank);
/**
* @param PiggyBank $piggyBank
*
@@ -44,9 +38,14 @@ interface PiggyBankRepositoryInterface
/**
* @param PiggyBank $piggyBank
*
* @return bool
* @return Collection
*/
public function destroy(PiggyBank $piggyBank);
public function getEvents(PiggyBank $piggyBank);
/**
* @return Collection
*/
public function getPiggyBanks();
/**
* Set all piggy banks to order 0.

View File

@@ -78,9 +78,13 @@ class TagRepository implements TagRepositoryInterface
/** @var Tag $tag */
foreach ($tags as $tag) {
$transfer = $tag->transactionjournals()->after($start)->before($end)->toAccountIs($account)->transactionTypes(['Transfer'])->first();
if ($transfer) {
$amount += $transfer->amount;
$journals = $tag->transactionjournals()->after($start)->before($end)->transactionTypes(['Transfer'])->get(['transaction_journals.*']);
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
if ($journal->destination_account->id == $account->id) {
$amount += $journal->amount;
}
}
}
@@ -139,6 +143,79 @@ class TagRepository implements TagRepositoryInterface
}
/**
* Can a tag become an advance payment?
*
* @param Tag $tag
*
* @return bool
*/
public function tagAllowAdvance(Tag $tag)
{
/*
* If this tag is a balancing act, and it contains transfers, it cannot be
* changes to an advancePayment.
*/
if ($tag->tagMode == 'balancingAct' || $tag->tagMode == 'nothing') {
foreach ($tag->transactionjournals as $journal) {
if ($journal->transactionType->type == 'Transfer') {
return false;
}
}
}
/*
* If this tag contains more than one expenses, it cannot become an advance payment.
*/
$count = 0;
foreach ($tag->transactionjournals as $journal) {
if ($journal->transactionType->type == 'Withdrawal') {
$count++;
}
}
if ($count > 1) {
return false;
}
return true;
}
/**
* Can a tag become a balancing act?
*
* @param Tag $tag
*
* @return bool
*/
public function tagAllowBalancing(Tag $tag)
{
/*
* If has more than two transactions already, cannot become a balancing act:
*/
if ($tag->transactionjournals->count() > 2) {
return false;
}
/*
* If any transaction is a deposit, cannot become a balancing act.
*/
$count = 0;
foreach ($tag->transactionjournals as $journal) {
if ($journal->transactionType->type == 'Deposit') {
$count++;
}
}
if ($count > 0) {
return false;
}
return true;
}
/**
* @param Tag $tag
* @param array $data

View File

@@ -18,6 +18,14 @@ interface TagRepositoryInterface
{
/**
* @param TransactionJournal $journal
* @param Tag $tag
*
* @return boolean
*/
public function connect(TransactionJournal $journal, Tag $tag);
/**
* This method scans the transaction journals from or to the given asset account
* and checks if these are part of a balancing act. If so, it will sum up the amounts
@@ -34,6 +42,18 @@ interface TagRepositoryInterface
*/
public function coveredByBalancingActs(Account $account, Carbon $start, Carbon $end);
/**
* @param Tag $tag
*
* @return boolean
*/
public function destroy(Tag $tag);
/**
* @return Collection
*/
public function get();
/**
* @param array $data
*
@@ -42,9 +62,22 @@ interface TagRepositoryInterface
public function store(array $data);
/**
* @return Collection
* Can a tag become an advance payment?
*
* @param Tag $tag
*
* @return bool
*/
public function get();
public function tagAllowAdvance(Tag $tag);
/**
* Can a tag become a balancing act?
*
* @param Tag $tag
*
* @return bool
*/
public function tagAllowBalancing(Tag $tag);
/**
* @param Tag $tag
@@ -53,19 +86,4 @@ interface TagRepositoryInterface
* @return Tag
*/
public function update(Tag $tag, array $data);
/**
* @param Tag $tag
*
* @return boolean
*/
public function destroy(Tag $tag);
/**
* @param TransactionJournal $journal
* @param Tag $tag
*
* @return boolean
*/
public function connect(TransactionJournal $journal, Tag $tag);
}

View File

@@ -232,15 +232,15 @@ class ExpandedForm
$fields = ['title', 'name', 'description'];
/** @var Eloquent $entry */
foreach ($set as $entry) {
$id = intval($entry->id);
$title = null;
$entryId = intval($entry->id);
$title = null;
foreach ($fields as $field) {
if (isset($entry->$field)) {
$title = $entry->$field;
}
}
$selectList[$id] = $title;
$selectList[$entryId] = $title;
}
return $selectList;

View File

@@ -261,18 +261,20 @@ class Navigation
public function periodShow(Carbon $date, $repeatFrequency)
{
$formatMap = [
'daily' => 'j F Y',
'week' => '\W\e\e\k W, Y',
'weekly' => '\W\e\e\k W, Y',
'quarter' => 'F Y',
'month' => 'F Y',
'monthly' => 'F Y',
'year' => 'Y',
'yearly' => 'Y',
'daily' => '%e %B %Y',
'week' => 'Week %W, %Y',
'weekly' => 'Week %W, %Y',
'quarter' => '%B %Y',
'month' => '%B %Y',
'monthly' => '%B %Y',
'year' => '%Y',
'yearly' => '%Y',
];
if (isset($formatMap[$repeatFrequency])) {
return $date->format($formatMap[$repeatFrequency]);
return $date->formatLocalized($formatMap[$repeatFrequency]);
}
throw new FireflyException('No date formats for frequency "' . $repeatFrequency . '"!');
}

View File

@@ -4,6 +4,7 @@ namespace FireflyIII\Support;
use Auth;
use FireflyIII\Models\Preference;
use Log;
/**
* Class Preferences
@@ -20,14 +21,19 @@ class Preferences
*/
public function get($name, $default = null)
{
$pref = Preference::where('user_id', Auth::user()->id)->where('name', $name)->first();
if (is_null($pref) && is_null($default)) {
$preferences = Preference::where('user_id', Auth::user()->id)->get();
/** @var Preference $preference */
foreach ($preferences as $preference) {
if ($preference->name == $name) {
return $preference;
}
}
// no preference found and default is null:
if (is_null($default)) {
// return NULL
return null;
}
if (!is_null($pref)) {
return $pref;
}
return $this->set($name, $default);
@@ -41,12 +47,20 @@ class Preferences
*/
public function set($name, $value)
{
$pref = Preference::where('user_id', Auth::user()->id)->where('name', $name)->first();
if (is_null($pref)) {
$pref = new Preference;
$pref->name = $name;
$preferences = Preference::where('user_id', Auth::user()->id)->get();
/** @var Preference $preference */
foreach ($preferences as $preference) {
if ($preference->name == $name) {
$preference->data = $value;
$preference->save();
return $preference;
}
}
$pref = new Preference;
$pref->name = $name;
$pref->data = $value;
if (!is_null(Auth::user()->id)) {
$pref->user()->associate(Auth::user());
$pref->save();

View File

@@ -34,16 +34,20 @@ class Steam
$firstDate = is_null($firstDateObject) ? clone $date : new Carbon($firstDateObject->date);
$date = $date < $firstDate ? $firstDate : $date;
$balance = floatval(
$account->transactions()->leftJoin(
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
)->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')
);
if (!$ignoreVirtualBalance) {
$balance += floatval($account->virtual_balance);
bcscale(2);
$set = $account->transactions()->leftJoin(
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
)->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->get(['transactions.*']);
$balance = '0';
foreach ($set as $entry) {
$balance = bcadd($balance, $entry->amount);
}
return $balance;
if (!$ignoreVirtualBalance) {
$balance = bcadd($balance, $account->virtual_balance);
}
return round($balance, 2);
}
/**

View File

@@ -3,7 +3,6 @@
namespace FireflyIII\Support\Twig;
use Auth;
use DB;
use FireflyIII\Models\LimitRepetition;
use Twig_Extension;
use Twig_SimpleFunction;
@@ -20,25 +19,6 @@ class Budget extends Twig_Extension
*/
public function getFunctions()
{
$functions[] = new Twig_SimpleFunction(
'spentInRepetition', function (LimitRepetition $repetition) {
$sum = DB::table('transactions')
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budget_transaction_journal.budget_id')
->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
->where('transaction_journals.date', '>=', $repetition->startdate->format('Y-m-d'))
->where('transaction_journals.date', '<=', $repetition->enddate->format('Y-m-d'))
->where('transaction_journals.user_id', Auth::user()->id)
->whereNull('transactions.deleted_at')
->where('transactions.amount', '>', 0)
->where('limit_repetitions.id', '=', $repetition->id)
->sum('transactions.amount');
return floatval($sum);
}
);
$functions[] = new Twig_SimpleFunction(
'spentInRepetitionCorrected', function (LimitRepetition $repetition) {
$sum

View File

@@ -84,7 +84,7 @@ class Journal extends Twig_Extension
if ($tag->tagMode == 'balancingAct') {
// return tag formatted for a "balancing act", even if other
// tags are present.
$amount = App::make('amount')->formatJournal($journal, false);
$amount = App::make('amount')->format($journal->actual_amount, false);
return '<a href="' . route('tags.show', $tag->id) . '" class="label label-success" title="' . $amount
. '"><i class="fa fa-fw fa-refresh"></i> ' . $tag->tag . '</a>';

View File

@@ -2,7 +2,6 @@
namespace FireflyIII\Support\Twig;
use FireflyIII\Models\LimitRepetition;
use Twig_Extension;
use Twig_SimpleFilter;

2
build/logs/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*.xml
*.json

View File

@@ -37,7 +37,9 @@
"phpspec/phpspec": "~2.1",
"satooshi/php-coveralls": "0.6.1",
"mockery/mockery": "0.9.*",
"league/factory-muffin": "~2.1"
"league/factory-muffin": "~2.1",
"codeclimate/php-test-reporter": "^0.1.2"
},

431
composer.lock generated
View File

@@ -1,10 +1,10 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at http://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"
],
"hash": "e3e90dd365b74f4878cf3b5b4a1c4007",
"hash": "5c085b2cc90ffa610e386897066315a7",
"packages": [
{
"name": "classpreloader/classpreloader",
@@ -943,16 +943,16 @@
},
{
"name": "laravel/framework",
"version": "v5.0.29",
"version": "v5.0.31",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "aa7046645e094b0134a4125cce6694f4b076ac62"
"reference": "db0a7400465df159ba8c6eaa954f97f50bc19687"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/aa7046645e094b0134a4125cce6694f4b076ac62",
"reference": "aa7046645e094b0134a4125cce6694f4b076ac62",
"url": "https://api.github.com/repos/laravel/framework/zipball/db0a7400465df159ba8c6eaa954f97f50bc19687",
"reference": "db0a7400465df159ba8c6eaa954f97f50bc19687",
"shasum": ""
},
"require": {
@@ -1065,7 +1065,7 @@
"framework",
"laravel"
],
"time": "2015-05-08 12:57:10"
"time": "2015-05-11 22:15:00"
},
{
"name": "league/commonmark",
@@ -1328,21 +1328,21 @@
},
{
"name": "nesbot/carbon",
"version": "1.18.0",
"version": "1.19.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "99e2f69f7bdc2cc4334b2d00f1e0ba450623ea36"
"reference": "68868e0b02d2d803d0052a59d4e5003cccf87320"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/99e2f69f7bdc2cc4334b2d00f1e0ba450623ea36",
"reference": "99e2f69f7bdc2cc4334b2d00f1e0ba450623ea36",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/68868e0b02d2d803d0052a59d4e5003cccf87320",
"reference": "68868e0b02d2d803d0052a59d4e5003cccf87320",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"symfony/translation": "2.6.*"
"symfony/translation": "~2.6"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
@@ -1371,7 +1371,7 @@
"datetime",
"time"
],
"time": "2015-03-26 03:05:57"
"time": "2015-05-09 03:23:44"
},
{
"name": "nikic/php-parser",
@@ -1529,21 +1529,21 @@
},
{
"name": "rcrowe/twigbridge",
"version": "0.7.x-dev",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/rcrowe/TwigBridge.git",
"reference": "ac0bfb5bcdb4fcd0cd01ab8425620ff07f6af026"
"reference": "0e2693d99745eb8bbd01a80e841951c0738e1d15"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/rcrowe/TwigBridge/zipball/ac0bfb5bcdb4fcd0cd01ab8425620ff07f6af026",
"reference": "ac0bfb5bcdb4fcd0cd01ab8425620ff07f6af026",
"url": "https://api.github.com/repos/rcrowe/TwigBridge/zipball/0e2693d99745eb8bbd01a80e841951c0738e1d15",
"reference": "0e2693d99745eb8bbd01a80e841951c0738e1d15",
"shasum": ""
},
"require": {
"illuminate/support": "5.0.*",
"illuminate/view": "5.0.*",
"illuminate/support": "5.0.*|5.1.*",
"illuminate/view": "5.0.*|5.1.*",
"php": ">=5.4.0",
"twig/twig": "~1.15"
},
@@ -1589,7 +1589,7 @@
"laravel",
"twig"
],
"time": "2015-04-22 09:19:03"
"time": "2015-05-21 13:46:00"
},
{
"name": "swiftmailer/swiftmailer",
@@ -1645,17 +1645,17 @@
},
{
"name": "symfony/console",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/Console",
"source": {
"type": "git",
"url": "https://github.com/symfony/Console.git",
"reference": "5b91dc4ed5eb08553f57f6df04c4730a73992667"
"reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Console/zipball/5b91dc4ed5eb08553f57f6df04c4730a73992667",
"reference": "5b91dc4ed5eb08553f57f6df04c4730a73992667",
"url": "https://api.github.com/repos/symfony/Console/zipball/ebc5679854aa24ed7d65062e9e3ab0b18a917272",
"reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272",
"shasum": ""
},
"require": {
@@ -1688,32 +1688,32 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Console Component",
"homepage": "http://symfony.com",
"time": "2015-03-30 15:54:10"
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
},
{
"name": "symfony/debug",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/Debug",
"source": {
"type": "git",
"url": "https://github.com/symfony/Debug.git",
"reference": "d49a46a20a8f0544aedac54466750ad787d3d3e3"
"reference": "ad4511a8fddce7ec163b513ba39a30ea4f32c9e7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Debug/zipball/d49a46a20a8f0544aedac54466750ad787d3d3e3",
"reference": "d49a46a20a8f0544aedac54466750ad787d3d3e3",
"url": "https://api.github.com/repos/symfony/Debug/zipball/ad4511a8fddce7ec163b513ba39a30ea4f32c9e7",
"reference": "ad4511a8fddce7ec163b513ba39a30ea4f32c9e7",
"shasum": ""
},
"require": {
@@ -1749,32 +1749,32 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Debug Component",
"homepage": "http://symfony.com",
"time": "2015-03-22 16:55:57"
"homepage": "https://symfony.com",
"time": "2015-05-08 13:17:44"
},
{
"name": "symfony/event-dispatcher",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/EventDispatcher",
"source": {
"type": "git",
"url": "https://github.com/symfony/EventDispatcher.git",
"reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284"
"reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/70f7c8478739ad21e3deef0d977b38c77f1fb284",
"reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284",
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/672593bc4b0043a0acf91903bb75a1c82d8f2e02",
"reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02",
"shasum": ""
},
"require": {
@@ -1808,32 +1808,32 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony EventDispatcher Component",
"homepage": "http://symfony.com",
"time": "2015-03-13 17:37:22"
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
},
{
"name": "symfony/filesystem",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/Filesystem",
"source": {
"type": "git",
"url": "https://github.com/symfony/Filesystem.git",
"reference": "4983964b3693e4f13449cb3800c64a9112c301b4"
"reference": "f73904bd2dae525c42ea1f0340c7c98480ecacde"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/4983964b3693e4f13449cb3800c64a9112c301b4",
"reference": "4983964b3693e4f13449cb3800c64a9112c301b4",
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/f73904bd2dae525c42ea1f0340c7c98480ecacde",
"reference": "f73904bd2dae525c42ea1f0340c7c98480ecacde",
"shasum": ""
},
"require": {
@@ -1858,32 +1858,32 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Filesystem Component",
"homepage": "http://symfony.com",
"time": "2015-03-22 16:55:57"
"homepage": "https://symfony.com",
"time": "2015-05-08 00:09:07"
},
{
"name": "symfony/finder",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/Finder",
"source": {
"type": "git",
"url": "https://github.com/symfony/Finder.git",
"reference": "5dbe2e73a580618f5b4880fda93406eed25de251"
"reference": "704c64c8b12c8882640d5c0330a8414b1e06dc99"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Finder/zipball/5dbe2e73a580618f5b4880fda93406eed25de251",
"reference": "5dbe2e73a580618f5b4880fda93406eed25de251",
"url": "https://api.github.com/repos/symfony/Finder/zipball/704c64c8b12c8882640d5c0330a8414b1e06dc99",
"reference": "704c64c8b12c8882640d5c0330a8414b1e06dc99",
"shasum": ""
},
"require": {
@@ -1908,32 +1908,32 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Finder Component",
"homepage": "http://symfony.com",
"time": "2015-03-30 15:54:10"
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
},
{
"name": "symfony/http-foundation",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/HttpFoundation",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpFoundation.git",
"reference": "8a6337233f08f7520de97f4ffd6f00e947d892f9"
"reference": "8a0d00980ef9f6b47ddbf24bdfbf70fead760816"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/8a6337233f08f7520de97f4ffd6f00e947d892f9",
"reference": "8a6337233f08f7520de97f4ffd6f00e947d892f9",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/8a0d00980ef9f6b47ddbf24bdfbf70fead760816",
"reference": "8a0d00980ef9f6b47ddbf24bdfbf70fead760816",
"shasum": ""
},
"require": {
@@ -1962,32 +1962,32 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony HttpFoundation Component",
"homepage": "http://symfony.com",
"time": "2015-04-01 16:50:12"
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
},
{
"name": "symfony/http-kernel",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/HttpKernel",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpKernel.git",
"reference": "3829cacfe21eaf3f73604a62d79183d1f6e792c4"
"reference": "2010194de0a57731af9404c7f97fd300db98b7a3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/3829cacfe21eaf3f73604a62d79183d1f6e792c4",
"reference": "3829cacfe21eaf3f73604a62d79183d1f6e792c4",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/2010194de0a57731af9404c7f97fd300db98b7a3",
"reference": "2010194de0a57731af9404c7f97fd300db98b7a3",
"shasum": ""
},
"require": {
@@ -2040,32 +2040,32 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony HttpKernel Component",
"homepage": "http://symfony.com",
"time": "2015-04-01 16:55:26"
"homepage": "https://symfony.com",
"time": "2015-05-11 01:58:49"
},
{
"name": "symfony/process",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/Process",
"source": {
"type": "git",
"url": "https://github.com/symfony/Process.git",
"reference": "a8bebaec1a9dc6cde53e0250e32917579b0be552"
"reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Process/zipball/a8bebaec1a9dc6cde53e0250e32917579b0be552",
"reference": "a8bebaec1a9dc6cde53e0250e32917579b0be552",
"url": "https://api.github.com/repos/symfony/Process/zipball/9f3c4baaf840ed849e1b1f7bfd5ae246e8509562",
"reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562",
"shasum": ""
},
"require": {
@@ -2090,32 +2090,32 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Process Component",
"homepage": "http://symfony.com",
"time": "2015-03-30 15:54:10"
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
},
{
"name": "symfony/routing",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/Routing",
"source": {
"type": "git",
"url": "https://github.com/symfony/Routing.git",
"reference": "4e173a645b63ff60a124f3741b4f15feebd908fa"
"reference": "1455ec537940f7428ea6aa9411f3c4bca69413a0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Routing/zipball/4e173a645b63ff60a124f3741b4f15feebd908fa",
"reference": "4e173a645b63ff60a124f3741b4f15feebd908fa",
"url": "https://api.github.com/repos/symfony/Routing/zipball/1455ec537940f7428ea6aa9411f3c4bca69413a0",
"reference": "1455ec537940f7428ea6aa9411f3c4bca69413a0",
"shasum": ""
},
"require": {
@@ -2153,28 +2153,28 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Routing Component",
"homepage": "http://symfony.com",
"homepage": "https://symfony.com",
"keywords": [
"router",
"routing",
"uri",
"url"
],
"time": "2015-03-30 15:54:10"
"time": "2015-05-02 15:18:45"
},
{
"name": "symfony/security-core",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/Security/Core",
"source": {
"type": "git",
@@ -2238,17 +2238,17 @@
},
{
"name": "symfony/translation",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/Translation",
"source": {
"type": "git",
"url": "https://github.com/symfony/Translation.git",
"reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af"
"reference": "398e0eedcb89243ad34a10d079a4b6ea4c0b61ff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Translation/zipball/bd939f05cdaca128f4ddbae1b447d6f0203b60af",
"reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af",
"url": "https://api.github.com/repos/symfony/Translation/zipball/398e0eedcb89243ad34a10d079a4b6ea4c0b61ff",
"reference": "398e0eedcb89243ad34a10d079a4b6ea4c0b61ff",
"shasum": ""
},
"require": {
@@ -2282,32 +2282,32 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Translation Component",
"homepage": "http://symfony.com",
"time": "2015-03-30 15:54:10"
"homepage": "https://symfony.com",
"time": "2015-05-05 16:51:00"
},
{
"name": "symfony/var-dumper",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/VarDumper",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "aafae00236e147568832de3c65ccb94cfc836278"
"reference": "89eec96645fb44af4a454a26c74c72ba6311f5bc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/aafae00236e147568832de3c65ccb94cfc836278",
"reference": "aafae00236e147568832de3c65ccb94cfc836278",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/89eec96645fb44af4a454a26c74c72ba6311f5bc",
"reference": "89eec96645fb44af4a454a26c74c72ba6311f5bc",
"shasum": ""
},
"require": {
@@ -2338,22 +2338,22 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony mechanism for exploring and dumping PHP variables",
"homepage": "http://symfony.com",
"homepage": "https://symfony.com",
"keywords": [
"debug",
"dump"
],
"time": "2015-03-31 08:12:29"
"time": "2015-05-01 14:14:24"
},
{
"name": "twig/extensions",
@@ -2517,29 +2517,29 @@
},
{
"name": "watson/validating",
"version": "1.0.0",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/dwightwatson/validating.git",
"reference": "9066ffd9342d1bf8a571d157df047e200a24e64a"
"reference": "47320813a45cc35384e72364484d54fe44dcd3fb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dwightwatson/validating/zipball/9066ffd9342d1bf8a571d157df047e200a24e64a",
"reference": "9066ffd9342d1bf8a571d157df047e200a24e64a",
"url": "https://api.github.com/repos/dwightwatson/validating/zipball/47320813a45cc35384e72364484d54fe44dcd3fb",
"reference": "47320813a45cc35384e72364484d54fe44dcd3fb",
"shasum": ""
},
"require": {
"illuminate/contracts": "~5.0",
"illuminate/database": "~5.0",
"illuminate/events": "~5.0",
"illuminate/support": "~5.0",
"illuminate/validation": "~5.0",
"illuminate/contracts": "5.0.*|5.1.*",
"illuminate/database": "5.0.*|5.1.*",
"illuminate/events": "5.0.*|5.1.*",
"illuminate/support": "5.0.*|5.1.*",
"illuminate/validation": "5.0.*|5.1.*",
"php": ">=5.4.0"
},
"require-dev": {
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "4.2.*"
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
@@ -2568,7 +2568,7 @@
"laravel",
"validation"
],
"time": "2015-03-17 10:52:36"
"time": "2015-05-23 00:03:54"
}
],
"packages-dev": [
@@ -2689,6 +2689,63 @@
],
"time": "2015-03-17 08:00:28"
},
{
"name": "codeclimate/php-test-reporter",
"version": "v0.1.2",
"source": {
"type": "git",
"url": "https://github.com/codeclimate/php-test-reporter.git",
"reference": "8ed24ff30f3663ecf40f1c12d6c97eb56c69e646"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/codeclimate/php-test-reporter/zipball/8ed24ff30f3663ecf40f1c12d6c97eb56c69e646",
"reference": "8ed24ff30f3663ecf40f1c12d6c97eb56c69e646",
"shasum": ""
},
"require": {
"ext-curl": "*",
"php": ">=5.3",
"satooshi/php-coveralls": "0.6.*",
"symfony/console": ">=2.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*@stable"
},
"bin": [
"composer/bin/test-reporter"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.1.x-dev"
}
},
"autoload": {
"psr-0": {
"CodeClimate\\Component": "src/",
"CodeClimate\\Bundle": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Code Climate",
"email": "hello@codeclimate.com",
"homepage": "https://codeclimate.com"
}
],
"description": "PHP client for reporting test coverage to Code Climate",
"homepage": "https://github.com/codeclimate/php-test-reporter",
"keywords": [
"codeclimate",
"coverage"
],
"time": "2014-07-23 13:42:41"
},
{
"name": "doctrine/instantiator",
"version": "1.0.4",
@@ -2888,16 +2945,16 @@
},
{
"name": "hamcrest/hamcrest-php",
"version": "v1.2.1",
"version": "v1.2.2",
"source": {
"type": "git",
"url": "https://github.com/hamcrest/hamcrest-php.git",
"reference": "ac50c470531243944f977b8de75be0b684a9cb51"
"reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/ac50c470531243944f977b8de75be0b684a9cb51",
"reference": "ac50c470531243944f977b8de75be0b684a9cb51",
"url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/b37020aa976fa52d3de9aa904aa2522dc518f79c",
"reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c",
"shasum": ""
},
"require": {
@@ -2929,7 +2986,7 @@
"keywords": [
"test"
],
"time": "2015-01-20 19:34:09"
"time": "2015-05-11 14:41:42"
},
{
"name": "league/factory-muffin",
@@ -4148,17 +4205,17 @@
},
{
"name": "symfony/class-loader",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/ClassLoader",
"source": {
"type": "git",
"url": "https://github.com/symfony/ClassLoader.git",
"reference": "861765b3e5f32979de5bd19ad2577cbb830a29d5"
"reference": "695134c9b39559297fa5d1dcff6a9054bb56facb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/861765b3e5f32979de5bd19ad2577cbb830a29d5",
"reference": "861765b3e5f32979de5bd19ad2577cbb830a29d5",
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/695134c9b39559297fa5d1dcff6a9054bb56facb",
"reference": "695134c9b39559297fa5d1dcff6a9054bb56facb",
"shasum": ""
},
"require": {
@@ -4184,32 +4241,32 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony ClassLoader Component",
"homepage": "http://symfony.com",
"time": "2015-03-27 10:19:51"
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
},
{
"name": "symfony/config",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/Config",
"source": {
"type": "git",
"url": "https://github.com/symfony/Config.git",
"reference": "d91be01336605db8da21b79bc771e46a7276d1bc"
"reference": "b6fddb4aa2daaa2b06f0040071ac131b4a1ecf25"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Config/zipball/d91be01336605db8da21b79bc771e46a7276d1bc",
"reference": "d91be01336605db8da21b79bc771e46a7276d1bc",
"url": "https://api.github.com/repos/symfony/Config/zipball/b6fddb4aa2daaa2b06f0040071ac131b4a1ecf25",
"reference": "b6fddb4aa2daaa2b06f0040071ac131b4a1ecf25",
"shasum": ""
},
"require": {
@@ -4235,32 +4292,32 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Config Component",
"homepage": "http://symfony.com",
"time": "2015-03-30 15:54:10"
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
},
{
"name": "symfony/stopwatch",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/Stopwatch",
"source": {
"type": "git",
"url": "https://github.com/symfony/Stopwatch.git",
"reference": "5f196e84b5640424a166d2ce9cca161ce1e9d912"
"reference": "b470f87c69837cb71115f1fa720388bb19b63635"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Stopwatch/zipball/5f196e84b5640424a166d2ce9cca161ce1e9d912",
"reference": "5f196e84b5640424a166d2ce9cca161ce1e9d912",
"url": "https://api.github.com/repos/symfony/Stopwatch/zipball/b470f87c69837cb71115f1fa720388bb19b63635",
"reference": "b470f87c69837cb71115f1fa720388bb19b63635",
"shasum": ""
},
"require": {
@@ -4285,32 +4342,32 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Stopwatch Component",
"homepage": "http://symfony.com",
"time": "2015-03-22 16:55:57"
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
},
{
"name": "symfony/yaml",
"version": "v2.6.6",
"version": "v2.6.7",
"target-dir": "Symfony/Component/Yaml",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
"reference": "174f009ed36379a801109955fc5a71a49fe62dd4"
"reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/174f009ed36379a801109955fc5a71a49fe62dd4",
"reference": "174f009ed36379a801109955fc5a71a49fe62dd4",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/f157ab074e453ecd4c0fa775f721f6e67a99d9e2",
"reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2",
"shasum": ""
},
"require": {
@@ -4335,18 +4392,18 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Yaml Component",
"homepage": "http://symfony.com",
"time": "2015-03-30 15:54:10"
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
}
],
"aliases": [],

223
config/twigbridge.php Normal file
View File

@@ -0,0 +1,223 @@
<?php
return [
'twig' => [
/*
|--------------------------------------------------------------------------
| Extension
|--------------------------------------------------------------------------
|
| File extension for Twig view files.
|
*/
'extension' => 'twig',
/*
|--------------------------------------------------------------------------
| Accepts all Twig environment configuration options
|--------------------------------------------------------------------------
|
| http://twig.sensiolabs.org/doc/api.html#environment-options
|
*/
'environment' => [
// When set to true, the generated templates have a __toString() method
// that you can use to display the generated nodes.
// default: false
'debug' => config('app.debug', false),
// The charset used by the templates.
// default: utf-8
'charset' => 'utf-8',
// The base template class to use for generated templates.
// default: TwigBridge\Twig\Template
'base_template_class' => 'TwigBridge\Twig\Template',
// An absolute path where to store the compiled templates, or false to disable caching. If null
// then the cache file path is used.
// default: cache file storage path
'cache' => null,
// When developing with Twig, it's useful to recompile the template
// whenever the source code changes. If you don't provide a value
// for the auto_reload option, it will be determined automatically based on the debug value.
'auto_reload' => true,
// If set to false, Twig will silently ignore invalid variables
// (variables and or attributes/methods that do not exist) and
// replace them with a null value. When set to true, Twig throws an exception instead.
// default: false
'strict_variables' => false,
// If set to true, auto-escaping will be enabled by default for all templates.
// default: true
'autoescape' => true,
// A flag that indicates which optimizations to apply
// (default to -1 -- all optimizations are enabled; set it to 0 to disable)
'optimizations' => -1,
],
/*
|--------------------------------------------------------------------------
| Global variables
|--------------------------------------------------------------------------
|
| These will always be passed in and can be accessed as Twig variables.
| NOTE: these will be overwritten if you pass data into the view with the same key.
|
*/
'globals' => [],
],
'extensions' => [
/*
|--------------------------------------------------------------------------
| Extensions
|--------------------------------------------------------------------------
|
| Enabled extensions.
|
| `Twig_Extension_Debug` is enabled automatically if twig.debug is TRUE.
|
*/
'enabled' => [
'TwigBridge\Extension\Loader\Facades',
'TwigBridge\Extension\Loader\Filters',
'TwigBridge\Extension\Loader\Functions',
'TwigBridge\Extension\Laravel\Auth',
'TwigBridge\Extension\Laravel\Config',
'TwigBridge\Extension\Laravel\Dump',
'TwigBridge\Extension\Laravel\Input',
'TwigBridge\Extension\Laravel\Session',
'TwigBridge\Extension\Laravel\String',
'TwigBridge\Extension\Laravel\Translator',
'TwigBridge\Extension\Laravel\Url',
// 'TwigBridge\Extension\Laravel\Form',
// 'TwigBridge\Extension\Laravel\Html',
// 'TwigBridge\Extension\Laravel\Legacy\Facades',
],
/*
|--------------------------------------------------------------------------
| Facades
|--------------------------------------------------------------------------
|
| Available facades. Access like `{{ Config.get('foo.bar') }}`.
|
| Each facade can take an optional array of options. To mark the whole facade
| as safe you can set the option `'is_safe' => true`. Setting the facade as
| safe means that any HTML returned will not be escaped.
|
| It is advisable to not set the whole facade as safe and instead mark the
| each appropriate method as safe for security reasons. You can do that with
| the following syntax:
|
| <code>
| 'Form' => [
| 'is_safe' => [
| 'open'
| ]
| ]
| </code>
|
| The values of the `is_safe` array must match the called method on the facade
| in order to be marked as safe.
|
*/
'facades' => [
'Breadcrumbs' => [
'is_safe' => [
'renderIfExists'
]
],
'Session',
'Route',
'Auth',
'Lang',
'URL',
'Config',
'ExpandedForm' => [
'is_safe' => [
'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location',
'multiRadio'
]
],
'Form' => [
'is_safe' => [
'input', 'select', 'checkbox', 'model', 'open', 'radio', 'textarea'
]
],
],
/*
|--------------------------------------------------------------------------
| Functions
|--------------------------------------------------------------------------
|
| Available functions. Access like `{{ secure_url(...) }}`.
|
| Each function can take an optional array of options. These options are
| passed directly to `Twig_SimpleFunction`.
|
| So for example, to mark a function as safe you can do the following:
|
| <code>
| 'link_to' => [
| 'is_safe' => ['html']
| ]
| </code>
|
| The options array also takes a `callback` that allows you to name the
| function differently in your Twig templates than what it's actually called.
|
| <code>
| 'link' => [
| 'callback' => 'link_to'
| ]
| </code>
|
*/
'functions' => [
'elixir',
'head',
'last',
'old'
],
/*
|--------------------------------------------------------------------------
| Filters
|--------------------------------------------------------------------------
|
| Available filters. Access like `{{ variable|filter }}`.
|
| Each filter can take an optional array of options. These options are
| passed directly to `Twig_SimpleFilter`.
|
| So for example, to mark a filter as safe you can do the following:
|
| <code>
| 'studly_case' => [
| 'is_safe' => ['html']
| ]
| </code>
|
| The options array also takes a `callback` that allows you to name the
| filter differently in your Twig templates than what is actually called.
|
| <code>
| 'snake' => [
| 'callback' => 'snake_case'
| ]
| </code>
|
*/
'filters' => [],
]
];

View File

@@ -0,0 +1,148 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
*
* Class ChangesForV3409
*/
class ChangesForV3409 extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// remove decryption, but this will destroy amounts.
Schema::table(
'accounts', function (Blueprint $table) {
$table->dropColumn('virtual_balance_encrypted');
}
);
Schema::table(
'bills', function (Blueprint $table) {
$table->dropColumn('amount_min_encrypted');
$table->dropColumn('amount_max_encrypted');
}
);
Schema::table(
'budget_limits', function (Blueprint $table) {
$table->dropColumn('amount_encrypted');
}
);
Schema::table(
'limit_repetitions', function (Blueprint $table) {
$table->dropColumn('amount_encrypted');
}
);
Schema::table(
'piggy_bank_events', function (Blueprint $table) {
$table->dropColumn('amount_encrypted');
}
);
Schema::table(
'piggy_bank_repetitions', function (Blueprint $table) {
$table->dropColumn('currentamount_encrypted');
}
);
Schema::table(
'piggy_banks', function (Blueprint $table) {
$table->dropColumn('targetamount_encrypted');
}
);
Schema::table(
'preferences', function (Blueprint $table) {
$table->dropColumn('name_encrypted');
$table->dropColumn('data_encrypted');
}
);
Schema::table(
'transactions', function (Blueprint $table) {
$table->dropColumn('amount_encrypted');
}
);
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// encrypt account virtual balance:
Schema::table(
'accounts', function (Blueprint $table) {
$table->string('virtual_balance_encrypted')->nullable()->after('virtual_balance');
}
);
// encrypt bill amount_min and amount_max:
Schema::table(
'bills', function (Blueprint $table) {
$table->string('amount_min_encrypted')->nullable()->after('amount_min');
$table->string('amount_max_encrypted')->nullable()->after('amount_max');
}
);
// encrypt budget limit amount
Schema::table(
'budget_limits', function (Blueprint $table) {
$table->string('amount_encrypted')->nullable()->after('amount');
}
);
// encrypt limit repetition amount
Schema::table(
'limit_repetitions', function (Blueprint $table) {
$table->string('amount_encrypted')->nullable()->after('amount');
}
);
// encrypt piggy bank event amount
Schema::table(
'piggy_bank_events', function (Blueprint $table) {
$table->string('amount_encrypted')->nullable()->after('amount');
}
);
// encrypt piggy bank repetition currentamount
Schema::table(
'piggy_bank_repetitions', function (Blueprint $table) {
$table->string('currentamount_encrypted')->nullable()->after('currentamount');
}
);
// encrypt piggy bank targetamount
Schema::table(
'piggy_banks', function (Blueprint $table) {
$table->string('targetamount_encrypted')->nullable()->after('targetamount');
}
);
// encrypt preference name (add field)
// encrypt preference data (add field)
Schema::table(
'preferences', function (Blueprint $table) {
$table->text('name_encrypted')->nullable()->after('name');
$table->text('data_encrypted')->nullable()->after('data');
}
);
// encrypt transaction amount
Schema::table(
'transactions', function (Blueprint $table) {
$table->string('amount_encrypted')->nullable()->after('amount');
}
);
}
}

View File

@@ -134,7 +134,9 @@ class TestDataSeeder extends Seeder
$acc_a = Account::create(['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Checking account', 'active' => 1]);
$acc_b = Account::create(['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Savings account', 'active' => 1]);
$acc_c = Account::create(['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Delete me', 'active' => 1]);
$acc_c = Account::create(
['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Delete me', 'active' => 1, 'virtual_balance' => 123.45]
);
// create account meta:
AccountMeta::create(['account_id' => $acc_a->id, 'name' => 'accountRole', 'data' => 'defaultAsset']);
@@ -514,27 +516,6 @@ class TestDataSeeder extends Seeder
return null;
}
/**
* @param $name
*
* @return PiggyBank|null
*/
protected function findPiggyBank($name)
{
// account
$user = User::whereEmail('thegrumpydictator@gmail.com')->first();
/** @var Budget $budget */
foreach (PiggyBank::get() as $piggyBank) {
$account = $piggyBank->account()->first();
if ($piggyBank->name == $name && $user->id == $account->user_id) {
return $piggyBank;
break;
}
}
return null;
}
/**
* @param $name
*
@@ -680,5 +661,26 @@ class TestDataSeeder extends Seeder
);
}
/**
* @param $name
*
* @return PiggyBank|null
*/
protected function findPiggyBank($name)
{
// account
$user = User::whereEmail('thegrumpydictator@gmail.com')->first();
/** @var Budget $budget */
foreach (PiggyBank::get() as $piggyBank) {
$account = $piggyBank->account()->first();
if ($piggyBank->name == $name && $user->id == $account->user_id) {
return $piggyBank;
break;
}
}
return null;
}
}

View File

@@ -1,3 +1,4 @@
/* globals require */
var elixir = require('laravel-elixir');
/*
@@ -12,5 +13,6 @@ var elixir = require('laravel-elixir');
*/
elixir(function(mix) {
"use strict";
mix.less('app.less');
});

View File

@@ -22,7 +22,7 @@
<!-- code coverage -->
<logging>
<log type="coverage-clover" target="./storage/coverage/clover.xml" charset="UTF-8" />
<log type="coverage-clover" target="./build/logs/clover.xml" charset="UTF-8" />
</logging>
<php>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,11 +1,23 @@
$(function () {
/* global $ */
// Return a helper with preserved width of cells
var fixHelper = function (e, ui) {
"use strict";
ui.children().each(function () {
$(this).width($(this).width());
});
return ui;
};
$(function () {
"use strict";
if (typeof(googleLineChart) === "function" && typeof accountID !== 'undefined') {
googleLineChart('chart/account/' + accountID, 'overview-chart');
}
// sortable!
if (typeof $(".sortable-table tbody").sortable != "undefined") {
if (typeof $(".sortable-table tbody").sortable !== "undefined") {
$(".sortable-table tbody").sortable(
{
helper: fixHelper,
@@ -19,23 +31,14 @@ $(function () {
});
// Return a helper with preserved width of cells
var fixHelper = function (e, ui) {
ui.children().each(function () {
$(this).width($(this).width());
});
return ui;
};
function sortStop(event, ui) {
"use strict";
var current = $(ui.item);
var thisDate = current.data('date');
var originalBG = current.css('backgroundColor');
if (current.prev().data('date') != thisDate && current.next().data('date') != thisDate) {
//console.log('False!');
//console.log('[' + current.prev().data('date') + '] [' + thisDate + '] [' + current.next().data('date') + ']');
if (current.prev().data('date') !== thisDate && current.next().data('date') !== thisDate) {
// animate something with color:
current.animate({
backgroundColor: "#d9534f"
@@ -59,10 +62,6 @@ function sortStop(event, ui) {
// do extra animation when done?
$.post('/transaction/reorder', {items: submit, date: thisDate, _token: token});
console.log(submit);
//console.log('TRUE!');
//console.log('[' + current.prev().data('date') + '] [' + thisDate + '] [' + current.next().data('date') + ']');
current.animate({
backgroundColor: "#5cb85c"

View File

@@ -1,7 +1,9 @@
$(document).ready(function () {
/* global googleComboChart, billID */
if (typeof(googleComboChart) === 'function' && typeof(billID) !== 'undefined') {
googleComboChart('chart/bill/' + billID, 'bill-overview');
}
}
$(document).ready(function () {
"use strict";
if (typeof(googleComboChart) === 'function' && typeof(billID) !== 'undefined') {
googleComboChart('chart/bill/' + billID, 'bill-overview');
}
}
);

View File

@@ -1,12 +1,104 @@
/* globals $, budgeted:false, currencySymbol, budgetIncomeTotal ,budgetedMuch, budgetedPercentage, token, budgetID, repetitionID, spent, budgeted*/
function drawSpentBar() {
"use strict";
var overspent = spent > budgeted;
var pct;
if (overspent) {
// draw overspent bar
pct = (budgeted / spent) * 100;
$('.spentBar .progress-bar-warning').css('width', pct + '%');
$('.spentBar .progress-bar-danger').css('width', (100 - pct) + '%');
} else {
// draw normal bar:
pct = (spent / budgeted) * 100;
$('.spentBar .progress-bar-info').css('width', pct + '%');
}
}
function drawBudgetedBar() {
"use strict";
var budgetedMuch = budgeted > budgetIncomeTotal;
// recalculate percentage:
var pct;
if (budgetedMuch) {
// budgeted too much.
pct = (budgetIncomeTotal / budgeted) * 100;
$('.budgetedBar .progress-bar-warning').css('width', pct + '%');
$('.budgetedBar .progress-bar-danger').css('width', (100 - pct) + '%');
$('.budgetedBar .progress-bar-info').css('width', 0);
} else {
pct = (budgeted / budgetIncomeTotal) * 100;
$('.budgetedBar .progress-bar-warning').css('width', 0);
$('.budgetedBar .progress-bar-danger').css('width', 0);
$('.budgetedBar .progress-bar-info').css('width', pct + '%');
}
$('#budgetedAmount').html(currencySymbol + ' ' + budgeted.toFixed(2));
}
function updateBudgetedAmounts(e) {
"use strict";
var target = $(e.target);
var id = target.data('id');
var value = target.val();
var original = target.data('original');
var difference = value - original;
if (difference !== 0) {
// add difference to 'budgeted' var
budgeted = budgeted + difference;
// update original:
target.data('original', value);
// run drawBudgetedBar() again:
drawBudgetedBar();
// send a post to Firefly to update the amount:
$.post('budgets/amount/' + id, {amount: value, _token: token}).success(function (data) {
// update the link if relevant:
if (data.repetition > 0) {
$('.budget-link[data-id="' + id + '"]').attr('href', 'budgets/show/' + id + '/' + data.repetition);
} else {
$('.budget-link[data-id="' + id + '"]').attr('href', 'budgets/show/' + id);
}
});
}
console.log('Budget id is ' + id);
console.log('Difference = ' + (value - original ));
}
$(function () {
updateRanges();
//$('input[type="range"]').change(updateSingleRange);
$('input[type="range"]').on('input', updateSingleRange);
//$('input[type="number"]').on('change', updateSingleRange);
$('input[type="number"]').on('input', updateSingleRange);
"use strict";
$('.updateIncome').on('click', updateIncome);
/*
On start, fill the "spent"-bar using the content from the page.
*/
drawSpentBar();
drawBudgetedBar();
/*
When the input changes, update the percentages for the budgeted bar:
*/
$('input[type="number"]').on('input', updateBudgetedAmounts);
//updateRanges();
//$('input[type="range"]').on('input', updateSingleRange);
//$('input[type="number"]').on('input', updateSingleRange);
/*
Draw the charts, if necessary:
*/
if (typeof budgetID !== 'undefined' && typeof repetitionID === 'undefined') {
googleColumnChart('chart/budget/' + budgetID, 'budgetOverview');
}
@@ -17,139 +109,138 @@ $(function () {
});
function updateSingleRange(e) {
// get some values:
var input = $(e.target);
var id = input.data('id');
var value = parseInt(input.val());
var spent = parseFloat($('#spent-' + id).data('value'));
// update small display:
if (value > 0) {
// show the input:
$('#budget-info-' + id + ' span').show();
$('#budget-info-' + id + ' input').show();
// update the text:
$('#budget-description-' + id).text('Budgeted: ');
} else {
// hide the input:
$('#budget-info-' + id + ' span').hide();
$('#budget-info-' + id + ' input').hide();
// update the text:
$('#budget-description-' + id).html('<em>No budget</em>');
}
// update the range display text:
$('#budget-range-display-' + id).text('\u20AC ' + value.toFixed(2));
// send a post to Firefly to update the amount:
$.post('budgets/amount/' + id, {amount: value, _token: token}).success(function (data) {
// update the link if relevant:
$('#budget-link-' + id).attr('href', 'budgets/show/' + id + '/' + data.repetition);
});
if (input.attr('type') == 'number') {
// update the range-input:
$('#budget-range-' + id).val(value);
} else {
// update the number-input:
$('#budget-info-' + id + ' input').val(value);
}
// update or hide the bar, whichever is necessary.
updateTotal();
return value;
}
function updateTotal() {
var sum = 0;
$('input[type="range"]').each(function (i, v) {
// get some values:
sum += parseInt($(v).val());
});
/**
* Update total sum:
*/
var totalAmount = parseInt($('#totalAmount').data('value'));
var pct;
if (sum <= totalAmount) {
pct = sum / totalAmount * 100;
$('#progress-bar-default').css('width', pct + '%');
$('#progress-bar-warning').css('width', '0');
$('#progress-bar-danger').css('width', '0');
$('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-success').removeClass('text-danger');
} else {
// we gaan er X overheen,
pct = totalAmount / sum * 100;
var danger = 100 - pct;
var err = 100 - danger;
$('#progress-bar-default').css('width', 0);
$('#progress-bar-warning').css('width', err + '%');
$('#progress-bar-danger').css('width', danger + '%');
$('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-danger').removeClass('text-success');
}
}
function updateIncome(e) {
//function updateSingleRange(e) {
// "use strict";
// // get some values:
// var input = $(e.target);
// var id = input.data('id');
// var value = parseInt(input.val());
// var spent = parseFloat($('#spent-' + id).data('value'));
//
// // update small display:
// if (value > 0) {
// // show the input:
// $('#budget-info-' + id + ' span').show();
// $('#budget-info-' + id + ' input').show();
//
// // update the text:
// $('#budget-description-' + id).text('Budgeted: ');
// } else {
// // hide the input:
// $('#budget-info-' + id + ' span').hide();
// $('#budget-info-' + id + ' input').hide();
//
// // update the text:
// $('#budget-description-' + id).html('<em>No budget</em>');
// }
//
// // update the range display text:
// $('#budget-range-display-' + id).text('\u20AC ' + value.toFixed(2));
//
// // send a post to Firefly to update the amount:
// $.post('budgets/amount/' + id, {amount: value, _token: token}).success(function (data) {
// // update the link if relevant:
// $('#budget-link-' + id).attr('href', 'budgets/show/' + id + '/' + data.repetition);
// });
// if (input.attr('type') === 'number') {
// // update the range-input:
// $('#budget-range-' + id).val(value);
// } else {
// // update the number-input:
// $('#budget-info-' + id + ' input').val(value);
// }
//
// // update or hide the bar, whichever is necessary.
// updateTotal();
// return value;
//}
//
//function updateTotal() {
// "use strict";
// var sum = 0;
// $('input[type="range"]').each(function (i, v) {
// // get some values:
// sum += parseInt($(v).val());
// });
//
// /**
// * Update total sum:
// */
// var totalAmount = parseInt($('#totalAmount').data('value'));
// var pct;
// if (sum <= totalAmount) {
// pct = sum / totalAmount * 100;
// $('#progress-bar-default').css('width', pct + '%');
// $('#progress-bar-warning').css('width', '0');
// $('#progress-bar-danger').css('width', '0');
// $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-success').removeClass('text-danger');
// } else {
// // we gaan er X overheen,
//
// pct = totalAmount / sum * 100;
// var danger = 100 - pct;
// var err = 100 - danger;
// $('#progress-bar-default').css('width', 0);
// $('#progress-bar-warning').css('width', err + '%');
// $('#progress-bar-danger').css('width', danger + '%');
// $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-danger').removeClass('text-success');
// }
//
//}
//
function updateIncome() {
"use strict";
$('#monthlyBudgetModal').empty().load('budgets/income', function () {
$('#monthlyBudgetModal').modal('show');
});
return false;
}
function updateRanges() {
/**
* Update all ranges.
*/
var sum = 0;
$('input[type="range"]').each(function (i, v) {
// get some values:
var input = $(v);
var id = input.data('id');
var value = parseInt(input.val());
// calculate sum:
sum += value;
// update small display:
$('#budget-range-display-' + id).text('\u20AC ' + value.toFixed(2));
// update progress bar (if relevant)
var barHolder = $('#budget-progress-' + id);
var spent = parseFloat(barHolder.data('spent'));
// send a post to Firefly to update the amount:
$.post('budgets/amount/' + id, {amount: value, _token: token}).success(function (data) {
});
});
/**
* Update total sum:
*/
var totalAmount = parseInt($('#totalAmount').data('value'));
if (sum <= totalAmount) {
var pct = sum / totalAmount * 100;
$('#progress-bar-default').css('width', pct + '%');
$('#progress-bar-warning').css('width', '0');
$('#progress-bar-danger').css('width', '0');
$('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-success').removeClass('text-danger');
} else {
// we gaan er X overheen,
var pct = totalAmount / sum * 100;
var danger = 100 - pct;
var err = 100 - danger;
$('#progress-bar-default').css('width', 0);
$('#progress-bar-warning').css('width', err + '%');
$('#progress-bar-danger').css('width', danger + '%');
$('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-danger').removeClass('text-success');
}
}
//
//function updateRanges() {
// "use strict";
//
//
// var sum = 0;
// $('input[type="range"]').each(function (i, v) {
// // get some values:
// var input = $(v);
// var id = input.data('id');
// var value = parseInt(input.val());
//
// // calculate sum:
// sum += value;
//
// // update small display:
// $('#budget-range-display-' + id).text('\u20AC ' + value.toFixed(2));
//
// // send a post to Firefly to update the amount:
// $.post('budgets/amount/' + id, {amount: value, _token: token});
//
// });
//
// /**
// * Update total sum:
// */
// var totalAmount = parseInt($('#totalAmount').data('value'));
// var pct;
// if (sum <= totalAmount) {
// pct = sum / totalAmount * 100;
// $('#progress-bar-default').css('width', pct + '%');
// $('#progress-bar-warning').css('width', '0');
// $('#progress-bar-danger').css('width', '0');
// $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-success').removeClass('text-danger');
// } else {
// // we gaan er X overheen,
//
// pct = totalAmount / sum * 100;
// var danger = 100 - pct;
// var err = 100 - danger;
// $('#progress-bar-default').css('width', 0);
// $('#progress-bar-warning').css('width', err + '%');
// $('#progress-bar-danger').css('width', danger + '%');
// $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-danger').removeClass('text-success');
// }
//
//
//}

View File

@@ -1,5 +1,6 @@
/* globals $, categoryID */
$(function () {
"use strict";
if (typeof categoryID !== 'undefined') {
googleColumnChart('chart/category/' + categoryID + '/all', 'all');
googleColumnChart('chart/category/' + categoryID + '/month', 'month');

View File

@@ -1,8 +1,9 @@
/* globals start, end, dateRangeURL, everything, firstDate, moment, currentMonthName, $, previousMonthName, nextMonthName, applyLabel, cancelLabel, toLabel, customRangeLabel, fromLabel, */
$(function () {
"use strict";
$('.currencySelect').click(currencySelect);
ranges = {};
var ranges = {};
ranges[currentMonthName] = [moment().startOf('month'), moment().endOf('month')];
ranges[previousMonthName] = [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')];
ranges[nextMonthName] = [moment().add(1, 'month').startOf('month'), moment().add(1, 'month').endOf('month')];
@@ -10,11 +11,6 @@ $(function () {
$('#daterange').daterangepicker(
{
//View::share('currentMonthName', $current);
//View::share('previousMonthName', $prev);
//View::share('nextMonthName', $next);
ranges: ranges,
opens: 'left',
locale: {
@@ -54,6 +50,7 @@ $(function () {
});
function currencySelect(e) {
"use strict";
var target = $(e.target);
var symbol = target.data('symbol');
var code = target.data('code');

View File

@@ -1,13 +1,16 @@
/* globals currencyCode, language, defaultPieChartOptions, defaultLineChartOptions, defaultColumnChartOptions, defaultBarChartOptions, defaultStackedColumnChartOptions, defaultComboChartOptions */
/* exported googleLineChart, googleBarChart, googleColumnChart, googleStackedColumnChart, googleComboChart, googlePieChart */
var google = google || {};
google.load('visualization', '1.1', {'packages': ['corechart', 'bar', 'line'],'language': language });
function googleChart(chartType, URL, container, options) {
"use strict";
if ($('#' + container).length === 1) {
$.getJSON(URL).success(function (data) {
/*
Get the data from the JSON
*/
gdata = new google.visualization.DataTable(data);
var gdata = new google.visualization.DataTable(data);
/*
Format as money
@@ -67,25 +70,32 @@ function googleChart(chartType, URL, container, options) {
function googleLineChart(URL, container, options) {
"use strict";
return googleChart('line', URL, container, options);
}
function googleBarChart(URL, container, options) {
"use strict";
return googleChart('bar', URL, container, options);
}
function googleColumnChart(URL, container, options) {
"use strict";
return googleChart('column', URL, container, options);
}
function googleStackedColumnChart(URL, container, options) {
"use strict";
return googleChart('stackedColumn', URL, container, options);
}
function googleComboChart(URL, container, options) {
"use strict";
return googleChart('combo', URL, container, options);
}
function googlePieChart(URL, container, options) {
"use strict";
return googleChart('pie', URL, container, options);
}

View File

@@ -1,3 +1,5 @@
/* exported defaultLineChartOptions, defaultBarChartOptions, defaultComboChartOptions, defaultColumnChartOptions, defaultStackedColumnChartOptions, defaultPieChartOptions */
var defaultLineChartOptions = {
curveType: 'function',
legend: {
@@ -69,7 +71,7 @@ var defaultBarChartOptions = {
legend: {
position: 'none'
},
}
};
var defaultComboChartOptions = {
@@ -127,7 +129,7 @@ var defaultColumnChartOptions = {
},
legend: {
position: 'none'
},
}
};
var defaultStackedColumnChartOptions = {

View File

@@ -1,13 +1,16 @@
$(function () {
"use strict";
$('#help').click(showHelp);
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
$('[data-toggle="tooltip"]').tooltip();
});
});
function showHelp(e) {
target = $(e.target);
route = target.data('route');
"use strict";
var target = $(e.target);
var route = target.data('route');
//
$('#helpBody').html('<i class="fa fa-refresh fa-spin"></i>');
$('#helpTitle').html('Please hold...');

View File

@@ -1,7 +1,9 @@
/* globals google */
google.setOnLoadCallback(drawChart);
function drawChart() {
"use strict";
googleLineChart('chart/account/frontpage', 'accounts-chart');
googlePieChart('chart/bill/frontpage', 'bills-chart');
googleStackedColumnChart('chart/budget/frontpage', 'budgets-chart');
@@ -12,13 +14,20 @@ function drawChart() {
}
function getBoxAmounts() {
"use strict";
var boxes = ['in', 'out', 'bills-unpaid', 'bills-paid'];
for (x in boxes) {
for (var x in boxes) {
var box = boxes[x];
$.getJSON('/json/box/' + box).success(function (data) {
$('#box-' + data.box).html(data.amount);
}).fail(function () {
console.log('Failed to get box!')
});
$.getJSON('/json/box/' + box).success(putData).fail(failData);
}
}
function putData(data) {
"use strict";
$('#box-' + data.box).html(data.amount);
}
function failData() {
"use strict";
console.log('Failed to get box!');
}

View File

@@ -1,4 +1,19 @@
/* globals $, googleLineChart, token */
// Return a helper with preserved width of cells
var fixHelper = function (e, tr) {
"use strict";
var $originals = tr.children();
var $helper = tr.clone();
$helper.children().each(function (index) {
// Set helper cell sizes to match the original sizes
$(this).width($originals.eq(index).width());
});
return $helper;
};
$(function () {
"use strict";
$('.addMoney').on('click', addMoney);
$('.removeMoney').on('click', removeMoney);
@@ -31,18 +46,9 @@ $(function () {
);
});
// Return a helper with preserved width of cells
var fixHelper = function(e, tr) {
var $originals = tr.children();
var $helper = tr.clone();
$helper.children().each(function (index) {
// Set helper cell sizes to match the original sizes
$(this).width($originals.eq(index).width());
});
return $helper;
}
function addMoney(e) {
"use strict";
var pigID = parseInt($(e.target).data('id'));
$('#moneyManagementModal').empty().load('piggy-banks/add/' + pigID, function () {
$('#moneyManagementModal').modal('show');
@@ -52,6 +58,7 @@ function addMoney(e) {
}
function removeMoney(e) {
"use strict";
var pigID = parseInt($(e.target).data('id'));
$('#moneyManagementModal').empty().load('piggy-banks/remove/' + pigID, function () {
$('#moneyManagementModal').modal('show');
@@ -60,15 +67,15 @@ function removeMoney(e) {
return false;
}
function stopSorting() {
"use strict";
$('.loadSpin').addClass('fa fa-refresh fa-spin');
var order = [];
$.each($('#sortable>tbody>tr'), function(i,v) {
$.each($('#sortable>tbody>tr'), function (i, v) {
var holder = $(v);
var id = holder.data('id');
order.push(id);
});
$.post('/piggy-banks/sort',{_token: token, order: order}).success(function(data) {
"use strict";
$.post('/piggy-banks/sort', {_token: token, order: order}).success(function () {
$('.loadSpin').removeClass('fa fa-refresh fa-spin');
});
}

View File

@@ -1,9 +1,11 @@
if (typeof(google) != 'undefined') {
/* globals expenseRestShow:true, incomeRestShow:true, year, shared, month, hideTheRest, showTheRest, showTheRestExpense, hideTheRestExpense, googleColumnChart, googleLineChart, googleStackedColumnChartg */
if (typeof(google) !== 'undefined') {
google.setOnLoadCallback(drawChart);
}
function drawChart() {
"use strict";
googleColumnChart('chart/report/in-out/' + year + shared, 'income-expenses-chart');
googleColumnChart('chart/report/in-out-sum/' + year + shared, 'income-expenses-sum-chart');
@@ -13,16 +15,8 @@ function drawChart() {
googleLineChart('/chart/account/month/' + year + '/' + month + shared, 'account-balances-chart');
}
$(function () {
$('.openModal').on('click', openModal);
// click open the top X income list:
$('#showIncomes').click(showIncomes);
// click open the top X expense list:
$('#showExpenses').click(showExpenses);
});
function openModal(e) {
"use strict";
var target = $(e.target).parent();
@@ -61,6 +55,7 @@ function showIncomes() {
}
function showExpenses() {
"use strict";
if (expenseRestShow) {
// hide everything, make button say "show"
$('#showExpenses').text(showTheRestExpense);
@@ -78,4 +73,15 @@ function showExpenses() {
}
return false;
}
}
$(function () {
"use strict";
$('.openModal').on('click', openModal);
// click open the top X income list:
$('#showIncomes').click(showIncomes);
// click open the top X expense list:
$('#showExpenses').click(showExpenses);
});

Some files were not shown because too many files have changed in this diff Show More