Compare commits

..

56 Commits

Author SHA1 Message Date
James Cole
2af98b259a Merge branch 'release/5.2.2' 2020-04-14 21:01:02 +02:00
James Cole
015242a666 Update meta files for new release. 2020-04-14 20:56:30 +02:00
James Cole
54933fda2e Fix #3263 2020-04-14 17:23:58 +02:00
James Cole
852d057a47 Fix #3259 2020-04-13 07:57:46 +02:00
James Cole
1778f0b4f3 Fix storing of virtual balance. 2020-04-13 07:57:32 +02:00
James Cole
6daf083b3f Clean up some code. 2020-04-12 06:24:35 +02:00
James Cole
4a7d9b130a Fix issue with multi-currency in asset accounts. 2020-04-12 06:23:35 +02:00
James Cole
4163efba55 Clean up phpdoc 2020-04-11 06:42:47 +02:00
James Cole
db5847b49b Consistent in minimum password length 2020-04-11 06:42:40 +02:00
James Cole
6829003f5e Change to safer hash methods. 2020-04-11 06:42:21 +02:00
James Cole
047927718e Merge branch 'release/5.2.1' 2020-04-10 21:23:53 +02:00
James Cole
91deb22a3f Merge tag '5.2.1' into develop
5.2.1
2020-04-10 21:23:53 +02:00
James Cole
1629ca0739 Update for some bugs. 2020-04-10 21:20:04 +02:00
James Cole
8b87204f10 User unable to store budgets without auto budget info. 2020-04-10 21:16:46 +02:00
James Cole
f920d90e3d Fix chart problem 2020-04-10 21:16:29 +02:00
James Cole
1cb91282af Merge tag '5.2.0' into develop
5.2.0
2020-04-10 13:51:23 +02:00
James Cole
a6ce294131 Merge branch 'release/5.2.0' 2020-04-10 13:51:22 +02:00
James Cole
34ceb69776 Update last minute files. 2020-04-10 13:50:37 +02:00
James Cole
eed68b5d95 Fix some code quality issues. 2020-04-10 10:47:24 +02:00
James Cole
79374c11ee Fix for #3248 2020-04-10 10:12:12 +02:00
James Cole
404f9df6d3 Bad link to model. 2020-04-10 07:29:15 +02:00
James Cole
4b716e35b9 Prep changelog for new release. 2020-04-10 07:20:45 +02:00
James Cole
166fc7a3e2 Fix trait 2020-04-09 20:33:55 +02:00
James Cole
06afbc7a0a Fix chart 2020-04-09 06:27:43 +02:00
James Cole
49a98de63a Add YNAB 2020-04-09 06:27:29 +02:00
James Cole
5b572c0da2 Expand readme. 2020-04-09 06:27:20 +02:00
James Cole
59014b1a87 Meta files for the next release. 2020-04-08 06:54:16 +02:00
James Cole
4aec1f06e0 Fix issue updating categories. 2020-04-08 06:43:58 +02:00
James Cole
136af9625a Better link for tags. 2020-04-07 18:19:29 +02:00
James Cole
edac26f757 Merge pull request #3236 from SuperSandro2000/patch-1
Add missing date based on releases page
2020-04-05 07:54:01 +02:00
Sandro
ac54dd05bf Add missing date based on releases page 2020-04-05 07:31:30 +02:00
James Cole
7948058364 Fix #3234 2020-04-05 07:14:17 +02:00
James Cole
f13a6f7bf9 New php docs [skip ci] 2020-04-05 07:10:59 +02:00
James Cole
e1a5d143c5 Merge tag '5.2.0-beta.1' into develop
5.2.0-beta.1
2020-04-02 06:54:50 +02:00
James Cole
f98011cd0d Merge branch 'release/5.2.0-beta.1' 2020-04-02 06:54:49 +02:00
James Cole
e7c10dec5c Update meta files for new release. 2020-04-02 06:39:09 +02:00
James Cole
ae2b28fdee Use correct methods. 2020-03-31 07:41:48 +02:00
James Cole
8d3fc18ca6 Use correct methods. 2020-03-31 07:40:20 +02:00
James Cole
61521cf478 Use correct methods. 2020-03-31 07:39:57 +02:00
James Cole
06c5e4df2c Use correct methods. 2020-03-31 07:39:36 +02:00
James Cole
9e4b7f8bb4 Add IBAN to account validator. 2020-03-31 07:04:00 +02:00
James Cole
144bc29eb3 Fix issue with budgets. 2020-03-31 07:03:37 +02:00
James Cole
2c0d8b9cb3 Fix #3122 2020-03-28 16:06:37 +01:00
James Cole
511b1258ba Merge pull request #3212 from rubenverhoef/CSV-ING
ING CSV
2020-03-27 05:22:02 +00:00
Ruben Verhoef
8cfe0af502 New saving acount function, supports account numbers with chars and make it easier to link when account numbers are the same but name are different 2020-03-26 20:51:07 +01:00
James Cole
54e3c7d729 Fix #3211 2020-03-26 19:59:38 +01:00
James Cole
628b493128 Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2020-03-26 19:58:40 +01:00
Ruben Verhoef
8c552b8fa8 Fix functions moveValutadatumDescription and removeNameIngDescription 2020-03-26 19:52:30 +01:00
James Cole
c864d904b0 Fix #3079 2020-03-26 18:00:18 +01:00
James Cole
ecb61676ab Fix #3210 2020-03-26 12:05:15 +01:00
James Cole
ee5a4caaab Some extra code for #1376 2020-03-26 07:10:39 +01:00
James Cole
84bdd47109 update issue templates. 2020-03-25 19:25:50 +01:00
James Cole
5445752588 Update some phpdocs, courtesy of Psalm. 2020-03-25 07:03:23 +01:00
James Cole
bcfbdcf3f0 Clean up models.
Clean up models.
2020-03-25 06:58:39 +01:00
James Cole
7e6cd77203 Clean up models. 2020-03-25 06:58:29 +01:00
James Cole
5e3d00ecde Merge tag '5.2.0-alpha.1' into develop
5.2.0-alpha.1
2020-03-24 07:22:27 +01:00
202 changed files with 3263 additions and 1460 deletions

View File

@@ -59,7 +59,7 @@ APP_LOG_LEVEL=notice
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
# Use "mysql" for MySQL and MariaDB. Use "sqlite" for SQLite.
DB_CONNECTION=pgsql
DB_HOST=firefly_iii_db
DB_HOST=fireflyiiidb
DB_PORT=5432
DB_DATABASE=firefly
DB_USERNAME=firefly

View File

