Merge branch 'release/5.6.0-alpha.1'

This commit is contained in:
James Cole
2021-07-03 12:35:07 +02:00
772 changed files with 11053 additions and 10938 deletions

View File

@@ -188,7 +188,7 @@ AUTHENTICATION_GUARD=web
# Enter a custom URL here that will force a logout (your authentication provider can tell you).
# Setting this variable only works when AUTHENTICATION_GUARD != web
#
CUSTOM_LOGOUT_URI=
CUSTOM_LOGOUT_URL=
# LDAP connection configuration
# OpenLDAP, FreeIPA or ActiveDirectory

View File

@@ -189,7 +189,7 @@ AUTHENTICATION_GUARD=web
# Enter a custom URL here that will force a logout (your authentication provider can tell you).
# Setting this variable only works when AUTHENTICATION_GUARD != web
#
CUSTOM_LOGOUT_URI=
CUSTOM_LOGOUT_URL=
# LDAP connection configuration
# OpenLDAP, FreeIPA or ActiveDirectory

View File

@@ -53,8 +53,7 @@ LOG_CHANNEL=stack
APP_LOG_LEVEL=notice
# Audit log level.
# set to "emergency" if you dont want to store audit logs.
# leave on info otherwise.
# Set this to "emergency" if you dont want to store audit logs, leave on info otherwise.
AUDIT_LOG_LEVEL=info
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
@@ -89,11 +88,11 @@ PGSQL_SSL_CERT=null
PGSQL_SSL_KEY=null
PGSQL_SSL_CRL_FILE=null
# If you're looking for performance improvements, you could install memcached.
# If you're looking for performance improvements, you could install memcached or redis
CACHE_DRIVER=file
SESSION_DRIVER=file
# If you set either of these to 'redis', you might want to update these settings too
# If you set either of the options above to 'redis', you might want to update these settings too
# If you use Docker or similar, you can set REDIS_HOST_FILE, REDIS_PASSWORD_FILE or
# REDIS_PORT_FILE to set the value from a file instead of from an environment variable
@@ -106,8 +105,8 @@ REDIS_PATH=
# use only when using 'tcp' or 'http' for REDIS_SCHEME. Leave empty otherwise.
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=null
# always use quotes and make sure redis db "0" and "1" exists. Otherwise change accordingly.
REDIS_DB="0"
REDIS_CACHE_DB="1"
@@ -115,12 +114,13 @@ REDIS_CACHE_DB="1"
# Cookie settings. Should not be necessary to change these.
# If you use Docker or similar, you can set COOKIE_DOMAIN_FILE to set
# the value from a file instead of from an environment variable
# Setting samesite to "strict" may give you trouble logging in.
COOKIE_PATH="/"
COOKIE_DOMAIN=
COOKIE_SECURE=false
COOKIE_SAMESITE=lax
# If you want Firefly III to mail you, update these settings
# If you want Firefly III to email you, update these settings
# For instructions, see: https://docs.firefly-iii.org/advanced-installation/email
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
MAIL_MAILER=log
@@ -145,7 +145,7 @@ MAILGUN_ENDPOINT=api.mailgun.net
MANDRILL_SECRET=
SPARKPOST_SECRET=
# Firefly III can send you the following messages
# Firefly III can send you the following messages.
SEND_REGISTRATION_MAIL=true
SEND_ERROR_MESSAGE=true
SEND_LOGIN_NEW_IP_WARNING=true
@@ -153,16 +153,9 @@ SEND_LOGIN_NEW_IP_WARNING=true
# These messages contain (sensitive) transaction information:
SEND_REPORT_JOURNALS=true
# Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places.
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
# Take note: it is no longer necessary to set this value, and it will be removed in future versions.
MAPBOX_API_KEY=
#
# Instead of the mapbox API key, just set this value to true if you want to set the location
# Set this value to true if you want to set the location
# of certain things, like transactions. Since this involves an external service, it's optional
# and disabled by default.
#
ENABLE_EXTERNAL_MAP=false
# The map will default to this location:
@@ -170,100 +163,47 @@ MAP_DEFAULT_LAT=51.983333
MAP_DEFAULT_LONG=5.916667
MAP_DEFAULT_ZOOM=6
# Firefly III has two options for user authentication. "eloquent" is the default,
# and "ldap" for LDAP servers.
# For full instructions on these settings please visit:
# https://docs.firefly-iii.org/advanced-installation/authentication
# If you use Docker or similar, you can set this variable from a file by appending it with _FILE
#
# If you enable 'ldap' AND you run Docker, the Docker image will contact packagist.org
# This is necessary to download the required packages.
# Firefly III authentication settings
#
LOGIN_PROVIDER=eloquent
# It's also possible to change the way users are authenticated. You could use Authelia for example.
# Authentication via the REMOTE_USER header is supported. Change the value below to "remote_user_guard".
#
# This will also allow Windows SSO.
#
# If you do this please read the documentation for instructions and warnings:
# Firefly III supports a few authentication methods:
# - 'web' (default, uses built in DB)
# - 'ldap'
# - 'remote_user_guard' for Authelia etc
# Read more about these settings in the documentation.
# https://docs.firefly-iii.org/advanced-installation/authentication
#
# Set to 'ldap' to enable LDAP
#
# This function is available in Firefly III v5.3.0 and higher.
AUTHENTICATION_GUARD=web
# If the guard is changed, Firefly III uses the 'REMOTE_USER' header as per RFC 3875.
# You can also use another header, like AUTH_USER when using Windows SSO.
# Some systems use X-Auth headers. In that case, use HTTP_X_AUTH_USERNAME or HTTP_X_AUTH_EMAIL
# Depending on your system, REMOTE_USER may need to be changed to HTTP_REMOTE_USER
#
# If this header is 'unexpectedly empty', check out the documentation.
# https://docs.firefly-iii.org/advanced-installation/authentication
# LDAP connection settings:
#
AUTHENTICATION_GUARD_HEADER=REMOTE_USER
LDAP_HOST=ldap.yourserver.com
LDAP_USERNAME="uid=X,ou=,o=,dc=something,dc=com"
LDAP_PASSWORD=super_secret
LDAP_PORT=389
LDAP_BASE_DN="o=something,dc=site,dc=com"
LDAP_TIMEOUT=5
LDAP_SSL=false
LDAP_TLS=false
LDAP_AUTH_FIELD=uid
#
# Firefly III uses email addresses as user identifiers. When you're using an external authentication guard
# that doesn't do this, Firefly III is incapable of emailing you. Messages sent to "Bill Gates" always fail.
#
# However, if you set this value, Firefly III will store the value from this header as the user's backup
# email address and use it to communicate. So user "Bill Gates" could still have
# the email address "bill@microsoft.com".
#
# Example value: AUTHENTICATION_GUARD_EMAIL=HTTP_X_AUTH_EMAIL
# Remote user guard settings
#
AUTHENTICATION_GUARD_HEADER=REMOTE_USER
AUTHENTICATION_GUARD_EMAIL=
# It's impossible to log out users who's authentication is handled by an external system.
# Enter a custom URL here that will force a logout (your authentication provider can tell you).
# Setting this variable only works when AUTHENTICATION_GUARD != web
#
CUSTOM_LOGOUT_URI=
# LDAP connection configuration
# OpenLDAP, FreeIPA or ActiveDirectory
# # If you use Docker or similar, you can set this variable from a file by appending it with _FILE
ADLDAP_CONNECTION_SCHEME=OpenLDAP
ADLDAP_AUTO_CONNECT=true
# LDAP connection settings
# You can set the following variables from a file by appending them with _FILE:
# ADLDAP_CONTROLLERS, ADLDAP_PORT, ADLDAP_BASEDN
ADLDAP_CONTROLLERS=
ADLDAP_PORT=389
ADLDAP_TIMEOUT=5
ADLDAP_BASEDN=""
ADLDAP_FOLLOW_REFFERALS=false
# SSL/TLS settings
ADLDAP_USE_SSL=false
ADLDAP_USE_TLS=false
ADLDAP_SSL_CACERTDIR=
ADLDAP_SSL_CACERTFILE=
ADLDAP_SSL_CERTFILE=
ADLDAP_SSL_KEYFILE=
ADLDAP_SSL_CIPHER_SUITE=
ADLDAP_SSL_REQUIRE_CERT=
# You can set the following variables from a file by appending them with _FILE:
ADLDAP_ADMIN_USERNAME=
ADLDAP_ADMIN_PASSWORD=
# You can set the following variables from a file by appending them with _FILE:
ADLDAP_ACCOUNT_PREFIX=
ADLDAP_ACCOUNT_SUFFIX=
# LDAP authentication settings.
ADLDAP_PASSWORD_SYNC=false
ADLDAP_LOGIN_FALLBACK=false
ADLDAP_DISCOVER_FIELD=distinguishedname
ADLDAP_AUTH_FIELD=distinguishedname
# field to sync as local username.
# You can set the following variable from a file by appending it with _FILE:
ADLDAP_SYNC_FIELD=userprincipalname
# Extra authentication settings
#
CUSTOM_LOGOUT_URL=
# You can disable the X-Frame-Options header if it interferes with tools like
# Organizr. This is at your own risk. Applications running in frames run the risk
@@ -284,16 +224,20 @@ DISABLE_CSP_HEADER=false
TRACKER_SITE_ID=
TRACKER_URL=
# Firefly III can collect telemetry on how you use Firefly III. This is opt-in.
# In order to allow this, change the following variable to true.
# To read more about this feature, go to this page: https://docs.firefly-iii.org/support/telemetry
SEND_TELEMETRY=false
#
# Firefly III supports webhooks. These are security sensitive and must be enabled manually first.
#
ALLOW_WEBHOOKS=false
#
# The static cron job token can be useful when you use Docker and wish to manage cron jobs.
# 1. Set this token to any 32-character value (this is important!).
# 2. Use this token in the cron URL instead of a user's command line token.
#
# For more info: https://docs.firefly-iii.org/firefly-iii/advanced-installation/cron/
#
STATIC_CRON_TOKEN=
# You can fine tune the start-up of a Docker container by editing these environment variables.
# Use this at your own risk. Disabling certain checks and features may result in lost of inconsistent data.
# However if you know what you're doing you can significantly speed up container start times.

