Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
6.45% covered (danger)
6.45%
2 / 31
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Kernel
6.45% covered (danger)
6.45%
2 / 31
50.00% covered (danger)
50.00%
1 / 2
17.10
0.00% covered (danger)
0.00%
0 / 1
 schedule
0.00% covered (danger)
0.00%
0 / 29
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('invoices:call-center')->dailyAt('18:00');
43
44        $schedule->command('quotations:sync-missing')->dailyAt('06:01');
45
46        $schedule->command('administrators-invoices:sync')
47             ->dailyAt('11:00')
48             ->when(function () {
49                 $today = Carbon::today();
50                 
51                 if ($today->isWeekend()) {
52                     return false; 
53                 }
54                 
55                 $firstDayOfMonth = Carbon::parse($today->year . '-' . $today->month . '-01');
56                 
57                 $firstWorkDayOfMonth = $firstDayOfMonth;
58                 while ($firstWorkDayOfMonth->isWeekend()) {
59                     $firstWorkDayOfMonth->addDay();
60                 }
61                 
62                 return $today->toDateString() === $firstWorkDayOfMonth->toDateString();
63             });
64    }
65
66    /**
67     * Register the commands for the application.
68     *
69     * @return void
70     */
71    protected function commands()
72    {
73        $this->load(__DIR__.'/Commands');
74
75        require base_path('routes/console.php');
76    }
77}