mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 20:22:07 +00:00
Fix #7505
This commit is contained in:
@@ -63,9 +63,9 @@ class UpdateRequest extends FormRequest
|
|||||||
'account_role' => ['account_role', 'convertString'],
|
'account_role' => ['account_role', 'convertString'],
|
||||||
'liability_type' => ['liability_type', 'convertString'],
|
'liability_type' => ['liability_type', 'convertString'],
|
||||||
'opening_balance' => ['opening_balance', 'convertString'],
|
'opening_balance' => ['opening_balance', 'convertString'],
|
||||||
'opening_balance_date' => ['opening_balance_date', 'date'],
|
'opening_balance_date' => ['opening_balance_date', 'convertDateTime'],
|
||||||
'cc_type' => ['credit_card_type', 'convertString'],
|
'cc_type' => ['credit_card_type', 'convertString'],
|
||||||
'cc_monthly_payment_date' => ['monthly_payment_date', 'convertString'],
|
'cc_monthly_payment_date' => ['monthly_payment_date', 'convertDateTime'],
|
||||||
'notes' => ['notes', 'stringWithNewlines'],
|
'notes' => ['notes', 'stringWithNewlines'],
|
||||||
'interest' => ['interest', 'convertString'],
|
'interest' => ['interest', 'convertString'],
|
||||||
'interest_period' => ['interest_period', 'convertString'],
|
'interest_period' => ['interest_period', 'convertString'],
|
||||||
|
@@ -52,8 +52,8 @@ class UpdateRequest extends FormRequest
|
|||||||
'account_id' => ['account_id', 'convertInteger'],
|
'account_id' => ['account_id', 'convertInteger'],
|
||||||
'targetamount' => ['target_amount', 'convertString'],
|
'targetamount' => ['target_amount', 'convertString'],
|
||||||
'current_amount' => ['current_amount', 'convertString'],
|
'current_amount' => ['current_amount', 'convertString'],
|
||||||
'startdate' => ['start_date', 'date'],
|
'startdate' => ['start_date', 'convertDateTime'],
|
||||||
'targetdate' => ['target_date', 'convertString'],
|
'targetdate' => ['target_date', 'convertDateTime'],
|
||||||
'notes' => ['notes', 'stringWithNewlines'],
|
'notes' => ['notes', 'stringWithNewlines'],
|
||||||
'order' => ['order', 'convertInteger'],
|
'order' => ['order', 'convertInteger'],
|
||||||
'object_group_title' => ['object_group_title', 'convertString'],
|
'object_group_title' => ['object_group_title', 'convertString'],
|
||||||
|
@@ -57,8 +57,8 @@ class StoreRequest extends FormRequest
|
|||||||
'type' => ['type', 'convertString'],
|
'type' => ['type', 'convertString'],
|
||||||
'title' => ['title', 'convertString'],
|
'title' => ['title', 'convertString'],
|
||||||
'description' => ['description', 'convertString'],
|
'description' => ['description', 'convertString'],
|
||||||
'first_date' => ['first_date', 'date'],
|
'first_date' => ['first_date', 'convertDateTime'],
|
||||||
'repeat_until' => ['repeat_until', 'date'],
|
'repeat_until' => ['repeat_until', 'convertDateTime'],
|
||||||
'nr_of_repetitions' => ['nr_of_repetitions', 'convertInteger'],
|
'nr_of_repetitions' => ['nr_of_repetitions', 'convertInteger'],
|
||||||
'apply_rules' => ['apply_rules', 'boolean'],
|
'apply_rules' => ['apply_rules', 'boolean'],
|
||||||
'active' => ['active', 'boolean'],
|
'active' => ['active', 'boolean'],
|
||||||
|
@@ -58,8 +58,8 @@ class UpdateRequest extends FormRequest
|
|||||||
$fields = [
|
$fields = [
|
||||||
'title' => ['title', 'convertString'],
|
'title' => ['title', 'convertString'],
|
||||||
'description' => ['description', 'convertString'],
|
'description' => ['description', 'convertString'],
|
||||||
'first_date' => ['first_date', 'date'],
|
'first_date' => ['first_date', 'convertDateTime'],
|
||||||
'repeat_until' => ['repeat_until', 'date'],
|
'repeat_until' => ['repeat_until', 'convertDateTime'],
|
||||||
'nr_of_repetitions' => ['nr_of_repetitions', 'convertInteger'],
|
'nr_of_repetitions' => ['nr_of_repetitions', 'convertInteger'],
|
||||||
'apply_rules' => ['apply_rules', 'boolean'],
|
'apply_rules' => ['apply_rules', 'boolean'],
|
||||||
'active' => ['active', 'boolean'],
|
'active' => ['active', 'boolean'],
|
||||||
|
@@ -86,7 +86,7 @@ class PiggyBank extends Model
|
|||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that should be casted to native types.
|
* The attributes that should be cast to native types.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
@@ -394,7 +394,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $journal->date->format('Y-m-d');
|
return $journal->date->format('Y-m-d H:i:s');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -154,6 +154,9 @@ trait AccountServiceTrait
|
|||||||
if (is_bool($data[$field]) && true === $data[$field]) {
|
if (is_bool($data[$field]) && true === $data[$field]) {
|
||||||
$data[$field] = 1;
|
$data[$field] = 1;
|
||||||
}
|
}
|
||||||
|
if($data[$field] instanceof Carbon) {
|
||||||
|
$data[$field] = $data[$field]->toAtomString();
|
||||||
|
}
|
||||||
|
|
||||||
$factory->crud($account, $field, (string)$data[$field]);
|
$factory->crud($account, $field, (string)$data[$field]);
|
||||||
}
|
}
|
||||||
|
@@ -296,6 +296,7 @@ class AccountUpdateService
|
|||||||
$type = $account->accountType;
|
$type = $account->accountType;
|
||||||
if (in_array($type->type, $this->canHaveOpeningBalance, true)) {
|
if (in_array($type->type, $this->canHaveOpeningBalance, true)) {
|
||||||
// check if is submitted as empty, that makes it valid:
|
// check if is submitted as empty, that makes it valid:
|
||||||
|
|
||||||
if ($this->validOBData($data) && !$this->isEmptyOBData($data)) {
|
if ($this->validOBData($data) && !$this->isEmptyOBData($data)) {
|
||||||
$openingBalance = $data['opening_balance'];
|
$openingBalance = $data['opening_balance'];
|
||||||
$openingBalanceDate = $data['opening_balance_date'];
|
$openingBalanceDate = $data['opening_balance_date'];
|
||||||
@@ -306,7 +307,6 @@ class AccountUpdateService
|
|||||||
$openingBalance
|
$openingBalance
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->updateOBGroupV2($account, $openingBalance, $openingBalanceDate);
|
$this->updateOBGroupV2($account, $openingBalance, $openingBalanceDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Support\Request;
|
namespace FireflyIII\Support\Request;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Carbon\Exceptions\InvalidDateException;
|
||||||
use Carbon\Exceptions\InvalidFormatException;
|
use Carbon\Exceptions\InvalidFormatException;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
@@ -255,6 +256,44 @@ trait ConvertsDataTypes
|
|||||||
return $carbon;
|
return $carbon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function convertDateTime(?string $string): ?Carbon
|
||||||
|
{
|
||||||
|
$value = $this->get($string);
|
||||||
|
if (null === $value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ('' === $value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (10 === strlen($value)) {
|
||||||
|
// probably a date format.
|
||||||
|
try {
|
||||||
|
$carbon = Carbon::createFromFormat('Y-m-d', $value);
|
||||||
|
} catch (InvalidDateException $e) {
|
||||||
|
Log::error(sprintf('[1] "%s" is not a valid date: %s', $value, $e->getMessage()));
|
||||||
|
return null;
|
||||||
|
} catch (InvalidFormatException $e) {
|
||||||
|
Log::error(sprintf('[2] "%s" is of an invalid format: %s', $value, $e->getMessage()));
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $carbon;
|
||||||
|
}
|
||||||
|
// is an atom string, I hope?
|
||||||
|
try {
|
||||||
|
$carbon = Carbon::parse($value);
|
||||||
|
} catch (InvalidDateException $e) {
|
||||||
|
Log::error(sprintf('[3] "%s" is not a valid date or time: %s', $value, $e->getMessage()));
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} catch (InvalidFormatException $e) {
|
||||||
|
Log::error(sprintf('[4] "%s" is of an invalid format: %s', $value, $e->getMessage()));
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $carbon;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all data in the request, or omits the field if not set,
|
* Returns all data in the request, or omits the field if not set,
|
||||||
* according to the config from the request. This is the way.
|
* according to the config from the request. This is the way.
|
||||||
|
@@ -209,7 +209,13 @@ class AccountTransformer extends AbstractTransformer
|
|||||||
$monthlyPaymentDate = $this->repository->getMetaValue($account, 'cc_monthly_payment_date');
|
$monthlyPaymentDate = $this->repository->getMetaValue($account, 'cc_monthly_payment_date');
|
||||||
}
|
}
|
||||||
if (null !== $monthlyPaymentDate) {
|
if (null !== $monthlyPaymentDate) {
|
||||||
$monthlyPaymentDate = Carbon::createFromFormat('!Y-m-d', $monthlyPaymentDate, config('app.timezone'))->toAtomString();
|
// try classic date:
|
||||||
|
if(10 === strlen($monthlyPaymentDate)) {
|
||||||
|
$monthlyPaymentDate = Carbon::createFromFormat('!Y-m-d', $monthlyPaymentDate, config('app.timezone'))->toAtomString();
|
||||||
|
}
|
||||||
|
if(10 !== strlen($monthlyPaymentDate)) {
|
||||||
|
$monthlyPaymentDate = Carbon::parse($monthlyPaymentDate, config('app.timezone'))->toAtomString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$creditCardType, $monthlyPaymentDate];
|
return [$creditCardType, $monthlyPaymentDate];
|
||||||
@@ -233,7 +239,7 @@ class AccountTransformer extends AbstractTransformer
|
|||||||
$openingBalanceDate = $this->repository->getOpeningBalanceDate($account);
|
$openingBalanceDate = $this->repository->getOpeningBalanceDate($account);
|
||||||
}
|
}
|
||||||
if (null !== $openingBalanceDate) {
|
if (null !== $openingBalanceDate) {
|
||||||
$openingBalanceDate = Carbon::createFromFormat('!Y-m-d', $openingBalanceDate, config('app.timezone'))->toAtomString();
|
$openingBalanceDate = Carbon::createFromFormat('Y-m-d H:i:s', $openingBalanceDate, config('app.timezone'))->toAtomString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$openingBalance, $openingBalanceDate];
|
return [$openingBalance, $openingBalanceDate];
|
||||||
|
@@ -103,9 +103,8 @@ class PiggyBankTransformer extends AbstractTransformer
|
|||||||
$leftToSave = app('steam')->bcround($leftToSave, $currency->decimal_places);
|
$leftToSave = app('steam')->bcround($leftToSave, $currency->decimal_places);
|
||||||
$savePerMonth = app('steam')->bcround($this->piggyRepos->getSuggestedMonthlyAmount($piggyBank), $currency->decimal_places);
|
$savePerMonth = app('steam')->bcround($this->piggyRepos->getSuggestedMonthlyAmount($piggyBank), $currency->decimal_places);
|
||||||
}
|
}
|
||||||
$startDate = $piggyBank->startdate?->toAtomString();
|
$startDate = $piggyBank->startdate?->format('Y-m-d');
|
||||||
$targetDate = $piggyBank->targetdate?->toAtomString();
|
$targetDate = $piggyBank->targetdate?->format('Y-m-d');
|
||||||
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => (string)$piggyBank->id,
|
'id' => (string)$piggyBank->id,
|
||||||
|
@@ -92,9 +92,9 @@ class RecurrenceTransformer extends AbstractTransformer
|
|||||||
'type' => $shortType,
|
'type' => $shortType,
|
||||||
'title' => $recurrence->title,
|
'title' => $recurrence->title,
|
||||||
'description' => $recurrence->description,
|
'description' => $recurrence->description,
|
||||||
'first_date' => $recurrence->first_date->toAtomString(),
|
'first_date' => $recurrence->first_date->format('Y-m-d'),
|
||||||
'latest_date' => $recurrence->latest_date?->toAtomString(),
|
'latest_date' => $recurrence->latest_date?->format('Y-m-d'),
|
||||||
'repeat_until' => $recurrence->repeat_until?->toAtomString(),
|
'repeat_until' => $recurrence->repeat_until?->format('Y-m-d'),
|
||||||
'apply_rules' => $recurrence->apply_rules,
|
'apply_rules' => $recurrence->apply_rules,
|
||||||
'active' => $recurrence->active,
|
'active' => $recurrence->active,
|
||||||
'nr_of_repetitions' => $reps,
|
'nr_of_repetitions' => $reps,
|
||||||
|
@@ -42,7 +42,7 @@ class TagTransformer extends AbstractTransformer
|
|||||||
*/
|
*/
|
||||||
public function transform(Tag $tag): array
|
public function transform(Tag $tag): array
|
||||||
{
|
{
|
||||||
$date = $tag->date?->toAtomString();
|
$date = $tag->date?->format('Y-m-d');
|
||||||
/** @var Location $location */
|
/** @var Location $location */
|
||||||
$location = $tag->locations()->first();
|
$location = $tag->locations()->first();
|
||||||
$latitude = null;
|
$latitude = null;
|
||||||
|
@@ -108,7 +108,7 @@ return [
|
|||||||
'handle_debts' => true,
|
'handle_debts' => true,
|
||||||
],
|
],
|
||||||
'version' => '6.0.10',
|
'version' => '6.0.10',
|
||||||
'api_version' => '2.0.1',
|
'api_version' => '2.0.2',
|
||||||
'db_version' => 19,
|
'db_version' => 19,
|
||||||
|
|
||||||
// generic settings
|
// generic settings
|
||||||
|
Reference in New Issue
Block a user