mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Some intermittent changes to storing journals.
This commit is contained in:
parent
1a721ac6b5
commit
166cdad58b
@ -340,32 +340,13 @@ class SingleController extends Controller
|
||||
$doSplit = 1 === intval($request->get('split_journal'));
|
||||
$createAnother = 1 === intval($request->get('create_another'));
|
||||
$data = $request->getJournalData();
|
||||
$data['user'] = auth()->user()->id;
|
||||
$data['bill_id'] = null;
|
||||
$data['bill_name'] = null;
|
||||
$data['piggy_bank_name'] = null;
|
||||
$data['transactions'] = [
|
||||
[
|
||||
'amount' => $data['amount'],
|
||||
'currency_id' => $data['currency_id'],
|
||||
'description' => null,
|
||||
'reconciled' => false,
|
||||
'identifier' => 0,
|
||||
'currency_code' => null,
|
||||
'budget_id' => $data['budget_id'],
|
||||
'budget_name' => null,
|
||||
'category_id' => null,
|
||||
'category_name' => $data['category'],
|
||||
'source_id' => (int)$data['source_account_id'],
|
||||
'source_name' => $data['source_account_name'],
|
||||
'destination_id' => (int)$data['destination_account_id'],
|
||||
'destination_name' => $data['destination_account_name'],
|
||||
'foreign_currency_id' => null,
|
||||
'foreign_currency_code' => null,
|
||||
'foreign_amount' => null,
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
var_dump($data);exit;
|
||||
|
||||
$journal = $repository->store($data);
|
||||
|
||||
|
||||
if (null === $journal->id) {
|
||||
// error!
|
||||
Log::error('Could not store transaction journal: ', $journal->getErrors()->toArray());
|
||||
|
@ -46,10 +46,12 @@ class JournalFormRequest extends Request
|
||||
*/
|
||||
public function getJournalData()
|
||||
{
|
||||
var_dump($this->all());
|
||||
$data = [
|
||||
'type' => $this->get('what'), // type. can be 'deposit', 'withdrawal' or 'transfer'
|
||||
'date' => $this->date('date'),
|
||||
'tags' => explode(',', $this->string('tags')),
|
||||
'user' => auth()->user()->id,
|
||||
|
||||
|
||||
// all custom fields:
|
||||
@ -65,15 +67,16 @@ class JournalFormRequest extends Request
|
||||
// journal data:
|
||||
'description' => $this->string('description'),
|
||||
'piggy_bank_id' => $this->integer('piggy_bank_id'),
|
||||
'piggy_bank_name' => null,
|
||||
'bill_id' => null,
|
||||
'bill_name' => null,
|
||||
|
||||
// native amount and stuff like that:
|
||||
'currency_id' => $this->integer('amount_currency_id_amount'),
|
||||
'amount' => $this->string('amount'),
|
||||
'native_amount' => $this->string('native_amount'),
|
||||
'source_amount' => $this->string('source_amount'),
|
||||
'destination_amount' => $this->string('destination_amount'),
|
||||
//'currency_id' => $this->integer('amount_currency_id_amount'),
|
||||
//'amount' => $this->string('amount'),
|
||||
//'native_amount' => $this->string('native_amount'),
|
||||
//'source_amount' => $this->string('source_amount'),
|
||||
//'destination_amount' => $this->string('destination_amount'),
|
||||
|
||||
// transaction data:
|
||||
'transactions' => [
|
||||
@ -98,6 +101,18 @@ class JournalFormRequest extends Request
|
||||
],
|
||||
],
|
||||
];
|
||||
switch ($data['type']) {
|
||||
case 'withdrawal':
|
||||
$data['transactions'][0]['currency_id'] = $this->integer('source_currency_id');
|
||||
break;
|
||||
case 'deposit':
|
||||
$data['transactions'][0]['currency_id'] = $this->integer('destination_currency_id');
|
||||
break;
|
||||
case 'transfer':
|
||||
$data['transactions'][0]['currency_id'] = $this->integer('destination_currency_id');
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user