firefly-iii/app/Http/Requests/ReconciliationStoreRequest.php

82 lines
2.5 KiB
PHP
Raw Normal View History

2018-02-23 08:13:01 -06:00
<?php
/**
* ReconciliationStoreRequest.php
2020-01-31 00:32:04 -06:00
* Copyright (c) 2019 james@firefly-iii.org
2018-02-23 08:13:01 -06:00
*
* This file is part of Firefly III (https://github.com/firefly-iii).
2018-02-23 08:13:01 -06:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
2018-02-23 08:13:01 -06:00
*
* This program is distributed in the hope that it will be useful,
2018-02-23 08:13:01 -06:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
2018-02-23 08:13:01 -06:00
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2018-02-23 08:13:01 -06:00
*/
declare(strict_types=1);
namespace FireflyIII\Http\Requests;
2019-06-22 22:53:01 -05:00
use FireflyIII\Rules\ValidJournals;
2020-10-24 00:55:09 -05:00
use FireflyIII\Support\Request\ChecksLogin;
2020-07-18 01:42:13 -05:00
use FireflyIII\Support\Request\ConvertsDataTypes;
2020-10-24 00:55:09 -05:00
use Illuminate\Foundation\Http\FormRequest;
2018-02-23 08:13:01 -06:00
use Log;
/**
* Class ReconciliationStoreRequest
*/
2020-10-24 00:55:09 -05:00
class ReconciliationStoreRequest extends FormRequest
2018-02-23 08:13:01 -06:00
{
2020-10-24 00:55:09 -05:00
use ConvertsDataTypes, ChecksLogin;
2018-02-23 08:13:01 -06:00
/**
2018-07-22 01:10:16 -05:00
* Returns the data required by the controller.
*
2018-02-23 08:13:01 -06:00
* @return array
*/
public function getAll(): array
{
$transactions = $this->get('journals');
if (!is_array($transactions)) {
2018-03-03 10:16:47 -06:00
$transactions = []; // @codeCoverageIgnore
2018-02-23 08:13:01 -06:00
}
$data = [
'start' => $this->date('start'),
'end' => $this->date('end'),
'start_balance' => $this->string('startBalance'),
'end_balance' => $this->string('endBalance'),
'difference' => $this->string('difference'),
2019-06-22 22:53:01 -05:00
'journals' => $transactions,
2018-02-23 08:13:01 -06:00
'reconcile' => $this->string('reconcile'),
];
Log::debug('In ReconciliationStoreRequest::getAll(). Will now return data.');
return $data;
}
/**
2018-07-22 01:10:16 -05:00
* Rules for this request.
*
2018-02-23 08:13:01 -06:00
* @return array
*/
public function rules(): array
{
return [
'start' => 'required|date',
'end' => 'required|date',
2019-09-12 00:11:20 -05:00
'startBalance' => 'numeric|max:1000000000',
'endBalance' => 'numeric|max:1000000000',
'difference' => 'required|numeric|max:1000000000',
2019-06-22 22:53:01 -05:00
'journals' => [new ValidJournals],
2018-02-23 08:13:01 -06:00
'reconcile' => 'required|in:create,nothing',
];
}
2018-03-05 12:35:58 -06:00
}