mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various code cleanup and fixed alignments.
This commit is contained in:
@@ -54,14 +54,9 @@ class MigrateRecurrenceType extends Command
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$this->friendlyWarning('This command has been disabled.');
|
$this->friendlyWarning('This command has been disabled.');
|
||||||
|
$this->markAsExecuted();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
// $this->migrateTypes();
|
|
||||||
// $this->markAsExecuted();
|
|
||||||
//
|
|
||||||
// return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isExecuted(): bool
|
private function isExecuted(): bool
|
||||||
@@ -71,37 +66,6 @@ class MigrateRecurrenceType extends Command
|
|||||||
return (bool)$configVar?->data;
|
return (bool)$configVar?->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function migrateTypes(): void
|
|
||||||
{
|
|
||||||
$set = Recurrence::get();
|
|
||||||
|
|
||||||
/** @var Recurrence $recurrence */
|
|
||||||
foreach ($set as $recurrence) {
|
|
||||||
if (TransactionType::INVALID !== $recurrence->transactionType->type) {
|
|
||||||
$this->migrateRecurrence($recurrence);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function migrateRecurrence(Recurrence $recurrence): void
|
|
||||||
{
|
|
||||||
$originalType = $recurrence->transaction_type_id;
|
|
||||||
$newType = $this->getInvalidType();
|
|
||||||
$recurrence->transaction_type_id = $newType->id;
|
|
||||||
$recurrence->save();
|
|
||||||
|
|
||||||
/** @var RecurrenceTransaction $transaction */
|
|
||||||
foreach ($recurrence->recurrenceTransactions as $transaction) {
|
|
||||||
$transaction->transaction_type_id = $originalType;
|
|
||||||
$transaction->save();
|
|
||||||
}
|
|
||||||
$this->friendlyInfo(sprintf('Updated recurrence #%d to new transaction type model.', $recurrence->id));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getInvalidType(): TransactionType
|
|
||||||
{
|
|
||||||
return TransactionType::whereType(TransactionType::INVALID)->firstOrCreate(['type' => TransactionType::INVALID]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function markAsExecuted(): void
|
private function markAsExecuted(): void
|
||||||
{
|
{
|
||||||
|
@@ -681,7 +681,7 @@ trait MetaCollection
|
|||||||
// this method adds a "postFilter" to the collector.
|
// this method adds a "postFilter" to the collector.
|
||||||
$list = $tags->pluck('tag')->toArray();
|
$list = $tags->pluck('tag')->toArray();
|
||||||
$list = array_map('strtolower', $list);
|
$list = array_map('strtolower', $list);
|
||||||
$filter = static function (array $object) use ($list): bool | array {
|
$filter = static function (array $object) use ($list): bool|array {
|
||||||
$return = $object;
|
$return = $object;
|
||||||
unset($return['transactions']);
|
unset($return['transactions']);
|
||||||
$return['transactions'] = [];
|
$return['transactions'] = [];
|
||||||
@@ -712,6 +712,7 @@ trait MetaCollection
|
|||||||
if (true === $result) {
|
if (true === $result) {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
$this->postFilters[] = $filter;
|
$this->postFilters[] = $filter;
|
||||||
|
@@ -561,7 +561,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
if (0 !== count($journalIds)) {
|
if (0 !== count($journalIds)) {
|
||||||
// make all integers.
|
// make all integers.
|
||||||
$integerIDs = array_map('intval', $journalIds);
|
$integerIDs = array_map('intval', $journalIds);
|
||||||
Log::debug(sprintf('GroupCollector: setJournalIds: %s', join(', ', $integerIDs)));
|
Log::debug(sprintf('GroupCollector: setJournalIds: %s', implode(', ', $integerIDs)));
|
||||||
|
|
||||||
$this->query->whereIn('transaction_journals.id', $integerIDs);
|
$this->query->whereIn('transaction_journals.id', $integerIDs);
|
||||||
}
|
}
|
||||||
|
@@ -60,6 +60,7 @@ class RecurrenceController extends Controller
|
|||||||
* Shows all events for a repetition. Used in calendar.
|
* Shows all events for a repetition. Used in calendar.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||||
*
|
*
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
@@ -126,7 +127,7 @@ class RecurrenceController extends Controller
|
|||||||
foreach ($occurrences as $current) {
|
foreach ($occurrences as $current) {
|
||||||
if ($current->gte($start)) {
|
if ($current->gte($start)) {
|
||||||
$event = [
|
$event = [
|
||||||
'id' => $repetitionType . $firstDate->format('Ymd'),
|
'id' => $repetitionType.$firstDate->format('Ymd'),
|
||||||
'title' => 'X',
|
'title' => 'X',
|
||||||
'allDay' => true,
|
'allDay' => true,
|
||||||
'start' => $current->format('Y-m-d'),
|
'start' => $current->format('Y-m-d'),
|
||||||
|
@@ -75,9 +75,8 @@ class BudgetFormStoreRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function withValidator(Validator $validator): void
|
public function withValidator(Validator $validator): void
|
||||||
{
|
{
|
||||||
|
|
||||||
if($validator->fails()) {
|
if($validator->fails()) {
|
||||||
Log::channel('audit')->error(sprintf('Validation errors for budget'), $validator->errors()->toArray());
|
Log::channel('audit')->error('Validation errors for budget', $validator->errors()->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
$validator->after(
|
$validator->after(
|
||||||
|
Reference in New Issue
Block a user