Fix date issue.

This commit is contained in:
James Cole 2021-12-28 20:42:50 +01:00
parent 3444146da3
commit 246fa0d6e4
No known key found for this signature in database
GPG Key ID: BDE6667570EADBD5
18 changed files with 30 additions and 30 deletions

View File

@ -54,7 +54,7 @@ class AutocompleteRequest extends FormRequest
return [
'types' => $array,
'query' => $this->string('query'),
'date' => $this->date('date'),
'date' => $this->getCarbonDate('date'),
'limit' => $limit,
];
}

View File

@ -45,8 +45,8 @@ class DateRequest extends FormRequest
public function getAll(): array
{
return [
'start' => $this->date('start'),
'end' => $this->date('end'),
'start' => $this->getCarbonDate('start'),
'end' => $this->getCarbonDate('end'),
];
}

View File

@ -41,8 +41,8 @@ class ExportRequest extends FormRequest
public function getAll(): array
{
$result = [
'start' => $this->date('start') ?? Carbon::now()->subYear(),
'end' => $this->date('end') ?? Carbon::now(),
'start' => $this->getCarbonDate('start') ?? Carbon::now()->subYear(),
'end' => $this->getCarbonDate('end') ?? Carbon::now(),
'type' => $this->string('type'),
];
$parts = explode(',', $this->string('accounts'));

View File

@ -58,8 +58,8 @@ class GenericRequest extends FormRequest
public function getAll(): array
{
return [
'start' => $this->date('start'),
'end' => $this->date('end'),
'start' => $this->getCarbonDate('start'),
'end' => $this->getCarbonDate('end'),
];
}
@ -204,7 +204,7 @@ class GenericRequest extends FormRequest
*/
public function getEnd(): Carbon
{
$date = $this->date('end');
$date = $this->getCarbonDate('end');
$date->endOfDay();
return $date;
@ -251,7 +251,7 @@ class GenericRequest extends FormRequest
*/
public function getStart(): Carbon
{
$date = $this->date('start');
$date = $this->getCarbonDate('start');
$date->startOfDay();
return $date;

View File

@ -70,7 +70,7 @@ class StoreRequest extends FormRequest
'account_number' => $this->string('account_number'),
'account_role' => $this->string('account_role'),
'opening_balance' => $this->string('opening_balance'),
'opening_balance_date' => $this->date('opening_balance_date'),
'opening_balance_date' => $this->getCarbonDate('opening_balance_date'),
'cc_type' => $this->string('credit_card_type'),
'cc_monthly_payment_date' => $this->string('monthly_payment_date'),
'notes' => $this->stringWithNewlines('notes'),
@ -82,7 +82,7 @@ class StoreRequest extends FormRequest
if ('liability' === $data['account_type_name'] || 'liabilities' === $data['account_type_name']) {
$data['opening_balance'] = app('steam')->negative($this->string('liability_amount'));
$data['opening_balance_date'] = $this->date('liability_start_date');
$data['opening_balance_date'] = $this->getCarbonDate('liability_start_date');
$data['account_type_name'] = $this->string('liability_type');
$data['liability_direction'] = $this->string('liability_direction');
$data['account_type_id'] = null;

View File

@ -44,8 +44,8 @@ class StoreRequest extends FormRequest
public function getAll(): array
{
return [
'start' => $this->date('start'),
'end' => $this->date('end'),
'start' => $this->getCarbonDate('start'),
'end' => $this->getCarbonDate('end'),
'amount' => $this->string('amount'),
'currency_id' => $this->integer('currency_id'),
'currency_code' => $this->string('currency_code'),

View File

@ -51,8 +51,8 @@ class StoreRequest extends FormRequest
$data['account_id'] = $this->integer('account_id');
$data['targetamount'] = $this->string('target_amount');
$data['current_amount'] = $this->string('current_amount');
$data['startdate'] = $this->date('start_date');
$data['targetdate'] = $this->date('target_date');
$data['startdate'] = $this->getCarbonDate('start_date');
$data['targetdate'] = $this->getCarbonDate('target_date');
$data['notes'] = $this->stringWithNewlines('notes');
$data['object_group_id'] = $this->integer('object_group_id');
$data['object_group_title'] = $this->string('object_group_title');

View File

@ -47,7 +47,7 @@ class StoreRequest extends FormRequest
{
$data = [
'tag' => $this->string('tag'),
'date' => $this->date('date'),
'date' => $this->getCarbonDate('date'),
'description' => $this->string('description'),
'has_location' => true,
];

View File

@ -62,7 +62,7 @@ class CronRequest extends FormRequest
$data['force'] = $this->boolean('force');
}
if ($this->has('date')) {
$data['date'] = $this->date('date');
$data['date'] = $this->getCarbonDate('date');
}
return $data;

View File

@ -55,7 +55,7 @@ class AccountFormRequest extends FormRequest
'account_number' => $this->string('account_number'),
'account_role' => $this->string('account_role'),
'opening_balance' => $this->string('opening_balance'),
'opening_balance_date' => $this->date('opening_balance_date'),
'opening_balance_date' => $this->getCarbonDate('opening_balance_date'),
'cc_type' => $this->string('cc_type'),
'cc_monthly_payment_date' => $this->string('cc_monthly_payment_date'),
'notes' => $this->stringWithNewlines('notes'),

View File

@ -46,7 +46,7 @@ class BillStoreRequest extends FormRequest
'currency_id' => $this->integer('transaction_currency_id'),
'currency_code' => '',
'amount_max' => $this->string('amount_max'),
'date' => $this->date('date'),
'date' => $this->getCarbonDate('date'),
'repeat_freq' => $this->string('repeat_freq'),
'skip' => $this->integer('skip'),
'notes' => $this->stringWithNewlines('notes'),

View File

@ -47,7 +47,7 @@ class BillUpdateRequest extends FormRequest
'currency_id' => $this->integer('transaction_currency_id'),
'currency_code' => '',
'amount_max' => $this->string('amount_max'),
'date' => $this->date('date'),
'date' => $this->getCarbonDate('date'),
'repeat_freq' => $this->string('repeat_freq'),
'skip' => $this->integer('skip'),
'notes' => $this->stringWithNewlines('notes'),

View File

@ -42,10 +42,10 @@ class PiggyBankStoreRequest extends FormRequest
{
return [
'name' => $this->string('name'),
'startdate' => $this->date('startdate'),
'startdate' => $this->getCarbonDate('startdate'),
'account_id' => $this->integer('account_id'),
'targetamount' => $this->string('targetamount'),
'targetdate' => $this->date('targetdate'),
'targetdate' => $this->getCarbonDate('targetdate'),
'notes' => $this->stringWithNewlines('notes'),
'object_group_title' => $this->string('object_group'),
];

View File

@ -43,10 +43,10 @@ class PiggyBankUpdateRequest extends FormRequest
{
return [
'name' => $this->string('name'),
'startdate' => $this->date('startdate'),
'startdate' => $this->getCarbonDate('startdate'),
'account_id' => $this->integer('account_id'),
'targetamount' => $this->string('targetamount'),
'targetdate' => $this->date('targetdate'),
'targetdate' => $this->getCarbonDate('targetdate'),
'notes' => $this->stringWithNewlines('notes'),
'object_group_title' => $this->string('object_group'),
];

View File

@ -48,8 +48,8 @@ class ReconciliationStoreRequest extends FormRequest
$transactions = [];
}
$data = [
'start' => $this->date('start'),
'end' => $this->date('end'),
'start' => $this->getCarbonDate('start'),
'end' => $this->getCarbonDate('end'),
'start_balance' => $this->string('startBalance'),
'end_balance' => $this->string('endBalance'),
'difference' => $this->string('difference'),

View File

@ -59,8 +59,8 @@ class RecurrenceFormRequest extends FormRequest
'type' => $this->string('transaction_type'),
'title' => $this->string('title'),
'description' => $this->string('recurring_description'),
'first_date' => $this->date('first_date'),
'repeat_until' => $this->date('repeat_until'),
'first_date' => $this->getCarbonDate('first_date'),
'repeat_until' => $this->getCarbonDate('repeat_until'),
'nr_of_repetitions' => $this->integer('repetitions'),
'apply_rules' => $this->boolean('apply_rules'),
'active' => $this->boolean('active'),

View File

@ -45,7 +45,7 @@ class TagFormRequest extends FormRequest
{
$data = [
'tag' => $this->string('tag'),
'date' => $this->date('date'),
'date' => $this->getCarbonDate('date'),
'description' => $this->string('description'),
];

View File

@ -187,7 +187,7 @@ trait ConvertsDataTypes
*
* @return Carbon|null
*/
protected function date(string $field): ?Carbon
protected function getCarbonDate(string $field): ?Carbon
{
$result = null;
try {