diff --git a/app/Console/Commands/UseEncryption.php b/app/Console/Commands/UseEncryption.php index d3c3e178c0..8cf70208b9 100644 --- a/app/Console/Commands/UseEncryption.php +++ b/app/Console/Commands/UseEncryption.php @@ -1,10 +1,20 @@ journal_id = $object->transaction_journal_id; - $entry->description = Steam::decrypt(intval($object->journal_encrypted), $object->journal_description); - $entry->amount = $object->amount; - $entry->date = $object->date; - $entry->transaction_type = $object->transaction_type; - $entry->currency_code = $object->transaction_currency_code; - $entry->source_account_id = $object->account_id; - $entry->source_account_name = Steam::decrypt(intval($object->account_name_encrypted), $object->account_name); - $entry->destination_account_id = $object->opposing_account_id; - $entry->destination_account_name = Steam::decrypt(intval($object->opposing_account_encrypted), $object->opposing_account_name); - $entry->category_id = $object->category_id ?? ''; - $entry->category_name = $object->category_name ?? ''; - $entry->budget_id = $object->budget_id ?? ''; - $entry->budget_name = $object->budget_name ?? ''; + $entry = new self; + $entry->journal_id = $object->transaction_journal_id; + $entry->description = Steam::decrypt(intval($object->journal_encrypted), $object->journal_description); + $entry->amount = $object->amount; + $entry->date = $object->date; + $entry->transaction_type = $object->transaction_type; + $entry->currency_code = $object->transaction_currency_code; + $entry->asset_account_id = $object->account_id; + $entry->asset_account_name = Steam::decrypt(intval($object->account_name_encrypted), $object->account_name); + $entry->opposing_account_id = $object->opposing_account_id; + $entry->opposing_account_name = Steam::decrypt(intval($object->opposing_account_encrypted), $object->opposing_account_name); + $entry->category_id = $object->category_id ?? ''; + $entry->category_name = $object->category_name ?? ''; + $entry->budget_id = $object->budget_id ?? ''; + $entry->budget_name = $object->budget_name ?? ''; // update description when transaction description is different: if (!is_null($object->description) && $object->description !== $entry->description) { diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 6d2822d398..b91b436c0c 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -53,7 +53,7 @@ class RegisterController extends Controller } /** - * @param Request $request + * @param UserRegistrationRequest|Request $request * * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View */ diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index a4592a5ce0..240e2e18ed 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -227,8 +227,6 @@ class CategoryController extends Controller $subTitleIcon = 'fa-bar-chart'; $page = intval($request->get('page')); $pageSize = intval(Preferences::get('transactionPageSize', 50)->data); - $count = 0; - $loop = 0; $range = Preferences::get('viewRange', '1M')->data; $start = null; $end = null; diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php index b3e23c25a8..b8baff5568 100644 --- a/app/Http/Controllers/Transaction/SingleController.php +++ b/app/Http/Controllers/Transaction/SingleController.php @@ -199,10 +199,10 @@ class SingleController extends Controller } /** - * @param JournalRepositoryInterface $repository - * @param TransactionJournal $transactionJournal + * @param TransactionJournal $transactionJournal * * @return \Illuminate\Http\RedirectResponse + * @internal param JournalRepositoryInterface $repository */ public function destroy(TransactionJournal $transactionJournal) { diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 1dcf3fe2de..059a1e3fb7 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -72,8 +72,6 @@ class TransactionController extends Controller $types = config('firefly.transactionTypesByWhat.' . $what); $page = intval($request->get('page')); $pageSize = intval(Preferences::get('transactionPageSize', 50)->data); - $count = 0; - $loop = 0; $range = Preferences::get('viewRange', '1M')->data; $start = null; $end = null; diff --git a/app/Import/FileProcessor/CsvProcessor.php b/app/Import/FileProcessor/CsvProcessor.php index 5be25f5ed1..b10549c703 100644 --- a/app/Import/FileProcessor/CsvProcessor.php +++ b/app/Import/FileProcessor/CsvProcessor.php @@ -151,6 +151,43 @@ class CsvProcessor implements FileProcessorInterface return $results; } + /** + * Will return string representation of JSON error code. + * + * @param int $jsonError + * + * @return string + */ + private function getJsonError(int $jsonError): string + { + switch ($jsonError) { + default: + return 'Unknown JSON error'; + case JSON_ERROR_NONE: + return 'No JSON error'; + case JSON_ERROR_DEPTH: + return 'JSON_ERROR_DEPTH'; + case JSON_ERROR_STATE_MISMATCH: + return 'JSON_ERROR_STATE_MISMATCH'; + case JSON_ERROR_CTRL_CHAR: + return 'JSON_ERROR_CTRL_CHAR'; + case JSON_ERROR_SYNTAX: + return 'JSON_ERROR_SYNTAX'; + case JSON_ERROR_UTF8: + return 'JSON_ERROR_UTF8'; + case JSON_ERROR_RECURSION: + return 'JSON_ERROR_RECURSION'; + case JSON_ERROR_INF_OR_NAN: + return 'JSON_ERROR_INF_OR_NAN'; + case JSON_ERROR_UNSUPPORTED_TYPE: + return 'JSON_ERROR_UNSUPPORTED_TYPE'; + case JSON_ERROR_INVALID_PROPERTY_NAME: + return 'JSON_ERROR_INVALID_PROPERTY_NAME'; + case JSON_ERROR_UTF16: + return 'JSON_ERROR_UTF16'; + } + } + /** * Take a row, build import journal by annotating each value and storing it in the import journal. * @@ -158,14 +195,22 @@ class CsvProcessor implements FileProcessorInterface * @param array $row * * @return ImportJournal + * @throws FireflyException */ private function importRow(int $index, array $row): ImportJournal { Log::debug(sprintf('Now at row %d', $index)); - $row = $this->specifics($row); + $row = $this->specifics($row); + $json = json_encode($row); + $jsonError = json_last_error(); + + if ($json === false) { + throw new FireflyException(sprintf('Error while encoding JSON: %s', $this->getJsonError($jsonError))); + } + $journal = new ImportJournal; $journal->setUser($this->job->user); - $journal->setHash(hash('sha256', json_encode($row))); + $journal->setHash(hash('sha256', $json)); foreach ($row as $rowIndex => $value) { $value = trim($value); diff --git a/app/Mail/RegisteredUser.php b/app/Mail/RegisteredUser.php index ea8e6a7e63..eba52d7dfa 100644 --- a/app/Mail/RegisteredUser.php +++ b/app/Mail/RegisteredUser.php @@ -1,5 +1,15 @@ + + diff --git a/public/js/ff/charts.js b/public/js/ff/charts.js index 9e545d8f57..5ef0380c10 100644 --- a/public/js/ff/charts.js +++ b/public/js/ff/charts.js @@ -7,7 +7,7 @@ * * See the LICENSE file for details. */ -/** global: Chart, defaultChartOptions, accounting, defaultPieOptions, noDataForChart, noDataForChart */ +/** global: Chart, defaultChartOptions, accounting, defaultPieOptions, noDataForChart */ var allCharts = {}; /* diff --git a/public/js/ff/export/index.js b/public/js/ff/export/index.js index c04d89f2cc..4dd745a078 100644 --- a/public/js/ff/export/index.js +++ b/public/js/ff/export/index.js @@ -78,8 +78,7 @@ function showDownload() { function showError(text) { "use strict"; - $('#export-error').show(); - $('#export-error').find('p').text(text); + $('#export-error').show().find('p').text(text); } function callExport() { diff --git a/public/js/ff/transactions/split/edit.js b/public/js/ff/transactions/split/edit.js index d9e7e22ed9..dbe9cfba98 100644 --- a/public/js/ff/transactions/split/edit.js +++ b/public/js/ff/transactions/split/edit.js @@ -220,18 +220,24 @@ function resetDivSplits() { function calculateSum() { "use strict"; + var left = originalSum * -1; var sum = 0; var set = $('input[name$="][amount]"]'); for (var i = 0; i < set.length; i++) { var current = $(set[i]); sum += (current.val() === "" ? 0 : parseFloat(current.val())); + left += (current.val() === "" ? 0 : parseFloat(current.val())); } sum = Math.round(sum * 100) / 100; + left = Math.round(left * 100) / 100; $('.amount-warning').remove(); if (sum !== originalSum) { var holder = $('#journal_amount_holder'); var par = holder.find('p.form-control-static'); $('').text(' (' + accounting.formatMoney(sum) + ')').addClass('text-danger amount-warning').appendTo(par); + // also add what's left to divide (or vice versa) + $('').text(' (' + accounting.formatMoney(left) + ')').addClass('text-danger amount-warning').appendTo(par); } + } \ No newline at end of file diff --git a/public/safari-pinned-tab.svg b/public/safari-pinned-tab.svg index b433d7b8ed..b7b99c70e8 100644 --- a/public/safari-pinned-tab.svg +++ b/public/safari-pinned-tab.svg @@ -1,4 +1,13 @@ + + 'Update amount', 'update_budget' => 'Update budget', 'update_budget_amount_range' => 'Update (expected) available amount between :start and :end', + 'budget_period_navigator' => 'Period navigator', // bills: 'matching_on' => 'Matching on', diff --git a/resources/views/transactions/show.twig b/resources/views/transactions/show.twig index a6a7fc8876..5fb3fee0c3 100644 --- a/resources/views/transactions/show.twig +++ b/resources/views/transactions/show.twig @@ -221,7 +221,7 @@
{% if journal.transactionType.type != "Withdrawal" %}

