Update request data to match API definition.

This commit is contained in:
James Cole
2018-12-14 18:33:07 +01:00
parent 2a30293905
commit 4bd94e5450
14 changed files with 102 additions and 99 deletions

View File

@@ -23,7 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers; namespace FireflyIII\Api\V1\Controllers;
use FireflyIII\Api\V1\Requests\JournalLinkRequest; use FireflyIII\Api\V1\Requests\TransactionLinkRequest;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\TransactionJournalLink; use FireflyIII\Models\TransactionJournalLink;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
@@ -148,12 +148,12 @@ class TransactionLinkController extends Controller
/** /**
* Store new object. * Store new object.
* *
* @param JournalLinkRequest $request * @param TransactionLinkRequest $request
* *
* @return JsonResponse * @return JsonResponse
* @throws FireflyException * @throws FireflyException
*/ */
public function store(JournalLinkRequest $request): JsonResponse public function store(TransactionLinkRequest $request): JsonResponse
{ {
$manager = new Manager; $manager = new Manager;
$data = $request->getAll(); $data = $request->getAll();
@@ -174,13 +174,13 @@ class TransactionLinkController extends Controller
/** /**
* Update object. * Update object.
* *
* @param JournalLinkRequest $request * @param TransactionLinkRequest $request
* @param TransactionJournalLink $journalLink * @param TransactionJournalLink $journalLink
* *
* @return JsonResponse * @return JsonResponse
* @throws FireflyException * @throws FireflyException
*/ */
public function update(JournalLinkRequest $request, TransactionJournalLink $journalLink): JsonResponse public function update(TransactionLinkRequest $request, TransactionJournalLink $journalLink): JsonResponse
{ {
$manager = new Manager; $manager = new Manager;
$data = $request->getAll(); $data = $request->getAll();

View File

@@ -23,6 +23,9 @@
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests; namespace FireflyIII\Api\V1\Requests;
use FireflyIII\Rules\IsBoolean;
/** /**
* Class AccountRequest * Class AccountRequest
*/ */
@@ -69,12 +72,7 @@ class AccountRequest extends Request
'interest' => $this->string('interest'), 'interest' => $this->string('interest'),
'interest_period' => $this->string('interest_period'), 'interest_period' => $this->string('interest_period'),
]; ];
// new fields for liabilities
// 'liability_type' => $this->string('liability_type'),
// 'liability_start_date' => $this->date('liability_start_date'),
//];
if ('liability' === $data['accountType']) { if ('liability' === $data['accountType']) {
$data['openingBalance'] = bcmul($this->string('liability_amount'), '-1'); $data['openingBalance'] = bcmul($this->string('liability_amount'), '-1');
$data['openingBalanceDate'] = $this->date('liability_start_date'); $data['openingBalanceDate'] = $this->date('liability_start_date');
@@ -96,35 +94,27 @@ class AccountRequest extends Request
$types = implode(',', array_keys(config('firefly.subTitlesByIdentifier'))); $types = implode(',', array_keys(config('firefly.subTitlesByIdentifier')));
$ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes'))); $ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes')));
$rules = [ $rules = [
'name' => 'required|min:1|uniqueAccountForUser', 'name' => 'required|min:1|uniqueAccountForUser',
'type' => 'required|in:' . $types, 'type' => 'required|in:' . $types,
'active' => 'required|boolean', 'iban' => 'iban|nullable',
'account_role' => 'in:' . $accountRoles . '|required_if:type,asset', 'bic' => 'bic|nullable',
'currency_id' => 'numeric|exists:transaction_currencies,id|required_without:currency_code', 'account_number' => 'between:1,255|nullable|uniqueAccountNumberForUser',
'currency_code' => 'min:3|max:3|exists:transaction_currencies,code|required_without:currency_id', 'opening_balance' => 'numeric|required_with:opening_balance_date|nullable',
'notes' => 'min:0|max:65536', 'opening_balance_date' => 'date|required_with:opening_balance|nullable',
'monthly_payment_date' => 'date' . '|required_if:account_role,ccAsset|required_if:cc_type,monthlyFull', 'virtual_balance' => 'numeric|nullable',
'credit_card_type' => 'in:' . $ccPaymentTypes . '|required_if:account_role,ccAsset', 'currency_id' => 'numeric|exists:transaction_currencies,id',
'account_number' => 'between:1,255|nullable|uniqueAccountNumberForUser', 'currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
'iban' => 'iban|nullable', 'active' => [new IsBoolean],
'bic' => 'bic|nullable', 'include_net_worth' => [new IsBoolean],
'virtual_balance' => 'numeric|nullable', 'account_role' => 'in:' . $accountRoles . '|required_if:type,asset',
'opening_balance' => 'numeric|required_with:opening_balance_date|nullable', 'cc_type' => 'in:' . $ccPaymentTypes . '|required_if:account_role,ccAsset',
'opening_balance_date' => 'date|required_with:opening_balance|nullable', 'cc_monthly_payment_date' => 'date' . '|required_if:account_role,ccAsset|required_if:cc_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',
'include_net_worth' => 'required|boolean', 'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly',
'notes' => 'min:0|max:65536',
// required fields for liabilities:
'liability_type' => 'required_if:type,liability|in:loan,debt,mortgage,credit card',
'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',
]; ];
switch ($this->method()) { switch ($this->method()) {
default: default:

View File

@@ -72,6 +72,7 @@ class AttachmentRequest extends Request
Bill::class, Bill::class,
ImportJob::class, ImportJob::class,
TransactionJournal::class, TransactionJournal::class,
ImportJob::class,
] ]
); );
$model = $this->string('model'); $model = $this->string('model');

