Fix split deposit.

This commit is contained in:
James Cole
2016-07-26 20:26:46 +02:00
parent 90865a5284
commit ce191fa6d3
5 changed files with 168 additions and 167 deletions

View File

@@ -105,9 +105,6 @@ class Journal implements JournalInterface
*/
public function updateJournal(TransactionJournal $journal, array $data): TransactionJournal
{
echo '<pre>';
print_r($data);
$journal->description = $data['journal_description'];
$journal->transaction_currency_id = $data['journal_currency_id'];
$journal->date = $data['date'];
@@ -167,7 +164,8 @@ class Journal implements JournalInterface
{
$destinationAccount = Account::where('user_id', $this->user->id)->where('id', $data['destination_account_id'])->first(['accounts.*']);
if (strlen($data['source_account_name']) > 0) {
if (isset($data['source_account_name']) && strlen($data['source_account_name']) > 0) {
$sourceType = AccountType::where('type', 'Revenue account')->first();
$sourceAccount = Account::firstOrCreateEncrypted(
['user_id' => $this->user->id, 'account_type_id' => $sourceType->id, 'name' => $data['source_account_name'], 'active' => 1]

View File

@@ -59,14 +59,10 @@ class SplitJournalFormRequest extends Request
'amount' => round($this->get('amount')[$index], 2),
'budget_id' => $this->get('budget_id')[$index] ? intval($this->get('budget_id')[$index]) : 0,
'category' => $this->get('category')[$index] ?? '',
'source_account_id' => intval($this->get('journal_source_account_id')),
'source_account_name' => $this->get('journal_source_account_name'),
'piggy_bank_id' => isset($this->get('piggy_bank_id')[$index])
? intval($this->get('piggy_bank_id')[$index])
: 0,
'destination_account_id' => isset($this->get('destination_account_id')[$index])
? intval($this->get('destination_account_id')[$index])
: intval($this->get('journal_destination_account_id')),
'source_account_id' => isset($this->get('source_account_id')[$index]) ? intval($this->get('source_account_id')[$index]) : intval($this->get('journal_source_account_id')),
'source_account_name' => $this->get('source_account_name')[$index] ?? '',
'piggy_bank_id' => isset($this->get('piggy_bank_id')[$index]) ? intval($this->get('piggy_bank_id')[$index]) : 0,
'destination_account_id' => isset($this->get('destination_account_id')[$index]) ? intval($this->get('destination_account_id')[$index]) : intval($this->get('journal_destination_account_id')),
'destination_account_name' => $this->get('destination_account_name')[$index] ?? '',
];
$data['transactions'][] = $transaction;

View File

@@ -29,6 +29,7 @@ return [
'lastMatch' => 'Last match',
'split_number' => 'Split #',
'destination' => 'Destination',
'source' => 'Source',
'expectedMatch' => 'Expected match',
'automatch' => 'Auto match?',
'repeat_freq' => 'Repeats',

View File

@@ -85,9 +85,12 @@
<tr>
<th>{{ trans('list.split_number') }}</th>
<th>{{ trans('list.description') }}</th>
{% if preFilled.what == 'withdrawal' or preFilled.what == 'deposit' %}
{% if preFilled.what == 'withdrawal' %}
<th>{{ trans('list.destination') }}</th>
{% endif %}
{% if preFilled.what == 'deposit' %}
<th>{{ trans('list.source') }}</th>
{% endif %}
<th>{{ trans('list.amount') }}</th>
{% if preFilled.what == 'withdrawal' %}
<th>{{ trans('list.budget') }}</th>

View File

@@ -94,9 +94,12 @@
<th>{{ trans('list.description') }}</th>
<!-- withdrawal and deposit have a destination. -->
{% if preFilled.what == 'withdrawal' or preFilled.what == 'deposit' %}
{% if preFilled.what == 'withdrawal' %}
<th>{{ trans('list.destination') }}</th>
{% endif %}
{% if preFilled.what == 'deposit' %}
<th>{{ trans('list.source') }}</th>
{% endif %}
<th>{{ trans('list.amount') }}</th>