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
@ -337,35 +337,16 @@ class SingleController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function store(JournalFormRequest $request, JournalRepositoryInterface $repository)
|
public function store(JournalFormRequest $request, JournalRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$doSplit = 1 === intval($request->get('split_journal'));
|
$doSplit = 1 === intval($request->get('split_journal'));
|
||||||
$createAnother = 1 === intval($request->get('create_another'));
|
$createAnother = 1 === intval($request->get('create_another'));
|
||||||
$data = $request->getJournalData();
|
$data = $request->getJournalData();
|
||||||
$data['user'] = auth()->user()->id;
|
|
||||||
$data['bill_id'] = null;
|
|
||||||
$data['bill_name'] = null;
|
var_dump($data);exit;
|
||||||
$data['piggy_bank_name'] = null;
|
|
||||||
$data['transactions'] = [
|
$journal = $repository->store($data);
|
||||||
[
|
|
||||||
'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,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
$journal = $repository->store($data);
|
|
||||||
if (null === $journal->id) {
|
if (null === $journal->id) {
|
||||||
// error!
|
// error!
|
||||||
Log::error('Could not store transaction journal: ', $journal->getErrors()->toArray());
|
Log::error('Could not store transaction journal: ', $journal->getErrors()->toArray());
|
||||||
|
@ -46,10 +46,12 @@ class JournalFormRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function getJournalData()
|
public function getJournalData()
|
||||||
{
|
{
|
||||||
|
var_dump($this->all());
|
||||||
$data = [
|
$data = [
|
||||||
'type' => $this->get('what'), // type. can be 'deposit', 'withdrawal' or 'transfer'
|
'type' => $this->get('what'), // type. can be 'deposit', 'withdrawal' or 'transfer'
|
||||||
'date' => $this->date('date'),
|
'date' => $this->date('date'),
|
||||||
'tags' => explode(',', $this->string('tags')),
|
'tags' => explode(',', $this->string('tags')),
|
||||||
|
'user' => auth()->user()->id,
|
||||||
|
|
||||||
|
|
||||||
// all custom fields:
|
// all custom fields:
|
||||||
@ -65,15 +67,16 @@ class JournalFormRequest extends Request
|
|||||||
// journal data:
|
// journal data:
|
||||||
'description' => $this->string('description'),
|
'description' => $this->string('description'),
|
||||||
'piggy_bank_id' => $this->integer('piggy_bank_id'),
|
'piggy_bank_id' => $this->integer('piggy_bank_id'),
|
||||||
|
'piggy_bank_name' => null,
|
||||||
'bill_id' => null,
|
'bill_id' => null,
|
||||||
'bill_name' => null,
|
'bill_name' => null,
|
||||||
|
|
||||||
// native amount and stuff like that:
|
// native amount and stuff like that:
|
||||||
'currency_id' => $this->integer('amount_currency_id_amount'),
|
//'currency_id' => $this->integer('amount_currency_id_amount'),
|
||||||
'amount' => $this->string('amount'),
|
//'amount' => $this->string('amount'),
|
||||||
'native_amount' => $this->string('native_amount'),
|
//'native_amount' => $this->string('native_amount'),
|
||||||
'source_amount' => $this->string('source_amount'),
|
//'source_amount' => $this->string('source_amount'),
|
||||||
'destination_amount' => $this->string('destination_amount'),
|
//'destination_amount' => $this->string('destination_amount'),
|
||||||
|
|
||||||
// transaction data:
|
// transaction data:
|
||||||
'transactions' => [
|
'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;
|
return $data;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user