View File

@@ -2,8 +2,7 @@
Before you create a new PR, please consider:
1) Pull requests for the MAIN branch will be closed.
2) We cannot accept pull requests to add new currencies.
3) DO NOT include translations in your PR. Only English US sentences.
2) DO NOT include translations in your PR. Only English US sentences.
Thanks.
-->

View File

@@ -87,7 +87,7 @@ class AccountController extends Controller
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
$default = app('amount')->getDefaultCurrency();
if (0 === count($frontPage->data)) {
if (empty($frontPage->data)) {
$frontPage->data = $defaultSet;
$frontPage->save();
}
@@ -114,7 +114,6 @@ class AccountController extends Controller
'yAxisID' => 0, // 0, 1, 2
'entries' => [],
];
/** @var Carbon $currentStart */
$currentStart = clone $start;
$range = app('steam')->balanceInRange($account, $start, clone $end);
$previous = round((float)array_values($range)[0], 12);

View File

@@ -46,6 +46,7 @@ abstract class Controller extends BaseController
protected const CONTENT_TYPE = 'application/vnd.api+json';
protected ParameterBag $parameters;
protected array $allowedSort;
/**
* Controller constructor.
@@ -53,7 +54,8 @@ abstract class Controller extends BaseController
public function __construct()
{
// get global parameters
$this->parameters = $this->getParameters();
$this->allowedSort = config('firefly.allowed_sort_parameters');
$this->parameters = $this->getParameters();
$this->middleware(
function ($request, $next) {
if (auth()->check()) {
@@ -106,10 +108,40 @@ abstract class Controller extends BaseController
}
}
return $bag;
// sort fields:
return $this->getSortParameters($bag);
}
/**
* @param ParameterBag $bag
*
* @return ParameterBag
*/
private function getSortParameters(ParameterBag $bag): ParameterBag
{
$sortParameters = [];
$param = (string)request()->query->get('sort');
if ('' === $param) {
return $bag;
}
$parts = explode(',', $param);
foreach ($parts as $part) {
$part = trim($part);
$direction = 'asc';
if ('-' === $part[0]) {
$part = substr($part, 1);
$direction = 'desc';
}
if (in_array($part, $this->allowedSort, true)) {
$sortParameters[] = [$part, $direction];
}
}
$bag->set('sort', $sortParameters);
return $bag;
}
/**
* Method to help build URI's.
*

View File

@@ -38,8 +38,8 @@ class AccountController extends Controller
public function moveTransactions(MoveTransactionsRequest $request): JsonResponse
{
$accountIds = $request->getAll();
$original = $this->repository->findNull($accountIds['original_account']);
$destination = $this->repository->findNull($accountIds['destination_account']);
$original = $this->repository->find($accountIds['original_account']);
$destination = $this->repository->find($accountIds['destination_account']);
/** @var AccountDestroyService $service */
$service = app(AccountDestroyService::class);

View File

