Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
6.67% covered (danger)
6.67%
2 / 30
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Kernel
6.67% covered (danger)
6.67%
2 / 30
50.00% covered (danger)
50.00%
1 / 2
17.01
0.00% covered (danger)
0.00%
0 / 1
 schedule
0.00% covered (danger)
0.00%
0 / 28
0.00% covered (danger)
0.00%
0 / 1
12
 commands
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Console;
4
5use App\Models\TblCompanies;
6use Illuminate\Console\Scheduling\Schedule;
7use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
8use Carbon\Carbon;
9
10class Kernel extends ConsoleKernel
11{
12    /**
13     * Define the application's command schedule.
14     *
15     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
16     * @return void
17     */
18    protected function schedule(Schedule $schedule)
19    {
20        // $schedule->command('inspire')->hourly();
21        $schedule->command('presupuestos:sincronizar')->dailyAt('03:00');
22        $schedule->command('quotations:sync')
23            ->everyFiveMinutes()
24            ->weekdays(); // from monday to friday
25
26        $schedule->command('ifex-quotations:sync')
27            ->everyFiveMinutes()
28            ->weekdays(); // from monday to friday
29
30        $schedule->command('quotations:sync')
31            ->dailyAt('22:00')
32            ->weekends(); // saturday and sunday
33
34        $schedule->command('quotations:sync-work')->weeklyOn(6, '03:00');
35
36        $schedule->command('update:commercial-numbers')->everyMinute()->when(function () {
37            return now()->minute % 3 == 0;
38        });
39
40        $schedule->command('invoices:send-reminder')->dailyAt('08:00');
41
42        $schedule->command('quotations:sync-missing')->dailyAt('06:01');
43
44        $schedule->command('administrators-invoices:sync')
45             ->dailyAt('11:00')
46             ->when(function () {
47                 $today = Carbon::today();
48                 
49                 if ($today->isWeekend()) {
50                     return false; 
51                 }
52                 
53                 $firstDayOfMonth = Carbon::parse($today->year . '-' . $today->month . '-01');
54                 
55                 $firstWorkDayOfMonth = $firstDayOfMonth;
56                 while ($firstWorkDayOfMonth->isWeekend()) {
57                     $firstWorkDayOfMonth->addDay();
58                 }
59                 
60                 return $today->toDateString() === $firstWorkDayOfMonth->toDateString();
61             });
62    }
63
64    /**
65     * Register the commands for the application.
66     *
67     * @return void
68     */
69    protected function commands()
70    {
71        $this->load(__DIR__.'/Commands');
72
73        require base_path('routes/console.php');
74    }
75}