Smaller notes

This commit is contained in:
James Cole 2024-01-04 11:41:03 +01:00
parent 72a2d417af
commit c32044a8eb
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
15 changed files with 73 additions and 69 deletions

View File

@ -83,7 +83,7 @@ class StoreRequest extends FormRequest
'repeat_freq' => 'in:weekly,monthly,quarterly,half-year,yearly|required',
'skip' => 'between:0,31',
'active' => [new IsBoolean()],
'notes' => 'between:1,65536',
'notes' => 'min:1|max:32768',
];
}

View File

@ -86,7 +86,7 @@ class UpdateRequest extends FormRequest
'repeat_freq' => 'in:weekly,monthly,quarterly,half-year,yearly',
'skip' => 'between:0,31',
'active' => [new IsBoolean()],
'notes' => 'between:1,65536',
'notes' => 'min:1|max:32768',
];
}

View File

@ -72,7 +72,7 @@ class StoreRequest extends FormRequest
'active' => [new IsBoolean()],
'currency_id' => 'exists:transaction_currencies,id',
'currency_code' => 'exists:transaction_currencies,code',
'notes' => 'nullable|between:1,65536',
'notes' => 'nullable|min:1|max:32768',
// auto budget info
'auto_budget_type' => 'in:reset,rollover,adjusted,none',
'auto_budget_amount' => ['required_if:auto_budget_type,reset', 'required_if:auto_budget_type,rollover', 'required_if:auto_budget_type,adjusted', new IsValidPositiveAmount()],

View File

@ -83,7 +83,7 @@ class UpdateRequest extends FormRequest
return [
'name' => sprintf('between:1,100|uniqueObjectForUser:budgets,name,%d', $budget->id),
'active' => [new IsBoolean()],
'notes' => 'nullable|between:1,65536',
'notes' => 'nullable|min:1|max:32768',
'auto_budget_type' => 'in:reset,rollover,adjusted,none',
'auto_budget_currency_id' => 'exists:transaction_currencies,id',
'auto_budget_currency_code' => 'exists:transaction_currencies,code',

View File

@ -116,7 +116,7 @@ class AccountFormRequest extends FormRequest
'amount_currency_id_virtual_balance' => 'exists:transaction_currencies,id',
'what' => 'in:'.$types,
'interest_period' => 'in:daily,monthly,yearly',
'notes' => 'between:1,65536|nullable',
'notes' => 'min:1|max:32768|nullable',
];
$rules = Location::requestRules($rules);

View File

@ -54,7 +54,7 @@ class AttachmentFormRequest extends FormRequest
// fixed
return [
'title' => 'between:1,255|nullable',
'notes' => 'between:1,65536|nullable',
'notes' => 'min:1|max:32768|nullable',
];
}
}

View File

@ -69,7 +69,7 @@ class BillStoreRequest extends FormRequest
'amount_max' => ['required', new IsValidPositiveAmount()],
'transaction_currency_id' => 'required|exists:transaction_currencies,id',
'date' => 'required|date',
'notes' => 'between:1,65536|nullable',
'notes' => 'min:1|max:32768|nullable',
'bill_end_date' => 'nullable|date',
'extension_date' => 'nullable|date',
'repeat_freq' => sprintf('required|in:%s', implode(',', config('firefly.bill_periods'))),

View File

@ -78,7 +78,7 @@ class BillUpdateRequest extends FormRequest
'repeat_freq' => sprintf('required|in:%s', implode(',', config('firefly.bill_periods'))),
'skip' => 'required|integer|gte:0|lte:31',
'active' => 'boolean',
'notes' => 'between:1,65536|nullable',
'notes' => 'min:1|max:32768|nullable',
];
}
}

View File

@ -67,7 +67,7 @@ class BudgetFormStoreRequest extends FormRequest
'auto_budget_currency_id' => 'exists:transaction_currencies,id',
'auto_budget_amount' => ['required_if:auto_budget_type,1', 'required_if:auto_budget_type,2', new IsValidPositiveAmount()],
'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly',
'notes' => 'between:1,65536|nullable',
'notes' => 'min:1|max:32768|nullable',
];
}

View File

@ -76,7 +76,7 @@ class BudgetFormUpdateRequest extends FormRequest
'auto_budget_currency_id' => 'exists:transaction_currencies,id',
'auto_budget_amount' => ['required_if:auto_budget_type,1', 'required_if:auto_budget_type,2|numeric', new IsValidPositiveAmount()],
'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly',
'notes' => 'between:1,65536|nullable',
'notes' => 'min:1|max:32768|nullable',
];
}

View File

@ -64,7 +64,7 @@ class CategoryFormRequest extends FormRequest
// fixed
return [
'name' => $nameRule,
'notes' => 'between:1,65536|nullable',
'notes' => 'min:1|max:32768|nullable',
];
}
}

View File

@ -65,7 +65,7 @@ class PiggyBankStoreRequest extends FormRequest
'targetdate' => 'date|nullable',
'order' => 'integer|min:1',
'object_group' => 'min:0|max:255',
'notes' => 'between:1,65536|nullable',
'notes' => 'min:1|max:32768|nullable',
];
}
}

View File

