mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
commit
18ba2e563e
@ -63,9 +63,9 @@ class UpdateRequest extends FormRequest
|
||||
'account_role' => ['account_role', 'convertString'],
|
||||
'liability_type' => ['liability_type', '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_monthly_payment_date' => ['monthly_payment_date', 'convertString'],
|
||||
'cc_monthly_payment_date' => ['monthly_payment_date', 'convertDateTime'],
|
||||
'notes' => ['notes', 'stringWithNewlines'],
|
||||
'interest' => ['interest', 'convertString'],
|
||||
'interest_period' => ['interest_period', 'convertString'],
|
||||
|
@ -52,8 +52,8 @@ class UpdateRequest extends FormRequest
|
||||
'account_id' => ['account_id', 'convertInteger'],
|
||||
'targetamount' => ['target_amount', 'convertString'],
|
||||
'current_amount' => ['current_amount', 'convertString'],
|
||||
'startdate' => ['start_date', 'date'],
|
||||
'targetdate' => ['target_date', 'convertString'],
|
||||
'startdate' => ['start_date', 'convertDateTime'],
|
||||
'targetdate' => ['target_date', 'convertDateTime'],
|
||||
'notes' => ['notes', 'stringWithNewlines'],
|
||||
'order' => ['order', 'convertInteger'],
|
||||
'object_group_title' => ['object_group_title', 'convertString'],
|
||||
|
@ -57,8 +57,8 @@ class StoreRequest extends FormRequest
|
||||
'type' => ['type', 'convertString'],
|
||||
'title' => ['title', 'convertString'],
|
||||
'description' => ['description', 'convertString'],
|
||||
'first_date' => ['first_date', 'date'],
|
||||
'repeat_until' => ['repeat_until', 'date'],
|
||||
'first_date' => ['first_date', 'convertDateTime'],
|
||||
'repeat_until' => ['repeat_until', 'convertDateTime'],
|
||||
'nr_of_repetitions' => ['nr_of_repetitions', 'convertInteger'],
|
||||
'apply_rules' => ['apply_rules', 'boolean'],
|
||||
'active' => ['active', 'boolean'],
|
||||
|
@ -58,8 +58,8 @@ class UpdateRequest extends FormRequest
|
||||
$fields = [
|
||||
'title' => ['title', 'convertString'],
|
||||
'description' => ['description', 'convertString'],
|
||||
'first_date' => ['first_date', 'date'],
|
||||
'repeat_until' => ['repeat_until', 'date'],
|
||||
'first_date' => ['first_date', 'convertDateTime'],
|
||||
'repeat_until' => ['repeat_until', 'convertDateTime'],
|
||||
'nr_of_repetitions' => ['nr_of_repetitions', 'convertInteger'],
|
||||
'apply_rules' => ['apply_rules', 'boolean'],
|
||||
'active' => ['active', 'boolean'],
|
||||
|
@ -86,7 +86,7 @@ class PiggyBank extends Model
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
@ -394,7 +394,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
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]) {
|
||||
$data[$field] = 1;
|
||||
}
|
||||
if($data[$field] instanceof Carbon) {
|
||||
$data[$field] = $data[$field]->toAtomString();
|
||||
}
|
||||
|
||||
$factory->crud($account, $field, (string)$data[$field]);
|
||||
}
|
||||
|
@ -296,6 +296,7 @@ class AccountUpdateService
|
||||
$type = $account->accountType;
|
||||
if (in_array($type->type, $this->canHaveOpeningBalance, true)) {
|
||||
// check if is submitted as empty, that makes it valid:
|
||||
|
||||
if ($this->validOBData($data) && !$this->isEmptyOBData($data)) {
|
||||
$openingBalance = $data['opening_balance'];
|
||||
$openingBalanceDate = $data['opening_balance_date'];
|
||||
@ -306,7 +307,6 @@ class AccountUpdateService
|
||||
$openingBalance
|
||||
);
|
||||
}
|
||||
|
||||
$this->updateOBGroupV2($account, $openingBalance, $openingBalanceDate);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Support\Request;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Carbon\Exceptions\InvalidDateException;
|
||||
use Carbon\Exceptions\InvalidFormatException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@ -255,6 +256,44 @@ trait ConvertsDataTypes
|
||||
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,
|
||||
* 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');
|
||||
}
|
||||
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];
|
||||
@ -233,7 +239,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
$openingBalanceDate = $this->repository->getOpeningBalanceDate($account);
|
||||
}
|
||||
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];
|
||||
|
@ -103,9 +103,8 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
$leftToSave = app('steam')->bcround($leftToSave, $currency->decimal_places);
|
||||
$savePerMonth = app('steam')->bcround($this->piggyRepos->getSuggestedMonthlyAmount($piggyBank), $currency->decimal_places);
|
||||
}
|
||||
$startDate = $piggyBank->startdate?->toAtomString();
|
||||
$targetDate = $piggyBank->targetdate?->toAtomString();
|
||||
|
||||
$startDate = $piggyBank->startdate?->format('Y-m-d');
|
||||
$targetDate = $piggyBank->targetdate?->format('Y-m-d');
|
||||
|
||||
return [
|
||||
'id' => (string)$piggyBank->id,
|
||||
|
@ -92,9 +92,9 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
'type' => $shortType,
|
||||
'title' => $recurrence->title,
|
||||
'description' => $recurrence->description,
|
||||
'first_date' => $recurrence->first_date->toAtomString(),
|
||||
'latest_date' => $recurrence->latest_date?->toAtomString(),
|
||||
'repeat_until' => $recurrence->repeat_until?->toAtomString(),
|
||||
'first_date' => $recurrence->first_date->format('Y-m-d'),
|
||||
'latest_date' => $recurrence->latest_date?->format('Y-m-d'),
|
||||
'repeat_until' => $recurrence->repeat_until?->format('Y-m-d'),
|
||||
'apply_rules' => $recurrence->apply_rules,
|
||||
'active' => $recurrence->active,
|
||||
'nr_of_repetitions' => $reps,
|
||||
|
@ -42,7 +42,7 @@ class TagTransformer extends AbstractTransformer
|
||||
*/
|
||||
public function transform(Tag $tag): array
|
||||
{
|
||||
$date = $tag->date?->toAtomString();
|
||||
$date = $tag->date?->format('Y-m-d');
|
||||
/** @var Location $location */
|
||||
$location = $tag->locations()->first();
|
||||
$latitude = null;
|
||||
|
@ -108,7 +108,7 @@ return [
|
||||
'handle_debts' => true,
|
||||
],
|
||||
'version' => '6.0.10',
|
||||
'api_version' => '2.0.1',
|
||||
'api_version' => '2.0.2',
|
||||
'db_version' => 19,
|
||||
|
||||
// generic settings
|
||||
|
Loading…
Reference in New Issue
Block a user