Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
16.67% |
1 / 6 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| SincronizarPresupuestos | |
16.67% |
1 / 6 |
|
50.00% |
1 / 2 |
8.21 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| handle | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Console\Commands; |
| 4 | |
| 5 | use App\Services\PresupuestosService; |
| 6 | use Illuminate\Console\Command; |
| 7 | |
| 8 | class SincronizarPresupuestos extends Command |
| 9 | { |
| 10 | protected $signature = 'presupuestos:sincronizar {fecha?}'; |
| 11 | |
| 12 | protected $description = 'Sincroniza los presupuestos con Gestiona.'; |
| 13 | |
| 14 | public function __construct(protected PresupuestosService $presupuestosService) |
| 15 | { |
| 16 | parent::__construct(); |
| 17 | } |
| 18 | |
| 19 | public function handle(): void |
| 20 | { |
| 21 | $fecha = $this->argument('fecha') ?? now()->toDateString(); |
| 22 | $result = $this->presupuestosService->syncByDate($fecha); |
| 23 | |
| 24 | if ($result['success']) { |
| 25 | $this->info($result['message']); |
| 26 | } else { |
| 27 | $this->error($result['error']); |
| 28 | } |
| 29 | } |
| 30 | } |