@@ -70,6 +70,8 @@ class ExportController extends Controller
*
* @return LaravelResponse
* @throws CannotInsertRecord
* @throws \FireflyIII\Exceptions\FireflyException
* @throws \League\Csv\Exception
*/
private function returnExport(string $key): LaravelResponse
{

View File

@@ -81,7 +81,7 @@ class BudgetController extends Controller
}
/** @var Budget $budget */
foreach ($budgets as $budget) {
$expenses = $this->opsRepository->sumExpenses($start, $end, $assetAccounts, new Collection([$budget]), null);
$expenses = $this->opsRepository->sumExpenses($start, $end, $assetAccounts, new Collection([$budget]));
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [
@@ -109,7 +109,7 @@ class BudgetController extends Controller
$end = $request->getEnd();
$assetAccounts = $request->getAssetAccounts();
$result = [];
$expenses = $this->noRepository->sumExpenses($start, $end, $assetAccounts, null);
$expenses = $this->noRepository->sumExpenses($start, $end, $assetAccounts);
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [

View File

@@ -38,7 +38,7 @@ use Illuminate\Http\JsonResponse;
*
* Shows income information grouped or limited by date.
* Ie. all income grouped by account + currency.
* TODO same code as Expense/AccountController.
* See reference nr. 75
*/
class AccountController extends Controller
{
@@ -74,8 +74,9 @@ class AccountController extends Controller
}
/**
* TODO same code as Expense/AccountController.
* TODO does not actually include the name of the expense account.
* See reference nr. 76
* See reference nr. 77
*
* @param GenericRequest $request
*
* @return JsonResponse
@@ -103,7 +104,7 @@ class AccountController extends Controller
}
/**
* TODO does not actually include the name of the expense account.
* See reference nr. 78
*
* @param GenericRequest $request
*

View File

@@ -35,7 +35,7 @@ use Illuminate\Support\Collection;
/**
* Class CategoryController
* TODO same as opposing category controller
* See reference nr. 79
*/
class CategoryController extends Controller
{

View File

@@ -58,8 +58,8 @@ class AccountController extends Controller
}
/**
* TODO same code as Expense/AccountController.
* TODO does not actually include the name of the expense account.
* See reference nr. 80
* See reference nr. 81
*
* @param GenericRequest $request
*

View File

@@ -39,7 +39,7 @@ class TagController extends Controller
/**
* TagController constructor.
* TODO lots of copying and pasting here.
* See reference nr. 82
*/
public function __construct()
{

View File

@@ -72,6 +72,7 @@ class ListController extends Controller
* @param Account $account
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function attachments(Account $account): JsonResponse
@@ -103,6 +104,7 @@ class ListController extends Controller
* @param Account $account
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function piggyBanks(Account $account): JsonResponse
@@ -142,6 +144,7 @@ class ListController extends Controller
* @param Account $account
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function transactions(Request $request, Account $account): JsonResponse
{

View File

@@ -69,8 +69,9 @@ class ShowController extends Controller
*
* @param Request $request
*
* @codeCoverageIgnore
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(Request $request): JsonResponse
{
@@ -84,8 +85,12 @@ class ShowController extends Controller
// get list of accounts. Count it and split it.
$this->repository->resetAccountOrder();
$collection = $this->repository->getAccountsByType($types);
$collection = $this->repository->getAccountsByType($types, $this->parameters->get('sort') ?? []);
$count = $collection->count();
// continue sort:
$accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:

View File

@@ -31,6 +31,7 @@ use FireflyIII\Transformers\AccountTransformer;
use Illuminate\Http\JsonResponse;
use League\Fractal\Resource\Item;
use Log;
use Preferences;
/**
* Class UpdateController
@@ -75,6 +76,7 @@ class UpdateController extends Controller
$account = $this->repository->update($account, $data);
$manager = $this->getManager();
$account->refresh();
Preferences::mark();
/** @var AccountTransformer $transformer */
$transformer = app(AccountTransformer::class);

View File

@@ -111,6 +111,7 @@ class ShowController extends Controller
* Display a listing of the resource.
*
* @return JsonResponse
* @throws FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse

View File

@@ -65,6 +65,7 @@ class ShowController extends Controller
* Display a listing of the resource.
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse

View File

@@ -71,6 +71,7 @@ class ListController extends Controller
* @param Bill $bill
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function attachments(Bill $bill): JsonResponse
@@ -102,6 +103,7 @@ class ListController extends Controller
* @param Bill $bill
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function rules(Bill $bill): JsonResponse
@@ -138,6 +140,7 @@ class ListController extends Controller
* @param Bill $bill
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function transactions(Request $request, Bill $bill): JsonResponse

View File

@@ -63,6 +63,7 @@ class ShowController extends Controller
* Display a listing of the resource.
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse

View File

@@ -73,6 +73,7 @@ class ListController extends Controller
* @param Budget $budget
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function attachments(Budget $budget): JsonResponse
@@ -104,6 +105,7 @@ class ListController extends Controller
* @param Budget $budget
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function budgetLimits(Budget $budget): JsonResponse
@@ -134,6 +136,7 @@ class ListController extends Controller
* @param Budget $budget
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function transactions(Request $request, Budget $budget): JsonResponse

View File

@@ -66,6 +66,7 @@ class ShowController extends Controller
* Display a listing of the resource.
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse

View File

@@ -65,6 +65,7 @@ class DestroyController extends Controller
* @param BudgetLimit $budgetLimit
*
* @return JsonResponse
* @throws FireflyException
* @codeCoverageIgnore
*/
public function destroy(Budget $budget, BudgetLimit $budgetLimit): JsonResponse

View File

@@ -73,6 +73,7 @@ class ListController extends Controller
* @param BudgetLimit $budgetLimit
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function transactions(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse

View File

@@ -73,8 +73,10 @@ class ShowController extends Controller
* Display a listing of the budget limits for this budget..
*
* @param Request $request
* @param Budget $budget
*
* @return JsonResponse
* @throws FireflyException
* @codeCoverageIgnore
*/
public function index(Request $request, Budget $budget): JsonResponse
@@ -104,6 +106,7 @@ class ShowController extends Controller
* @param DateRequest $request
*
* @return JsonResponse
* @throws FireflyException
* @codeCoverageIgnore
*/
public function indexAll(DateRequest $request): JsonResponse
@@ -133,6 +136,7 @@ class ShowController extends Controller
* @param BudgetLimit $budgetLimit
*
* @return JsonResponse
* @throws FireflyException
*/
public function show(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
{

View File

@@ -64,10 +64,9 @@ class StoreController extends Controller
* Store a newly created resource in storage.
*
* @param StoreRequest $request
* @param Budget $budget
*
* @return JsonResponse
* @throws FireflyException
*
*/
public function store(StoreRequest $request, Budget $budget): JsonResponse
{

View File

@@ -69,6 +69,7 @@ class UpdateController extends Controller
* @param BudgetLimit $budgetLimit
*
* @return JsonResponse
* @throws FireflyException
*/
public function update(UpdateRequest $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
{

View File

@@ -68,6 +68,7 @@ class ListController extends Controller
* @param Category $category
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function attachments(Category $category): JsonResponse
@@ -101,6 +102,7 @@ class ListController extends Controller
* @param Category $category
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function transactions(Request $request, Category $category): JsonResponse

View File

@@ -63,6 +63,7 @@ class ShowController extends Controller
* Display a listing of the resource.
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse

View File

@@ -67,6 +67,7 @@ class ListController extends Controller
* @param ObjectGroup $objectGroup
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function bills(ObjectGroup $objectGroup): JsonResponse
@@ -99,6 +100,7 @@ class ListController extends Controller
* @param ObjectGroup $objectGroup
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function piggyBanks(ObjectGroup $objectGroup): JsonResponse

View File

@@ -67,8 +67,9 @@ class ShowController extends Controller
*
* @param Request $request
*
* @codeCoverageIgnore
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(Request $request): JsonResponse
{

View File

@@ -62,6 +62,7 @@ class ListController extends Controller
* @param PiggyBank $piggyBank
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function attachments(PiggyBank $piggyBank): JsonResponse
@@ -93,6 +94,7 @@ class ListController extends Controller
* @param PiggyBank $piggyBank
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function piggyBankEvents(PiggyBank $piggyBank): JsonResponse

View File

@@ -62,6 +62,7 @@ class ShowController extends Controller
* List all of them.
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse

View File

@@ -69,6 +69,7 @@ class ListController extends Controller
* @param Recurrence $recurrence
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function transactions(Request $request, Recurrence $recurrence): JsonResponse

View File

@@ -63,6 +63,7 @@ class ShowController extends Controller
* List all of them.
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse

View File

@@ -66,6 +66,7 @@ class ShowController extends Controller
* List all of them.
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse

View File

@@ -65,6 +65,7 @@ class ListController extends Controller
* @param RuleGroup $group
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function rules(RuleGroup $group): JsonResponse

View File

@@ -66,6 +66,7 @@ class ShowController extends Controller
* List all of them.
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse

View File

@@ -77,7 +77,6 @@ class TriggerController extends Controller
*/
public function testGroup(TestRequest $request, RuleGroup $group): JsonResponse
{
/** @var Collection $rules */
$rules = $this->ruleGroupRepository->getActiveRules($group);
if (0 === $rules->count()) {
throw new FireflyException('200023: No rules in this rule group.');
@@ -132,7 +131,6 @@ class TriggerController extends Controller
*/
public function triggerGroup(TriggerRequest $request, RuleGroup $group): JsonResponse
{
/** @var Collection $rules */
$rules = $this->ruleGroupRepository->getActiveRules($group);
if (0 === $rules->count()) {
throw new FireflyException('200023: No rules in this rule group.');

View File

@@ -71,6 +71,7 @@ class ListController extends Controller
* @param Tag $tag
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function attachments(Tag $tag): JsonResponse
@@ -103,6 +104,7 @@ class ListController extends Controller
* @param Tag $tag
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function transactions(Request $request, Tag $tag): JsonResponse

View File

@@ -66,6 +66,7 @@ class ShowController extends Controller
* List all of them.
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse

View File

@@ -69,6 +69,7 @@ class ListController extends Controller
* @param TransactionGroup $transactionGroup
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function attachments(TransactionGroup $transactionGroup): JsonResponse
@@ -101,6 +102,7 @@ class ListController extends Controller
* @param TransactionGroup $transactionGroup
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function piggyBankEvents(TransactionGroup $transactionGroup): JsonResponse
@@ -136,6 +138,7 @@ class ListController extends Controller
* @param TransactionJournal $transactionJournal
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function transactionLinks(TransactionJournal $transactionJournal): JsonResponse

View File

@@ -50,6 +50,7 @@ class ShowController extends Controller
* @param Request $request
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(Request $request): JsonResponse

View File

@@ -103,7 +103,9 @@ class StoreController extends Controller
throw new ValidationException($validator,0, $e);
}
app('preferences')->mark();
event(new StoredTransactionGroup($transactionGroup, $data['apply_rules'] ?? true));
$applyRules = $data['apply_rules'] ?? true;
$fireWebhooks = $data['fire_webhooks'] ?? true;
event(new StoredTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));
$manager = $this->getManager();
/** @var User $admin */

View File

@@ -80,7 +80,9 @@ class UpdateController extends Controller
$manager = $this->getManager();
app('preferences')->mark();
event(new UpdatedTransactionGroup($transactionGroup, $data['apply_rules'] ?? true));
$applyRules = $data['apply_rules'] ?? true;
$fireWebhooks = $data['fire_webhooks'] ?? true;
event(new UpdatedTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));
/** @var User $admin */
$admin = auth()->user();

View File

@@ -93,6 +93,7 @@ class ListController extends Controller
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function accounts(Request $request, TransactionCurrency $currency): JsonResponse
@@ -143,6 +144,7 @@ class ListController extends Controller
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function availableBudgets(TransactionCurrency $currency): JsonResponse
@@ -178,6 +180,7 @@ class ListController extends Controller
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function bills(TransactionCurrency $currency): JsonResponse
@@ -218,6 +221,7 @@ class ListController extends Controller
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function budgetLimits(TransactionCurrency $currency): JsonResponse
@@ -249,6 +253,7 @@ class ListController extends Controller
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function recurrences(TransactionCurrency $currency): JsonResponse
@@ -299,6 +304,7 @@ class ListController extends Controller
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function rules(TransactionCurrency $currency): JsonResponse
@@ -350,6 +356,7 @@ class ListController extends Controller
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function transactions(Request $request, TransactionCurrency $currency): JsonResponse

View File

@@ -68,6 +68,7 @@ class ShowController extends Controller
* Display a listing of the resource.
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse

View File

@@ -68,6 +68,7 @@ class ShowController extends Controller
* @param Request $request
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(Request $request): JsonResponse

View File

@@ -78,8 +78,8 @@ class StoreController extends Controller
{
$manager = $this->getManager();
$data = $request->getAll();
$inward = $this->journalRepository->findNull($data['inward_id'] ?? 0);
$outward = $this->journalRepository->findNull($data['outward_id'] ?? 0);
$inward = $this->journalRepository->find($data['inward_id'] ?? 0);
$outward = $this->journalRepository->find($data['outward_id'] ?? 0);
if (null === $inward || null === $outward) {
throw new FireflyException('200024: Source or destination does not exist.');
}

View File

@@ -71,9 +71,8 @@ class UpdateController extends Controller
* @param TransactionJournalLink $journalLink
*
* @return JsonResponse
* @throws FireflyException
*
* TODO generates query exception when link exists.
* See reference nr. 84
*/
public function update(UpdateRequest $request, TransactionJournalLink $journalLink): JsonResponse
{

View File

@@ -75,6 +75,7 @@ class ListController extends Controller
* @param LinkType $linkType
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function transactions(Request $request, LinkType $linkType): JsonResponse

View File

@@ -72,6 +72,7 @@ class ShowController extends Controller
* List all of them.
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse

View File

@@ -42,6 +42,7 @@ class TransactionController extends Controller
* @param SearchInterface $searcher
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function search(Request $request, SearchInterface $searcher): JsonResponse
{

View File

@@ -175,7 +175,7 @@ class BasicController extends Controller
// format amounts:
$keys = array_keys($sums);
foreach ($keys as $currencyId) {
$currency = $this->currencyRepos->findNull($currencyId);
$currency = $this->currencyRepos->find($currencyId);
if (null === $currency) {
continue;
}
@@ -239,7 +239,7 @@ class BasicController extends Controller
$return = [];
foreach ($paidAmount as $currencyId => $amount) {
$amount = bcmul($amount, '-1');
$currency = $this->currencyRepos->findNull((int)$currencyId);
$currency = $this->currencyRepos->find((int)$currencyId);
if (null === $currency) {
continue;
}
@@ -259,7 +259,7 @@ class BasicController extends Controller
foreach ($unpaidAmount as $currencyId => $amount) {
$amount = bcmul($amount, '-1');
$currency = $this->currencyRepos->findNull((int)$currencyId);
$currency = $this->currencyRepos->find((int)$currencyId);
if (null === $currency) {
continue;
}

View File

@@ -51,7 +51,6 @@ class CronController extends Controller
$return = [];
$return['recurring_transactions'] = $this->runRecurring($config['force'], $config['date']);
$return['auto_budgets'] = $this->runAutoBudget($config['force'], $config['date']);
$return['telemetry'] = $this->runTelemetry($config['force'], $config['date']);
return response()->json($return);
}

View File

@@ -90,6 +90,7 @@ class UserController extends Controller
* Display a listing of the resource.
*
* @return JsonResponse
* @throws FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse

View File

@@ -47,11 +47,12 @@ class PreferencesController extends Controller
* List all of them.
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse
{
// TODO via repository.
// See reference nr. 83
$collection = auth()->user()->preferences()->get();
$manager = $this->getManager();
$count = $collection->count();
@@ -115,8 +116,10 @@ class PreferencesController extends Controller
/**
* @param PreferenceUpdateRequest $request
* @param Preference $preference
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function update(PreferenceUpdateRequest $request, Preference $preference): JsonResponse
{

View File

@@ -62,9 +62,11 @@ class AttemptController extends Controller
}
/**
* @param Webhook $webhook
* @param Webhook $webhook
* @param WebhookMessage $message
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(Webhook $webhook, WebhookMessage $message): JsonResponse
{

View File

@@ -74,9 +74,12 @@ class DestroyController extends Controller
/**
* Remove the specified resource from storage.
*
* @param Webhook $webhook
* @param Webhook $webhook
* @param WebhookMessage $message
* @param WebhookAttempt $attempt
*
* @return JsonResponse
* @throws FireflyException
* @codeCoverageIgnore
*/
public function destroyAttempt(Webhook $webhook, WebhookMessage $message, WebhookAttempt $attempt): JsonResponse
@@ -97,9 +100,11 @@ class DestroyController extends Controller
/**
* Remove the specified resource from storage.
*
* @param Webhook $webhook
* @param Webhook $webhook
* @param WebhookMessage $message
*
* @return JsonResponse
* @throws FireflyException
* @codeCoverageIgnore
*/
public function destroyMessage(Webhook $webhook, WebhookMessage $message): JsonResponse

View File

@@ -61,6 +61,7 @@ class MessageController extends Controller
* @param Webhook $webhook
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(Webhook $webhook): JsonResponse
{

View File

@@ -62,6 +62,7 @@ class ShowController extends Controller
* Display a listing of the webhooks of the user.
*
* @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException
* @codeCoverageIgnore
*/
public function index(): JsonResponse

View File

@@ -73,6 +73,6 @@ class SubmitController extends Controller
SendWebhookMessage::dispatch($message)->afterResponse();
}
return response()->json([], 200);
return response()->json([]);
}
}

View File

@@ -42,7 +42,7 @@ class MoveTransactionsRequest extends FormRequest
* Configure the validator instance with special rules for after the basic validation rules.
*
* @param Validator $validator
* TODO duplicate code.
* See reference nr. 74
*
* @return void
*/
@@ -55,8 +55,8 @@ class MoveTransactionsRequest extends FormRequest
if (array_key_exists('original_account', $data) && array_key_exists('destination_account', $data)) {
$repository = app(AccountRepositoryInterface::class);
$repository->setUser(auth()->user());
$original = $repository->findNull((int)$data['original_account']);
$destination = $repository->findNull((int)$data['destination_account']);
$original = $repository->find((int)$data['original_account']);
$destination = $repository->find((int)$data['destination_account']);
if ($original->accountType->type !== $destination->accountType->type) {
$validator->errors()->add('title', (string)trans('validation.same_account_type'));
@@ -76,8 +76,6 @@ class MoveTransactionsRequest extends FormRequest
}
if ($originalCurrency->code !== $destinationCurrency->code) {
$validator->errors()->add('title', (string)trans('validation.same_account_currency'));
return;
}
}
}

View File

@@ -53,7 +53,7 @@ class ExportRequest extends FormRequest
foreach ($parts as $part) {
$accountId = (int)$part;
if (0 !== $accountId) {
$account = $repository->findNull($accountId);
$account = $repository->find($accountId);
if (null !== $account && AccountType::ASSET === $account->accountType->type) {
$accounts->push($account);
}

View File

@@ -95,7 +95,7 @@ class GenericRequest extends FormRequest
if (is_array($array)) {
foreach ($array as $accountId) {
$accountId = (int)$accountId;
$account = $repository->findNull($accountId);
$account = $repository->find($accountId);
if (null !== $account) {
$this->accounts->push($account);
}
@@ -159,7 +159,7 @@ class GenericRequest extends FormRequest
if (is_array($array)) {
foreach ($array as $budgetId) {
$budgetId = (int)$budgetId;
$budget = $repository->findNull($budgetId);
$budget = $repository->find($budgetId);
if (null !== $budgetId) {
$this->budgets->push($budget);
}
@@ -191,7 +191,7 @@ class GenericRequest extends FormRequest
if (is_array($array)) {
foreach ($array as $categoryId) {
$categoryId = (int)$categoryId;
$category = $repository->findNull($categoryId);
$category = $repository->find($categoryId);
if (null !== $categoryId) {
$this->categories->push($category);
}
@@ -281,7 +281,7 @@ class GenericRequest extends FormRequest
if (is_array($array)) {
foreach ($array as $tagId) {
$tagId = (int)$tagId;
$tag = $repository->findNull($tagId);
$tag = $repository->find($tagId);
if (null !== $tagId) {
$this->tags->push($tag);
}

View File

@@ -77,13 +77,14 @@ class StoreRequest extends FormRequest
'interest' => $this->string('interest'),
'interest_period' => $this->string('interest_period'),
];
// append Location information.
// append location information.
$data = $this->appendLocationData($data, null);
if ('liability' === $data['account_type_name'] || 'liabilities' === $data['account_type_name']) {
$data['opening_balance'] = bcmul($this->string('liability_amount'), '-1');
$data['opening_balance'] = app('steam')->negative($this->string('liability_amount'));
$data['opening_balance_date'] = $this->date('liability_start_date');
$data['account_type_name'] = $this->string('liability_type');
$data['account_type_name'] = $this->string('liability_type');
$data['liability_direction'] = $this->string('liability_direction');
$data['account_type_id'] = null;
}
@@ -118,11 +119,12 @@ class StoreRequest extends FormRequest
'account_role' => sprintf('in:%s|required_if:type,asset', $accountRoles),
'credit_card_type' => sprintf('in:%s|required_if:account_role,ccAsset', $ccPaymentTypes),
'monthly_payment_date' => 'date' . '|required_if:account_role,ccAsset|required_if:credit_card_type,monthlyFull',
'liability_type' => 'required_if:type,liability|in:loan,debt,mortgage',
'liability_amount' => 'required_if:type,liability|min:0|numeric',
'liability_start_date' => 'required_if:type,liability|date',
'interest' => 'required_if:type,liability|between:0,100|numeric',
'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly',
'liability_type' => 'required_if:type,liability|required_if:type,liabilities|in:loan,debt,mortgage',
'liability_amount' => 'required_with:liability_start_date|min:0|numeric',
'liability_start_date' => 'required_with:liability_amount|date',
'liability_direction' => 'required_if:type,liability|required_if:type,liabilities|in:credit,debit',
'interest' => 'between:0,100|numeric',
'interest_period' => sprintf('in:%s', join(',', config('firefly.interest_periods'))),
'notes' => 'min:0|max:65536',
];

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Account;
use FireflyIII\Models\Account;
use FireflyIII\Models\Location;
use FireflyIII\Rules\IsBoolean;
use FireflyIII\Rules\UniqueAccountNumber;
@@ -32,6 +33,7 @@ use FireflyIII\Support\Request\AppendsLocationData;
use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest;
use Log;
/**
* Class UpdateRequest
@@ -68,15 +70,23 @@ class UpdateRequest extends FormRequest
'order' => ['order', 'integer'],
'currency_id' => ['currency_id', 'integer'],
'currency_code' => ['currency_code', 'string'],
'liability_direction' => ['liability_direction', 'string'],
'liability_amount' => ['liability_amount', 'string'],
'liability_start_date' => ['liability_start_date', 'date'],
];
$data = $this->getAllData($fields);
$data = $this->appendLocationData($data, null);
/** @var Account $account */
$account = $this->route()->parameter('account');
$data = $this->getAllData($fields);
$data = $this->appendLocationData($data, null);
$valid = config('firefly.valid_liabilities');
if (array_key_exists('liability_amount', $data) && in_array($account->accountType->type, $valid, true)) {
$data['opening_balance'] = app('steam')->negative($data['liability_amount']);
Log::debug(sprintf('Opening balance for liability is "%s".', $data['opening_balance']));
}
if (array_key_exists('account_type_name', $data) && 'liability' === $data['account_type_name']) {
$data['opening_balance'] = bcmul($this->string('liability_amount'), '-1');
$data['opening_balance_date'] = $this->date('liability_start_date');
$data['account_type_name'] = $this->string('liability_type');
$data['account_type_id'] = null;
if (array_key_exists('liability_start_date', $data) && in_array($account->accountType->type, $valid, true)) {
$data['opening_balance_date'] = $data['liability_start_date'];
Log::debug(sprintf('Opening balance date for liability is "%s".', $data['opening_balance_date']));
}
return $data;
@@ -112,6 +122,7 @@ class UpdateRequest extends FormRequest
'credit_card_type' => sprintf('in:%s|nullable|required_if:account_role,ccAsset', $ccPaymentTypes),
'monthly_payment_date' => 'date' . '|nullable|required_if:account_role,ccAsset|required_if:credit_card_type,monthlyFull',
'liability_type' => 'required_if:type,liability|in:loan,debt,mortgage',
'liability_direction' => 'required_if:type,liability|in:credit,debit',
'interest' => 'required_if:type,liability|between:0,100|numeric',
'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly',
'notes' => 'min:0|max:65536',

View File

@@ -76,7 +76,7 @@ class UpdateRequest extends FormRequest
* Configure the validator instance with special rules for after the basic validation rules.
*
* @param Validator $validator
* TODO duplicate code.
* See reference nr. 72
*
* @return void
*/

View File

@@ -135,8 +135,6 @@ class StoreRequest extends FormRequest
*/
public function rules(): array
{
$today = Carbon::now()->addDay();
return [
'type' => 'required|in:withdrawal,transfer,deposit',
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',

View File

@@ -109,7 +109,7 @@ class UpdateRequest extends FormRequest
}
$return[] = $current;
}
if (0 === count($return)) {
if (empty($return)) {
return null;
}

View File

@@ -167,7 +167,7 @@ class StoreRequest extends FormRequest
$data = $validator->getData();
$triggers = $data['triggers'] ?? [];
// need at least one trigger
if (!is_countable($triggers) || 0 === count($triggers)) {
if (!is_countable($triggers) || empty($triggers)) {
$validator->errors()->add('title', (string)trans('validation.at_least_one_trigger'));
}
}
@@ -182,7 +182,7 @@ class StoreRequest extends FormRequest
$data = $validator->getData();
$actions = $data['actions'] ?? [];
// need at least one trigger
if (!is_countable($actions) || 0 === count($actions)) {
if (!is_countable($actions) || empty($actions)) {
$validator->errors()->add('title', (string)trans('validation.at_least_one_action'));
}
}

View File

@@ -180,7 +180,7 @@ class UpdateRequest extends FormRequest
$data = $validator->getData();
$triggers = $data['triggers'] ?? null;
// need at least one trigger
if (is_array($triggers) && 0 === count($triggers)) {
if (is_array($triggers) && empty($triggers)) {
$validator->errors()->add('title', (string)trans('validation.at_least_one_trigger'));
}
}
@@ -195,7 +195,7 @@ class UpdateRequest extends FormRequest
$data = $validator->getData();
$actions = $data['actions'] ?? null;
// need at least one action
if (is_array($actions) && 0 === count($actions)) {
if (is_array($actions) && empty($actions)) {
$validator->errors()->add('title', (string)trans('validation.at_least_one_action'));
}
}

View File

@@ -51,9 +51,8 @@ class StoreRequest extends FormRequest
'description' => $this->string('description'),
'has_location' => true,
];
$data = $this->appendLocationData($data, null);
return $data;
return $this->appendLocationData($data, null);
}
/**

View File

@@ -53,9 +53,8 @@ class UpdateRequest extends FormRequest
'description' => ['description', 'string'],
];
$data = $this->getAllData($fields);
$data = $this->appendLocationData($data, null);
return $data;
return $this->appendLocationData($data, null);
}
/**
@@ -66,7 +65,7 @@ class UpdateRequest extends FormRequest
public function rules(): array
{
$tag = $this->route()->parameter('tagOrId');
// TODO is uniqueObjectForUser not obsolete?
// See reference nr. 73
$rules = [
'tag' => 'min:1|uniqueObjectForUser:tags,tag,' . $tag->id,
'description' => 'min:1|nullable',

View File

@@ -53,15 +53,14 @@ class StoreRequest extends FormRequest
public function getAll(): array
{
Log::debug('get all data in TransactionStoreRequest');
$data = [
return [
'group_title' => $this->string('group_title'),
'error_if_duplicate_hash' => $this->boolean('error_if_duplicate_hash'),
'apply_rules' => $this->boolean('apply_rules', true),
'fire_webhooks' => $this->boolean('fire_webhooks', true),
'transactions' => $this->getTransactionData(),
];
// TODO location
return $data;
// See reference nr. 71
}
/**

View File

@@ -129,6 +129,9 @@ class UpdateRequest extends FormRequest
if ($this->has('apply_rules')) {
$data['apply_rules'] = $this->boolean('apply_rules', true);
}
if ($this->has('fire_webhooks')) {
$data['fire_webhooks'] = $this->boolean('fire_webhooks', true);
}
if ($this->has('group_title')) {
$data['group_title'] = $this->string('group_title');
}
@@ -366,7 +369,7 @@ class UpdateRequest extends FormRequest
$this->validateJournalIds($validator, $transactionGroup);
// all transaction types must be equal:
$this->validateTransactionTypesForUpdate($validator, $transactionGroup);
$this->validateTransactionTypesForUpdate($validator);
// validate source/destination is equal, depending on the transaction journal type.
$this->validateEqualAccountsForUpdate($validator, $transactionGroup);

View File

@@ -72,8 +72,8 @@ class StoreRequest extends FormRequest
{
return [
'name' => 'required|between:1,255|unique:transaction_currencies,name',
'code' => 'required|between:3,3|unique:transaction_currencies,code',
'symbol' => 'required|between:1,8|unique:transaction_currencies,symbol',
'code' => 'required|between:3,51|unique:transaction_currencies,code',
'symbol' => 'required|between:1,51|unique:transaction_currencies,symbol',
'decimal_places' => 'between:0,20|numeric|min:0|max:20',
'enabled' => [new IsBoolean()],
'default' => [new IsBoolean()],

View File

@@ -54,10 +54,8 @@ class UpdateRequest extends FormRequest
'enabled' => ['enabled', 'boolean'],
];
$return = $this->getAllData($fields);
return $return;
return $this->getAllData($fields);
// return $return;
}
/**
@@ -71,8 +69,8 @@ class UpdateRequest extends FormRequest
return [
'name' => sprintf('between:1,255|unique:transaction_currencies,name,%d', $currency->id),
'code' => sprintf('between:3,3|unique:transaction_currencies,code,%d', $currency->id),
'symbol' => sprintf('between:1,8|unique:transaction_currencies,symbol,%d', $currency->id),
'code' => sprintf('between:3,51|unique:transaction_currencies,code,%d', $currency->id),
'symbol' => sprintf('between:1,51|unique:transaction_currencies,symbol,%d', $currency->id),
'decimal_places' => 'between:0,20|numeric|min:0|max:20',
'enabled' => [new IsBoolean()],
'default' => [new IsBoolean()],

View File

@@ -104,8 +104,8 @@ class StoreRequest extends FormRequest
$data = $validator->getData();
$inwardId = (int)($data['inward_id'] ?? 0);
$outwardId = (int)($data['outward_id'] ?? 0);
$inward = $journalRepos->findNull($inwardId);
$outward = $journalRepos->findNull($outwardId);
$inward = $journalRepos->find($inwardId);
$outward = $journalRepos->find($outwardId);
if (null === $inward) {
$validator->errors()->add('inward_id', 'Invalid inward ID.');

View File

@@ -104,8 +104,8 @@ class UpdateRequest extends FormRequest
$inwardId = $data['inward_id'] ?? $existing->source_id;
$outwardId = $data['outward_id'] ?? $existing->destination_id;
$inward = $journalRepos->findNull((int)$inwardId);
$outward = $journalRepos->findNull((int)$outwardId);
$inward = $journalRepos->find((int)$inwardId);
$outward = $journalRepos->find((int)$outwardId);
if (null === $inward) {
$inward = $existing->source;
}

View File

@@ -96,6 +96,7 @@ class CorrectOpeningBalanceCurrencies extends Command
* @param TransactionJournal $journal
*
* @return int
* @throws JsonException
*/
private function correctJournal(TransactionJournal $journal): int
{
@@ -146,7 +147,6 @@ class CorrectOpeningBalanceCurrencies extends Command
* @param Account $account
*
* @return TransactionCurrency
* @throws JsonException
*/
private function getCurrency(Account $account): TransactionCurrency
{

View File

@@ -63,7 +63,7 @@ class CreateAccessTokens extends Command
$users = $repository->all();
/** @var User $user */
foreach ($users as $user) {
$pref = app('preferences')->getForUser($user, 'access_token', null);
$pref = app('preferences')->getForUser($user, 'access_token');
if (null === $pref) {
$token = $user->generateAccessToken();
app('preferences')->setForUser($user, 'access_token', $token);

View File

@@ -57,7 +57,6 @@ class DeleteZeroAmount extends Command
$start = microtime(true);
$set = Transaction::where('amount', 0)->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
$set = array_unique($set);
/** @var Collection $journals */
$journals = TransactionJournal::whereIn('id', $set)->get();
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {

View File

@@ -67,14 +67,12 @@ class EnableCurrencies extends Command
}
// get all from journals:
/** @var Collection $journals */
$journals = TransactionJournal::groupBy('transaction_currency_id')->get(['transaction_currency_id']);
foreach ($journals as $entry) {
$found[] = (int)$entry->transaction_currency_id;
}
// get all from transactions
/** @var Collection $transactions */
$transactions = Transaction::groupBy('transaction_currency_id', 'foreign_currency_id')->get(['transaction_currency_id', 'foreign_currency_id']);
foreach ($transactions as $entry) {
$found[] = (int)$entry->transaction_currency_id;
@@ -82,7 +80,6 @@ class EnableCurrencies extends Command
}
// get all from budget limits
/** @var Collection $limits */
$limits = BudgetLimit::groupBy('transaction_currency_id')->get(['transaction_currency_id']);
foreach ($limits as $entry) {
$found[] = (int)$entry->transaction_currency_id;

View File

@@ -56,12 +56,12 @@ class FixFrontpageAccounts extends Command
*/
public function handle(): int
{
$start = microtime(true);
$start = microtime(true);
$users = User::get();
/** @var User $user */
foreach ($users as $user) {
$preference = Preferences::getForUser($user, 'frontPageAccounts', null);
$preference = Preferences::getForUser($user, 'frontPageAccounts');
if (null !== $preference) {
$this->fixPreference($preference);
}
@@ -88,16 +88,12 @@ class FixFrontpageAccounts extends Command
if (is_array($data)) {
/** @var string $accountId */
foreach ($data as $accountId) {
$accountId = (int)$accountId;
$account = $repository->findNull($accountId);
if (null !== $account) {
if (
in_array($account->accountType->type, [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE], true)
&& true === $account->active
) {
$fixed[] = $account->id;
continue;
}
$accountIdInt = (int)$accountId;
$account = $repository->find($accountIdInt);
if (null !== $account
&& in_array($account->accountType->type, [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE], true)
&& true === $account->active) {
$fixed[] = $account->id;
}
}
}

View File

@@ -48,9 +48,6 @@ class FixPiggies extends Command
*/
protected $signature = 'firefly-iii:fix-piggies';
/** @var int */
private $count;
/**
* Execute the console command.
*
@@ -58,8 +55,8 @@ class FixPiggies extends Command
*/
public function handle(): int
{
$this->count = 0;
$start = microtime(true);
$count = 0;
$start = microtime(true);
$set = PiggyBankEvent::with(['PiggyBank', 'TransactionJournal', 'TransactionJournal.TransactionType'])->get();
/** @var PiggyBankEvent $event */
@@ -74,7 +71,7 @@ class FixPiggies extends Command
if (null === $journal) {
$event->transaction_journal_id = null;
$event->save();
$this->count++;
$count++;
continue;
}
@@ -84,14 +81,14 @@ class FixPiggies extends Command
$event->transaction_journal_id = null;
$event->save();
$this->line(sprintf('Piggy bank #%d was referenced by an invalid event. This has been fixed.', $event->piggy_bank_id));
$this->count++;
$count++;
}
}
if (0 === $this->count) {
if (0 === $count) {
$this->line('All piggy bank events are correct.');
}
if (0 !== $this->count) {
$this->line(sprintf('Fixed %d piggy bank event(s).', $this->count));
if (0 !== $count) {
$this->line(sprintf('Fixed %d piggy bank event(s).', $count));
}
$end = round(microtime(true) - $start, 2);

View File

@@ -77,7 +77,6 @@ class ExportData extends Command
{--force : Force overwriting of previous exports if found.}';
private AccountRepositoryInterface $accountRepository;
private JournalRepositoryInterface $journalRepository;
private User $user;
/**
* Execute the console command.
@@ -85,6 +84,7 @@ class ExportData extends Command
* @return int
* @throws CannotInsertRecord
* @throws FireflyException
* @throws \League\Csv\Exception
*/
public function handle(): int
{
@@ -96,9 +96,9 @@ class ExportData extends Command
}
// set up repositories.
$this->stupidLaravel();
$this->user = $this->getUser();
$this->journalRepository->setUser($this->user);
$this->accountRepository->setUser($this->user);
$user = $this->getUser();
$this->journalRepository->setUser($user);
$this->accountRepository->setUser($user);
// get the options.
try {
$options = $this->parseOptions();
@@ -110,7 +110,7 @@ class ExportData extends Command
// make export object and configure it.
/** @var ExportDataGenerator $exporter */
$exporter = app(ExportDataGenerator::class);
$exporter->setUser($this->user);
$exporter->setUser($user);
$exporter->setStart($options['start']);
$exporter->setEnd($options['end']);
@@ -125,18 +125,16 @@ class ExportData extends Command
$exporter->setExportBills($options['export']['bills']);
$exporter->setExportPiggies($options['export']['piggies']);
$data = $exporter->export();
if (0 === count($data)) {
if (empty($data)) {
$this->error('You must export *something*. Use --export-transactions or another option. See docs.firefly-iii.org');
}
$returnCode = 0;
if (0 !== count($data)) {
if (!empty($data)) {
try {
$this->exportData($options, $data);
app('telemetry')->feature('system.command.executed', $this->signature);
} catch (FireflyException $e) {
$this->error(sprintf('Could not store data: %s', $e->getMessage()));
app('telemetry')->feature('system.command.errored', $this->signature);
$returnCode = 1;
}
}

View File

@@ -19,8 +19,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
declare(strict_types=1);
namespace FireflyIII\Console\Commands;
@@ -86,8 +84,6 @@ class ScanAttachments extends Command
$this->line(sprintf('Fixed attachment #%d', $attachment->id));
}
app('telemetry')->feature('system.command.executed', $this->signature);
return 0;
}
}

View File

@@ -60,8 +60,6 @@ class SetLatestVersion extends Command
app('fireflyconfig')->set('ff3_version', config('firefly.version'));
$this->line('Updated version.');
app('telemetry')->feature('system.command.executed', $this->signature);
return 0;
}
}

View File

@@ -99,8 +99,6 @@ class ApplyRules extends Command
$result = $this->verifyInput();
if (false === $result) {
app('telemetry')->feature('system.command.errored', $this->signature);
return 1;
}
@@ -119,8 +117,6 @@ class ApplyRules extends Command
$this->warn(' --rule_groups=1,2,...');
$this->warn(' --all_rules');
app('telemetry')->feature('system.command.errored', $this->signature);
return 1;
}
@@ -148,8 +144,6 @@ class ApplyRules extends Command
// file the rule(s)
$ruleEngine->fire();
app('telemetry')->feature('system.command.executed', $this->signature);
$this->line('');
$end = round(microtime(true) - $start, 2);
$this->line(sprintf('Done in %s seconds!', $end));
@@ -219,7 +213,7 @@ class ApplyRules extends Command
$accountRepository->setUser($this->getUser());
foreach ($accountList as $accountId) {
$accountId = (int)$accountId;
$account = $accountRepository->findNull($accountId);
$account = $accountRepository->find($accountId);
if (null !== $account && in_array($account->accountType->type, $this->acceptedAccounts, true)) {
$finalList->push($account);
}

View File

@@ -25,11 +25,9 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Tools;
use Carbon\Carbon;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Support\Cronjobs\AutoBudgetCronjob;
use FireflyIII\Support\Cronjobs\RecurringCronjob;
use FireflyIII\Support\Cronjobs\TelemetryCronjob;
use Illuminate\Console\Command;
use InvalidArgumentException;
use Log;
@@ -92,21 +90,8 @@ class Cron extends Command
$this->error($e->getMessage());
}
/*
* Fire telemetry cron job
*/
try {
$this->telemetryCronJob($force, $date);
} catch (FireflyException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
$this->error($e->getMessage());
}
$this->info('More feedback on the cron jobs can be found in the log files.');
app('telemetry')->feature('system.command.executed', $this->signature);
return 0;
}
@@ -127,13 +112,13 @@ class Cron extends Command
}
$recurring->fire();
if($recurring->jobErrored) {
if ($recurring->jobErrored) {
$this->error(sprintf('Error in "create recurring transactions" cron: %s', $recurring->message));
}
if($recurring->jobFired) {
if ($recurring->jobFired) {
$this->error(sprintf('"Create recurring transactions" cron fired: %s', $recurring->message));
}
if($recurring->jobSucceeded) {
if ($recurring->jobSucceeded) {
$this->error(sprintf('"Create recurring transactions" cron ran with success: %s', $recurring->message));
}
}
@@ -142,7 +127,6 @@ class Cron extends Command
* @param bool $force
* @param Carbon|null $date
*
* @throws FireflyException
*/
private function autoBudgetCronJob(bool $force, ?Carbon $date): void
{
@@ -155,50 +139,15 @@ class Cron extends Command
$autoBudget->fire();
if($autoBudget->jobErrored) {
if ($autoBudget->jobErrored) {
$this->error(sprintf('Error in "create auto budgets" cron: %s', $autoBudget->message));
}
if($autoBudget->jobFired) {
if ($autoBudget->jobFired) {
$this->error(sprintf('"Create auto budgets" cron fired: %s', $autoBudget->message));
}
if($autoBudget->jobSucceeded) {
if ($autoBudget->jobSucceeded) {
$this->error(sprintf('"Create auto budgets" cron ran with success: %s', $autoBudget->message));
}
}
/**
* @param bool $force
* @param Carbon|null $date
*
* @throws FireflyException
*/
private function telemetryCronJob(bool $force, ?Carbon $date): void
{
if (false === config('firefly.send_telemetry') || false === config('firefly.feature_flags.telemetry')) {
// if not configured to do anything with telemetry, do nothing.
return;
}
$telemetry = new TelemetryCronjob;
$telemetry->setForce($force);
// set date in cron job:
if (null !== $date) {
$telemetry->setDate($date);
}
$telemetry->fire();
if($telemetry->jobErrored) {
$this->error(sprintf('Error in "send telemetry" cron: %s', $telemetry->message));
}
if($telemetry->jobFired) {
$this->error(sprintf('"Send telemetry" cron fired: %s', $telemetry->message));
}
if($telemetry->jobSucceeded) {
$this->error(sprintf('"Send telemetry" cron ran with success: %s', $telemetry->message));
}
}
}

View File

@@ -106,6 +106,7 @@ class AccountCurrencies extends Command
/**
* @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/
private function isExecuted(): bool
{
@@ -134,6 +135,8 @@ class AccountCurrencies extends Command
/**
* @param User $user
* @param string $systemCurrencyCode
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
private function updateCurrenciesForUser(User $user, string $systemCurrencyCode): void
{

View File

@@ -69,6 +69,7 @@ class AppendBudgetLimitPeriods extends Command
/**
* @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/
private function isExecuted(): bool
{

View File

@@ -83,6 +83,7 @@ class BackToJournals extends Command
/**
* @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/
private function isMigrated(): bool
{
@@ -93,6 +94,7 @@ class BackToJournals extends Command
/**
* @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/
private function isExecuted(): bool
{

View File

@@ -67,7 +67,6 @@ class BudgetLimitCurrency extends Command
/** @var BudgetLimit $budgetLimit */
foreach ($budgetLimits as $budgetLimit) {
if (null === $budgetLimit->transaction_currency_id) {
/** @var Budget $budget */
$budget = $budgetLimit->budget;
if (null !== $budget) {
$user = $budget->user;
@@ -96,6 +95,7 @@ class BudgetLimitCurrency extends Command
/**
* @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/
private function isExecuted(): bool
{

View File

@@ -93,6 +93,7 @@ class CCLiabilities extends Command
/**
* @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/
private function isExecuted(): bool
{

View File

@@ -105,6 +105,7 @@ class MigrateAttachments extends Command
/**
* @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/
private function isExecuted(): bool
{

View File

@@ -64,7 +64,6 @@ class MigrateJournalNotes extends Command
}
$count = 0;
/** @noinspection PhpUndefinedMethodInspection */
$set = TransactionJournalMeta::whereName('notes')->get();
/** @var TransactionJournalMeta $meta */
foreach ($set as $meta) {
@@ -104,6 +103,7 @@ class MigrateJournalNotes extends Command
/**
* @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/
private function isExecuted(): bool
{

View File

@@ -79,6 +79,7 @@ class MigrateRecurrenceMeta extends Command
/**
* @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/
private function isExecuted(): bool
{
@@ -92,6 +93,7 @@ class MigrateRecurrenceMeta extends Command
/**
* @return int
* @throws \JsonException
*/
private function migrateMetaData(): int
{
@@ -110,6 +112,7 @@ class MigrateRecurrenceMeta extends Command
* @param RecurrenceMeta $meta
*
* @return int
* @throws \JsonException
*/
private function migrateEntry(RecurrenceMeta $meta): int
{
@@ -125,7 +128,7 @@ class MigrateRecurrenceMeta extends Command
if ('tags' === $meta->name) {
$array = explode(',', $meta->value);
$value = json_encode($array, JSON_THROW_ON_ERROR, 512);
$value = json_encode($array, JSON_THROW_ON_ERROR);
}
RecurrenceTransactionMeta::create(

View File

@@ -74,6 +74,7 @@ class MigrateRecurrenceType extends Command
/**
* @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/
private function isExecuted(): bool
{

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