- + {{ ('convert_'~journal.transactionType.type~'_to_withdrawal')|_ }} @@ -229,7 +229,7 @@ {% endif %} {% if journal.transactionType.type != "Deposit" %}

- + {{ ('convert_'~journal.transactionType.type~'_to_deposit')|_ }} @@ -238,21 +238,24 @@ {% if journal.transactionType.type != "Transfer" %}

- + {{ ('convert_'~journal.transactionType.type~'_to_transfer')|_ }}

{% endif %} - {% if transactions|length == 1 %}

- + {{ ('clone_'~journal.transactionType.type|lower)|_ }}

- {% endif %} - +

+ + + {{ ('split_this_'~what)|_ }} + +

{% endif %} diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php index ab92402550..0574e65161 100644 --- a/tests/CreatesApplication.php +++ b/tests/CreatesApplication.php @@ -1,5 +1,15 @@ mock(TagRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); diff --git a/tests/TestCase.php b/tests/TestCase.php index 72d9dd4995..f6d3efafb1 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,5 +1,15 @@ shouldReceive('getJournals')->andReturn($collection); // mock all repositories: - $accountRepos = $this->mock(AccountRepositoryInterface::class); + $accountRepos = $this->mock(AccountRepositoryInterface::class); $accountRepos->shouldReceive('setUser'); $accountRepos->shouldReceive('find')->withArgs([1])->andReturn($accounts[1]); @@ -122,7 +119,7 @@ class MetaPieChartTest extends TestCase $collector->shouldReceive('getJournals')->andReturn($others)->once(); // mock all repositories: - $accountRepos = $this->mock(AccountRepositoryInterface::class); + $accountRepos = $this->mock(AccountRepositoryInterface::class); $accountRepos->shouldReceive('setUser'); $accountRepos->shouldReceive('find')->withArgs([1])->andReturn($accounts[1]);