Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Code fixes.
James Cole2bff7750b44b
diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.phpindex 5bc4cc2871..99f95c0ee8 100644--- a/app/Api/V1/Controllers/Controller.php+++ b/app/Api/V1/Controllers/Controller.php@@ -46,6 +46,7 @@ abstract class Controller extends BaseControllerprotected const CONTENT_TYPE = 'application/vnd.api+json';protected ParameterBag $parameters;+ protected array $allowedSort;/*** Controller constructor.@@ -53,7 +54,8 @@ abstract class Controller extends BaseControllerpublic 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,42 @@ abstract class Controller extends BaseController}}+ // sort fields:+ $bag = $this->getSortParameters($bag);+return $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.*diff --git a/app/Api/V1/Controllers/Models/Account/ShowController.php b/app/Api/V1/Controllers/Models/Account/ShowController.phpindex 2a96fc56dc..e2c37b4096 100644--- a/app/Api/V1/Controllers/Models/Account/ShowController.php+++ b/app/Api/V1/Controllers/Models/Account/ShowController.php@@ -84,8 +84,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:diff --git a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.phpindex 1167326e7f..6c036b7648 100644--- a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php+++ b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php@@ -76,8 +76,6 @@ class MoveTransactionsRequest extends FormRequest}if ($originalCurrency->code !== $destinationCurrency->code) {$validator->errors()->add('title', (string)trans('validation.same_account_currency'));-- return;}}}diff --git a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.phpindex 972952d600..6432808af9 100644--- a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php@@ -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',diff --git a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php b/app/Api/V1/Requests/Models/Transaction/StoreRequest.phpindex 07ffdb674d..81fb1afa4e 100644--- a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Transaction/StoreRequest.php@@ -53,15 +53,13 @@ class StoreRequest extends FormRequestpublic 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),'transactions' => $this->getTransactionData(),];-// TODO location- return $data;}/**diff --git a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.phpindex dc4a0593ce..677afd1469 100644--- a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php@@ -366,7 +366,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);diff --git a/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php b/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.phpindex 9b5efb00e2..9b570af6f2 100644--- a/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php@@ -54,10 +54,8 @@ class UpdateRequest extends FormRequest'enabled' => ['enabled', 'boolean'],];- $return = $this->getAllData($fields);-- return $return;-+ return $this->getAllData($fields);+// return $return;}/**diff --git a/app/Console/Commands/Correction/FixFrontpageAccounts.php b/app/Console/Commands/Correction/FixFrontpageAccounts.phpindex 865b11a3da..fc6bdebb32 100644--- a/app/Console/Commands/Correction/FixFrontpageAccounts.php+++ b/app/Console/Commands/Correction/FixFrontpageAccounts.php@@ -56,7 +56,7 @@ class FixFrontpageAccounts extends Command*/public function handle(): int{- $start = microtime(true);+ $start = microtime(true);$users = User::get();/** @var User $user */@@ -88,16 +88,12 @@ class FixFrontpageAccounts extends Commandif (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->findNull($accountIdInt);+ if (null !== $account+ && in_array($account->accountType->type, [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE], true)+ && true === $account->active) {+ $fixed[] = $account->id;}}}diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.phpindex 846d1874dc..e5129dbbde 100644--- a/app/Helpers/Collector/GroupCollector.php+++ b/app/Helpers/Collector/GroupCollector.php@@ -227,16 +227,6 @@ class GroupCollector implements GroupCollectorInterface*/public function getGroups(): Collection{- $filterQuery = false;-- // now filter the query according to the page and the limit (if necessary)- if ($filterQuery) {- if (null !== $this->limit && null !== $this->page) {- $offset = ($this->page - 1) * $this->limit;- $this->query->take($this->limit)->skip($offset);- }- }-/** @var Collection $result */$result = $this->query->get($this->fields);@@ -245,12 +235,10 @@ class GroupCollector implements GroupCollectorInterface$this->total = $collection->count();// now filter the array according to the page and the limit (if necessary)- if (!$filterQuery) {- if (null !== $this->limit && null !== $this->page) {- $offset = ($this->page - 1) * $this->limit;+ if (null !== $this->limit && null !== $this->page) {+ $offset = ($this->page - 1) * $this->limit;- return $collection->slice($offset, $this->limit);- }+ return $collection->slice($offset, $this->limit);}return $collection;diff --git a/app/Models/WebhookAttempt.php b/app/Models/WebhookAttempt.phpindex b138bdd80d..346b613749 100644--- a/app/Models/WebhookAttempt.php+++ b/app/Models/WebhookAttempt.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Models;+use FireflyIII\User;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\Relations\BelongsTo;@@ -31,14 +32,14 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** Class WebhookAttempt*- * @property int $id- * @property \Illuminate\Support\Carbon|null $created_at- * @property \Illuminate\Support\Carbon|null $updated_at- * @property string|null $deleted_at- * @property int $webhook_message_id- * @property int $status_code- * @property string|null $logs- * @property string|null $response+ * @property int $id+ * @property \Illuminate\Support\Carbon|null $created_at+ * @property \Illuminate\Support\Carbon|null $updated_at+ * @property string|null $deleted_at+ * @property int $webhook_message_id+ * @property int $status_code+ * @property string|null $logs+ * @property string|null $response* @property-read \FireflyIII\Models\WebhookMessage $webhookMessage* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt newQuery()@@ -59,6 +60,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;class WebhookAttempt extends Model{use SoftDeletes;+/*** @codeCoverageIgnore* @return BelongsTo@@ -84,10 +86,8 @@ class WebhookAttempt extends Model$user = auth()->user();/** @var WebhookAttempt $attempt */$attempt = self::find($attemptId);- if (null !== $attempt) {- if($attempt->webhookMessage->webhook->user_id === $user->id) {- return $attempt;- }+ if (null !== $attempt && $attempt->webhookMessage->webhook->user_id === $user->id) {+ return $attempt;}}throw new NotFoundHttpException;diff --git a/app/Models/WebhookMessage.php b/app/Models/WebhookMessage.phpindex be3bc14a6c..42d20744bb 100644--- a/app/Models/WebhookMessage.php+++ b/app/Models/WebhookMessage.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Models;+use FireflyIII\User;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\Relations\BelongsTo;@@ -31,18 +32,18 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\WebhookMessage*- * @property int $id- * @property \Illuminate\Support\Carbon|null $created_at- * @property \Illuminate\Support\Carbon|null $updated_at- * @property string|null $deleted_at- * @property int $webhook_id- * @property bool $sent- * @property bool $errored- * @property int $attempts- * @property string $uuid- * @property array $message- * @property array|null $logs- * @property-read \FireflyIII\Models\Webhook $webhook+ * @property int $id+ * @property \Illuminate\Support\Carbon|null $created_at+ * @property \Illuminate\Support\Carbon|null $updated_at+ * @property string|null $deleted_at+ * @property int $webhook_id+ * @property bool $sent+ * @property bool $errored+ * @property int $attempts+ * @property string $uuid+ * @property array $message+ * @property array|null $logs+ * @property-read \FireflyIII\Models\Webhook $webhook* @method static \Illuminate\Database\Eloquent\Builder|WebhookMessage newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|WebhookMessage newQuery()* @method static \Illuminate\Database\Eloquent\Builder|WebhookMessage query()@@ -59,7 +60,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static \Illuminate\Database\Eloquent\Builder|WebhookMessage whereWebhookId($value)* @mixin \Eloquent* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\WebhookAttempt[] $webhookAttempts- * @property-read int|null $webhook_attempts_count+ * @property-read int|null $webhook_attempts_count*/class WebhookMessage extends Model{@@ -70,7 +71,7 @@ class WebhookMessage extends Model'errored' => 'boolean','uuid' => 'string','message' => 'json',- 'logs' => 'json',+ 'logs' => 'json',];/**@@ -89,10 +90,8 @@ class WebhookMessage extends Model$user = auth()->user();/** @var WebhookMessage $message */$message = self::find($messageId);- if (null !== $message) {- if($message->webhook->user_id === $user->id) {- return $message;- }+ if (null !== $message && $message->webhook->user_id === $user->id) {+ return $message;}}throw new NotFoundHttpException;diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex a35794052b..ed0c0be8a0 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -233,25 +233,35 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @param array $types+ * @param array $types+ * @param array|null $sort** @return Collection*/- public function getAccountsByType(array $types): Collection+ public function getAccountsByType(array $types, ?array $sort = []): Collection{+ $res = array_intersect([AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT], $types);$query = $this->user->accounts();if (0 !== count($types)) {$query->accountTypeIn($types);}- $res = array_intersect([AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT], $types);- if (0 !== count($res)) {- $query->orderBy('accounts.order', 'ASC');++ // add sort parameters. At this point they're filtered to allowed fields to sort by:+ if (count($sort) > 0) {+ foreach ($sort as $param) {+ $query->orderBy($param[0], $param[1]);+ }}- $query->orderBy('accounts.active', 'DESC');- $query->orderBy('accounts.name', 'ASC');- return $query->get(['accounts.*']);+ if (0 === count($sort)) {+ if (0 !== count($res)) {+ $query->orderBy('accounts.order', 'ASC');+ }+ $query->orderBy('accounts.active', 'DESC');+ $query->orderBy('accounts.name', 'ASC');+ }+ return $query->get(['accounts.*']);}/**diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.phpindex f2f8e6876a..ee570d8e7a 100644--- a/app/Repositories/Account/AccountRepositoryInterface.php+++ b/app/Repositories/Account/AccountRepositoryInterface.php@@ -121,11 +121,12 @@ interface AccountRepositoryInterfacepublic function getAccountsById(array $accountIds): Collection;/**- * @param array $types+ * @param array $types+ * @param array|null $sort** @return Collection*/- public function getAccountsByType(array $types): Collection;+ public function getAccountsByType(array $types, ?array $sort = []): Collection;/*** @param array $typesdiff --git a/app/Repositories/Account/OperationsRepository.php b/app/Repositories/Account/OperationsRepository.phpindex ed24597cc8..0fbbca6fed 100644--- a/app/Repositories/Account/OperationsRepository.php+++ b/app/Repositories/Account/OperationsRepository.php@@ -88,7 +88,7 @@ class OperationsRepository implements OperationsRepositoryInterface*/public function sumExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $expense = null, ?TransactionCurrency $currency = null): array {- $journals = $this->getTransactionsForSum($start, $end, $accounts, $expense, $currency, TransactionType::WITHDRAWAL);+ $journals = $this->getTransactionsForSum(TransactionType::WITHDRAWAL, $start, $end, $accounts, $expense, $currency);return $this->groupByCurrency($journals, 'negative');@@ -100,7 +100,7 @@ class OperationsRepository implements OperationsRepositoryInterfacepublic function sumExpensesByDestination(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $expense = null, ?TransactionCurrency $currency = null): array {- $journals = $this->getTransactionsForSum($start, $end, $accounts, $expense, $currency, TransactionType::WITHDRAWAL);+ $journals = $this->getTransactionsForSum(TransactionType::WITHDRAWAL, $start, $end, $accounts, $expense, $currency);return $this->groupByDirection($journals, 'destination', 'negative');}@@ -111,7 +111,7 @@ class OperationsRepository implements OperationsRepositoryInterfacepublic function sumExpensesBySource(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $expense = null, ?TransactionCurrency $currency = null): array {- $journals = $this->getTransactionsForSum($start, $end, $accounts, $expense, $currency, TransactionType::WITHDRAWAL);+ $journals = $this->getTransactionsForSum(TransactionType::WITHDRAWAL, $start, $end, $accounts, $expense, $currency);return $this->groupByDirection($journals, 'source', 'negative');}@@ -121,7 +121,7 @@ class OperationsRepository implements OperationsRepositoryInterface*/public function sumIncome(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $revenue = null, ?TransactionCurrency $currency = null): array {- $journals = $this->getTransactionsForSum($start, $end, $accounts, $revenue, $currency, TransactionType::DEPOSIT);+ $journals = $this->getTransactionsForSum(TransactionType::DEPOSIT, $start, $end, $accounts, $revenue, $currency);return $this->groupByCurrency($journals, 'positive');}@@ -132,7 +132,7 @@ class OperationsRepository implements OperationsRepositoryInterfacepublic function sumIncomeByDestination(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $revenue = null, ?TransactionCurrency $currency = null): array {- $journals = $this->getTransactionsForSum($start, $end, $accounts, $revenue, $currency, TransactionType::DEPOSIT);+ $journals = $this->getTransactionsForSum(TransactionType::DEPOSIT, $start, $end, $accounts, $revenue, $currency);return $this->groupByDirection($journals, 'destination', 'positive');}@@ -143,7 +143,7 @@ class OperationsRepository implements OperationsRepositoryInterfacepublic function sumIncomeBySource(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $revenue = null, ?TransactionCurrency $currency = null): array {- $journals = $this->getTransactionsForSum($start, $end, $accounts, $revenue, $currency, TransactionType::DEPOSIT);+ $journals = $this->getTransactionsForSum(TransactionType::DEPOSIT, $start, $end, $accounts, $revenue, $currency);return $this->groupByDirection($journals, 'source', 'positive');}@@ -153,7 +153,7 @@ class OperationsRepository implements OperationsRepositoryInterface*/public function sumTransfers(Carbon $start, Carbon $end, ?Collection $accounts = null, ?TransactionCurrency $currency = null): array{- $journals = $this->getTransactionsForSum($start, $end, $accounts, null, $currency, TransactionType::TRANSFER);+ $journals = $this->getTransactionsForSum(TransactionType::TRANSFER, $start, $end, $accounts, null, $currency);return $this->groupByEither($journals);}@@ -234,8 +234,8 @@ class OperationsRepository implements OperationsRepositoryInterface* @return array*/private function getTransactionsForSum(- Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $opposing = null, ?TransactionCurrency $currency = null,- string $type+ string $type, Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $opposing = null, ?TransactionCurrency $currency = null+): array {$start->startOfDay();$end->endOfDay();@@ -261,11 +261,9 @@ class OperationsRepository implements OperationsRepositoryInterface$collector->setSourceAccounts($opposing);}}- if(TransactionType::TRANSFER === $type) {- // supports only accounts, not opposing.- if(null !== $accounts) {- $collector->setAccounts($accounts);- }+ // supports only accounts, not opposing.+ if (TransactionType::TRANSFER === $type && null !== $accounts) {+ $collector->setAccounts($accounts);}if (null !== $currency) {diff --git a/app/Repositories/Attachment/AttachmentRepository.php b/app/Repositories/Attachment/AttachmentRepository.phpindex b7923a4370..0d1b363425 100644--- a/app/Repositories/Attachment/AttachmentRepository.php+++ b/app/Repositories/Attachment/AttachmentRepository.php@@ -174,10 +174,8 @@ class AttachmentRepository implements AttachmentRepositoryInterface$attachment->title = $data['title'];}- if (array_key_exists('filename', $data)) {- if ('' !== (string)$data['filename'] && $data['filename'] !== $attachment->filename) {- $attachment->filename = $data['filename'];- }+ if (array_key_exists('filename', $data) && '' !== (string)$data['filename'] && $data['filename'] !== $attachment->filename) {+ $attachment->filename = $data['filename'];}// update model (move attachment)// should be validated already:diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.phpindex bae560b7c9..6e697e3112 100644--- a/app/Repositories/Bill/BillRepository.php+++ b/app/Repositories/Bill/BillRepository.php@@ -505,14 +505,6 @@ class BillRepository implements BillRepositoryInterface$currentStart = clone $nextExpectedMatch;}- $simple = $set->each(- static function (Carbon $date) {- return $date->format('Y-m-d');- }- );-- //Log::debug(sprintf('Found dates between %s and %s:', $start->format('Y-m-d'), $end->format('Y-m-d')), $simple->toArray());-return $set;}@@ -657,12 +649,6 @@ class BillRepository implements BillRepositoryInterfacewhile ($start < $date) {$start = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip);}-- $end = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip);-- //Log::debug('nextDateMatch: Final start is ' . $start->format('Y-m-d'));- //Log::debug('nextDateMatch: Matching end is ' . $end->format('Y-m-d'));-$cache->store($start);return $start;diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.phpindex 9f6ce7bc85..7f7bfec617 100644--- a/app/Repositories/Tag/TagRepository.php+++ b/app/Repositories/Tag/TagRepository.php@@ -151,7 +151,7 @@ class TagRepository implements TagRepositoryInterface$disk = Storage::disk('upload');return $set->each(- static function (Attachment $attachment, int $index) use ($disk) {+ static function (Attachment $attachment) use ($disk) {/** @var Note $note */$note = $attachment->notes()->first();// only used in v1 view of tagsdiff --git a/app/Repositories/Webhook/WebhookRepository.php b/app/Repositories/Webhook/WebhookRepository.phpindex 871fc9e8b6..f9ee12bb74 100644--- a/app/Repositories/Webhook/WebhookRepository.php+++ b/app/Repositories/Webhook/WebhookRepository.php@@ -116,7 +116,7 @@ class WebhookRepository implements WebhookRepositoryInterface*/public function store(array $data): Webhook{- $secret = $random = Str::random(24);+ $secret = Str::random(24);$fullData = ['user_id' => $this->user->id,'active' => $data['active'] ?? false,@@ -144,7 +144,7 @@ class WebhookRepository implements WebhookRepositoryInterface$webhook->url = $data['url'] ?? $webhook->url;if (true === $data['secret']) {- $secret = $random = Str::random(24);+ $secret = Str::random(24);$webhook->secret = $secret;}diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.phpindex 68b4076e16..c2bae2535c 100644--- a/app/Services/Internal/Support/AccountServiceTrait.php+++ b/app/Services/Internal/Support/AccountServiceTrait.php@@ -522,7 +522,7 @@ trait AccountServiceTrait],],];- Log::debug('Going for submission', $submission);+ Log::debug('Going for submission in createOBGroupV2', $submission);/** @var TransactionGroupFactory $factory */$factory = app(TransactionGroupFactory::class);@@ -595,7 +595,7 @@ trait AccountServiceTrait],],];- Log::debug('Going for submission', $submission);+ Log::debug('Going for submission in createCreditTransaction', $submission);/** @var TransactionGroupFactory $factory */$factory = app(TransactionGroupFactory::class);@@ -688,7 +688,7 @@ trait AccountServiceTrait],],];- Log::debug('Going for submission', $submission);+ Log::debug('Going for submission in createOBGroup', $submission);/** @var TransactionGroupFactory $factory */$factory = app(TransactionGroupFactory::class);diff --git a/app/Services/Internal/Support/CreditRecalculateService.php b/app/Services/Internal/Support/CreditRecalculateService.phpindex 2d3e09d394..a1928482ea 100644--- a/app/Services/Internal/Support/CreditRecalculateService.php+++ b/app/Services/Internal/Support/CreditRecalculateService.php@@ -55,7 +55,6 @@ class CreditRecalculateService*/public function recalculate(): void{- Log::debug(sprintf('Now in %s', __METHOD__));if (true !== config('firefly.feature_flags.handle_debts')) {Log::debug('handle_debts is disabled.');@@ -83,7 +82,6 @@ class CreditRecalculateServiceprivate function processWork(): void{$this->repository = app(AccountRepositoryInterface::class);- Log::debug(sprintf('Now in %s', __METHOD__));foreach ($this->work as $account) {$this->processWorkAccount($account);}@@ -127,7 +125,6 @@ class CreditRecalculateService*/private function processGroup(): void{- Log::debug(sprintf('Now in %s', __METHOD__));/** @var TransactionJournal $journal */foreach ($this->group->transactionJournals as $journal) {if (0 === count($this->work)) {@@ -149,7 +146,6 @@ class CreditRecalculateService*/private function findByJournal(TransactionJournal $journal): void{- Log::debug(sprintf('Now in %s', __METHOD__));$source = $this->getSourceAccount($journal);$destination = $this->getDestinationAccount($journal);@@ -190,12 +186,12 @@ class CreditRecalculateServiceif (null === $transaction) {throw new FireflyException(sprintf('Cannot find "%s"-transaction of journal #%d', $direction, $journal->id));}- $account = $transaction->account;- if (null === $account) {+ $foundAccount = $transaction->account;+ if (null === $foundAccount) {throw new FireflyException(sprintf('Cannot find "%s"-account of transaction #%d of journal #%d', $direction, $transaction->id, $journal->id));}- return $account;+ return $foundAccount;}/**@@ -214,7 +210,6 @@ class CreditRecalculateService*/private function processAccount(): void{- Log::debug(sprintf('Now in %s', __METHOD__));$valid = config('firefly.valid_liabilities');if (in_array($this->account->accountType->type, $valid)) {Log::debug(sprintf('Account type is "%s", include it.', $this->account->accountType->type));diff --git a/app/Services/Internal/Update/CategoryUpdateService.php b/app/Services/Internal/Update/CategoryUpdateService.phpindex 6520cabdad..1db4e1c845 100644--- a/app/Services/Internal/Update/CategoryUpdateService.php+++ b/app/Services/Internal/Update/CategoryUpdateService.php@@ -167,8 +167,6 @@ class CategoryUpdateService}$dbNote->text = trim($note);$dbNote->save();-- return;}}diff --git a/app/Support/Authentication/RemoteUserGuard.php b/app/Support/Authentication/RemoteUserGuard.phpindex f5ab52986a..0144dea99d 100644--- a/app/Support/Authentication/RemoteUserGuard.php+++ b/app/Support/Authentication/RemoteUserGuard.php@@ -98,9 +98,7 @@ class RemoteUserGuard implements Guard*/public function check(): bool{- $result = !is_null($this->user());-- return $result;+ return !is_null($this->user());}/**diff --git a/app/Support/Export/ExportDataGenerator.php b/app/Support/Export/ExportDataGenerator.phpindex 03657a2201..2d11087c7b 100644--- a/app/Support/Export/ExportDataGenerator.php+++ b/app/Support/Export/ExportDataGenerator.php@@ -75,6 +75,9 @@ class ExportDataGeneratorprivate Carbon $start;private User $user;+ private const ADD_RECORD_ERR = 'Could not add record to set: %s';+ private const EXPORT_ERR = 'Could not export to string: %s';+public function __construct(){$this->accounts = new Collection;@@ -142,10 +145,10 @@ class ExportDataGenerator/** @var AccountRepositoryInterface $repository */$repository = app(AccountRepositoryInterface::class);$repository->setUser($this->user);- $accounts = $repository->getAccountsByType([]);- $records = [];+ $allAccounts = $repository->getAccountsByType([]);+ $records = [];/** @var Account $account */- foreach ($accounts as $account) {+ foreach ($allAccounts as $account) {$currency = $repository->getAccountCurrency($account);$records[] = [$this->user->id,@@ -175,7 +178,7 @@ class ExportDataGeneratortry {$csv->insertOne($header);} catch (CannotInsertRecord $e) {- throw new FireflyException(sprintf('Could not add record to set: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::ADD_RECORD_ERR, $e->getMessage()), 0, $e);}//insert all the records@@ -184,7 +187,7 @@ class ExportDataGeneratortry {$string = $csv->toString();} catch (Exception $e) {- throw new FireflyException(sprintf('Could not export to string: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e);}return $string;@@ -229,7 +232,7 @@ class ExportDataGeneratortry {$csv->insertOne($header);} catch (CannotInsertRecord $e) {- throw new FireflyException(sprintf('Could not add record to set: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::ADD_RECORD_ERR, $e->getMessage()), 0, $e);}//insert all the records@@ -238,7 +241,7 @@ class ExportDataGeneratortry {$string = $csv->toString();} catch (Exception $e) {- throw new FireflyException(sprintf('Could not export to string: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e);}return $string;@@ -293,7 +296,7 @@ class ExportDataGeneratortry {$csv->insertOne($header);} catch (CannotInsertRecord $e) {- throw new FireflyException(sprintf('Could not add record to set: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::ADD_RECORD_ERR, $e->getMessage()), 0, $e);}//insert all the records@@ -302,7 +305,7 @@ class ExportDataGeneratortry {$string = $csv->toString();} catch (Exception $e) {- throw new FireflyException(sprintf('Could not export to string: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e);}return $string;@@ -342,7 +345,7 @@ class ExportDataGeneratortry {$csv->insertOne($header);} catch (CannotInsertRecord $e) {- throw new FireflyException(sprintf('Could not add record to set: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::ADD_RECORD_ERR, $e->getMessage()), 0, $e);}//insert all the records@@ -351,7 +354,7 @@ class ExportDataGeneratortry {$string = $csv->toString();} catch (Exception $e) {- throw new FireflyException(sprintf('Could not export to string: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e);}return $string;@@ -406,7 +409,7 @@ class ExportDataGeneratortry {$csv->insertOne($header);} catch (CannotInsertRecord $e) {- throw new FireflyException(sprintf('Could not add record to set: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::ADD_RECORD_ERR, $e->getMessage()), 0, $e);}//insert all the records@@ -415,7 +418,7 @@ class ExportDataGeneratortry {$string = $csv->toString();} catch (Exception $e) {- throw new FireflyException(sprintf('Could not export to string: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e);}return $string;@@ -504,7 +507,7 @@ class ExportDataGeneratortry {$csv->insertOne($header);} catch (CannotInsertRecord $e) {- throw new FireflyException(sprintf('Could not add record to set: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::ADD_RECORD_ERR, $e->getMessage()), 0, $e);}//insert all the records@@ -513,7 +516,7 @@ class ExportDataGeneratortry {$string = $csv->toString();} catch (Exception $e) {- throw new FireflyException(sprintf('Could not export to string: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e);}return $string;@@ -571,7 +574,7 @@ class ExportDataGeneratortry {$csv->insertOne($header);} catch (CannotInsertRecord $e) {- throw new FireflyException(sprintf('Could not add record to set: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::ADD_RECORD_ERR, $e->getMessage()), 0, $e);}//insert all the records@@ -580,7 +583,7 @@ class ExportDataGeneratortry {$string = $csv->toString();} catch (Exception $e) {- throw new FireflyException(sprintf('Could not export to string: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e);}return $string;@@ -621,7 +624,7 @@ class ExportDataGeneratortry {$csv->insertOne($header);} catch (CannotInsertRecord $e) {- throw new FireflyException(sprintf('Could not add record to set: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::ADD_RECORD_ERR, $e->getMessage()), 0, $e);}//insert all the records@@ -630,7 +633,7 @@ class ExportDataGeneratortry {$string = $csv->toString();} catch (Exception $e) {- throw new FireflyException(sprintf('Could not export to string: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e);}return $string;@@ -741,7 +744,7 @@ class ExportDataGeneratortry {$csv->insertOne($header);} catch (CannotInsertRecord $e) {- throw new FireflyException(sprintf('Could not add record to set: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::ADD_RECORD_ERR, $e->getMessage()), 0, $e);}//insert all the records@@ -750,7 +753,7 @@ class ExportDataGeneratortry {$string = $csv->toString();} catch (Exception $e) {- throw new FireflyException(sprintf('Could not export to string: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(sprintf(self::EXPORT_ERR, $e->getMessage()), 0, $e);}return $string;diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.phpindex 6692be0952..54a9be581f 100644--- a/app/Support/Search/OperatorQuerySearch.php+++ b/app/Support/Search/OperatorQuerySearch.php@@ -259,9 +259,9 @@ class OperatorQuerySearch implements SearchInterfacecase Emoticon::class:case Emoji::class:case Mention::class:- $words = (string)$searchNode->getValue();- Log::debug(sprintf('Add words "%s" to search string, because Node class is "%s"', $words, $class));- $this->words[] = $words;+ $allWords = (string)$searchNode->getValue();+ Log::debug(sprintf('Add words "%s" to search string, because Node class is "%s"', $allWords, $class));+ $this->words[] = $allWords;break;case Field::class:Log::debug(sprintf('Now handle Node class %s', $class));@@ -836,11 +836,11 @@ class OperatorQuerySearch implements SearchInterfaceif ($parser->isDateRange($value)) {return $parser->parseRange($value, $this->date);}- $date = $parser->parseDate($value);+ $parsedDate = $parser->parseDate($value);return [- 'start' => $date,- 'end' => $date,+ 'start' => $parsedDate,+ 'end' => $parsedDate,];}diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.phpindex 71327d2b6b..9c1e061f1f 100644--- a/app/TransactionRules/Engine/SearchRuleEngine.php+++ b/app/TransactionRules/Engine/SearchRuleEngine.php@@ -293,11 +293,9 @@ class SearchRuleEngine implements RuleEngineInterface$journalTrigger = false;$dateTrigger = false;foreach ($array as $triggerName => $values) {- if ('journal_id' === $triggerName) {- if (is_array($values) && 1 === count($values)) {- Log::debug('Found a journal_id trigger with 1 journal, true.');- $journalTrigger = true;- }+ if ('journal_id' === $triggerName && is_array($values) && 1 === count($values)) {+ Log::debug('Found a journal_id trigger with 1 journal, true.');+ $journalTrigger = true;}if (in_array($triggerName, ['date_is', 'date', 'on', 'date_before', 'before', 'date_after', 'after'], true)) {Log::debug('Found a date related trigger, set to true.');@@ -320,11 +318,9 @@ class SearchRuleEngine implements RuleEngineInterfaceLog::debug('Now in setDateFromJournalTrigger()');$journalId = 0;foreach ($array as $triggerName => $values) {- if ('journal_id' === $triggerName) {- if (is_array($values) && 1 === count($values)) {- $journalId = (int)trim(($values[0] ?? '"0"'), '"'); // follows format "123".- Log::debug(sprintf('Found journal ID #%d', $journalId));- }+ if ('journal_id' === $triggerName && is_array($values) && 1 === count($values)) {+ $journalId = (int)trim(($values[0] ?? '"0"'), '"'); // follows format "123".+ Log::debug(sprintf('Found journal ID #%d', $journalId));}}if (0 !== $journalId) {diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.phpindex 300dab679b..d75d311aeb 100644--- a/app/Transformers/BillTransformer.php+++ b/app/Transformers/BillTransformer.php@@ -255,9 +255,7 @@ class BillTransformer extends AbstractTransformerreturn $date->format('Y-m-d');});- $array = $simple->toArray();-- return $array;+ return $simple->toArray();}/**diff --git a/app/Validation/RecurrenceValidation.php b/app/Validation/RecurrenceValidation.phpindex dd4f1d6dbc..eed310d3a9 100644--- a/app/Validation/RecurrenceValidation.php+++ b/app/Validation/RecurrenceValidation.php@@ -182,8 +182,6 @@ trait RecurrenceValidationif ($reps > 0 && null !== $repeatUntil) {$validator->errors()->add('nr_of_repetitions', trans('validation.require_repeat_until'));$validator->errors()->add('repeat_until', trans('validation.require_repeat_until'));-- return;}}diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.phpindex 6dd17d06ed..b49a0c11e3 100644--- a/app/Validation/TransactionValidation.php+++ b/app/Validation/TransactionValidation.php@@ -331,9 +331,8 @@ trait TransactionValidation* All types of splits must be equal.** @param Validator $validator- * @param TransactionGroup $transactionGroup*/- public function validateTransactionTypesForUpdate(Validator $validator, TransactionGroup $transactionGroup): void+ public function validateTransactionTypesForUpdate(Validator $validator): void{Log::debug('Now in validateTransactionTypesForUpdate()');$transactions = $this->getTransactionsArray($validator);diff --git a/frontend/src/components/accounts/Index.vue b/frontend/src/components/accounts/Index.vueindex a4d6d3e90e..30f4911315 100644--- a/frontend/src/components/accounts/Index.vue+++ b/frontend/src/components/accounts/Index.vue@@ -36,8 +36,8 @@<div class="card-header"></div><div class="card-body p-0">- <b-table id="my-table" striped hover responsive="md" primary-key="id"- :items="accounts" :fields="fields"+ <b-table id="my-table" striped hover responsive="md" primary-key="id" :no-local-sorting="true"+ :items="itemsProvider" :fields="fields":per-page="perPage"sort-icon-leftref="table"@@ -46,7 +46,7 @@:sort-by.sync="sortBy":sort-desc.sync="sortDesc">- <template #cell(title)="data">+ <template #cell(name)="data"><a :class="false === data.item.active ? 'text-muted' : ''" :href="'./accounts/show/' + data.item.id" :title="data.value">{{ data.value }}</a></template><template #cell(number)="data">@@ -162,6 +162,10 @@import {mapGetters} from "vuex";import Sortable from "sortablejs";import format from "date-fns/format";+import {setup} from 'axios-cache-adapter'+// import {cacheAdapterEnhancer} from 'axios-extensions';+// pas wat teruggeven als die pagina ook gevraagd wordt, anders een empty array+// van X lang?export default {name: "Index",@@ -179,9 +183,10 @@ export default {fields: [],currentPage: 1,perPage: 5,- total: 0,+ total: 1,sortBy: 'order',sortDesc: false,+ api: null,sortableOptions: {disabled: false,chosenClass: 'is-selected',@@ -192,13 +197,13 @@ export default {},watch: {storeReady: function () {- this.getAccountList();+ //this.getAccountList();},start: function () {- this.getAccountList();+ //this.getAccountList();},end: function () {- this.getAccountList();+ //this.getAccountList();},orderMode: function (value) {// update the table headers@@ -229,14 +234,55 @@ export default {let pathName = window.location.pathname;let parts = pathName.split('/');this.type = parts[parts.length - 1];+ this.perPage = this.listPageSize ?? 51;+ console.log('Per page: ' + this.perPage);let params = new URLSearchParams(window.location.search);this.currentPage = params.get('page') ? parseInt(params.get('page')) : 1;this.updateFieldList();this.ready = true;++ // make object thing:+ let token = document.head.querySelector('meta[name="csrf-token"]');+ this.api = setup(+ {+ // `axios` options+ //baseURL: './',+ headers: {'X-CSRF-TOKEN': token.content, 'X-James': 'yes'},++ // `axios-cache-adapter` options+ cache: {+ maxAge: 15 * 60 * 1000,+ readHeaders: false,+ exclude: {+ query: false,+ },+ debug: true+ }+ });},methods: {+ itemsProvider: function (ctx, callback) {+ console.log('itemsProvider()');+ console.log('ctx.currentPage = ' + ctx.currentPage);+ console.log('this.currentPage = ' + this.currentPage);+ if (ctx.currentPage === this.currentPage) {+ let direction = this.sortDesc ? '-' : '+';+ let url = 'api/v1/accounts?type=' + this.type + '&page=' + ctx.currentPage + '&sort=' + direction + this.sortBy;+ this.api.get(url)+ .then(async (response) => {+ this.total = parseInt(response.data.meta.pagination.total);+ let items = this.parseAccountsAndReturn(response.data.data);+ items = this.filterAccountListAndReturn(items);+ callback(items);+ }+ );+ return null;+ }+ return [];+ },+saveAccountSort: function (event) {let oldIndex = parseInt(event.oldIndex);let newIndex = parseInt(event.newIndex);@@ -277,7 +323,7 @@ export default {updateFieldList: function () {this.fields = [];- this.fields = [{key: 'title', label: this.$t('list.name'), sortable: !this.orderMode}];+ this.fields = [{key: 'name', label: this.$t('list.name'), sortable: !this.orderMode}];if ('asset' === this.type) {this.fields.push({key: 'role', label: this.$t('list.role'), sortable: !this.orderMode});}@@ -305,7 +351,7 @@ export default {this.perPage = this.listPageSize ?? 51;this.accounts = [];this.allAccounts = [];- this.downloadAccountList(1);+ //this.downloadAccountList(1);}if (this.indexReady && !this.loading && this.downloaded) {// console.log('Index ready, not loading and not downloaded.');@@ -314,8 +360,13 @@ export default {}},downloadAccountList: function (page) {+ const http = axios.create({+ baseURL: './',+ headers: {'Cache-Control': 'no-cache'},+ });+// console.log('downloadAccountList(' + page + ')');- axios.get('./api/v1/accounts?type=' + this.type + '&page=' + page)+ http.get('./api/v1/accounts?type=' + this.type + '&page=' + page).then(response => {let currentPage = parseInt(response.data.meta.pagination.current_page);let totalPage = parseInt(response.data.meta.pagination.total_pages);@@ -333,6 +384,29 @@ export default {});},+ filterAccountListAndReturn: function (allAccounts) {+ console.log('filterAccountListAndReturn()');+ let accounts = [];+ for (let i in allAccounts) {+ if (allAccounts.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) {+ // 1 = active only+ // 2 = inactive only+ // 3 = both+ if (1 === this.activeFilter && false === allAccounts[i].active) {+ // console.log('Skip account #' + this.allAccounts[i].id + ' because not active.');+ continue;+ }+ if (2 === this.activeFilter && true === allAccounts[i].active) {+ // console.log('Skip account #' + this.allAccounts[i].id + ' because active.');+ continue;+ }+ // console.log('Include account #' + this.allAccounts[i].id + '.');++ accounts.push(allAccounts[i]);+ }+ }+ return accounts;+ },filterAccountList: function () {// console.log('filterAccountList()');this.accounts = [];@@ -367,6 +441,49 @@ export default {this.total = parseInt(data.pagination.total);//console.log('Total is now ' + this.total);},+ parseAccountsAndReturn: function (data) {+ console.log('In parseAccountsAndReturn()');+ let allAccounts = [];+ for (let key in data) {+ if (data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {+ let current = data[key];+ let acct = {};+ acct.id = parseInt(current.id);+ acct.order = current.attributes.order;+ acct.name = current.attributes.name;+ acct.active = current.attributes.active;+ acct.role = this.roleTranslate(current.attributes.account_role);+ acct.account_number = current.attributes.account_number;+ acct.current_balance = current.attributes.current_balance;+ acct.currency_code = current.attributes.currency_code;++ if ('liabilities' === this.type) {+ acct.liability_type = this.$t('firefly.account_type_' + current.attributes.liability_type);+ acct.liability_direction = this.$t('firefly.liability_direction_' + current.attributes.liability_direction + '_short');+ acct.interest = current.attributes.interest;+ acct.interest_period = this.$t('firefly.interest_calc_' + current.attributes.interest_period);+ acct.amount_due = current.attributes.current_debt;+ }+ acct.balance_diff = 'loading';+ acct.last_activity = 'loading';++ if (null !== current.attributes.iban) {+ acct.iban = current.attributes.iban.match(/.{1,4}/g).join(' ');+ }+ if (null === current.attributes.iban) {+ acct.iban = null;+ }++ allAccounts.push(acct);+ if ('asset' === this.type) {+ // TODO+ //this.getAccountBalanceDifference(this.allAccounts.length - 1, current);+ //this.getAccountLastActivity(this.allAccounts.length - 1, current);+ }+ }+ }+ return allAccounts;+ },parseAccounts: function (data) {// console.log('In parseAccounts()');for (let key in data) {@@ -375,7 +492,7 @@ export default {let acct = {};acct.id = parseInt(current.id);acct.order = current.attributes.order;- acct.title = current.attributes.name;+ acct.name = current.attributes.name;acct.active = current.attributes.active;acct.role = this.roleTranslate(current.attributes.account_role);acct.account_number = current.attributes.account_number;diff --git a/frontend/src/components/accounts/LiabilityDirection.vue b/frontend/src/components/accounts/LiabilityDirection.vueindex d43d91817d..dd84299c28 100644--- a/frontend/src/components/accounts/LiabilityDirection.vue+++ b/frontend/src/components/accounts/LiabilityDirection.vue@@ -65,8 +65,6 @@ export default {liability_direction: function (value) {this.$emit('set-field', {field: 'liability_direction', value: value});},- },- created() {}}</script>diff --git a/frontend/src/components/budgets/Index.vue b/frontend/src/components/budgets/Index.vueindex 746f59b198..cc9f2bdb46 100644--- a/frontend/src/components/budgets/Index.vue+++ b/frontend/src/components/budgets/Index.vue@@ -71,10 +71,7 @@<script>export default {- name: "Index",- created() {-- }+ name: "Index"}</script>diff --git a/frontend/src/components/charts/DataConverter.vue b/frontend/src/components/charts/DataConverter.vueindex c7ccbee79b..cd767e3a53 100644--- a/frontend/src/components/charts/DataConverter.vue+++ b/frontend/src/components/charts/DataConverter.vue@@ -74,8 +74,9 @@ export default {//let strokePointHighColors = [];- for (let i = 0; i < colourSet.length; i++) {- fillColors.push("rgba(" + colourSet[i][0] + ", " + colourSet[i][1] + ", " + colourSet[i][2] + ", 0.5)");+ //for (let i = 0; i < colourSet.length; i++) {+ for (let value of colourSet) {+ fillColors.push("rgba(" + value[0] + ", " + value[1] + ", " + value[2] + ", 0.5)");//strokePointHighColors.push("rgba(" + colourSet[i][0] + ", " + colourSet[i][1] + ", " + colourSet[i][2] + ", 0.9)");}this.newDataSet.labels = this.dataSet.labels;@@ -123,8 +124,9 @@ export default {//let strokePointHighColors = [];- for (let i = 0; i < colourSet.length; i++) {- fillColors.push("rgba(" + colourSet[i][0] + ", " + colourSet[i][1] + ", " + colourSet[i][2] + ", 0.5)");+ //for (let i = 0; i < colourSet.length; i++) {+ for (let value of colourSet) {+ fillColors.push("rgba(" + value[0] + ", " + value[1] + ", " + value[2] + ", 0.5)");//strokePointHighColors.push("rgba(" + colourSet[i][0] + ", " + colourSet[i][1] + ", " + colourSet[i][2] + ", 0.9)");}this.newDataSet.labels = this.dataSet.labels;diff --git a/frontend/src/components/dashboard/Calendar.vue b/frontend/src/components/dashboard/Calendar.vueindex 88ff610427..6c4c0b163b 100644--- a/frontend/src/components/dashboard/Calendar.vue+++ b/frontend/src/components/dashboard/Calendar.vue@@ -327,7 +327,6 @@ export default {let title = 'todo';let half = 1;-// its currently first half of year:if (today.getMonth() <= 5) {// previous year, last half:@@ -398,7 +397,6 @@ export default {end.setMonth(5);end.setDate(30);end = endOfDay(end);- half = 1;title = format(start, this.$t('config.half_year_fns', {half: half}));this.periods.push({@@ -450,7 +448,6 @@ export default {let today = new Date(this.range.start);let start;let end;- let title;// last yearstart = new Date(today);diff --git a/frontend/src/components/dashboard/MainAccountChart.vue b/frontend/src/components/dashboard/MainAccountChart.vueindex 2c83e9e664..56bf34714c 100644--- a/frontend/src/components/dashboard/MainAccountChart.vue+++ b/frontend/src/components/dashboard/MainAccountChart.vue@@ -22,9 +22,6 @@//import {Line, mixins} from 'vue-chartjs'--import { Chart, LineController, LineElement, PointElement, LinearScale, Title } from 'chart.js'-const {reactiveProp} = mixinsexport default {diff --git a/frontend/src/components/dashboard/MainCreditList.vue b/frontend/src/components/dashboard/MainCreditList.vueindex 9f7f7d6da4..91fe797cfd 100644--- a/frontend/src/components/dashboard/MainCreditList.vue+++ b/frontend/src/components/dashboard/MainCreditList.vue@@ -141,9 +141,9 @@ export default {});},parseIncome(data) {- for (let mainKey in data) {- if (data.hasOwnProperty(mainKey)) {- mainKey = parseInt(mainKey);+ for (let i in data) {+ if (data.hasOwnProperty(i)) {+ let mainKey = parseInt(i);// contains currency info and entries.let current = data[mainKey];current.pct = 0;diff --git a/frontend/src/components/transactions/Create.vue b/frontend/src/components/transactions/Create.vueindex 4692e4d8f7..a2bd27cc3f 100644--- a/frontend/src/components/transactions/Create.vue+++ b/frontend/src/components/transactions/Create.vue@@ -25,8 +25,6 @@<form @submit="submitTransaction" autocomplete="off"><SplitPills :transactions="transactions"/><div class="tab-content">- <!-- v-on:switch-accounts="switchAccounts($event)" -->- <!-- :allowed-opposing-types="allowedOpposingTypes" --><SplitFormv-for="(transaction, index) in this.transactions"v-bind:key="index"@@ -119,8 +117,6 @@ import SplitPills from "./SplitPills";import TransactionGroupTitle from "./TransactionGroupTitle";import SplitForm from "./SplitForm";import {mapGetters, mapMutations} from "vuex";-import {getDefaultErrors} from "../../shared/transactions";-export default {name: "Create",diff --git a/frontend/src/components/transactions/SplitForm.vue b/frontend/src/components/transactions/SplitForm.vueindex 5104dddc49..64ba777d3a 100644--- a/frontend/src/components/transactions/SplitForm.vue+++ b/frontend/src/components/transactions/SplitForm.vue@@ -386,23 +386,23 @@ export default {},sourceAccount: function () {//console.log('computed::sourceAccount(' + this.index + ')');- let value = {+ return {id: this.transaction.source_account_id,name: this.transaction.source_account_name,type: this.transaction.source_account_type,};//console.log(JSON.stringify(value));- return value;+ //return value;},destinationAccount: function () {//console.log('computed::destinationAccount(' + this.index + ')');- let value = {+ return {id: this.transaction.destination_account_id,name: this.transaction.destination_account_name,type: this.transaction.destination_account_type,};//console.log(JSON.stringify(value));- return value;+ //return value;},hasMetaFields: function () {let requiredFields = [diff --git a/frontend/src/components/transactions/SwitchAccount.vue b/frontend/src/components/transactions/SwitchAccount.vueindex 20b86d83e0..ff19bdede9 100644--- a/frontend/src/components/transactions/SwitchAccount.vue+++ b/frontend/src/components/transactions/SwitchAccount.vue@@ -26,11 +26,6 @@</span><span v-if="'any' === this.transactionType" class="text-muted"> </span></div>- <!--- <div class="btn-group d-flex">- <button class="btn btn-light" @click="switchAccounts">↔</button>- </div>- --></div></template>diff --git a/frontend/src/components/transactions/TransactionAccount.vue b/frontend/src/components/transactions/TransactionAccount.vueindex 258c0612ed..9654084ab5 100644--- a/frontend/src/components/transactions/TransactionAccount.vue+++ b/frontend/src/components/transactions/TransactionAccount.vue@@ -23,7 +23,6 @@<div v-if="visible" class="text-xs d-none d-lg-block d-xl-block"><span v-if="0 === this.index">{{ $t('firefly.' + this.direction + '_account') }}</span><span v-if="this.index > 0" class="text-warning">{{ $t('firefly.first_split_overrules_' + this.direction) }}</span>- <!--<br><span>{{ selectedAccount }}</span>--></div><div v-if="!visible" class="text-xs d-none d-lg-block d-xl-block"> diff --git a/resources/assets/js/components/transactions/CreateTransaction.vue b/resources/assets/js/components/transactions/CreateTransaction.vueindex b3a2340d81..3d45639159 100644--- a/resources/assets/js/components/transactions/CreateTransaction.vue+++ b/resources/assets/js/components/transactions/CreateTransaction.vue@@ -378,8 +378,6 @@ export default {}tagList = [];- foreignAmount = null;- foreignCurrency = null;// loop tagsfor (let tagKey in row.tags) {if (row.tags.hasOwnProperty(tagKey) && /^0$|^[1-9]\d*$/.test(tagKey) && tagKey <= 4294967294) {diff --git a/resources/assets/js/components/transactions/CustomAttachments.vue b/resources/assets/js/components/transactions/CustomAttachments.vueindex 7c8c6aae3a..4916c78e07 100644--- a/resources/assets/js/components/transactions/CustomAttachments.vue+++ b/resources/assets/js/components/transactions/CustomAttachments.vue@@ -56,9 +56,9 @@ export default {error: Array},mounted: function () {- window.addEventListener('paste', e => {- this.$refs.input.files = e.clipboardData.files;- });+ // window.addEventListener('paste', e => {+ // this.$refs.input.files = e.clipboardData.files;+ // });},methods: {clearAtt: function () {diff --git a/tests/Api/Models/Transaction/UpdateControllerTest.php b/tests/Api/Models/Transaction/UpdateControllerTest.phpindex 924e00a2b2..c251a89a4b 100644--- a/tests/Api/Models/Transaction/UpdateControllerTest.php+++ b/tests/Api/Models/Transaction/UpdateControllerTest.php@@ -165,8 +165,6 @@ class UpdateControllerTest extends TestCase$fieldSet->addField(Field::createBasic('transactions/0/' . $value, 'uuid'));$configuration->addOptionalFieldSet($value, $fieldSet);}- $result = $configuration->generateAll();-- return $result;+ return $configuration->generateAll();}}diff --git a/tests/Api/Models/TransactionCurrency/UpdateControllerTest.php b/tests/Api/Models/TransactionCurrency/UpdateControllerTest.phpindex b3f38838c7..998c9fb9ed 100644--- a/tests/Api/Models/TransactionCurrency/UpdateControllerTest.php+++ b/tests/Api/Models/TransactionCurrency/UpdateControllerTest.php@@ -113,7 +113,7 @@ class UpdateControllerTest extends TestCasepublic function updateDataSet(): array{$faker = Factory::create();- $set = [+ return ['name' => ['id' => 'INR','fields' => [@@ -157,7 +157,5 @@ class UpdateControllerTest extends TestCase'extra_ignore' => [],],];-- return $set;}}diff --git a/tests/Objects/TestConfiguration.php b/tests/Objects/TestConfiguration.phpindex 3b8feb4188..8dae309f83 100644--- a/tests/Objects/TestConfiguration.php+++ b/tests/Objects/TestConfiguration.php@@ -21,10 +21,11 @@*/declare(strict_types=1);+namespace Tests\Objects;use Faker\Factory;-use RuntimeException;+use UnexpectedValueException;/*** Class TestConfiguration@@ -70,10 +71,10 @@ class TestConfiguration{$this->debugMsg('Now in generateAll()');// generate submissions- $array = $this->generateSubmissions();- $parameters = $this->parameters;- $ignored = $this->ignores;- $expected = $this->expected;+ $array = $this->generateSubmissions();+ $allParameters = $this->parameters;+ $ignored = $this->ignores;+ $expectedValue = $this->expected;$this->debugMsg(sprintf('Now validating %d ignored() values.', count($ignored)));@@ -111,9 +112,9 @@ class TestConfigurationforeach ($array as $index => $submission) {$final[] = [['submission' => $submission,- 'expected' => $expected[$index] ?? $submission,+ 'expected' => $expectedValue[$index] ?? $submission,'ignore' => $newIgnored[$index] ?? [],- 'parameters' => $parameters[$index] ?? [],+ 'parameters' => $allParameters[$index] ?? [],]];}@@ -205,7 +206,7 @@ class TestConfiguration$this->debugMsg(sprintf(' Set #%d will consist of:', $totalCount));// the custom set is born!$custom = [];- $expected = [];+ $expectedValue = [];foreach ($combinationSet as $combination) {$this->debugMsg(sprintf(' %s', $combination));// here we start adding stuff to a copy of the standard submission.@@ -217,7 +218,7 @@ class TestConfigurationforeach ($customSet->fields as $field) {$this->debugMsg(sprintf(' added field "%s" from custom set "%s"', $field->fieldTitle, $combination));$custom = $this->parseField($custom, $field);- $expected = $this->parseExpected($expected, $field, $custom);+ $expectedValue = $this->parseExpected($expectedValue, $field, $custom);// for each field, add the ignores to the current index (+1!) of// ignores.$count = count($this->submission);@@ -248,7 +249,7 @@ class TestConfiguration$this->debugMsg(sprintf(' New set of ignore things (%d) is: %s', $count, json_encode($this->ignores[$count])));}- $this->expected[$count] = $expected;+ $this->expected[$count] = $expectedValue;}$count = count($this->submission);$this->parameters[$count] = $customSet->parameters ?? [];@@ -341,12 +342,12 @@ class TestConfiguration{$ignore = [];$result = [];- $expected = [];+ $expectedValue = [];/** @var Field $field */foreach ($set->fields as $field) {// this is what we will submit:$result = $this->parseField($result, $field);- $expected = $this->parseExpected($expected, $field, $result);+ $expectedValue = $this->parseExpected($expectedValue, $field, $result);// this is what we will ignore:$newIgnore = array_unique($ignore + $field->ignorableFields);@@ -355,7 +356,7 @@ class TestConfiguration}$this->ignores[] = array_values($ignore);- $this->expected[] = $expected;+ $this->expected[] = $expectedValue;$this->parameters[] = $set->parameters ?? [];return $result;@@ -388,7 +389,7 @@ class TestConfigurationreturn $current;}- throw new RuntimeException(sprintf('Did not expect count %d from fieldTitle "%s".', $count, $field->fieldTitle));+ throw new UnexpectedValueException(sprintf('Did not expect count %d from fieldTitle "%s".', $count, $field->fieldTitle));}/**@@ -401,7 +402,7 @@ class TestConfiguration$faker = Factory::create();switch ($type) {default:- throw new RuntimeException(sprintf('Cannot handle field "%s"', $type));+ throw new UnexpectedValueException(sprintf('Cannot handle field "%s"', $type));case 'uuid':return $faker->uuid;case 'static-asset':@@ -604,7 +605,7 @@ class TestConfigurationreturn $expected;}- throw new RuntimeException(sprintf('Did not expect count %d from fieldTitle "%s".', $count, $field->fieldTitle));+ throw new UnexpectedValueException(sprintf('Did not expect count %d from fieldTitle "%s".', $count, $field->fieldTitle));}/**diff --git a/tests/Traits/TestHelpers.php b/tests/Traits/TestHelpers.phpindex 7f9c43755b..1dd5ffa5f8 100644--- a/tests/Traits/TestHelpers.php+++ b/tests/Traits/TestHelpers.php@@ -193,7 +193,6 @@ trait TestHelpers$url);$this->assertEquals($response[$key], $original[$key], $message);- continue;}}}