mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 10:47:00 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			76 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			76 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| 
 | |
| /*
 | |
|  * UpgradesNativeAmounts.php
 | |
|  * Copyright (c) 2025 james@firefly-iii.org.
 | |
|  *
 | |
|  * This file is part of Firefly III (https://github.com/firefly-iii).
 | |
|  *
 | |
|  * This program is free software: you can redistribute it and/or modify
 | |
|  * it under the terms of the GNU Affero General Public License as
 | |
|  * published by the Free Software Foundation, either version 3 of the
 | |
|  * License, or (at your option) any later version.
 | |
|  *
 | |
|  * This program is distributed in the hope that it will be useful,
 | |
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | |
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | |
|  * GNU Affero General Public License for more details.
 | |
|  *
 | |
|  * You should have received a copy of the GNU Affero General Public License
 | |
|  * along with this program.  If not, see https://www.gnu.org/licenses/.
 | |
|  */
 | |
| 
 | |
| declare(strict_types=1);
 | |
| 
 | |
| 
 | |
| namespace FireflyIII\Console\Commands\Upgrade;
 | |
| 
 | |
| use FireflyIII\Console\Commands\ShowsFriendlyMessages;
 | |
| use Illuminate\Console\Command;
 | |
| use Illuminate\Support\Facades\Artisan;
 | |
| 
 | |
| class UpgradesNativeAmounts extends Command
 | |
| {
 | |
|     use ShowsFriendlyMessages;
 | |
|     public const string CONFIG_NAME = '620_native_amounts';
 | |
| 
 | |
|     protected $description          = 'Runs the native amounts calculations.';
 | |
| 
 | |
|     protected $signature            = 'upgrade:620-native-amounts {--F|force : Force the execution of this command.}';
 | |
| 
 | |
|     /**
 | |
|      * Execute the console command.
 | |
|      */
 | |
|     public function handle(): int
 | |
|     {
 | |
|         if ($this->isExecuted() && true !== $this->option('force')) {
 | |
|             $this->friendlyInfo('This command has already been executed.');
 | |
| 
 | |
|             return 0;
 | |
|         }
 | |
| 
 | |
|         Artisan::call('correction:recalculate-native-amounts');
 | |
| 
 | |
|         $this->markAsExecuted();
 | |
| 
 | |
| 
 | |
|         return 0;
 | |
|     }
 | |
| 
 | |
|     private function isExecuted(): bool
 | |
|     {
 | |
|         $configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
 | |
|         if (null !== $configVar) {
 | |
|             return (bool)$configVar->data;
 | |
|         }
 | |
| 
 | |
|         return false;
 | |
|     }
 | |
| 
 | |
|     private function markAsExecuted(): void
 | |
|     {
 | |
|         app('fireflyconfig')->set(self::CONFIG_NAME, true);
 | |
|     }
 | |
| }
 |