mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Fix transactions.
This commit is contained in:
@@ -24,7 +24,6 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Api\V1\Controllers;
|
namespace FireflyIII\Api\V1\Controllers;
|
||||||
|
|
||||||
use FireflyIII\Api\V1\Requests\TransactionRequest;
|
use FireflyIII\Api\V1\Requests\TransactionRequest;
|
||||||
use FireflyIII\Factory\TransactionJournalFactory;
|
|
||||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||||
use FireflyIII\Helpers\Filter\NegativeAmountFilter;
|
use FireflyIII\Helpers\Filter\NegativeAmountFilter;
|
||||||
@@ -179,14 +178,11 @@ class TransactionController extends Controller
|
|||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
* @throws \FireflyIII\Exceptions\FireflyException
|
* @throws \FireflyIII\Exceptions\FireflyException
|
||||||
*/
|
*/
|
||||||
public function store(TransactionRequest $request)
|
public function store(TransactionRequest $request, JournalRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$data = $request->getAll();
|
$data = $request->getAll();
|
||||||
$data['user'] = auth()->user()->id;
|
$data['user'] = auth()->user()->id;
|
||||||
/** @var TransactionJournalFactory $factory */
|
$journal = $repository->store($data);
|
||||||
$factory = app(TransactionJournalFactory::class);
|
|
||||||
$factory->setUser(auth()->user());
|
|
||||||
$journal = $factory->create($data);
|
|
||||||
|
|
||||||
$manager = new Manager();
|
$manager = new Manager();
|
||||||
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
|
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
|
||||||
@@ -196,7 +192,6 @@ class TransactionController extends Controller
|
|||||||
$include = $request->get('include') ?? '';
|
$include = $request->get('include') ?? '';
|
||||||
$manager->parseIncludes($include);
|
$manager->parseIncludes($include);
|
||||||
|
|
||||||
// needs a lot of extra data to match the journal collector. Or just expand that one.
|
|
||||||
// collect transactions using the journal collector
|
// collect transactions using the journal collector
|
||||||
$collector = app(JournalCollectorInterface::class);
|
$collector = app(JournalCollectorInterface::class);
|
||||||
$collector->setUser(auth()->user());
|
$collector->setUser(auth()->user());
|
||||||
|
@@ -424,7 +424,16 @@ class SingleController extends Controller
|
|||||||
}
|
}
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
$data = $request->getJournalData();
|
$data = $request->getJournalData();
|
||||||
|
$data['transactions'][0]['currency_id'] = $journal->transaction_currency_id;
|
||||||
|
if ($data['currency_id'] !== $journal->transaction_currency_id) {
|
||||||
|
// currency ID is changed by user. Update transaction:
|
||||||
|
|
||||||
|
$data['transactions'][0]['amount'] = $data['native_amount'];
|
||||||
|
$data['transactions'][0]['foreign_currency_id'] = $data['currency_id'];
|
||||||
|
$data['transactions'][0]['foreign_amount'] = $data['amount'];
|
||||||
|
}
|
||||||
|
|
||||||
$journal = $repository->update($journal, $data);
|
$journal = $repository->update($journal, $data);
|
||||||
/** @var array $files */
|
/** @var array $files */
|
||||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||||
|
@@ -47,36 +47,56 @@ class JournalFormRequest extends Request
|
|||||||
public function getJournalData()
|
public function getJournalData()
|
||||||
{
|
{
|
||||||
$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')),
|
||||||
'currency_id' => $this->integer('amount_currency_id_amount'),
|
|
||||||
|
|
||||||
// all custom fields:
|
// all custom fields:
|
||||||
'interest_date' => $this->date('interest_date'),
|
'interest_date' => $this->date('interest_date'),
|
||||||
'book_date' => $this->date('book_date'),
|
'book_date' => $this->date('book_date'),
|
||||||
'process_date' => $this->date('process_date'),
|
'process_date' => $this->date('process_date'),
|
||||||
'due_date' => $this->date('due_date'),
|
'due_date' => $this->date('due_date'),
|
||||||
'payment_date' => $this->date('payment_date'),
|
'payment_date' => $this->date('payment_date'),
|
||||||
'invoice_date' => $this->date('invoice_date'),
|
'invoice_date' => $this->date('invoice_date'),
|
||||||
'internal_reference' => $this->string('internal_reference'),
|
'internal_reference' => $this->string('internal_reference'),
|
||||||
'notes' => $this->string('notes'),
|
'notes' => $this->string('notes'),
|
||||||
|
|
||||||
// transaction / journal data:
|
// journal data:
|
||||||
'description' => $this->string('description'),
|
'description' => $this->string('description'),
|
||||||
'amount' => $this->string('amount'),
|
'piggy_bank_id' => $this->integer('piggy_bank_id'),
|
||||||
'budget_id' => $this->integer('budget_id'),
|
'bill_id' => null,
|
||||||
'category' => $this->string('category'),
|
'bill_name' => null,
|
||||||
'source_account_id' => $this->integer('source_account_id'),
|
|
||||||
'source_account_name' => $this->string('source_account_name'),
|
|
||||||
'destination_account_id' => $this->string('destination_account_id'),
|
|
||||||
'destination_account_name' => $this->string('destination_account_name'),
|
|
||||||
'piggy_bank_id' => $this->integer('piggy_bank_id'),
|
|
||||||
|
|
||||||
// native amount and stuff like that:
|
// native amount and stuff like that:
|
||||||
'native_amount' => $this->string('native_amount'),
|
'currency_id' => $this->integer('amount_currency_id_amount'),
|
||||||
'source_amount' => $this->string('source_amount'),
|
'amount' => $this->string('amount'),
|
||||||
'destination_amount' => $this->string('destination_amount'),
|
'native_amount' => $this->string('native_amount'),
|
||||||
|
'source_amount' => $this->string('source_amount'),
|
||||||
|
'destination_amount' => $this->string('destination_amount'),
|
||||||
|
|
||||||
|
// transaction data:
|
||||||
|
'transactions' => [
|
||||||
|
[
|
||||||
|
'currency_id' => null,
|
||||||
|
'currency_code' => null,
|
||||||
|
'description' => null,
|
||||||
|
'amount' => $this->string('amount'),
|
||||||
|
'budget_id' => $this->integer('budget_id'),
|
||||||
|
'budget_name' => null,
|
||||||
|
'category_id' => null,
|
||||||
|
'category_name' => $this->string('category'),
|
||||||
|
'source_id' => $this->integer('source_account_id'),
|
||||||
|
'source_name' => $this->string('source_account_name'),
|
||||||
|
'destination_id' => $this->integer('destination_account_id'),
|
||||||
|
'destination_name' => $this->string('destination_account_name'),
|
||||||
|
'foreign_currency_id' => null,
|
||||||
|
'foreign_currency_code' => null,
|
||||||
|
'foreign_amount' => null,
|
||||||
|
'reconciled' => false,
|
||||||
|
'identifier' => 0,
|
||||||
|
],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@@ -1,5 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BelongsUser.php
|
||||||
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace FireflyIII\Rules;
|
namespace FireflyIII\Rules;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
@@ -1,5 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ValidTransactions.php
|
||||||
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace FireflyIII\Rules;
|
namespace FireflyIII\Rules;
|
||||||
|
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
|
@@ -1,5 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* breadcrumbs.php
|
||||||
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1,5 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* google2fa.php
|
||||||
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the names of files you want to add to generated javascript.
|
|
||||||
* Otherwise all the files will be included.
|
|
||||||
*
|
|
||||||
* 'messages' => [
|
|
||||||
* 'validation',
|
|
||||||
* 'forum/thread',
|
|
||||||
* ],
|
|
||||||
*/
|
|
||||||
'messages' => [
|
|
||||||
'components',
|
|
||||||
'list',
|
|
||||||
],
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The default path to use for the generated javascript.
|
|
||||||
*/
|
|
||||||
'path' => public_path('messages.js'),
|
|
||||||
];
|
|
@@ -1,5 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2018_01_01_000001_create_oauth_auth_codes_table.php
|
||||||
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
@@ -1,5 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2018_01_01_000002_create_oauth_access_tokens_table.php
|
||||||
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
@@ -1,5 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2018_01_01_000003_create_oauth_refresh_tokens_table.php
|
||||||
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
@@ -1,5 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2018_01_01_000004_create_oauth_clients_table.php
|
||||||
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
@@ -1,5 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2018_01_01_000005_create_oauth_personal_access_clients_table.php
|
||||||
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
Reference in New Issue
Block a user