-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
461 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
/* | ||
* Author: Raul Perusquia <raul@inikoo.com> | ||
* Created: Fri, 03 Jan 2025 23:34:09 Malaysia Time, Kuala Lumpur, Malaysia | ||
* Copyright (c) 2025, Raul A Perusquia Flores | ||
*/ | ||
|
||
namespace App\Actions\Helpers\Intervals; | ||
|
||
use App\Actions\Catalogue\Shop\Hydrators\ShopHydrateSales; | ||
use App\Actions\SysAdmin\Group\Hydrators\GroupHydrateSales; | ||
use App\Actions\SysAdmin\Organisation\Hydrators\OrganisationHydrateSales; | ||
use App\Enums\DateIntervals\DateIntervalEnum; | ||
use App\Enums\SysAdmin\Organisation\OrganisationTypeEnum; | ||
use App\Models\Catalogue\Shop; | ||
use App\Models\SysAdmin\Group; | ||
use App\Models\SysAdmin\Organisation; | ||
use Lorisleiva\Actions\Concerns\AsAction; | ||
|
||
class ResetDailyIntervals | ||
{ | ||
use AsAction; | ||
|
||
protected string $signature = 'intervals:reset-day'; | ||
protected string $description = 'Reset day intervals'; | ||
|
||
|
||
public function handle(): void | ||
{ | ||
$this->resetDailyGroups(); | ||
$this->resetDailyOrganisations(); | ||
$this->resetDailyShops(); | ||
} | ||
|
||
|
||
protected function resetDailyGroups(): void | ||
{ | ||
foreach (Group::all() as $group) { | ||
GroupHydrateSales::dispatch( | ||
group: $group, | ||
intervals: [ | ||
DateIntervalEnum::YESTERDAY, | ||
DateIntervalEnum::TODAY | ||
], | ||
doPreviousPeriods: [] | ||
); | ||
} | ||
} | ||
|
||
protected function resetDailyOrganisations(): void | ||
{ | ||
foreach (Organisation::whereNot('type', OrganisationTypeEnum::AGENT)->get() as $organisation) { | ||
OrganisationHydrateSales::dispatch( | ||
organisation: $organisation, | ||
intervals: [ | ||
DateIntervalEnum::YESTERDAY, | ||
DateIntervalEnum::TODAY | ||
], | ||
doPreviousPeriods: [] | ||
); | ||
} | ||
} | ||
|
||
protected function resetDailyShops(): void | ||
{ | ||
foreach (Shop::all() as $shop) { | ||
ShopHydrateSales::dispatch( | ||
shop: $shop, | ||
intervals: [ | ||
DateIntervalEnum::YESTERDAY, | ||
DateIntervalEnum::TODAY | ||
], | ||
doPreviousPeriods: [] | ||
); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
/* | ||
* Author: Raul Perusquia <raul@inikoo.com> | ||
* Created: Sat, 04 Jan 2025 00:00:58 Malaysia Time, Kuala Lumpur, Malaysia | ||
* Copyright (c) 2025, Raul A Perusquia Flores | ||
*/ | ||
|
||
namespace App\Actions\Helpers\Intervals; | ||
|
||
use App\Actions\Catalogue\Shop\Hydrators\ShopHydrateSales; | ||
use App\Actions\SysAdmin\Group\Hydrators\GroupHydrateSales; | ||
use App\Actions\SysAdmin\Organisation\Hydrators\OrganisationHydrateSales; | ||
use App\Enums\DateIntervals\DateIntervalEnum; | ||
use App\Enums\SysAdmin\Organisation\OrganisationTypeEnum; | ||
use App\Models\Catalogue\Shop; | ||
use App\Models\SysAdmin\Group; | ||
use App\Models\SysAdmin\Organisation; | ||
use Lorisleiva\Actions\Concerns\AsAction; | ||
|
||
class ResetMonthlyIntervals | ||
{ | ||
use AsAction; | ||
|
||
protected string $signature = 'intervals:reset-month'; | ||
protected string $description = 'Reset monthly intervals'; | ||
|
||
|
||
public function handle(): void | ||
{ | ||
$this->resetMonthlyGroups(); | ||
$this->resetMonthlyOrganisations(); | ||
|
||
|
||
$this->resetMonthlyShops(); | ||
} | ||
|
||
|
||
protected function resetMonthlyGroups(): void | ||
{ | ||
foreach (Group::all() as $group) { | ||
GroupHydrateSales::dispatch( | ||
group: $group, | ||
intervals: [ | ||
DateIntervalEnum::LAST_MONTH, | ||
DateIntervalEnum::MONTH_TO_DAY | ||
], | ||
doPreviousPeriods: [] | ||
); | ||
} | ||
} | ||
|
||
protected function resetMonthlyOrganisations(): void | ||
{ | ||
foreach (Organisation::whereNot('type', OrganisationTypeEnum::AGENT)->get() as $organisation) { | ||
OrganisationHydrateSales::dispatch( | ||
organisation: $organisation, | ||
intervals: [ | ||
DateIntervalEnum::LAST_MONTH, | ||
DateIntervalEnum::MONTH_TO_DAY | ||
], | ||
doPreviousPeriods: [] | ||
); | ||
} | ||
} | ||
|
||
protected function resetMonthlyShops(): void | ||
{ | ||
foreach (Shop::all() as $shop) { | ||
ShopHydrateSales::dispatch( | ||
shop: $shop, | ||
intervals: [ | ||
DateIntervalEnum::LAST_MONTH, | ||
DateIntervalEnum::MONTH_TO_DAY | ||
], | ||
doPreviousPeriods: [] | ||
); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
/* | ||
* Author: Raul Perusquia <raul@inikoo.com> | ||
* Created: Fri, 03 Jan 2025 17:46:17 Malaysia Time, Kuala Lumpur, Malaysia | ||
* Copyright (c) 2025, Raul A Perusquia Flores | ||
*/ | ||
|
||
namespace App\Actions\Helpers\Intervals; | ||
|
||
use App\Actions\Catalogue\Shop\Hydrators\ShopHydrateSales; | ||
use App\Actions\SysAdmin\Group\Hydrators\GroupHydrateSales; | ||
use App\Actions\SysAdmin\Organisation\Hydrators\OrganisationHydrateSales; | ||
use App\Enums\DateIntervals\DateIntervalEnum; | ||
use App\Enums\SysAdmin\Organisation\OrganisationTypeEnum; | ||
use App\Models\Catalogue\Shop; | ||
use App\Models\SysAdmin\Group; | ||
use App\Models\SysAdmin\Organisation; | ||
use Lorisleiva\Actions\Concerns\AsAction; | ||
|
||
class ResetQuarterlyIntervals | ||
{ | ||
use AsAction; | ||
|
||
protected string $signature = 'intervals:reset-quarter'; | ||
protected string $description = 'Reset quarter intervals'; | ||
|
||
|
||
public function handle(): void | ||
{ | ||
$this->resetQuarterlyGroups(); | ||
$this->resetQuarterlyOrganisations(); | ||
$this->resetQuarterlyShops(); | ||
} | ||
|
||
|
||
protected function resetQuarterlyGroups(): void | ||
{ | ||
foreach (Group::all() as $group) { | ||
GroupHydrateSales::dispatch( | ||
group: $group, | ||
intervals: [ | ||
DateIntervalEnum::QUARTER_TO_DAY | ||
], | ||
doPreviousPeriods: ['previous_quarters'] | ||
); | ||
} | ||
} | ||
|
||
protected function resetQuarterlyOrganisations(): void | ||
{ | ||
foreach (Organisation::whereNot('type', OrganisationTypeEnum::AGENT)->get() as $organisation) { | ||
OrganisationHydrateSales::dispatch( | ||
organisation: $organisation, | ||
intervals: [ | ||
DateIntervalEnum::QUARTER_TO_DAY | ||
], | ||
doPreviousPeriods: ['previous_quarters'] | ||
); | ||
} | ||
} | ||
|
||
protected function resetQuarterlyShops(): void | ||
{ | ||
foreach (Shop::all() as $shop) { | ||
ShopHydrateSales::dispatch( | ||
shop: $shop, | ||
intervals: [ | ||
DateIntervalEnum::QUARTER_TO_DAY | ||
], | ||
doPreviousPeriods: ['previous_quarters'] | ||
); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
/* | ||
* Author: Raul Perusquia <raul@inikoo.com> | ||
* Created: Sat, 04 Jan 2025 00:45:24 Malaysia Time, Kuala Lumpur, Malaysia | ||
* Copyright (c) 2025, Raul A Perusquia Flores | ||
*/ | ||
|
||
namespace App\Actions\Helpers\Intervals; | ||
|
||
use App\Actions\Catalogue\Shop\Hydrators\ShopHydrateSales; | ||
use App\Actions\SysAdmin\Group\Hydrators\GroupHydrateSales; | ||
use App\Actions\SysAdmin\Organisation\Hydrators\OrganisationHydrateSales; | ||
use App\Enums\DateIntervals\DateIntervalEnum; | ||
use App\Enums\SysAdmin\Organisation\OrganisationTypeEnum; | ||
use App\Models\Catalogue\Shop; | ||
use App\Models\SysAdmin\Group; | ||
use App\Models\SysAdmin\Organisation; | ||
use Lorisleiva\Actions\Concerns\AsAction; | ||
|
||
class ResetWeeklyIntervals | ||
{ | ||
use AsAction; | ||
|
||
protected string $signature = 'intervals:reset-week'; | ||
protected string $description = 'Reset weekly intervals'; | ||
|
||
|
||
public function handle(): void | ||
{ | ||
$this->resetWeeklyGroups(); | ||
$this->resetWeeklyOrganisations(); | ||
|
||
|
||
$this->resetWeeklyShops(); | ||
} | ||
|
||
|
||
protected function resetWeeklyGroups(): void | ||
{ | ||
foreach (Group::all() as $group) { | ||
GroupHydrateSales::dispatch( | ||
group: $group, | ||
intervals: [ | ||
DateIntervalEnum::LAST_WEEK, | ||
DateIntervalEnum::WEEK_TO_DAY | ||
], | ||
doPreviousPeriods: [] | ||
); | ||
} | ||
} | ||
|
||
protected function resetWeeklyOrganisations(): void | ||
{ | ||
foreach (Organisation::whereNot('type', OrganisationTypeEnum::AGENT)->get() as $organisation) { | ||
OrganisationHydrateSales::dispatch( | ||
organisation: $organisation, | ||
intervals: [ | ||
DateIntervalEnum::LAST_WEEK, | ||
DateIntervalEnum::WEEK_TO_DAY | ||
], | ||
doPreviousPeriods: [] | ||
); | ||
} | ||
} | ||
|
||
protected function resetWeeklyShops(): void | ||
{ | ||
foreach (Shop::all() as $shop) { | ||
ShopHydrateSales::dispatch( | ||
shop: $shop, | ||
intervals: [ | ||
DateIntervalEnum::LAST_WEEK, | ||
DateIntervalEnum::WEEK_TO_DAY | ||
], | ||
doPreviousPeriods: [] | ||
); | ||
} | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.