@@ -19,7 +19,7 @@ I am running Firefly III version x.x.x, and my problem is:
<!-- Earn bonus points by checking the boxes -->
- [ ] Nobody reported this bug before
- [ ] I have added a stack trace from my log files.
- [ ] I have added a stack trace from my log files <!-- (see https://bit.ly/FF3-get-debug-info) -->
- [ ] I have added a screenshot.
- [ ] I was able to replicate it on the demo site https://demo.firefly-iii.org/
<!-- - [ ] I donated money (this is a joke :wink:)-->

View File

@@ -18,6 +18,6 @@ I am running Firefly III version x.x.x.
- [ ] I have read the FAQ at https://bit.ly/FF3-FAQ
- [ ] I added a screenshot
- [ ] I added log files (see https://bit.ly/FF3-get-logs)
- [ ] I added log files <!-- (see https://bit.ly/FF3-get-debug-info) -->
- [ ] I was able to replicate the issue on the demo site.
<!-- - [ ] I donated money (this is a joke :wink:)-->

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* CorrectOpeningBalanceCurrencies.php
* Copyright (c) 2020 james@firefly-iii.org

View File

@@ -47,7 +47,7 @@ class CreateLinkTypes extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
*/
public function handle(): int
{

View File

@@ -50,7 +50,8 @@ class DeleteEmptyGroups extends Command
* Execute the console command.
*
* @throws Exception;
* @return mixed
*
* @return int
*/
public function handle(): int
{

View File

@@ -52,7 +52,7 @@ class EnableCurrencies extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
*/
public function handle(): int
{

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* FixLongDescriptions.php
* Copyright (c) 2020 james@firefly-iii.org
@@ -65,7 +66,7 @@ class FixLongDescriptions extends Command
$groups = TransactionGroup::get(['id', 'title']);
/** @var TransactionGroup $group */
foreach ($groups as $group) {
if (strlen($group->title) > self::MAX_LENGTH) {
if (strlen((string)$group->title) > self::MAX_LENGTH) {
$group->title = substr($group->title, 0, self::MAX_LENGTH);
$group->save();
$this->line(sprintf('Truncated description of transaction group #%d', $group->id));

View File

@@ -54,7 +54,7 @@ class FixPiggies extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
*/
public function handle(): int
{

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* FixRecurringTransactions.php
* Copyright (c) 2020 james@firefly-iii.org

View File

@@ -48,7 +48,7 @@ class RemoveBills extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
*/
public function handle(): int
{

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**

View File

@@ -30,6 +30,7 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Preference;
use Illuminate\Console\Command;
use Illuminate\Contracts\Encryption\DecryptException;
use JsonException;
use Log;
/**
@@ -92,7 +93,11 @@ class DecryptDatabase extends Command
// A separate routine for preferences:
if ('preferences' === $table) {
// try to json_decrypt the value.
$value = json_decode($value, true, 512, JSON_THROW_ON_ERROR) ?? $value;
try {
$value = json_decode($value, true, 512, JSON_THROW_ON_ERROR) ?? $value;
} catch(JsonException $e) {
Log::error($e->getMessage());
}
Log::debug(sprintf('Decrypted field "%s" "%s" to "%s" in table "%s" (row #%d)', $field, $original, print_r($value, true), $table, $id));
/** @var Preference $object */

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* ExportData.php
* Copyright (c) 2020 james@firefly-iii.org
@@ -238,11 +239,12 @@ class ExportData extends Command
/**
* @throws FireflyException
*
* @return string
*/
private function getExportDirectory(): string
{
$directory = $this->option('export_directory');
$directory = (string) $this->option('export_directory');
if (null === $directory) {
$directory = './';
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* RestoreOAuthKeys.php
* Copyright (c) 2020 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* MigrateRecurrenceMeta.php
* Copyright (c) 2020 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* MigrateTagLocations.php
* Copyright (c) 2020 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* DuplicateTransactionException.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -50,6 +50,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
* @param Request $request
* @param Exception $exception
*
* @throws Exception
* @return mixed
*/
public function render($request, Exception $exception)
@@ -137,9 +138,10 @@ class GracefulNotFoundHandler extends ExceptionHandler
* @param Request $request
* @param Exception $exception
*
* @return \Illuminate\Http\Response|Response
* @throws Exception
* @return Redirector|Response
*/
private function handleAccount($request, Exception $exception)
private function handleAccount(Request $request, Exception $exception)
{
Log::debug('404 page is probably a deleted account. Redirect to overview of account types.');
/** @var User $user */
@@ -160,6 +162,13 @@ class GracefulNotFoundHandler extends ExceptionHandler
return redirect(route('accounts.index', [$shortType]));
}
/**
* @param Request $request
* @param Exception $exception
*
* @throws Exception
* @return RedirectResponse|Redirector|Response
*/
private function handleAttachment(Request $request, Exception $exception)
{
Log::debug('404 page is probably a deleted attachment. Redirect to parent object.');
@@ -199,12 +208,13 @@ class GracefulNotFoundHandler extends ExceptionHandler
}
/**
* @param $request
* @param Request $request
* @param Exception $exception
*
* @throws Exception
* @return RedirectResponse|\Illuminate\Http\Response|Redirector|Response
*/
private function handleGroup($request, Exception $exception)
private function handleGroup(Request $request, Exception $exception)
{
Log::debug('404 page is probably a deleted group. Redirect to overview of group types.');
/** @var User $user */

View File

@@ -116,8 +116,8 @@ class Handler extends ExceptionHandler
* @param Exception $exception
*
* @throws Exception
* @return mixed|void
*
* @return void
*/
public function report(Exception $exception)
{

View File

@@ -98,7 +98,7 @@ class AccountFactory
'user_id' => $this->user->id,
'account_type_id' => $type->id,
'name' => $data['name'],
'virtual_balance' => $data['virtual_balance'] ?? '0',
'virtual_balance' => $data['virtual_balance'] ?? null,
'active' => true === $data['active'],
'iban' => $data['iban'],
];
@@ -109,12 +109,12 @@ class AccountFactory
// remove virtual balance when not an asset account or a liability
if (!in_array($type->type, $this->canHaveVirtual, true)) {
$databaseData['virtual_balance'] = '0';
$databaseData['virtual_balance'] = null;
}
// fix virtual balance when it's empty
if ('' === $databaseData['virtual_balance']) {
$databaseData['virtual_balance'] = '0';
if ('' === (string)$databaseData['virtual_balance']) {
$databaseData['virtual_balance'] = null;
}
$return = Account::create($databaseData);

View File

@@ -275,27 +275,34 @@ class TransactionJournalFactory
return null;
}
// TODO typeOverrule: the account validator may have another opinion on the transaction type.
/** create or get source and destination accounts */
$sourceInfo = [
'id' => (int) $row['source_id'],
'name' => $row['source_name'],
'iban' => $row['source_iban'],
'number' => $row['source_number'],
'bic' => $row['source_bic'],
'id' => (int) $row['source_id'],
'name' => $row['source_name'],
'iban' => $row['source_iban'],
'number' => $row['source_number'],
'bic' => $row['source_bic'],
'currency_id' => $currency->id,
];
$destInfo = [
'id' => (int) $row['destination_id'],
'name' => $row['destination_name'],
'iban' => $row['destination_iban'],
'number' => $row['destination_number'],
'bic' => $row['destination_bic'],
'id' => (int) $row['destination_id'],
'name' => $row['destination_name'],
'iban' => $row['destination_iban'],
'number' => $row['destination_number'],
'bic' => $row['destination_bic'],
'currency_id' => $currency->id,
];
Log::debug('Source info:', $sourceInfo);
Log::debug('Destination info:', $destInfo);
$sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo);
Log::debug('Now calling getAccount for the source.');
$sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo);
Log::debug('Now calling getAccount for the destination.');
$destinationAccount = $this->getAccount($type->type, 'destination', $destInfo);
Log::debug('Done with getAccount(2x)');
$currency = $this->getCurrencyByAccount($type->type, $currency, $sourceAccount, $destinationAccount);
$foreignCurrency = $this->compareCurrencies($currency, $foreignCurrency);
$foreignCurrency = $this->getForeignByAccount($type->type, $foreignCurrency, $destinationAccount);
@@ -465,12 +472,13 @@ class TransactionJournalFactory
*/
private function getCurrency(?TransactionCurrency $currency, Account $account): TransactionCurrency
{
Log::debug('Now in getCurrency()');
$preference = $this->accountRepository->getAccountCurrency($account);
if (null === $preference && null === $currency) {
// return user's default:
return app('amount')->getDefaultCurrencyByUser($this->user);
}
$result = $preference ?? $currency;
$result = ($preference ?? $currency) ?? app('amount')->getSystemCurrency();
Log::debug(sprintf('Currency is now #%d (%s) because of account #%d (%s)', $result->id, $result->code, $account->id, $account->name));
return $result;
@@ -486,6 +494,7 @@ class TransactionJournalFactory
*/
private function getCurrencyByAccount(string $type, ?TransactionCurrency $currency, Account $source, Account $destination): TransactionCurrency
{
Log::debug('Now ingetCurrencyByAccount()');
switch ($type) {
default:
case TransactionType::WITHDRAWAL:
@@ -535,15 +544,15 @@ class TransactionJournalFactory
$dataRow = $row->getArrayCopy();
unset($dataRow['import_hash_v2'], $dataRow['original_source']);
$json = json_encode($dataRow);
$json = json_encode($dataRow, JSON_THROW_ON_ERROR, 512);
if (false === $json) {
// @codeCoverageIgnoreStart
$json = json_encode((string) microtime());
$json = json_encode((string) microtime(), JSON_THROW_ON_ERROR, 512);
Log::error(sprintf('Could not hash the original row! %s', json_last_error_msg()), $dataRow);
// @codeCoverageIgnoreEnd
}
$hash = hash('sha256', $json);
Log::debug(sprintf('The hash is: %s', $hash));
Log::debug(sprintf('The hash is: %s', $hash), $dataRow);
return $hash;
}
@@ -599,7 +608,7 @@ class TransactionJournalFactory
// validate source account.
$sourceId = isset($data['source_id']) ? (int) $data['source_id'] : null;
$sourceName = $data['source_name'] ?? null;
$validSource = $this->accountValidator->validateSource($sourceId, $sourceName);
$validSource = $this->accountValidator->validateSource($sourceId, $sourceName, null);
// do something with result:
if (false === $validSource) {
@@ -608,8 +617,8 @@ class TransactionJournalFactory
Log::debug('Source seems valid.');
// validate destination account
$destinationId = isset($data['destination_id']) ? (int) $data['destination_id'] : null;
$destinationName = $data['destination_name'] ?? null;
$validDestination = $this->accountValidator->validateDestination($destinationId, $destinationName);
$destinationName = (string)($data['destination_name'] ?? null);
$validDestination = $this->accountValidator->validateDestination($destinationId, $destinationName, null);
// do something with result:
if (false === $validDestination) {
throw new FireflyException(sprintf('Destination: %s', $this->accountValidator->destError)); // @codeCoverageIgnore

View File

@@ -165,7 +165,8 @@ class UserEventHandler
$user = $event->user;
$ipAddress = $event->ipAddress;
$token = app('preferences')->getForUser($user, 'email_change_undo_token', 'invalid');
$uri = route('profile.undo-email-change', [$token->data, hash('sha256', $oldEmail)]);
$hashed = hash('sha256', sprintf('%s%s', (string) config('app.key'), $oldEmail));
$uri = route('profile.undo-email-change', [$token->data,$hashed]);
try {
Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress));
// @codeCoverageIgnoreStart

View File

@@ -71,7 +71,7 @@ class DeleteController extends Controller
*
* @param Account $account
*
* @return Factory|View
* @return Factory|RedirectResponse|Redirector|View
*/
public function delete(Account $account)
{

View File

@@ -81,8 +81,7 @@ class EditController extends Controller
* @param Account $account
* @param AccountRepositoryInterface $repository
*
* @return Factory|View
*
* @return Factory|RedirectResponse|Redirector|View
*/
public function edit(Request $request, Account $account, AccountRepositoryInterface $repository)
{

View File

@@ -216,7 +216,8 @@ class ReconcileController extends Controller
* @param string $difference
*
* @throws DuplicateTransactionException
* @return string
*
* @return RedirectResponse|Redirector|string
*/
private function createReconciliation(Account $account, Carbon $start, Carbon $end, string $difference)
{

View File

@@ -86,7 +86,8 @@ class ShowController extends Controller
* @param Carbon|null $end
*
* @throws Exception
* @return RedirectResponse|Redirector|View
*
* @return RedirectResponse|Redirector|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show(Request $request, Account $account, Carbon $start = null, Carbon $end = null)
{
@@ -158,7 +159,8 @@ class ShowController extends Controller
* @param Account $account
*
* @throws Exception
* @return RedirectResponse|Redirector|View
*
* @return RedirectResponse|Redirector|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showAll(Request $request, Account $account)
{

View File

@@ -90,7 +90,7 @@ class LinkController extends Controller
* @param Request $request
* @param LinkType $linkType
*
* @return RedirectResponse|Redirector|View
* @return Factory|RedirectResponse|Redirector|\Illuminate\View\View
*/
public function delete(Request $request, LinkType $linkType)
{

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* TelemetryController.php
* Copyright (c) 2020 thegrumpydictator@gmail.com
@@ -55,7 +56,7 @@ class TelemetryController extends Controller
}
/**
* @return string
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function deleteSubmitted()
{
@@ -67,7 +68,7 @@ class TelemetryController extends Controller
}
/**
* @return string
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function deleteAll()
{

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**

View File

@@ -57,10 +57,9 @@ class ForgotPasswordController extends Controller
* Send a reset link to the given user.
*
* @param Request $request
*
* @param UserRepositoryInterface $repository
*
* @return RedirectResponse|JsonResponse
* @return Factory|RedirectResponse|View
*/
public function sendResetLinkEmail(Request $request, UserRepositoryInterface $repository)
{

View File

@@ -68,7 +68,8 @@ class ResetPasswordController extends Controller
* @param Request $request
*
* @throws \Illuminate\Validation\ValidationException
* @return RedirectResponse|JsonResponse
*
* @return Factory|JsonResponse|RedirectResponse|View
*/
public function reset(Request $request)
{

View File

@@ -236,6 +236,7 @@ class IndexController extends Controller
$repository->setBudgetOrder($budget, $index + 1);
}
}
app('preferences')->mark();
return response()->json(['OK']);
}

View File

@@ -432,9 +432,15 @@ class AccountController extends Controller
$cache->addProperty($end);
$cache->addProperty($account->id);
if ($cache->has()) {
return response()->json($cache->get()); // @codeCoverageIgnore
return response()->json($cache->get()); // @codeCoverageIgnore
}
$currencies = $this->accountRepository->getUsedCurrencies($account);
// if the account is not expense or revenue, just use the account's default currency.
if (!in_array($account->accountType->type, [AccountType::REVENUE, AccountType::EXPENSE], true)) {
$currencies = [$this->accountRepository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency()];
}
/** @var TransactionCurrency $currency */
foreach ($currencies as $currency) {
$chartData[] = $this->periodByCurrency($start, $end, $account, $currency);

View File

@@ -450,8 +450,6 @@ class TagReportController extends Controller
$data = $this->generator->multiCurrencyPieChart($result);
return response()->json($data);
return response()->json($data);
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* TransactionController.php
* Copyright (c) 2020 thegrumpydictator@gmail.com
@@ -137,6 +138,7 @@ class TransactionController extends Controller
$collector->setTypes([TransactionType::DEPOSIT]);
break;
case 'transfers':
case 'transfer':
$collector->setTypes([TransactionType::TRANSFER]);
break;
}
@@ -204,6 +206,7 @@ class TransactionController extends Controller
$collector->setTypes([TransactionType::DEPOSIT]);
break;
case 'transfers':
case 'transfer':
$collector->setTypes([TransactionType::TRANSFER]);
break;
}
@@ -270,6 +273,7 @@ class TransactionController extends Controller
$collector->setTypes([TransactionType::DEPOSIT]);
break;
case 'transfers':
case 'transfer':
$collector->setTypes([TransactionType::TRANSFER]);
break;
}

View File

@@ -75,7 +75,7 @@ class CurrencyController extends Controller
*
* @param Request $request
*
* @return RedirectResponse|Redirector|View
* @return Factory|RedirectResponse|Redirector|\Illuminate\View\View
*/
public function create(Request $request)
{
@@ -128,7 +128,7 @@ class CurrencyController extends Controller
* @param Request $request
* @param TransactionCurrency $currency
*
* @return RedirectResponse|Redirector|View
* @return Factory|RedirectResponse|Redirector|\Illuminate\View\View
*/
public function delete(Request $request, TransactionCurrency $currency)
{
@@ -266,7 +266,7 @@ class CurrencyController extends Controller
* @param Request $request
* @param TransactionCurrency $currency
*
* @return RedirectResponse|Redirector|View
* @return Factory|RedirectResponse|Redirector|\Illuminate\View\View
*/
public function edit(Request $request, TransactionCurrency $currency)
{

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* IndexController.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -73,7 +73,7 @@ class PrerequisitesController extends Controller
* @param string $importProvider
* @param ImportJob $importJob
*
* @return Factory|View
* @return Factory|RedirectResponse|Redirector|View
*/
public function index(string $importProvider, ImportJob $importJob = null)
{

View File

@@ -126,7 +126,7 @@ class JavascriptController extends Controller
/** @noinspection NullPointerExceptionInspection */
$lang = $pref->data;
$dateRange = $this->getDateRangeConfig();
$uid = substr(hash('sha256', auth()->user()->id . auth()->user()->email), 0, 12);
$uid = substr(hash('sha256', sprintf('%s-%s-%s', (string) config('app.key'), auth()->user()->id, auth()->user()->email)), 0, 12);
$data = [
'currencyCode' => $currency->code,

View File

@@ -263,7 +263,7 @@ class BoxController extends Controller
*/
public function netWorth(): JsonResponse
{
$date = Carbon::now()->startOfDay();
$date = Carbon::now()->endOfDay();
// start and end in the future? use $end
if ($this->notInSessionRange($date)) {

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use FireflyIII\Http\Requests\NewUserFormRequest;
use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Support\Http\Controllers\CreateStuff;
@@ -58,7 +59,7 @@ class NewUserController extends Controller
/**
* Form the user gets when he has no data in the system.
*
* @return RedirectResponse|Redirector|View
* @return RedirectResponse|Redirector|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
@@ -110,6 +111,12 @@ class NewUserController extends Controller
// store currency preference:
app('preferences')->set('currencyPreference', $currency->code);
// store frontpage preferences:
$accounts = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
app('preferences')->set('frontPageAccounts', $accounts);
// mark.
app('preferences')->mark();
// set default optional fields:

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* DataController.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -88,7 +88,7 @@ class ProfileController extends Controller
*
* @param Request $request
*
* @return Factory|View
* @return Factory|RedirectResponse|Redirector|View
*/
public function changeEmail(Request $request)
{
@@ -114,7 +114,7 @@ class ProfileController extends Controller
*
* @param Request $request
*
* @return Factory|View
* @return Factory|RedirectResponse|Redirector|View
*/
public function changePassword(Request $request)
{
@@ -555,7 +555,7 @@ class ProfileController extends Controller
/** @var string $match */
$match = null;
foreach ($set as $entry) {
$hashed = hash('sha256', $entry->data);
$hashed = hash('sha256', sprintf('%s%s', (string) config('app.key'), $entry->data));
if ($hashed === $hash) {
$match = $entry->data;
break;

View File

@@ -115,7 +115,7 @@ class InstallController extends Controller
/**
* Show index.
*
* @return RedirectResponse|Redirector
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{

View File

@@ -68,7 +68,7 @@ class BulkController extends Controller
*
* TODO user wont be able to tell if journal is part of split.
*
* @param Collection $journals
* @param array $journals
*
* @return Factory|View
*/

View File

@@ -87,7 +87,8 @@ class ConvertController extends Controller
* @param TransactionGroup $group
*
* @throws Exception
* @return RedirectResponse|Redirector|View
*
* @return RedirectResponse|Redirector|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(TransactionType $destinationType, TransactionGroup $group)
{
@@ -207,9 +208,9 @@ class ConvertController extends Controller
$sourceId = '' === $sourceId || null === $sourceId ? null : (int) $sourceId;
$sourceName = '' === $sourceName ? null : $sourceName;
$destinationId = '' === $destinationId || null === $destinationId ? null : (int) $destinationId;
$destinationName = '' === $destinationName ? null : $destinationName;
$validSource = $validator->validateSource($sourceId, $sourceName);
$validDestination = $validator->validateDestination($destinationId, $destinationName);
$destinationName = (string)('' === $destinationName ? null : $destinationName);
$validSource = $validator->validateSource($sourceId, $sourceName, null);
$validDestination = $validator->validateDestination($destinationId, $destinationName, null);
if (false === $validSource) {
throw new FireflyException(sprintf(trans('firefly.convert_invalid_source'), $journal->id));
@@ -218,6 +219,8 @@ class ConvertController extends Controller
throw new FireflyException(sprintf(trans('firefly.convert_invalid_destination'), $journal->id));
}
// TODO typeOverrule: the account validator may have another opinion on the transaction type.
$update = [
'source_id' => $sourceId,
'source_name' => $sourceName,

View File

@@ -63,7 +63,7 @@ class EditController extends Controller
/**
* @param TransactionGroup $transactionGroup
*
* @return Factory|View
* @return Factory|View|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function edit(TransactionGroup $transactionGroup)
{

View File

@@ -108,6 +108,7 @@ class ShowController extends Controller
if (!Str::contains($transaction['notes'], $search)) {
$groupArray['transactions'][$index]['notes'] = e($transaction['notes']);
}
$groupArray['transactions'][$index]['tags'] = $this->repository->getTagObjects($groupArray['transactions'][$index]['transaction_journal_id']);
}
$events = $this->repository->getPiggyEvents($transactionGroup);

View File

@@ -68,7 +68,7 @@ class BudgetFormStoreRequest extends Request
'name' => 'required|between:1,100|uniqueObjectForUser:budgets,name',
'active' => 'numeric|between:0,1',
'auto_budget_type' => 'numeric|between:0,2',
'auto_budget_currency_id' => 'required|exists:transaction_currencies,id',
'auto_budget_currency_id' => 'exists:transaction_currencies,id',
'auto_budget_amount' => 'min:0|max:1000000000',
'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly',
];

View File

@@ -78,7 +78,7 @@ class BudgetFormUpdateRequest extends Request
'name' => $nameRule,
'active' => 'numeric|between:0,1',
'auto_budget_option' => 'numeric|between:0,2',
'auto_budget_currency_id' => 'required|exists:transaction_currencies,id',
'auto_budget_currency_id' => 'exists:transaction_currencies,id',
'auto_budget_amount' => 'min:0|max:1000000000',
'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly',
];

View File

@@ -50,7 +50,7 @@ class ProfileFormRequest extends Request
// fixed
return [
'current_password' => 'required',
'new_password' => 'required|confirmed|secure_password',
'new_password' => 'required|confirmed|secure_password|min:16',
'new_password_confirmation' => 'required',
];
}

View File

@@ -246,6 +246,8 @@ class RecurrenceFormRequest extends Request
$sourceId = null;
$destinationId = null;
// TODO typeOverrule: the account validator may have another opinion on the transaction type.
switch ($this->string('transaction_type')) {
default:
throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->string('transaction_type'))); // @codeCoverageIgnore
@@ -265,7 +267,7 @@ class RecurrenceFormRequest extends Request
// validate source account.
$validSource = $accountValidator->validateSource($sourceId, null);
$validSource = $accountValidator->validateSource($sourceId, null, null);
// do something with result:
if (false === $validSource) {
@@ -277,7 +279,7 @@ class RecurrenceFormRequest extends Request
}
// validate destination account
$validDestination = $accountValidator->validateDestination($destinationId, null);
$validDestination = $accountValidator->validateDestination($destinationId, null, null);
// do something with result:
if (false === $validDestination) {
$message = (string) trans('validation.generic_invalid_destination');

View File

@@ -41,8 +41,7 @@ class BankDebitCredit implements ConverterInterface
*
* @param $value
*
* @return mixed
*
* @return int
*/
public function convert($value): int
{

View File

@@ -112,9 +112,10 @@ class IngDescription implements SpecificInterface
protected function moveValutadatumDescription(): void
{
$matches = [];
preg_match('/Valutadatum: ([0-9-]+)/', $this->row[8], $matches);
$this->row[9] = date("Ymd", strtotime($matches[1]));
$this->row[8] = preg_replace('/Valutadatum: [0-9-]+/', '', $this->row[8]);
if (preg_match('/Valutadatum: ([0-9-]+)/', $this->row[8], $matches)) {
$this->row[9] = date("Ymd", strtotime($matches[1]));
$this->row[8] = preg_replace('/Valutadatum: [0-9-]+/', '', $this->row[8]);
}
}
/**
@@ -140,11 +141,7 @@ class IngDescription implements SpecificInterface
*/
protected function removeNameIngDescription(): void
{
$matches = [];
if (preg_match('/Valutadatum: ([0-9-]+)/', $this->row[8], $matches)) {
$this->row[9] = date("Ymd", strtotime($matches[1]));
$this->row[8] = preg_replace('/Valutadatum: [0-9-]+/', '', $this->row[8]);
}
$this->row[8] = preg_replace('/Naam:.*?([a-zA-Z\/]+:)/', '$1', $this->row[8]);
}
/**
@@ -153,16 +150,23 @@ class IngDescription implements SpecificInterface
private function MoveSavingsAccount(): void
{
$matches = [];
if ('' === (string) $this->row[3]) {
if (preg_match('/(Naar|Van) (.*rekening) ([0-9]+)/', $this->row[8], $matches)) {
$matches[3] = sprintf("%010d", $matches[3]);
$this->row[1] = $matches[2]; // Savings account name
$this->row[3] = $matches[3]; // Savings account number
$this->row[8] = preg_replace('/(Naar|Van) (.*rekening) ([0-9]+)/', '', $this->row[8]); // Remove the savings account content from description
} elseif (preg_match('/(Naar|Van) (.*rekening) ([0-9]+)/', $this->row[1], $matches)) {
$matches[3] = sprintf("%010d", $matches[3]);
$this->row[1] = $matches[2]; // Savings account name
$this->row[3] = $matches[3]; // Savings account number
if (preg_match('/(Naar|Van) (.*rekening) ([A-Za-z0-9]+)/', $this->row[8], $matches)) { // Search for saving acount at 'Mededelingen' column
$this->row[1] = $this->row[1] . ' ' . $matches[2] . ' ' . $matches[3]; // Current name + Saving acount name + Acount number
if ('' === (string) $this->row[3]) { // if Saving account number does not yet exists
$this->row[3] = $matches[3]; // Copy savings account number
}
$this->row[8] = preg_replace('/(Naar|Van) (.*rekening) ([A-Za-z0-9]+)/', '', $this->row[8]); // Remove the savings account content from description
} elseif (preg_match('/(Naar|Van) (.*rekening) ([A-Za-z0-9]+)/', $this->row[1], $matches)) { // Search for saving acount at 'Naam / Omschrijving' column
$this->row[1] = $matches[2] . ' ' . $matches[3]; // Saving acount name + Acount number
if ('' === (string) $this->row[3]) { // if Saving account number does not yet exists
$this->row[3] = $matches[3]; // Copy savings account number
}
}
if ('' !== (string)$this->row[3]) { // if Saving account number exists
if (! preg_match('/[A-Za-z]/', $this->row[3])) { // if Saving account number has no characters
$this->row[3] = sprintf("%010d", $this->row[3]); // Make the number 10 digits
}
}
}

View File

@@ -85,6 +85,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Account withTrashed()
* @method static Builder|Account withoutTrashed()
* @mixin Eloquent
* @property-read int|null $account_meta_count
* @property-read \Illuminate\Database\Eloquent\Collection|Attachment[] $attachments
* @property-read int|null $attachments_count
* @property-read string $account_number
* @property-read \Illuminate\Database\Eloquent\Collection|Location[] $locations
* @property-read int|null $locations_count
* @property-read int|null $notes_count
* @property-read int|null $piggy_banks_count
* @property-read int|null $transactions_count
*/
class Account extends Model
{
@@ -243,7 +252,11 @@ class Account extends Model
*/
public function setVirtualBalanceAttribute($value): void
{
$this->attributes['virtual_balance'] = (string) $value;
$value = (string)$value;
if('' === $value) {
$value = null;
}
$this->attributes['virtual_balance'] = $value;
}
/**

View File

@@ -32,11 +32,11 @@ use Illuminate\Support\Carbon;
/**
* Class AccountType.
*
* @property string $type
* @property string $type
* @method whereType(string $type)
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property-read Collection|Account[] $accounts
* @method static Builder|AccountType newModelQuery()
* @method static Builder|AccountType newQuery()
@@ -45,6 +45,7 @@ use Illuminate\Support\Carbon;
* @method static Builder|AccountType whereId($value)
* @method static Builder|AccountType whereUpdatedAt($value)
* @mixin Eloquent
* @property-read int|null $accounts_count
*/
class AccountType extends Model
{

View File

@@ -78,6 +78,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Attachment withTrashed()
* @method static Builder|Attachment withoutTrashed()
* @mixin Eloquent
* @property-read int|null $notes_count
*/
class Attachment extends Model
{

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* AutoBudget.php
* Copyright (c) 2020 thegrumpydictator@gmail.com
@@ -21,12 +22,45 @@
namespace FireflyIII\Models;
use Eloquent;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Carbon;
/**
* Class AutoBudget
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property int $budget_id
* @property int $transaction_currency_id
* @property int $auto_budget_type
* @property float $amount
* @property string $period
* @property-read Budget $budget
* @property-read TransactionCurrency $transactionCurrency
* @method static bool|null forceDelete()
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget newQuery()
* @method static Builder|AutoBudget onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget query()
* @method static bool|null restore()
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget whereAmount($value)
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget whereAutoBudgetType($value)
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget whereBudgetId($value)
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget wherePeriod($value)
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget whereTransactionCurrencyId($value)
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget whereUpdatedAt($value)
* @method static Builder|AutoBudget withTrashed()
* @method static Builder|AutoBudget withoutTrashed()
* @mixin Eloquent
*/
class AutoBudget extends Model
{

View File

@@ -86,6 +86,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Bill withTrashed()
* @method static Builder|Bill withoutTrashed()
* @mixin Eloquent
* @property-read int|null $attachments_count
* @property-read int|null $notes_count
* @property-read int|null $transaction_journals_count
* @property bool $name_encrypted
* @property bool $match_encrypted
*/
class Bill extends Model
{

View File

@@ -70,6 +70,17 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Budget withTrashed()
* @method static Builder|Budget withoutTrashed()
* @mixin Eloquent
* @property-read \Illuminate\Database\Eloquent\Collection|Attachment[] $attachments
* @property-read int|null $attachments_count
* @property-read \Illuminate\Database\Eloquent\Collection|AutoBudget[] $autoBudgets
* @property-read int|null $auto_budgets_count
* @property-read int|null $budgetlimits_count
* @property-read int|null $transaction_journals_count
* @property-read int|null $transactions_count
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property bool $encrypted
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\BudgetLimit[] $budgetlimits
*/
class Budget extends Model
{

View File

@@ -66,6 +66,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Category withTrashed()
* @method static Builder|Category withoutTrashed()
* @mixin Eloquent
* @property-read Collection|Attachment[] $attachments
* @property-read int|null $attachments_count
* @property-read int|null $transaction_journals_count
* @property-read int|null $transactions_count
* @property bool $encrypted
*/
class Category extends Model
{

View File

@@ -37,12 +37,12 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*
* @codeCoverageIgnore
* @deprecated
* @property array $transactions
* @property array $configuration
* @property User $user
* @property int $user_id
* @property string $status
* @property string $stage
* @property array $transactions
* @property array $configuration
* @property User $user
* @property int $user_id
* @property string $status
* @property string $stage
* @property string $key
* @property string $provider
* @property string $file_type
@@ -72,6 +72,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|ImportJob whereUpdatedAt($value)
* @method static Builder|ImportJob whereUserId($value)
* @mixin Eloquent
* @property-read int|null $attachments_count
* @property int $id
* @property array|null $extended_status
*/
class ImportJob extends Model
{

View File

@@ -62,6 +62,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|LinkType withTrashed()
* @method static Builder|LinkType withoutTrashed()
* @mixin Eloquent
* @property-read int|null $transaction_journal_links_count
*/
class LinkType extends Model
{

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* Location.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -22,12 +23,42 @@
namespace FireflyIII\Models;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Support\Carbon;
/**
* Class Location
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property int $locatable_id
* @property string $locatable_type
* @property float|null $latitude
* @property float|null $longitude
* @property int|null $zoom_level
* @property-read Collection|Account[] $accounts
* @property-read int|null $accounts_count
* @property-read Model|Eloquent $locatable
* @method static Builder|Location newModelQuery()
* @method static Builder|Location newQuery()
* @method static Builder|Location query()
* @method static Builder|Location whereCreatedAt($value)
* @method static Builder|Location whereDeletedAt($value)
* @method static Builder|Location whereId($value)
* @method static Builder|Location whereLatitude($value)
* @method static Builder|Location whereLocatableId($value)
* @method static Builder|Location whereLocatableType($value)
* @method static Builder|Location whereLongitude($value)
* @method static Builder|Location whereUpdatedAt($value)
* @method static Builder|Location whereZoomLevel($value)
* @mixin Eloquent
*/
class Location extends Model
{

View File

@@ -73,6 +73,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|PiggyBank withTrashed()
* @method static Builder|PiggyBank withoutTrashed()
* @mixin Eloquent
* @property-read Collection|Attachment[] $attachments
* @property-read int|null $attachments_count
* @property-read int|null $notes_count
* @property-read int|null $piggy_bank_events_count
* @property-read int|null $piggy_bank_repetitions_count
*/
class PiggyBank extends Model
{

View File

@@ -51,6 +51,10 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @method static Builder|PiggyBankEvent whereTransactionJournalId($value)
* @method static Builder|PiggyBankEvent whereUpdatedAt($value)
* @mixin Eloquent
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon $date
* @property-read \FireflyIII\Models\TransactionJournal|null $transactionJournal
*/
class PiggyBankEvent extends Model
{

View File

@@ -50,6 +50,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Preference whereUpdatedAt($value)
* @method static Builder|Preference whereUserId($value)
* @mixin Eloquent
* @property-read \FireflyIII\User $user
*/
class Preference extends Model
{

View File

@@ -87,6 +87,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Recurrence withTrashed()
* @method static Builder|Recurrence withoutTrashed()
* @mixin Eloquent
* @property-read int|null $notes_count
* @property-read int|null $recurrence_meta_count
* @property-read int|null $recurrence_repetitions_count
* @property-read int|null $recurrence_transactions_count
*/
class Recurrence extends Model
{

View File

@@ -75,6 +75,8 @@ use Illuminate\Support\Collection;
* @method static Builder|RecurrenceTransaction withTrashed()
* @method static Builder|RecurrenceTransaction withoutTrashed()
* @mixin Eloquent
* @property-read int|null $recurrence_transaction_meta_count
* @property int $transaction_currency_id
*/
class RecurrenceTransaction extends Model
{

View File

@@ -50,6 +50,7 @@ use Illuminate\Support\Carbon;
* @method static Builder|Role whereName($value)
* @method static Builder|Role whereUpdatedAt($value)
* @mixin Eloquent
* @property-read int|null $users_count
*/
class Role extends Model
{

View File

@@ -73,6 +73,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Rule withTrashed()
* @method static Builder|Rule withoutTrashed()
* @mixin Eloquent
* @property-read int|null $rule_actions_count
* @property-read int|null $rule_triggers_count
*/
class Rule extends Model
{

View File

@@ -67,6 +67,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|RuleGroup withoutTrashed()
* @property bool $stop_processing
* @mixin Eloquent
* @property-read int|null $rules_count
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereStopProcessing($value)
* @property string|null $description
*/
class RuleGroup extends Model
{

View File

@@ -73,6 +73,18 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Tag withTrashed()
* @method static Builder|Tag withoutTrashed()
* @mixin Eloquent
* @property-read \Illuminate\Database\Eloquent\Collection|Attachment[] $attachments
* @property-read int|null $attachments_count
* @property-read \Illuminate\Database\Eloquent\Collection|Location[] $locations
* @property-read int|null $locations_count
* @property-read int|null $transaction_journals_count
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string $tagMode
* @property string|null $description
* @property float|null $latitude
* @property float|null $longitude
* @property int|null $zoomLevel
*/
class Tag extends Model
{

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* Telemetry.php
* Copyright (c) 2020 thegrumpydictator@gmail.com
@@ -22,10 +23,36 @@
namespace FireflyIII\Models;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
/**
* Class Telemetry
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $submitted
* @property int|null $user_id
* @property string $installation_id
* @property string $type
* @property string $key
* @property array $value
* @method static Builder|Telemetry newModelQuery()
* @method static Builder|Telemetry newQuery()
* @method static Builder|Telemetry query()
* @method static Builder|Telemetry whereCreatedAt($value)
* @method static Builder|Telemetry whereId($value)
* @method static Builder|Telemetry whereInstallationId($value)
* @method static Builder|Telemetry whereKey($value)
* @method static Builder|Telemetry whereSubmitted($value)
* @method static Builder|Telemetry whereType($value)
* @method static Builder|Telemetry whereUpdatedAt($value)
* @method static Builder|Telemetry whereUserId($value)
* @method static Builder|Telemetry whereValue($value)
* @mixin Eloquent
*/
class Telemetry extends Model
{

View File

@@ -130,6 +130,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @method static \Illuminate\Database\Query\Builder|Transaction withTrashed()
* @method static \Illuminate\Database\Query\Builder|Transaction withoutTrashed()
* @mixin Eloquent
* @property-read int|null $budgets_count
* @property-read int|null $categories_count
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property bool $reconciled
*/
class Transaction extends Model
{

View File

@@ -64,6 +64,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|TransactionCurrency withTrashed()
* @method static Builder|TransactionCurrency withoutTrashed()
* @mixin Eloquent
* @property-read int|null $budget_limits_count
* @property-read int|null $transaction_journals_count
* @property-read int|null $transactions_count
* @property string $name
*/
class TransactionCurrency extends Model
{

View File

@@ -60,11 +60,12 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|TransactionGroup withTrashed()
* @method static Builder|TransactionGroup withoutTrashed()
* @mixin Eloquent
* @property string amount
* @property string foreign_amount
* @property int transaction_group_id
* @property int transaction_journal_id
* @property string transaction_group_title
* @property string amount
* @property string foreign_amount
* @property int transaction_group_id
* @property int transaction_journal_id
* @property string transaction_group_title
* @property-read int|null $transaction_journals_count
*/
class TransactionGroup extends Model
{

View File

@@ -109,6 +109,30 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withTrashed()
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withoutTrashed()
* @mixin Eloquent
* @property-read int|null $attachments_count
* @property-read int|null $budgets_count
* @property-read int|null $categories_count
* @property-read \Illuminate\Database\Eloquent\Collection|TransactionJournalLink[] $destJournalLinks
* @property-read int|null $dest_journal_links_count
* @property-read int|null $notes_count
* @property-read int|null $piggy_bank_events_count
* @property-read int|null $source_journal_links_count
* @property-read int|null $tags_count
* @property-read int|null $transaction_journal_meta_count
* @property-read int|null $transactions_count
* @method static EloquentBuilder|TransactionJournal whereTransactionGroupId($value)
* @property int $user_id
* @property int|null $transaction_group_id
* @property int|null $transaction_currency_id
* @property \Illuminate\Support\Carbon|null $interest_date
* @property \Illuminate\Support\Carbon|null $book_date
* @property \Illuminate\Support\Carbon|null $process_date
* @property int $order
* @property bool $encrypted
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Budget[] $budgets
* @property-read \FireflyIII\Models\TransactionGroup|null $transactionGroup
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournalMeta[] $transactionJournalMeta
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Transaction[] $transactions
*/
class TransactionJournal extends Model
{

View File

@@ -56,6 +56,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|TransactionJournalLink whereSourceId($value)
* @method static Builder|TransactionJournalLink whereUpdatedAt($value)
* @mixin Eloquent
* @property-read int|null $notes_count
*/
class TransactionJournalLink extends Model
{

View File

@@ -54,6 +54,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|TransactionType withTrashed()
* @method static Builder|TransactionType withoutTrashed()
* @mixin Eloquent
* @property-read int|null $transaction_journals_count
*/
class TransactionType extends Model
{

View File

@@ -48,7 +48,7 @@ use FireflyIII\Services\FireflyIIIOrg\Update\UpdateRequest;
use FireflyIII\Services\FireflyIIIOrg\Update\UpdateRequestInterface;
use FireflyIII\Services\IP\IpifyOrg;
use FireflyIII\Services\IP\IPRetrievalInterface;
use FireflyIII\Services\Password\PwndVerifierV3;
use FireflyIII\Services\Password\PwndVerifierV2;
use FireflyIII\Services\Password\Verifier;
use FireflyIII\Support\Amount;
use FireflyIII\Support\ExpandedForm;
@@ -189,7 +189,7 @@ class FireflyServiceProvider extends ServiceProvider
$this->app->bind(ExchangeRateInterface::class, $class);
// password verifier thing
$this->app->bind(Verifier::class, PwndVerifierV3::class);
$this->app->bind(Verifier::class, PwndVerifierV2::class);
// IP thing:
$this->app->bind(IPRetrievalInterface::class, IpifyOrg::class);

View File

@@ -189,7 +189,7 @@ class BudgetRepository implements BudgetRepositoryInterface
{
/** @var Collection $set */
$set = $this->user->budgets()->where('active', 1)
->orderBy('order', 'ASC')
->orderBy('order', 'DESC')
->orderBy('name', 'ASC')
->get();

View File

@@ -267,6 +267,7 @@ class CategoryRepository implements CategoryRepositoryInterface
{
/** @var CategoryUpdateService $service */
$service = app(CategoryUpdateService::class);
$service->setUser($this->user);
return $service->update($category, $data);
}

View File

@@ -320,7 +320,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
* @param int|null $currencyId
* @param string|null $currencyCode
*
* @return TransactionCurrency|null
* @return TransactionCurrency
*/
public function findCurrency(?int $currencyId, ?string $currencyCode): TransactionCurrency
{

View File

@@ -156,7 +156,7 @@ interface CurrencyRepositoryInterface
* @param int|null $currencyId
* @param string|null $currencyCode
*
* @return TransactionCurrency|null
* @return TransactionCurrency
*/
public function findCurrency(?int $currencyId, ?string $currencyCode): TransactionCurrency;

View File

@@ -384,7 +384,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
$attachment = new Attachment; // create Attachment object.
$attachment->user()->associate($job->user);
$attachment->attachable()->associate($job);
$attachment->md5 = md5($content);
$attachment->md5 = substr(hash('sha256', $content), 0, 32); // limit due to DB.
$attachment->filename = $name;
$attachment->mime = 'plain/txt';
$attachment->size = strlen($content);

View File

@@ -118,7 +118,7 @@ interface TagRepositoryInterface
/**
* @param int|null $year
*
* @return Collection
* @return array
*/
public function getTagsInYear(?int $year): array;

View File

@@ -45,6 +45,7 @@ use FireflyIII\Services\Internal\Update\GroupUpdateService;
use FireflyIII\Support\NullArrayObject;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Log;
/**
@@ -468,4 +469,15 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
return $return;
}
/**
* @inheritDoc
*/
public function getTagObjects(int $journalId): Collection
{
/** @var TransactionJournal $journal */
$journal = $this->user->transactionJournals()->find($journalId);
return $journal->tags()->get();
}
}

View File

@@ -28,6 +28,7 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Support\NullArrayObject;
use FireflyIII\User;
use Illuminate\Support\Collection;
/**
* Interface TransactionGroupRepositoryInterface
@@ -122,6 +123,15 @@ interface TransactionGroupRepositoryInterface
*/
public function getTags(int $journalId): array;
/**
* Get the tags for a journal (by ID) as Tag objects.
*
* @param int $journalId
*
* @return Collection
*/
public function getTagObjects(int $journalId): Collection;
/**
* Set the user.
*

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* IsTransferAccount.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -35,7 +36,7 @@ class IsTransferAccount implements Rule
/**
* Get the validation error message.
*
* @return string|array
* @return string
*/
public function message(): string
{
@@ -58,14 +59,14 @@ class IsTransferAccount implements Rule
$validator->setTransactionType(TransactionType::TRANSFER);
$validator->setUser(auth()->user());
$validAccount = $validator->validateSource(null, (string)$value);
$validAccount = $validator->validateSource(null, (string)$value, null);
if (true === $validAccount) {
Log::debug('Found account based on name. Return true.');
// found by name, use repos to return.
return true;
}
$validAccount = $validator->validateSource((int)$value, null);
$validAccount = $validator->validateSource((int)$value, null, null);
Log::debug(sprintf('Search by id (%d), result is %s.', (int)$value, var_export($validAccount, true)));
return !(false === $validAccount);

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* LessThanPiggyTarget.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -128,7 +128,7 @@ class FixerIOv2 implements ExchangeRateInterface
/**
* @param User $user
*
* @return mixed|void
* @return void
*/
public function setUser(User $user)
{

View File

@@ -117,7 +117,7 @@ class RatesApiIOv1 implements ExchangeRateInterface
/**
* @param User $user
*
* @return mixed|void
* @return void
*/
public function setUser(User $user)
{

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* UpdateRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* UpdateRequestInterface.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -237,7 +237,6 @@ trait AccountServiceTrait
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
// @codeCoverageIgnoreEnd
return $group;

View File

@@ -345,6 +345,7 @@ trait JournalServiceTrait
*/
private function createAccount(?Account $account, array $data, string $preferredType): Account
{
Log::debug('Now in createAccount()', $data);
// return new account.
if (null === $account) {
$data['name'] = $data['name'] ?? '(no name)';
@@ -359,22 +360,25 @@ trait JournalServiceTrait
'account_type_id' => null,
'account_type' => $preferredType,
'name' => $data['name'],
'virtual_balance' => null,
'active' => true,
'iban' => $data['iban'],
'currency_id' => $data['currency_id'] ?? null,
]
);
// store BIC
if (null !== $data['bic']) {
/** @var AccountMetaFactory $metaFactory */
$metaFactory = app(AccountMetaFactory::class);
$metaFactory->create(['account_id' => $result->id, 'name' => 'BIC', 'data' => $data['bic']]);
$metaFactory->create(['account_id' => $account->id, 'name' => 'BIC', 'data' => $data['bic']]);
}
// store account number
if (null !== $data['number']) {
/** @var AccountMetaFactory $metaFactory */
$metaFactory = app(AccountMetaFactory::class);
$metaFactory->create(['account_id' => $result->id, 'name' => 'account_number', 'data' => $data['bic']]);
$metaFactory->create(['account_id' => $account->id, 'name' => 'account_number', 'data' => $data['bic']]);
}
}
return $account;

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* LocationServiceTrait.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@@ -98,14 +98,16 @@ trait RecurringTransactionTrait
$validator = app(AccountValidator::class);
$validator->setUser($recurrence->user);
$validator->setTransactionType($recurrence->transactionType->type);
if (!$validator->validateSource($source->id, null)) {
if (!$validator->validateSource($source->id, null, null)) {
throw new FireflyException(sprintf('Source invalid: %s', $validator->sourceError)); // @codeCoverageIgnore
}
if (!$validator->validateDestination($destination->id, null)) {
if (!$validator->validateDestination($destination->id, null, null)) {
throw new FireflyException(sprintf('Destination invalid: %s', $validator->destError)); // @codeCoverageIgnore
}
// TODO typeOverrule: the account validator may have another opinion on the transaction type.
$transaction = new RecurrenceTransaction(
[
'recurrence_id' => $recurrence->id,

Some files were not shown because too many files have changed in this diff Show More