mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Optimized decryption.
This commit is contained in:
parent
566fadad15
commit
e000fb5d80
@ -4,10 +4,12 @@ namespace FireflyIII\Helpers\Report;
|
|||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Crypt;
|
||||||
use DB;
|
use DB;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Query\JoinClause;
|
use Illuminate\Database\Query\JoinClause;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Steam;
|
use Steam;
|
||||||
@ -236,7 +238,8 @@ class ReportQuery implements ReportQueryInterface
|
|||||||
}
|
}
|
||||||
$query->groupBy('t_from.account_id')->orderBy('transaction_journals.date');
|
$query->groupBy('t_from.account_id')->orderBy('transaction_journals.date');
|
||||||
|
|
||||||
return $query->get(
|
// get everything, decrypt and return
|
||||||
|
$data = $query->get(
|
||||||
['transaction_journals.id',
|
['transaction_journals.id',
|
||||||
'transaction_journals.description',
|
'transaction_journals.description',
|
||||||
'transaction_journals.encrypted',
|
'transaction_journals.encrypted',
|
||||||
@ -248,6 +251,15 @@ class ReportQuery implements ReportQueryInterface
|
|||||||
'ac_from.encrypted as account_encrypted'
|
'ac_from.encrypted as account_encrypted'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$data->each(
|
||||||
|
function (Model $object) {
|
||||||
|
// $object->description = intval($object->encrypted);
|
||||||
|
$object->name = intval($object->account_encrypted) == 1 ? Crypt::decrypt($object->name) : $object->name;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -325,7 +337,15 @@ class ReportQuery implements ReportQueryInterface
|
|||||||
->groupBy('categories.id')
|
->groupBy('categories.id')
|
||||||
->orderBy('amount');
|
->orderBy('amount');
|
||||||
|
|
||||||
return $query->get(['categories.id', 'categories.encrypted', 'categories.name', DB::Raw('SUM(`transactions`.`amount`) AS `amount`')]);
|
$data = $query->get(['categories.id', 'categories.encrypted', 'categories.name', DB::Raw('SUM(`transactions`.`amount`) AS `amount`')]);
|
||||||
|
// decrypt data:
|
||||||
|
$data->each(
|
||||||
|
function (Model $object) {
|
||||||
|
$object->name = intval($object->encrypted) == 1 ? Crypt::decrypt($object->name) : $object->name;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +392,16 @@ class ReportQuery implements ReportQueryInterface
|
|||||||
->groupBy('t_to.account_id')
|
->groupBy('t_to.account_id')
|
||||||
->orderBy('amount', 'DESC');
|
->orderBy('amount', 'DESC');
|
||||||
|
|
||||||
return $query->get(['t_to.account_id as id', 'ac_to.name as name', 'ac_to.encrypted', DB::Raw('SUM(t_to.amount) as `amount`')]);
|
$data = $query->get(['t_to.account_id as id', 'ac_to.name as name', 'ac_to.encrypted', DB::Raw('SUM(t_to.amount) as `amount`')]);
|
||||||
|
|
||||||
|
// decrypt
|
||||||
|
$data->each(
|
||||||
|
function (Model $object) {
|
||||||
|
$object->name = intval($object->encrypted) == 1 ? Crypt::decrypt($object->name) : $object->name;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -414,9 +443,17 @@ class ReportQuery implements ReportQueryInterface
|
|||||||
|
|
||||||
$query->groupBy('t_from.account_id')->orderBy('amount');
|
$query->groupBy('t_from.account_id')->orderBy('amount');
|
||||||
|
|
||||||
return $query->get(
|
$data = $query->get(
|
||||||
['t_from.account_id as account_id', 'ac_from.name as name', 'ac_from.encrypted as encrypted', DB::Raw('SUM(t_from.amount) as `amount`')]
|
['t_from.account_id as account_id', 'ac_from.name as name', 'ac_from.encrypted as encrypted', DB::Raw('SUM(t_from.amount) as `amount`')]
|
||||||
);
|
);
|
||||||
|
// decrypt
|
||||||
|
$data->each(
|
||||||
|
function (Model $object) {
|
||||||
|
$object->name = intval($object->encrypted) == 1 ? Crypt::decrypt($object->name) : $object->name;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -270,12 +270,6 @@ class ReportController extends Controller
|
|||||||
$categories = Steam::makeArray($result);
|
$categories = Steam::makeArray($result);
|
||||||
|
|
||||||
|
|
||||||
// loop and decrypt if necessary:
|
|
||||||
foreach ($categories as $index => $category) {
|
|
||||||
$categories[$index]['name']
|
|
||||||
= intval($categories[$index]['encrypted']) == 1 ? Crypt::decrypt($categories[$index]['name']) : $categories[$index]['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// all transfers
|
// all transfers
|
||||||
if ($showSharedReports === false) {
|
if ($showSharedReports === false) {
|
||||||
$result = $this->query->sharedExpensesByCategory($start, $end);
|
$result = $this->query->sharedExpensesByCategory($start, $end);
|
||||||
|
@ -22,11 +22,7 @@
|
|||||||
@foreach($income as $entry)
|
@foreach($income as $entry)
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@if($entry->encrypted === true)
|
|
||||||
<a href="{{route('transactions.show',$entry->id)}}" title="{{{Crypt::decrypt($entry->description)}}}">{{{Crypt::decrypt($entry->description)}}}</a>
|
|
||||||
@else
|
|
||||||
<a href="{{route('transactions.show',$entry->id)}}" title="{{{$entry->description}}}">{{{$entry->description}}}</a>
|
<a href="{{route('transactions.show',$entry->id)}}" title="{{{$entry->description}}}">{{{$entry->description}}}</a>
|
||||||
@endif
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php $tableSum += floatval($entry->amount);?>
|
<?php $tableSum += floatval($entry->amount);?>
|
||||||
@ -44,11 +40,7 @@
|
|||||||
{{$entry->date->format('j F Y')}}
|
{{$entry->date->format('j F Y')}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if(intval($entry->account_encrypted) == 1)
|
|
||||||
<a href="{{route('accounts.show',$entry->account_id)}}">{{{Crypt::decrypt($entry->name)}}}</a>
|
|
||||||
@else
|
|
||||||
<a href="{{route('accounts.show',$entry->account_id)}}">{{{$entry->name}}}</a>
|
<a href="{{route('accounts.show',$entry->account_id)}}">{{{$entry->name}}}</a>
|
||||||
@endif
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
@ -73,14 +65,11 @@
|
|||||||
@foreach($expenses as $id => $expense)
|
@foreach($expenses as $id => $expense)
|
||||||
<?php
|
<?php
|
||||||
$sum += floatval($expense['amount']);
|
$sum += floatval($expense['amount']);
|
||||||
$name = isset($expense['encrypted']) && intval($expense['encrypted']) ==1 ? Crypt::decrypt($expense['name']) :$expense['name'];
|
|
||||||
//var_dump($expense);
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
@if($id > 0)
|
@if($id > 0)
|
||||||
<td><a href="{{route('accounts.show',$id)}}">{{{$name}}}</a></td>
|
<td><a href="{{route('accounts.show',$id)}}">{{{$expense['name']}}}</a></td>
|
||||||
@else
|
@else
|
||||||
|
|
||||||
<td><em>{{{$expense['name']}}}</em></td>
|
<td><em>{{{$expense['name']}}}</em></td>
|
||||||
@endif
|
@endif
|
||||||
<td>{!! Amount::format($expense['amount']) !!}</td>
|
<td>{!! Amount::format($expense['amount']) !!}</td>
|
||||||
|
@ -128,10 +128,9 @@
|
|||||||
@foreach($groupedIncomes as $income)
|
@foreach($groupedIncomes as $income)
|
||||||
<?php
|
<?php
|
||||||
$sum += floatval($income->amount)*-1;
|
$sum += floatval($income->amount)*-1;
|
||||||
$name = intval($income->encrypted) == 1 ? Crypt::decrypt($income->name) : $income->name;
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{route('accounts.show',$income->account_id)}}">{{{$name}}}</a></td>
|
<td><a href="{{route('accounts.show',$income->account_id)}}">{{{$income->name}}}</a></td>
|
||||||
<td>{!! Amount::format(floatval($income->amount)*-1) !!}</td>
|
<td>{!! Amount::format(floatval($income->amount)*-1) !!}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
@ -151,11 +150,8 @@
|
|||||||
<table class="table">
|
<table class="table">
|
||||||
<?php $sum = 0;?>
|
<?php $sum = 0;?>
|
||||||
@foreach($groupedExpenses as $id => $expense)
|
@foreach($groupedExpenses as $id => $expense)
|
||||||
<?php
|
|
||||||
$name = intval($expense['encrypted']) == 1 ? Crypt::decrypt($expense['name']) : $expense['name'];
|
|
||||||
?>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{route('accounts.show',$id)}}">{{{$name}}}</a></td>
|
<td><a href="{{route('accounts.show',$id)}}">{{{$expense['name']}}}</a></td>
|
||||||
<td>{!! Amount::format(floatval($expense['amount'])*-1) !!}</td>
|
<td>{!! Amount::format(floatval($expense['amount'])*-1) !!}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php $sum += floatval($expense['amount'])*-1;?>
|
<?php $sum += floatval($expense['amount'])*-1;?>
|
||||||
|
Loading…
Reference in New Issue
Block a user