Last updates, fixes the main list.

This commit is contained in:
James Cole
2016-03-02 12:33:07 +01:00
parent f2c1dd41d0
commit 1ac64fd0b3
3 changed files with 101 additions and 89 deletions

View File

@@ -166,6 +166,16 @@ class TransactionJournal extends Model
return $value; return $value;
} }
/**
* @param $value
*
* @return string
*/
public function getDestinationAccountNameAttribute($value)
{
return Crypt::decrypt($value);
}
/** /**
* *
* @param string $fieldName * @param string $fieldName
@@ -183,6 +193,16 @@ class TransactionJournal extends Model
return ''; return '';
} }
/**
* @param $value
*
* @return string
*/
public function getSourceAccountNameAttribute($value)
{
return Crypt::decrypt($value);
}
/** /**
* @return bool * @return bool
*/ */
@@ -319,6 +339,8 @@ class TransactionJournal extends Model
// join destination account type // join destination account type
$query->leftJoin('account_types as source_acct_type', 'source_account.account_type_id', '=', 'source_acct_type.id'); $query->leftJoin('account_types as source_acct_type', 'source_account.account_type_id', '=', 'source_acct_type.id');
$query->with(['categories', 'budgets', 'attachments', 'bill']);
} }
@@ -330,9 +352,6 @@ class TransactionJournal extends Model
*/ */
public function scopeTransactionTypes(EloquentBuilder $query, array $types) public function scopeTransactionTypes(EloquentBuilder $query, array $types)
{ {
$query->leftJoin(
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
);
$query->whereIn('transaction_types.type', $types); $query->whereIn('transaction_types.type', $types);
} }

View File

@@ -118,14 +118,20 @@ class JournalRepository implements JournalRepositoryInterface
*/ */
public function getJournalsOfTypes(array $types, int $offset, int $page, int $pagesize = 50) public function getJournalsOfTypes(array $types, int $offset, int $page, int $pagesize = 50)
{ {
$set = Auth::user()->transactionJournals()->transactionTypes($types)->withRelevantData()->take($pagesize)->offset($offset) $set = Auth::user()
->transactionJournals()
->expanded()
->transactionTypes($types)
->take($pagesize)
->offset($offset)
->orderBy('date', 'DESC') ->orderBy('date', 'DESC')
->orderBy('order', 'ASC') ->orderBy('order', 'ASC')
->orderBy('id', 'DESC') ->orderBy('id', 'DESC')
->get( ->get(TransactionJournal::QUERYFIELDS);
['transaction_journals.*']
); $count = Auth::user()->transactionJournals()
$count = Auth::user()->transactionJournals()->transactionTypes($types)->count(); ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->transactionTypes($types)->count();
$journals = new LengthAwarePaginator($set, $count, $pagesize, $page); $journals = new LengthAwarePaginator($set, $count, $pagesize, $page);
return $journals; return $journals;

View File

@@ -28,18 +28,6 @@
<tbody> <tbody>
{% set _sum = 0 %} {% set _sum = 0 %}
{% for journal in journals %} {% for journal in journals %}
{% if invalidJournal(journal) %}
<tr class="ignore">
<td>
<div class="btn-group btn-group-xs">
<a href="{{ route("transactions.delete",journal.id) }}" class="btn btn-xs btn-danger"><i class="fa fa-fw fa-trash-o"></i></a>
</div>
</td>
<td>&nbsp;</td>
<td>{{ journal.description }}</td>
<td colspan="7"><em>Invalid journal: Found {{ journal.transactions|length }} transaction(s)</em></td>
</tr>
{% else %}
{% set _sum = _sum + journal.amount %} {% set _sum = _sum + journal.amount %}
<tr class="drag" data-date="{{ journal.date.format('Y-m-d') }}" data-id="{{ journal.id }}"> <tr class="drag" data-date="{{ journal.date.format('Y-m-d') }}" data-id="{{ journal.id }}">
<td class="hidden-xs"> <td class="hidden-xs">
@@ -70,17 +58,17 @@
{{ journal.date.formatLocalized(monthAndDayFormat) }} {{ journal.date.formatLocalized(monthAndDayFormat) }}
</td> </td>
<td class="hidden-xs"> <td class="hidden-xs">
{% if journal.source_account.accountType.type == 'Cash account' %} {% if journal.source_account_type == 'Cash account' %}
<span class="text-success">(cash)</span> <span class="text-success">(cash)</span>
{% else %} {% else %}
<a href="{{ route('accounts.show',journal.source_account.id) }}">{{ journal.source_account.name }}</a> <a href="{{ route('accounts.show',journal.source_account_id) }}">{{ journal.source_account_name }}</a>
{% endif %} {% endif %}
</td> </td>
<td class="hidden-xs"> <td class="hidden-xs">
{% if journal.destination_account.accountType.type == 'Cash account' %} {% if journal.destination_account_type == 'Cash account' %}
<span class="text-success">(cash)</span> <span class="text-success">(cash)</span>
{% else %} {% else %}
<a href="{{ route('accounts.show',journal.destination_account.id) }}">{{ journal.destination_account.name }}</a> <a href="{{ route('accounts.show',journal.destination_account_id) }}">{{ journal.destination_account_name }}</a>
{% endif %} {% endif %}
</td> </td>
@@ -111,7 +99,6 @@
</td> </td>
{% endif %} {% endif %}
</tr> </tr>
{% endif %}
{% endfor %} {% endfor %}
</tbody> </tbody>
<tfoot> <tfoot>