mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-24 22:48:18 +00:00
Make sure rules work.
This commit is contained in:
@@ -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();
|
||||
|
@@ -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');
|
||||
|
@@ -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',
|
||||
|
@@ -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],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -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,
|
||||
|
@@ -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'),
|
||||
];
|
||||
|
@@ -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,
|
||||
|
4
public/v1/js/ff/rules/create-edit.js
vendored
4
public/v1/js/ff/rules/create-edit.js
vendored
@@ -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);
|
||||
|
@@ -4,9 +4,9 @@
|
||||
</td>
|
||||
<td style="width:30%;">
|
||||
{# todo error when invalid name. #}
|
||||
<select name="actions[{{ count }}][name]" class="form-control">
|
||||
{% for key,name in allRuleActions() %}
|
||||
<option value="{{ key }}" label="{{ name }}" {% if key == oldAction %} selected{% endif %}>{{ name }}</option>
|
||||
<select name="actions[{{ count }}][type]" class="form-control">
|
||||
{% for key,type in allRuleActions() %}
|
||||
<option value="{{ key }}" label="{{ type }}" {% if key == oldAction %} selected{% endif %}>{{ type }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
|
@@ -3,13 +3,13 @@
|
||||
<a href="#" class="btn btn-danger btn-sm remove-trigger"><i class="fa fa-trash"></i></a>
|
||||
</td>
|
||||
<td style="width:30%;">
|
||||
<select name="triggers[{{ count }}][name]" class="form-control">
|
||||
{% for key,name in allRuleTriggers() %}
|
||||
<option value="{{ key }}" label="{{ name }}"
|
||||
<select name="triggers[{{ count }}][type]" class="form-control">
|
||||
{% for key,type in allRuleTriggers() %}
|
||||
<option value="{{ key }}" label="{{ type }}"
|
||||
{% if key == oldTrigger %}
|
||||
selected
|
||||
{% endif %}
|
||||
>{{ name }}</option>
|
||||
>{{ type }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
|
Reference in New Issue
Block a user