mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 14:12:15 +00:00
Various code cleanup.
This commit is contained in:
@@ -48,7 +48,7 @@ class AccountFormRequest extends Request
|
||||
*/
|
||||
public function getAccountData(): array
|
||||
{
|
||||
return [
|
||||
$data = [
|
||||
'name' => $this->string('name'),
|
||||
'active' => $this->boolean('active'),
|
||||
'accountType' => $this->string('what'),
|
||||
@@ -64,7 +64,22 @@ class AccountFormRequest extends Request
|
||||
'ccType' => $this->string('ccType'),
|
||||
'ccMonthlyPaymentDate' => $this->string('ccMonthlyPaymentDate'),
|
||||
'notes' => $this->string('notes'),
|
||||
'interest' => $this->string('interest'),
|
||||
'interest_period' => $this->string('interest_period'),
|
||||
];
|
||||
|
||||
// if the account type is "liabilities" there are actually four types of liability
|
||||
// that could have been selected.
|
||||
if ($data['accountType'] === 'liabilities') {
|
||||
$data['accountType'] = null;
|
||||
$data['account_type_id'] = $this->integer('liability_type_id');
|
||||
// also reverse the opening balance:
|
||||
if ('' !== $data['openingBalance']) {
|
||||
$data['openingBalance'] = bcmul($data['openingBalance'], '-1');
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,8 +108,14 @@ class AccountFormRequest extends Request
|
||||
'amount_currency_id_openingBalance' => 'exists:transaction_currencies,id',
|
||||
'amount_currency_id_virtualBalance' => 'exists:transaction_currencies,id',
|
||||
'what' => 'in:' . $types,
|
||||
'interest_period' => 'in:daily,monthly,yearly',
|
||||
];
|
||||
|
||||
if ('liabilities' === $this->get('what')) {
|
||||
$rules['openingBalance'] = 'numeric|required|more:0';
|
||||
$rules['openingBalanceDate'] = 'date|required';
|
||||
}
|
||||
|
||||
/** @var Account $account */
|
||||
$account = $this->route()->parameter('account');
|
||||
if (null !== $account) {
|
||||
|
||||
@@ -50,7 +50,7 @@ class ExportFormRequest extends Request
|
||||
/** @var Carbon $sessionFirst */
|
||||
$sessionFirst = clone session('first');
|
||||
$first = $sessionFirst->subDay()->format('Y-m-d');
|
||||
$today = Carbon::create()->addDay()->format('Y-m-d');
|
||||
$today = Carbon::now()->addDay()->format('Y-m-d');
|
||||
$formats = implode(',', array_keys(config('firefly.export_formats')));
|
||||
|
||||
// fixed
|
||||
|
||||
@@ -149,7 +149,7 @@ class RecurrenceFormRequest extends Request
|
||||
public function rules(): array
|
||||
{
|
||||
$today = new Carbon;
|
||||
$tomorrow = Carbon::create()->addDay();
|
||||
$tomorrow = Carbon::now()->addDay();
|
||||
$rules = [
|
||||
// mandatory info for recurrence.
|
||||
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',
|
||||
|
||||
@@ -53,7 +53,7 @@ class SelectTransactionsRequest extends Request
|
||||
/** @var Carbon $sessionFirst */
|
||||
$sessionFirst = clone session('first');
|
||||
$first = $sessionFirst->subDay()->format('Y-m-d');
|
||||
$today = Carbon::create()->addDay()->format('Y-m-d');
|
||||
$today = Carbon::now()->addDay()->format('Y-m-d');
|
||||
|
||||
return [
|
||||
'start_date' => 'required|date|after:' . $first,
|
||||
|
||||
Reference in New Issue
Block a user