Skip to content

Firefly III: a personal finances manager

Various bug fixes and extensions to test routine.

James Colef2f9f8fbab34
diff --git a/.travis.yml b/.travis.yml
index a8f360bfff..3bc855b12c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,8 +11,6 @@ install:
- php artisan clear-compiled
- php artisan optimize
- php artisan env
- - ./test.sh -r
- - php artisan env
script:
- phpunit
\ No newline at end of file
diff --git a/app/Console/Commands/VerifyDatabase.php b/app/Console/Commands/VerifyDatabase.php
index 1d295abf0f..47b40ca69f 100644
--- a/app/Console/Commands/VerifyDatabase.php
+++ b/app/Console/Commands/VerifyDatabase.php
@@ -124,16 +124,16 @@ class VerifyDatabase extends Command
{
$set = Budget::leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budgets.id')
->leftJoin('users', 'budgets.user_id', '=', 'users.id')
- ->groupBy(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email'])
+ ->groupBy(['budgets.id', 'budgets.name', 'budgets.encrypted', 'budgets.user_id', 'users.email'])
->whereNull('budget_limits.id')
- ->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email']);
+ ->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'budgets.encrypted', 'users.email']);
- /** @var stdClass $entry */
+ /** @var Budget $entry */
foreach ($set as $entry) {
-
+ $name = $entry->encrypted ? Crypt::decrypt($entry->name) : $entry->name;
$line = sprintf(
'Notice: User #%d (%s) has budget #%d ("%s") which has no budget limits.',
- $entry->user_id, $entry->email, $entry->id, Crypt::decrypt($entry->name)
+ $entry->user_id, $entry->email, $entry->id, $name
);
$this->line($line);
}
diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.php
index 601e593d12..c874c9949e 100644
--- a/app/Helpers/Collector/JournalCollector.php
+++ b/app/Helpers/Collector/JournalCollector.php
@@ -60,6 +60,7 @@ class JournalCollector implements JournalCollectorInterface
'transaction_types.type as transaction_type_type',
'transaction_journals.bill_id',
'bills.name as bill_name',
+ 'bills.name_encrypted as bill_name_encrypted',
'transactions.id as id',
'transactions.amount as transaction_amount',
'transactions.description as transaction_description',
@@ -180,10 +181,12 @@ class JournalCollector implements JournalCollectorInterface
$set->each(
function (Transaction $transaction) {
$transaction->date = new Carbon($transaction->date);
- $transaction->description = intval($transaction->encrypted) === 1 ? Crypt::decrypt($transaction->description) : $transaction->description;
- $transaction->bill_name = !is_null($transaction->bill_name) ? Crypt::decrypt($transaction->bill_name) : '';
+ $transaction->description = $transaction->encrypted ? Crypt::decrypt($transaction->description) : $transaction->description;
+
+ if (!is_null($transaction->bill_name)) {
+ $transaction->bill_name = $transaction->bill_name_encrypted ? Crypt::decrypt($transaction->bill_name) : $transaction->bill_name;
+ }
- // optionally decrypted:
try {
$transaction->opposing_account_name = Crypt::decrypt($transaction->opposing_account_name);
} catch (DecryptException $e) {
diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php
index cf6a061c74..5b5036d7a0 100644
--- a/app/Models/Transaction.php
+++ b/app/Models/Transaction.php
@@ -33,11 +33,13 @@ class Transaction extends Model
* @var array
*/
protected $casts
- = [
- 'created_at' => 'date',
- 'updated_at' => 'date',
- 'deleted_at' => 'date',
- 'identifier' => 'int',
+ = [
+ 'created_at' => 'date',
+ 'updated_at' => 'date',
+ 'deleted_at' => 'date',
+ 'identifier' => 'int',
+ 'encrypted' => 'boolean', // model does not have these fields though
+ 'bill_name_encrypted' => 'boolean',
];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $fillable = ['account_id', 'transaction_journal_id', 'description', 'amount', 'identifier'];
diff --git a/test.sh b/test.sh
index 6e6e8065c7..befdb1c714 100755
--- a/test.sh
+++ b/test.sh
@@ -7,7 +7,7 @@ BACKUPENV=./.env.current
TESTINGENV=./.env.testing
# do something with flags:
-resetestflag=''
+resetTestFlag=''
testflag=''
coverageflag=''
acceptancetestclass=''
@@ -17,7 +17,7 @@ testsuite=''
while getopts 'vcrta:s:' flag; do
case "${flag}" in
r)
- resetestflag='true'
+ resetTestFlag='true'
;;
t)
testflag='true'
@@ -55,7 +55,7 @@ cp $TESTINGENV $ORIGINALENV
php artisan cache:clear
# reset database (optional)
-if [[ $resetestflag == "true" ]]
+if [[ $resetTestFlag == "true" ]]
then
echo "Must reset database"
@@ -69,12 +69,14 @@ then
# run migration
php artisan migrate:refresh --seed
+ # call test data generation script
+ $(which php) /sites/FF3/test-data/artisan generate:data testing sqlite
# copy new database over backup (resets backup)
cp $DATABASE $DATABASECOPY
fi
# do not reset database (optional)
-if [[ $resetestflag == "" ]]
+if [[ $resetTestFlag == "" ]]
then
echo "Will not reset database"
fi