View File

@@ -50,8 +50,8 @@ class AvailableBudgetRequest extends Request
'currency_id' => $this->integer('currency_id'), 'currency_id' => $this->integer('currency_id'),
'currency_code' => $this->string('currency_code'), 'currency_code' => $this->string('currency_code'),
'amount' => $this->string('amount'), 'amount' => $this->string('amount'),
'start_date' => $this->date('start_date'), 'start' => $this->date('start'),
'end_date' => $this->date('end_date'), 'end' => $this->date('end'),
]; ];
} }
@@ -63,11 +63,11 @@ class AvailableBudgetRequest extends Request
public function rules(): array public function rules(): array
{ {
$rules = [ $rules = [
'currency_id' => 'numeric|exists:transaction_currencies,id|required_without:currency_code', 'currency_id' => 'numeric|exists:transaction_currencies,id',
'currency_code' => 'min:3|max:3|exists:transaction_currencies,code|required_without:currency_id', 'currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
'amount' => 'required|numeric|more:0', 'amount' => 'required|numeric|more:0',
'start_date' => 'required|date|before:end_date', 'start' => 'required|date|before:end',
'end_date' => 'required|date|after:start_date', 'end' => 'required|date|after:start',
]; ];
return $rules; return $rules;

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests; namespace FireflyIII\Api\V1\Requests;
use FireflyIII\Rules\IsBoolean;
use Illuminate\Validation\Validator; use Illuminate\Validation\Validator;
/** /**
@@ -78,13 +79,13 @@ class BillRequest extends Request
'name' => 'required|between:1,255|uniqueObjectForUser:bills,name', 'name' => 'required|between:1,255|uniqueObjectForUser:bills,name',
'amount_min' => 'required|numeric|more:0', 'amount_min' => 'required|numeric|more:0',
'amount_max' => 'required|numeric|more:0', 'amount_max' => 'required|numeric|more:0',
'currency_id' => 'numeric|exists:transaction_currencies,id|required_without:currency_code', 'currency_id' => 'numeric|exists:transaction_currencies,id',
'currency_code' => 'min:3|max:3|exists:transaction_currencies,code|required_without:currency_id', 'currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
'date' => 'required|date', 'date' => 'required|date',
'repeat_freq' => 'required|in:weekly,monthly,quarterly,half-year,yearly', 'repeat_freq' => 'required|in:weekly,monthly,quarterly,half-year,yearly',
'skip' => 'required|between:0,31', 'skip' => 'between:0,31',
'automatch' => 'required|boolean', 'automatch' => [new IsBoolean],
'active' => 'required|boolean', 'active' => [new IsBoolean],
'notes' => 'between:1,65536', 'notes' => 'between:1,65536',
]; ];
switch ($this->method()) { switch ($this->method()) {

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests; namespace FireflyIII\Api\V1\Requests;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Rules\IsBoolean;
/** /**
* Class BudgetRequest * Class BudgetRequest
@@ -64,7 +65,7 @@ class BudgetRequest extends Request
{ {
$rules = [ $rules = [
'name' => 'required|between:1,100|uniqueObjectForUser:budgets,name', 'name' => 'required|between:1,100|uniqueObjectForUser:budgets,name',
'active' => 'required|boolean', 'active' => [new IsBoolean],
]; ];
switch ($this->method()) { switch ($this->method()) {
default: default:

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests; namespace FireflyIII\Api\V1\Requests;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Rules\IsBoolean;
/** /**
* Class CategoryRequest * Class CategoryRequest
@@ -49,8 +50,7 @@ class CategoryRequest extends Request
public function getAll(): array public function getAll(): array
{ {
return [ return [
'name' => $this->string('name'), 'name' => $this->string('name')
'active' => $this->boolean('active'),
]; ];
} }
@@ -62,8 +62,7 @@ class CategoryRequest extends Request
public function rules(): array public function rules(): array
{ {
$rules = [ $rules = [
'name' => 'required|between:1,100|uniqueObjectForUser:categories,name', 'name' => 'required|between:1,100|uniqueObjectForUser:categories,name'
'active' => 'required|boolean',
]; ];
switch ($this->method()) { switch ($this->method()) {
default: default:

View File

@@ -79,7 +79,7 @@ class CurrencyRequest extends Request
'name' => 'required|between:1,255|unique:transaction_currencies,name', 'name' => 'required|between:1,255|unique:transaction_currencies,name',
'code' => 'required|between:3,3|unique:transaction_currencies,code', 'code' => 'required|between:3,3|unique:transaction_currencies,code',
'symbol' => 'required|between:1,5|unique:transaction_currencies,symbol', 'symbol' => 'required|between:1,5|unique:transaction_currencies,symbol',
'decimal_places' => 'required|between:0,20|numeric|min:0|max:20', 'decimal_places' => 'between:0,20|numeric|min:0|max:20',
'enabled' => [new IsBoolean()], 'enabled' => [new IsBoolean()],
'default' => [new IsBoolean()], 'default' => [new IsBoolean()],

View File

@@ -58,8 +58,8 @@ class PiggyBankRequest extends Request
'account_id' => $this->integer('account_id'), 'account_id' => $this->integer('account_id'),
'targetamount' => $this->string('target_amount'), 'targetamount' => $this->string('target_amount'),
'current_amount' => $current, 'current_amount' => $current,
'startdate' => $this->date('start_date'), 'startdate' => $this->date('start_date'),
'targetdate' => $this->date('target_date'), 'targetdate' => $this->date('target_date'),
'notes' => $this->string('notes'), 'notes' => $this->string('notes'),
]; ];
} }

View File

@@ -96,23 +96,25 @@ class RecurrenceRequest extends Request
$today = Carbon::now()->addDay(); $today = Carbon::now()->addDay();
return [ return [
'type' => 'required|in:withdrawal,transfer,deposit', 'type' => 'required|in:Withdrawal,Transfer,Deposit',
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title', 'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',
'description' => 'between:1,65000', 'description' => 'between:1,65000',
'first_date' => sprintf('required|date|after:%s', $today->format('Y-m-d')), 'first_date' => sprintf('required|date|after:%s', $today->format('Y-m-d')),
'repeat_until' => sprintf('date|after:%s', $today->format('Y-m-d')),
'nr_of_repetitions' => 'numeric|between:1,31',
'apply_rules' => [new IsBoolean], 'apply_rules' => [new IsBoolean],
'active' => [new IsBoolean], 'active' => [new IsBoolean],
'repeat_until' => sprintf('date|after:%s', $today->format('Y-m-d')),
'nr_of_repetitions' => 'numeric|between:1,31',
'tags' => 'between:1,64000', 'tags' => 'between:1,64000',
'piggy_bank_id' => 'numeric', 'piggy_bank_id' => 'numeric',
'repetitions.*.type' => 'required|in:daily,weekly,ndom,monthly,yearly', 'repetitions.*.type' => 'required|in:daily,weekly,ndom,monthly,yearly',
'repetitions.*.moment' => 'between:0,10', 'repetitions.*.moment' => 'between:0,10',
'repetitions.*.skip' => 'required|numeric|between:0,31', 'repetitions.*.skip' => 'required|numeric|between:0,31',
'repetitions.*.weekend' => 'required|numeric|min:1|max:4', 'repetitions.*.weekend' => 'required|numeric|min:1|max:4',
'transactions.*.currency_id' => 'numeric|exists:transaction_currencies,id|required_without:transactions.*.currency_code', 'transactions.*.description' => 'required|between:1,255',
'transactions.*.currency_code' => 'min:3|max:3|exists:transaction_currencies,code|required_without:transactions.*.currency_id', 'transactions.*.amount' => 'required|numeric|more:0',
'transactions.*.foreign_amount' => 'numeric|more:0', 'transactions.*.foreign_amount' => 'numeric|more:0',
'transactions.*.currency_id' => 'numeric|exists:transaction_currencies,id',
'transactions.*.currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
'transactions.*.foreign_currency_id' => 'numeric|exists:transaction_currencies,id', 'transactions.*.foreign_currency_id' => 'numeric|exists:transaction_currencies,id',
'transactions.*.foreign_currency_code' => 'min:3|max:3|exists:transaction_currencies,code', 'transactions.*.foreign_currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
'transactions.*.budget_id' => ['mustExist:budgets,id', new BelongsUser], 'transactions.*.budget_id' => ['mustExist:budgets,id', new BelongsUser],
@@ -121,8 +123,8 @@ class RecurrenceRequest extends Request
'transactions.*.source_name' => 'between:1,255|nullable', 'transactions.*.source_name' => 'between:1,255|nullable',
'transactions.*.destination_id' => ['numeric', 'nullable', new BelongsUser], 'transactions.*.destination_id' => ['numeric', 'nullable', new BelongsUser],
'transactions.*.destination_name' => 'between:1,255|nullable', 'transactions.*.destination_name' => 'between:1,255|nullable',
'transactions.*.amount' => 'required|numeric|more:0',
'transactions.*.description' => 'required|between:1,255',
]; ];
} }

View File

@@ -95,20 +95,25 @@ class RuleRequest extends Request
$rules = [ $rules = [
'title' => 'required|between:1,100|uniqueObjectForUser:rules,title', 'title' => 'required|between:1,100|uniqueObjectForUser:rules,title',
'description' => 'between:1,5000|nullable', 'description' => 'between:1,5000|nullable',
'rule_group_id' => 'required|belongsToUser:rule_groups|required_without:rule_group_title', 'rule_group_id' => 'required|belongsToUser:rule_groups|required_without:rule_group_title',
'rule_group_title' => 'nullable|between:1,255|required_without:rule_group_id|belongsToUser:rule_groups,title', 'rule_group_title' => 'nullable|between:1,255|required_without:rule_group_id|belongsToUser:rule_groups,title',
'trigger' => 'required|in:store-journal,update-journal', 'trigger' => 'required|in:store-journal,update-journal',
'triggers.*.name' => 'required|in:' . implode(',', $validTriggers),
'triggers.*.stop_processing' => [new IsBoolean], 'triggers.*.type' => 'required|in:' . implode(',', $validTriggers),
'triggers.*.value' => 'required_if:actions.*.type,' . $contextTriggers . '|min:1|ruleTriggerValue', 'triggers.*.value' => 'required_if:actions.*.type,' . $contextTriggers . '|min:1|ruleTriggerValue',
'actions.*.name' => 'required|in:' . implode(',', $validActions), 'triggers.*.stop_processing' => [new IsBoolean],
'actions.*.value' => 'required_if:actions.*.type,' . $contextActions . '|ruleActionValue', 'triggers.*.active' => [new IsBoolean],
'actions.*.stop_processing' => [new IsBoolean],
'strict' => [new IsBoolean], 'actions.*.type' => 'required|in:' . implode(',', $validActions),
'stop_processing' => [new IsBoolean], 'actions.*.value' => 'required_if:actions.*.type,' . $contextActions . '|ruleActionValue',
'active' => [new IsBoolean], 'actions.*.stop_processing' => [new IsBoolean],
'actions.*.active' => [new IsBoolean],
'strict' => [new IsBoolean],
'stop_processing' => [new IsBoolean],
'active' => [new IsBoolean],
]; ];
return $rules; return $rules;
@@ -171,8 +176,9 @@ class RuleRequest extends Request
if (\is_array($actions)) { if (\is_array($actions)) {
foreach ($actions as $action) { foreach ($actions as $action) {
$return[] = [ $return[] = [
'name' => $action['name'], 'type' => $action['type'],
'value' => $action['value'], 'value' => $action['value'],
'active' => $this->convertBoolean((string)($action['active'] ?? 'false')),
'stop_processing' => $this->convertBoolean((string)($action['stop_processing'] ?? 'false')), 'stop_processing' => $this->convertBoolean((string)($action['stop_processing'] ?? 'false')),
]; ];
} }
@@ -191,8 +197,9 @@ class RuleRequest extends Request
if (\is_array($triggers)) { if (\is_array($triggers)) {
foreach ($triggers as $trigger) { foreach ($triggers as $trigger) {
$return[] = [ $return[] = [
'name' => $trigger['name'], 'type' => $trigger['type'],
'value' => $trigger['value'], 'value' => $trigger['value'],
'active' => $this->convertBoolean((string)($trigger['active'] ?? 'false')),
'stop_processing' => $this->convertBoolean((string)($trigger['stop_processing'] ?? 'false')), 'stop_processing' => $this->convertBoolean((string)($trigger['stop_processing'] ?? 'false')),
]; ];
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
/** /**
* JournalLinkRequest.php * TransactionLinkRequest.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
* *
* This file is part of Firefly III. * This file is part of Firefly III.
@@ -29,9 +29,9 @@ use Illuminate\Validation\Validator;
/** /**
* *
* Class JournalLinkRequest * Class TransactionLinkRequest
*/ */
class JournalLinkRequest extends Request class TransactionLinkRequest extends Request
{ {
/** /**
* Authorize logged in users. * Authorize logged in users.

View File

@@ -74,7 +74,7 @@ class TransactionRequest extends Request
'invoice_date' => $this->date('invoice_date'), 'invoice_date' => $this->date('invoice_date'),
'internal_reference' => $this->string('internal_reference'), 'internal_reference' => $this->string('internal_reference'),
'notes' => $this->string('notes'), 'notes' => $this->string('notes'),
'original-source' => sprintf('ff3-v%s|api-v%s', config('firefly.version'),config('firefly.api_version')), 'original-source' => sprintf('ff3-v%s|api-v%s', config('firefly.version'), config('firefly.api_version')),
'transactions' => $this->getTransactionData(), 'transactions' => $this->getTransactionData(),
// SEPA fields: // SEPA fields:
@@ -105,8 +105,8 @@ class TransactionRequest extends Request
$rules = [ $rules = [
// basic fields for journal: // basic fields for journal:
'type' => 'required|in:withdrawal,deposit,transfer', 'type' => 'required|in:withdrawal,deposit,transfer',
'date' => 'required|date',
'description' => 'between:1,255', 'description' => 'between:1,255',
'date' => 'required|date',
'piggy_bank_id' => ['numeric', 'nullable', 'mustExist:piggy_banks,id', new BelongsUser], 'piggy_bank_id' => ['numeric', 'nullable', 'mustExist:piggy_banks,id', new BelongsUser],
'piggy_bank_name' => ['between:1,255', 'nullable', new BelongsUser], 'piggy_bank_name' => ['between:1,255', 'nullable', new BelongsUser],
'bill_id' => ['numeric', 'nullable', 'mustExist:bills,id', new BelongsUser], 'bill_id' => ['numeric', 'nullable', 'mustExist:bills,id', new BelongsUser],
@@ -121,11 +121,14 @@ class TransactionRequest extends Request
'payment_date' => 'date|nullable', 'payment_date' => 'date|nullable',
'invoice_date' => 'date|nullable', 'invoice_date' => 'date|nullable',
'internal_reference' => 'min:1,max:255|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', 'notes' => 'min:1,max:50000|nullable',
// SEPA fields: // SEPA fields:
'sepa_cc' => 'min:1,max:255|nullable', 'sepa_cc' => 'min:1,max:255|nullable',
'sepa_ct_op' => 'min:1,max:255|nullable', 'sepa_ct_op' => 'min:1,max:255|nullable',
'sepa_ct_id' => 'min:1,max:255|nullable',
'sepa_db' => 'min:1,max:255|nullable', 'sepa_db' => 'min:1,max:255|nullable',
'sepa_country' => 'min:1,max:255|nullable', 'sepa_country' => 'min:1,max:255|nullable',
'sepa_ep' => 'min:1,max:255|nullable', 'sepa_ep' => 'min:1,max:255|nullable',
@@ -133,8 +136,8 @@ class TransactionRequest extends Request
'sepa_batch_id' => 'min:1,max:255|nullable', 'sepa_batch_id' => 'min:1,max:255|nullable',
// transaction rules (in array for splits): // transaction rules (in array for splits):
'transactions.*.description' => 'nullable|between:1,255',
'transactions.*.amount' => 'required|numeric|more:0', 'transactions.*.amount' => 'required|numeric|more:0',
'transactions.*.description' => 'nullable|between:1,255',
'transactions.*.currency_id' => 'numeric|exists:transaction_currencies,id', 'transactions.*.currency_id' => 'numeric|exists:transaction_currencies,id',
'transactions.*.currency_code' => 'min:3|max:3|exists:transaction_currencies,code', 'transactions.*.currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
'transactions.*.foreign_amount' => 'numeric|more:0', 'transactions.*.foreign_amount' => 'numeric|more:0',
@@ -145,7 +148,6 @@ class TransactionRequest extends Request
'transactions.*.category_id' => ['mustExist:categories,id', new BelongsUser], 'transactions.*.category_id' => ['mustExist:categories,id', new BelongsUser],
'transactions.*.category_name' => 'between:1,255|nullable', 'transactions.*.category_name' => 'between:1,255|nullable',
'transactions.*.reconciled' => [new IsBoolean], 'transactions.*.reconciled' => [new IsBoolean],
// basic rules will be expanded later.
'transactions.*.source_id' => ['numeric', 'nullable', new BelongsUser], 'transactions.*.source_id' => ['numeric', 'nullable', new BelongsUser],
'transactions.*.source_name' => 'between:1,255|nullable', 'transactions.*.source_name' => 'between:1,255|nullable',
'transactions.*.destination_id' => ['numeric', 'nullable', new BelongsUser], 'transactions.*.destination_id' => ['numeric', 'nullable', new BelongsUser],
@@ -195,8 +197,8 @@ class TransactionRequest extends Request
$return = []; $return = [];
foreach ($this->get('transactions') as $index => $transaction) { foreach ($this->get('transactions') as $index => $transaction) {
$return[] = [ $return[] = [
'description' => $transaction['description'] ?? null,
'amount' => $transaction['amount'], 'amount' => $transaction['amount'],
'description' => $transaction['description'] ?? null,
'currency_id' => isset($transaction['currency_id']) ? (int)$transaction['currency_id'] : null, 'currency_id' => isset($transaction['currency_id']) ? (int)$transaction['currency_id'] : null,
'currency_code' => $transaction['currency_code'] ?? null, 'currency_code' => $transaction['currency_code'] ?? null,
'foreign_amount' => $transaction['foreign_amount'] ?? null, 'foreign_amount' => $transaction['foreign_amount'] ?? null,

View File

@@ -142,7 +142,7 @@ class TransactionLinkControllerTest extends TestCase
/** /**
* @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest * @covers \FireflyIII\Api\V1\Requests\TransactionLinkRequest
*/ */
public function testStore(): void public function testStore(): void
{ {
@@ -193,7 +193,7 @@ class TransactionLinkControllerTest extends TestCase
* In this particular test the journal link request will fail. * In this particular test the journal link request will fail.
* *
* @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest * @covers \FireflyIII\Api\V1\Requests\TransactionLinkRequest
*/ */
public function testStoreExistingLink(): void public function testStoreExistingLink(): void
{ {
@@ -242,10 +242,10 @@ class TransactionLinkControllerTest extends TestCase
} }
/** /**
* In this particular test the JournalLinkRequest will report the failure. * In this particular test the TransactionLinkRequest will report the failure.
* *
* @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest * @covers \FireflyIII\Api\V1\Requests\TransactionLinkRequest
*/ */
public function testStoreInvalidInward(): void public function testStoreInvalidInward(): void
{ {
@@ -292,10 +292,10 @@ class TransactionLinkControllerTest extends TestCase
} }
/** /**
* In this particular test the JournalLinkRequest will report the failure. * In this particular test the TransactionLinkRequest will report the failure.
* *
* @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest * @covers \FireflyIII\Api\V1\Requests\TransactionLinkRequest
*/ */
public function testStoreInvalidOutward(): void public function testStoreInvalidOutward(): void
{ {
@@ -343,7 +343,7 @@ class TransactionLinkControllerTest extends TestCase
/** /**
* @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest * @covers \FireflyIII\Api\V1\Requests\TransactionLinkRequest
*/ */
public function testStoreNoJournal(): void public function testStoreNoJournal(): void
{ {
@@ -392,7 +392,7 @@ class TransactionLinkControllerTest extends TestCase
/** /**
* @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest * @covers \FireflyIII\Api\V1\Requests\TransactionLinkRequest
*/ */
public function testStoreWithNull(): void public function testStoreWithNull(): void
{ {
@@ -439,7 +439,7 @@ class TransactionLinkControllerTest extends TestCase
/** /**
* @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest * @covers \FireflyIII\Api\V1\Requests\TransactionLinkRequest
*/ */
public function testUpdate(): void public function testUpdate(): void
{ {
@@ -489,7 +489,7 @@ class TransactionLinkControllerTest extends TestCase
/** /**
* @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest * @covers \FireflyIII\Api\V1\Requests\TransactionLinkRequest
*/ */
public function testUpdateNoJournal(): void public function testUpdateNoJournal(): void
{ {
@@ -539,7 +539,7 @@ class TransactionLinkControllerTest extends TestCase
/** /**
* @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest * @covers \FireflyIII\Api\V1\Requests\TransactionLinkRequest
*/ */
public function testUpdateWithNull(): void public function testUpdateWithNull(): void
{ {