@ -69,7 +69,7 @@ class PiggyBankUpdateRequest extends FormRequest
'targetdate' => 'date|nullable',
'order' => 'integer|max:65536|min:1',
'object_group' => 'min:0|max:255',
'notes' => 'between:1,65536|nullable',
'notes' => 'min:1|max:32768|nullable',
];
}
}

View File

@ -163,7 +163,7 @@ class RecurrenceFormRequest extends FormRequest
'first_date' => sprintf('required|date|before:%s|after:%s', $before->format('Y-m-d'), $today->format('Y-m-d')),
'repetition_type' => ['required', new ValidRecurrenceRepetitionValue(), new ValidRecurrenceRepetitionType(), 'between:1,20'],
'skip' => 'required|numeric|integer|gte:0|lte:31',
'notes' => 'between:1,65536|nullable',
'notes' => 'min:1|max:32768|nullable',
// optional for recurrence:
'recurring_description' => 'between:0,65000',
'active' => 'numeric|between:0,1',

View File

@ -72,7 +72,8 @@ class AccountRepository implements AccountRepositoryInterface
/** @var Account $account */
foreach ($accounts as $account) {
$byName = $this->user->accounts()->where('name', $account->name)
->where('id', '!=', $account->id)->first();
->where('id', '!=', $account->id)->first()
;
if (null !== $byName) {
$result->push($account);
$result->push($byName);
@ -81,7 +82,8 @@ class AccountRepository implements AccountRepositoryInterface
}
if (null !== $account->iban) {
$byIban = $this->user->accounts()->where('iban', $account->iban)
->where('id', '!=', $account->id)->first();
->where('id', '!=', $account->id)->first()
;
if (null !== $byIban) {
$result->push($account);
$result->push($byIban);
@ -107,7 +109,8 @@ class AccountRepository implements AccountRepositoryInterface
$q1->where('account_meta.name', '=', 'account_number');
$q1->where('account_meta.data', '=', $json);
}
);
)
;
if (0 !== count($types)) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
@ -243,7 +246,8 @@ class AccountRepository implements AccountRepositoryInterface
$journal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.account_id', $account->id)
->transactionTypes([TransactionType::LIABILITY_CREDIT])
->first(['transaction_journals.*']);
->first(['transaction_journals.*'])
;
return $journal?->transactionGroup;
}
@ -290,7 +294,8 @@ class AccountRepository implements AccountRepositoryInterface
$journal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.account_id', $account->id)
->transactionTypes([TransactionType::OPENING_BALANCE, TransactionType::LIABILITY_CREDIT])
->first(['transaction_journals.*']);
->first(['transaction_journals.*'])
;
if (null === $journal) {
return null;
}
@ -310,7 +315,8 @@ class AccountRepository implements AccountRepositoryInterface
return TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.account_id', $account->id)
->transactionTypes([TransactionType::OPENING_BALANCE, TransactionType::LIABILITY_CREDIT])
->first(['transaction_journals.*'])?->date->format('Y-m-d H:i:s');
->first(['transaction_journals.*'])?->date->format('Y-m-d H:i:s')
;
}
public function getOpeningBalanceGroup(Account $account): ?TransactionGroup
@ -320,19 +326,13 @@ class AccountRepository implements AccountRepositoryInterface
return $journal?->transactionGroup;
}
/**
*
*
* @param Account $account
*
* @return TransactionJournal|null
*/
public function getOpeningBalance(Account $account): ?TransactionJournal
{
return TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.account_id', $account->id)
->transactionTypes([TransactionType::OPENING_BALANCE])
->first(['transaction_journals.*']);
->first(['transaction_journals.*'])
;
}
public function getPiggyBanks(Account $account): Collection
@ -357,7 +357,8 @@ class AccountRepository implements AccountRepositoryInterface
/** @var null|Account $current */
$current = $this->user->accounts()->where('account_type_id', $type->id)
->where('name', $name)
->first();
->first()
;
if (null !== $current) {
return $current;
@ -516,7 +517,8 @@ class AccountRepository implements AccountRepositoryInterface
->orderBy('transaction_journals.order', 'DESC')
->where('transaction_journals.user_id', $this->user->id)
->orderBy('transaction_journals.id', 'ASC')
->first(['transaction_journals.id']);
->first(['transaction_journals.id'])
;
if (null !== $first) {
return TransactionJournal::find($first->id);
}
@ -559,7 +561,8 @@ class AccountRepository implements AccountRepositoryInterface
->orderBy('accounts.order', 'ASC')
->orderBy('accounts.account_type_id', 'ASC')
->orderBy('accounts.name', 'ASC')
->with(['accountType']);
->with(['accountType'])
;
if ('' !== $query) {
// split query on spaces just in case:
$parts = explode(' ', $query);
@ -584,7 +587,8 @@ class AccountRepository implements AccountRepositoryInterface
->orderBy('accounts.order', 'ASC')
->orderBy('accounts.account_type_id', 'ASC')
->orderBy('accounts.name', 'ASC')
->with(['accountType', 'accountMeta']);
->with(['accountType', 'accountMeta'])
;
if ('' !== $query) {
// split query on spaces just in case:
$parts = explode(' ', $query);