diff --git a/app/Api/V1/Controllers/TransactionController.php b/app/Api/V1/Controllers/TransactionController.php index e442947c13..ab6caed46c 100644 --- a/app/Api/V1/Controllers/TransactionController.php +++ b/app/Api/V1/Controllers/TransactionController.php @@ -218,7 +218,7 @@ class TransactionController extends Controller $collector->addFilter(PositiveAmountFilter::class); } if (!($transactionType === TransactionType::WITHDRAWAL)) { - $collector->addFilter(NegativeAmountFilter::class); + $collector->addFilter(NegativeAmountFilter::class); // @codeCoverageIgnore } $transactions = $collector->getTransactions(); diff --git a/app/Api/V1/Requests/AttachmentRequest.php b/app/Api/V1/Requests/AttachmentRequest.php index be29aa510c..65e4d38d93 100644 --- a/app/Api/V1/Requests/AttachmentRequest.php +++ b/app/Api/V1/Requests/AttachmentRequest.php @@ -69,10 +69,10 @@ class AttachmentRequest extends Request { $models = implode( ',', [ - Bill::class, - ImportJob::class, - TransactionJournal::class, - ImportJob::class, + str_replace('FireflyIII\\Models\\', '', Bill::class), + str_replace('FireflyIII\\Models\\', '', ImportJob::class), + str_replace('FireflyIII\\Models\\', '', TransactionJournal::class), + str_replace('FireflyIII\\Models\\', '', ImportJob::class), ] ); $model = $this->string('model'); diff --git a/app/Api/V1/Requests/TransactionRequest.php b/app/Api/V1/Requests/TransactionRequest.php index e8250ab262..373fb298c8 100644 --- a/app/Api/V1/Requests/TransactionRequest.php +++ b/app/Api/V1/Requests/TransactionRequest.php @@ -66,6 +66,15 @@ class TransactionRequest extends Request 'bill_id' => $this->integer('bill_id'), 'bill_name' => $this->string('bill_name'), 'tags' => explode(',', $this->string('tags')), + 'notes' => $this->string('notes'), + 'sepa-cc' => $this->string('sepa_cc'), + 'sepa-ct-op' => $this->string('sepa_ct_op'), + 'sepa-ct-id' => $this->string('sepa_ct_id'), + 'sepa-db' => $this->string('sepa_db'), + 'sepa-country' => $this->string('sepa_country'), + 'sepa-ep' => $this->string('sepa_ep'), + 'sepa-ci' => $this->string('sepa_ci'), + 'sepa-batch-id' => $this->string('sepa_batch_id'), 'interest_date' => $this->date('interest_date'), 'book_date' => $this->date('book_date'), 'process_date' => $this->date('process_date'), @@ -73,22 +82,10 @@ class TransactionRequest extends Request 'payment_date' => $this->date('payment_date'), 'invoice_date' => $this->date('invoice_date'), 'internal_reference' => $this->string('internal_reference'), - 'notes' => $this->string('notes'), - 'original-source' => sprintf('ff3-v%s|api-v%s', config('firefly.version'), config('firefly.api_version')), - 'transactions' => $this->getTransactionData(), - - // SEPA fields: - 'sepa-cc' => $this->string('sepa_cc'), - 'sepa-ct-op' => $this->string('sepa_ct_op'), - 'sepa-db' => $this->string('sepa_db'), - 'sepa-country' => $this->string('sepa_country'), - 'sepa-ep' => $this->string('sepa_ep'), - 'sepa-ci' => $this->string('sepa_ci'), - 'sepa-batch-id' => $this->string('sepa_batch_id'), - - // others: 'bunq_payment_id' => $this->string('bunq_payment_id'), 'external_id' => $this->string('external_id'), + 'original-source' => sprintf('ff3-v%s|api-v%s', config('firefly.version'), config('firefly.api_version')), + 'transactions' => $this->getTransactionData(), ]; return $data; @@ -104,7 +101,7 @@ class TransactionRequest extends Request { $rules = [ // basic fields for journal: - 'type' => 'required|in:withdrawal,deposit,transfer', + 'type' => 'required|in:withdrawal,deposit,transfer,opening-balance,reconciliation', 'description' => 'between:1,255', 'date' => 'required|date', 'piggy_bank_id' => ['numeric', 'nullable', 'mustExist:piggy_banks,id', new BelongsUser], @@ -114,15 +111,6 @@ class TransactionRequest extends Request 'tags' => 'between:1,255', // then, custom fields for journal - 'interest_date' => 'date|nullable', - 'book_date' => 'date|nullable', - 'process_date' => 'date|nullable', - 'due_date' => 'date|nullable', - 'payment_date' => 'date|nullable', - 'invoice_date' => 'date|nullable', - 'internal_reference' => 'min:1,max:255|nullable', - 'bunq_payment_id' => 'min:1,max:255|nullable', - 'external_id' => 'min:1,max:255|nullable', 'notes' => 'min:1,max:50000|nullable', // SEPA fields: @@ -135,6 +123,17 @@ class TransactionRequest extends Request 'sepa_ci' => 'min:1,max:255|nullable', 'sepa_batch_id' => 'min:1,max:255|nullable', + // dates + 'interest_date' => 'date|nullable', + 'book_date' => 'date|nullable', + 'process_date' => 'date|nullable', + 'due_date' => 'date|nullable', + 'payment_date' => 'date|nullable', + 'invoice_date' => 'date|nullable', + 'internal_reference' => 'min:1,max:255|nullable', + 'bunq_payment_id' => 'min:1,max:255|nullable', + 'external_id' => 'min:1,max:255|nullable', + // transaction rules (in array for splits): 'transactions.*.amount' => 'required|numeric|more:0', 'transactions.*.description' => 'nullable|between:1,255', diff --git a/app/Http/Requests/RuleGroupFormRequest.php b/app/Http/Requests/RuleGroupFormRequest.php index 671607eabb..66531a33e6 100644 --- a/app/Http/Requests/RuleGroupFormRequest.php +++ b/app/Http/Requests/RuleGroupFormRequest.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Requests; use FireflyIII\Models\RuleGroup; +use FireflyIII\Rules\IsBoolean; /** * Class RuleGroupFormRequest. @@ -47,9 +48,15 @@ class RuleGroupFormRequest extends Request */ public function getRuleGroupData(): array { + $active = true; + if (null !== $this->get('active')) { + $active = $this->boolean('active'); + } + return [ 'title' => $this->string('title'), 'description' => $this->string('description'), + 'active' => $active, ]; } @@ -72,6 +79,7 @@ class RuleGroupFormRequest extends Request return [ 'title' => $titleRule, 'description' => 'between:1,5000|nullable', + 'active' => [new IsBoolean], ]; } } diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.php index 263bd2c3a7..46ac34376c 100644 --- a/app/Repositories/Rule/RuleRepository.php +++ b/app/Repositories/Rule/RuleRepository.php @@ -424,7 +424,7 @@ class RuleRepository implements RuleRepositoryInterface $stopProcessing = $action['stop_processing'] ?? false; $actionValues = [ - 'action' => $action['name'], + 'action' => $action['type'], 'value' => $value, 'stop_processing' => $stopProcessing, 'order' => $order, @@ -460,7 +460,7 @@ class RuleRepository implements RuleRepositoryInterface $stopProcessing = $trigger['stop_processing'] ?? false; $triggerValues = [ - 'action' => $trigger['name'], + 'action' => $trigger['type'], 'value' => $value, 'stop_processing' => $stopProcessing, 'order' => $order, diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.php index 33fcdce409..f92b3e2432 100644 --- a/app/Support/Http/Controllers/RequestInformation.php +++ b/app/Support/Http/Controllers/RequestInformation.php @@ -268,7 +268,7 @@ trait RequestInformation if (\is_array($data)) { foreach ($data as $index => $triggerInfo) { $triggers[] = [ - 'type' => $triggerInfo['name'] ?? '', + 'type' => $triggerInfo['type'] ?? '', 'value' => $triggerInfo['value'] ?? '', 'stop_processing' => 1 === (int)($triggerInfo['stop_processing'] ?? '0'), ]; diff --git a/app/Support/Http/Controllers/RuleManagement.php b/app/Support/Http/Controllers/RuleManagement.php index 66d832dd46..60851e30b3 100644 --- a/app/Support/Http/Controllers/RuleManagement.php +++ b/app/Support/Http/Controllers/RuleManagement.php @@ -54,13 +54,13 @@ trait RuleManagement 'active' => true, 'triggers' => [ [ - 'name' => 'description_is', + 'type' => 'description_is', 'value' => (string)trans('firefly.default_rule_trigger_description'), 'stop_processing' => false, ], [ - 'name' => 'from_account_is', + 'type' => 'from_account_is', 'value' => (string)trans('firefly.default_rule_trigger_from_account'), 'stop_processing' => false, @@ -69,12 +69,12 @@ trait RuleManagement ], 'actions' => [ [ - 'name' => 'prepend_description', + 'type' => 'prepend_description', 'value' => (string)trans('firefly.default_rule_action_prepend'), 'stop_processing' => false, ], [ - 'name' => 'set_category', + 'type' => 'set_category', 'value' => (string)trans('firefly.default_rule_action_set_category'), 'stop_processing' => false, ], @@ -102,7 +102,7 @@ trait RuleManagement $triggers[] = view( 'rules.partials.action', [ - 'oldAction' => $oldAction['name'], + 'oldAction' => $oldAction['type'], 'oldValue' => $oldAction['value'], 'oldChecked' => 1 === (int)($oldAction['stop_processing'] ?? '0'), 'count' => $index + 1, @@ -135,7 +135,7 @@ trait RuleManagement $triggers[] = view( 'rules.partials.trigger', [ - 'oldTrigger' => $oldTrigger['name'], + 'oldTrigger' => $oldTrigger['type'], 'oldValue' => $oldTrigger['value'], 'oldChecked' => 1 === (int)($oldTrigger['stop_processing'] ?? '0'), 'count' => $index + 1, diff --git a/public/v1/js/ff/rules/create-edit.js b/public/v1/js/ff/rules/create-edit.js index e3cc1308ad..8bdd9f9588 100644 --- a/public/v1/js/ff/rules/create-edit.js +++ b/public/v1/js/ff/rules/create-edit.js @@ -162,7 +162,7 @@ function onAddNewAction() { "use strict"; console.log('Now in onAddNewAction()'); - var selectQuery = 'select[name^="actions["][name$="][name]"]'; + var selectQuery = 'select[name^="actions["][name$="][type]"]'; var selectResult = $(selectQuery); console.log('Select query is "' + selectQuery + '" and the result length is ' + selectResult.length); @@ -190,7 +190,7 @@ function onAddNewTrigger() { "use strict"; console.log('Now in onAddNewTrigger()'); - var selectQuery = 'select[name^="triggers["][name$="][name]"]'; + var selectQuery = 'select[name^="triggers["][name$="][type]"]'; var selectResult = $(selectQuery); console.log('Select query is "' + selectQuery + '" and the result length is ' + selectResult.length); diff --git a/resources/views/v1/rules/partials/action.twig b/resources/views/v1/rules/partials/action.twig index 78864f7c8c..d9419ab082 100644 --- a/resources/views/v1/rules/partials/action.twig +++ b/resources/views/v1/rules/partials/action.twig @@ -4,9 +4,9 @@ {# todo error when invalid name. #} - + {% for key,type in allRuleActions() %} + {% endfor %} diff --git a/resources/views/v1/rules/partials/trigger.twig b/resources/views/v1/rules/partials/trigger.twig index ce86d398ef..1d2e4e46f4 100644 --- a/resources/views/v1/rules/partials/trigger.twig +++ b/resources/views/v1/rules/partials/trigger.twig @@ -3,13 +3,13 @@ -