Skip to content

Commit

Permalink
fixed repo
Browse files Browse the repository at this point in the history
  • Loading branch information
munyanezaarmel authored and dmohns committed Nov 27, 2024
1 parent e2a0309 commit 5a1765a
Show file tree
Hide file tree
Showing 1,466 changed files with 6,081 additions and 11,528 deletions.
9 changes: 3 additions & 6 deletions src/backend/app/Console/Commands/AbstractSharedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

abstract class AbstractSharedCommand extends Command
{
abstract class AbstractSharedCommand extends Command {
protected const EXECUTE_FOR_ONE = 1;
protected const EXECUTE_FOR_ALL = 0;

Expand All @@ -19,8 +18,7 @@ abstract class AbstractSharedCommand extends Command
/**
* Configure the command.
*/
protected function configure(): void
{
protected function configure(): void {
parent::configure();

$this->addOption(
Expand All @@ -31,8 +29,7 @@ protected function configure(): void
);
}

protected function execute(InputInterface $input, OutputInterface $output)
{
protected function execute(InputInterface $input, OutputInterface $output) {
/** @var DatabaseProxyManagerService $databaseProxyManagerService */
$databaseProxyManagerService = app()->make(DatabaseProxyManagerService::class);

Expand Down
6 changes: 2 additions & 4 deletions src/backend/app/Console/Commands/AccessRateChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
use App\Models\AccessRate\AccessRatePayment;
use Carbon\Carbon;

class AccessRateChecker extends AbstractSharedCommand
{
class AccessRateChecker extends AbstractSharedCommand {
protected $signature = 'accessrate:check';
protected $description = 'Updates the "debt" field, based on "due_date" field';

public function runInCompanyScope(): void
{
public function runInCompanyScope(): void {
// get all access-rate payments where due Date is <= today
$accessRatePayments = AccessRatePayment::where('due_date', '<=', Carbon::now())->get();

Expand Down
9 changes: 3 additions & 6 deletions src/backend/app/Console/Commands/AddMeterAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@
use App\Models\Address\Address;
use App\Models\Meter\MeterParameter;

class AddMeterAddress extends AbstractSharedCommand
{
class AddMeterAddress extends AbstractSharedCommand {
protected $signature = 'meters:addAddress';
protected $description = 'Creates an address entry for all every registered meter. Sets them all to village 1';

public function __construct(private MeterParameter $meterParameter, private Address $address)
{
public function __construct(private MeterParameter $meterParameter, private Address $address) {
parent::__construct();
}

public function runInCompanyScope(): void
{
public function runInCompanyScope(): void {
$usedMeters = $this->meterParameter::all();

foreach ($usedMeters as $meter) {
Expand Down
9 changes: 3 additions & 6 deletions src/backend/app/Console/Commands/AddPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@

use App\Services\PluginsService;

class AddPlugin extends AbstractSharedCommand
{
class AddPlugin extends AbstractSharedCommand {
protected $signature = 'plugin:add {name} {composer_name} {description}';
protected $description = 'Plugin Details adding to database';

public function __construct(private PluginsService $pluginsService)
{
public function __construct(private PluginsService $pluginsService) {
parent::__construct();
}

public function runInCompanyScope(): void
{
public function runInCompanyScope(): void {
$name = $this->argument('name');
$composer_name = $this->argument('composer_name');
$description = $this->argument('description');
Expand Down
9 changes: 3 additions & 6 deletions src/backend/app/Console/Commands/AdminPasswordResetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@

use App\Services\UserService;

class AdminPasswordResetter extends AbstractSharedCommand
{
class AdminPasswordResetter extends AbstractSharedCommand {
protected $signature = 'reset:admin-password';
protected $description = 'Reset forgotten password';

public function __construct(private UserService $userService)
{
public function __construct(private UserService $userService) {
parent::__construct();
}

public function runInCompanyScope(): void
{
public function runInCompanyScope(): void {
$admin = $this->userService->resetAdminPassword();
$this->alert('
Please use following credentials to login:
Expand Down
24 changes: 8 additions & 16 deletions src/backend/app/Console/Commands/AssetRateChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
use Inensus\Ticket\Models\TicketCategory;
use Inensus\Ticket\Services\TicketService;

class AssetRateChecker extends AbstractSharedCommand
{
class AssetRateChecker extends AbstractSharedCommand {
protected $signature = 'asset-rate:check';
protected $description = 'Checks if any asset rate is due and creates a ticket and reminds the customer';

Expand All @@ -29,14 +28,12 @@ public function __construct(
parent::__construct();
}

public function handle(): void
{
public function handle(): void {
$this->remindUpComingRates();
$this->findOverDueRates();
}

private function remindUpComingRates(): void
{
private function remindUpComingRates(): void {
$smsApplianceRemindRates = $this->getApplianceRemindRates();
$smsApplianceRemindRates->each(function ($smsApplianceRemindRate) {
$dueAssetRates = $this->assetRate::with([
Expand All @@ -60,8 +57,7 @@ function ($q) {
});
}

private function findOverDueRates(): void
{
private function findOverDueRates(): void {
$smsApplianceRemindRates = $this->getApplianceRemindRates();
$smsApplianceRemindRates->each(function ($smsApplianceRemindRate) {
$overDueRates = $this->assetRate::with(['assetPerson.asset', 'assetPerson.person.addresses'])
Expand All @@ -78,14 +74,12 @@ private function findOverDueRates(): void
});
}

private function sendReminderSms(AssetRate $assetRate): void
{
private function sendReminderSms(AssetRate $assetRate): void {
$smsService = app()->make(SmsService::class);
$smsService->sendSms($assetRate, SmsTypes::APPLIANCE_RATE, SmsConfigs::class);
}

private function sendReminders($dueAssetRates, $smsType)
{
private function sendReminders($dueAssetRates, $smsType) {
$dueAssetRates->each(function ($dueAssetRate) use ($smsType) {
$this->sendReminderSms($dueAssetRate);
if ($smsType === SmsTypes::OVER_DUE_APPLIANCE_RATE) {
Expand All @@ -96,8 +90,7 @@ private function sendReminders($dueAssetRates, $smsType)
});
}

private function createReminderTicket(AssetRate $assetRate, $overDue = false): void
{
private function createReminderTicket(AssetRate $assetRate, $overDue = false): void {
$currency = $this->mainSettingsService->getAll()->first()->currency;
// create ticket for customer service
$creator = $this->user->newQuery()->firstOrCreate([
Expand Down Expand Up @@ -127,8 +120,7 @@ private function createReminderTicket(AssetRate $assetRate, $overDue = false): v
);
}

private function getApplianceRemindRates(): Collection|array
{
private function getApplianceRemindRates(): Collection|array {
return $this->smsApplianceRemindRateService->getApplianceRemindRates();
}
}
6 changes: 2 additions & 4 deletions src/backend/app/Console/Commands/BackupFull.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@

use Illuminate\Console\Command;

class BackupFull extends Command
{
class BackupFull extends Command {
protected $signature = 'backup:full';
protected $description = 'Run the backup for core base database and all tenant databases';

public function handle(): void
{
public function handle(): void {
$this->info('Starting backup for core database');
config(['database.connections.mysql' => config('database.connections.micro_power_manager')]);
$this->call('backup:run', [
Expand Down
6 changes: 2 additions & 4 deletions src/backend/app/Console/Commands/BackupTenantDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

namespace App\Console\Commands;

class BackupTenantDatabase extends AbstractSharedCommand
{
class BackupTenantDatabase extends AbstractSharedCommand {
protected $signature = 'backup-tenant:run';
protected $description = 'Run the backup for provided tenant database(s)';

public function handle()
{
public function handle() {
$databaseName = config('database.connections.shard');
$this->info('Starting backup for tenant databases');
dump($this->arguments());
Expand Down
9 changes: 3 additions & 6 deletions src/backend/app/Console/Commands/CalinMeterReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@
* Reads the daily consumptions of meters
* Class CalinMeterReader.
*/
class CalinMeterReader extends AbstractSharedCommand
{
class CalinMeterReader extends AbstractSharedCommand {
protected $signature = 'calinMeters:readOnline';

public function __construct(private Meter $meter, private CalinReadMeter $calinReadMeter)
{
public function __construct(private Meter $meter, private CalinReadMeter $calinReadMeter) {
parent::__construct();
}

public function runInCompanyScope(): void
{
public function runInCompanyScope(): void {
$meters = $this->meter::whereHas(
'meterType',
function ($q) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

use App\Services\ClustersDashboardCacheDataService;

class ClustersDashboardCacheDataGenerator extends AbstractSharedCommand
{
class ClustersDashboardCacheDataGenerator extends AbstractSharedCommand {
protected $signature = 'update:cachedClustersDashboardData';
protected $description = 'Update Clusters Dashboard Data';

Expand All @@ -15,8 +14,7 @@ public function __construct(
parent::__construct();
}

public function handle(): void
{
public function handle(): void {
$this->clustersDashboardCacheDataService->setData();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
use Illuminate\Support\Facades\DB;
use MPM\DatabaseProxy\DatabaseProxyManagerService;

class CreateDummyCompanyWithData extends Command
{
class CreateDummyCompanyWithData extends Command {
public const SQL_DUMMY_DATA_FILE_NAMES = [
'dummy_agent_data.sql',
'dummy_data.sql',
Expand Down Expand Up @@ -42,8 +41,7 @@ public function __construct(
parent::__construct();
}

public function handle()
{
public function handle() {
try {
foreach (self::SQL_DUMMY_DATA_FILE_NAMES as $sqlFile) {
$path = __DIR__.'/../../../database/dummyData/'.$sqlFile;
Expand All @@ -63,8 +61,7 @@ public function handle()
}
}

private function importSqlDump($path, $databaseName)
{
private function importSqlDump($path, $databaseName) {
try {
DB::select("USE $databaseName");
$sql = file_get_contents($path);
Expand Down
18 changes: 6 additions & 12 deletions src/backend/app/Console/Commands/DummyDataCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
use Inensus\WavecomPaymentProvider\Models\WaveComTransaction;
use Inensus\WaveMoneyPaymentProvider\Models\WaveMoneyTransaction;

class DummyDataCreator extends AbstractSharedCommand
{
class DummyDataCreator extends AbstractSharedCommand {
protected $signature = 'dummy:create-data {amount} {--company-id=} {--type=}';
protected $description = 'creates dummy data for demo company';

Expand Down Expand Up @@ -61,8 +60,7 @@ public function __construct(
parent::__construct();
}

public function handle()
{
public function handle() {
$companyId = $this->option('company-id');
$type = $this->option('type') ?? 'transaction';
$amount = $this->argument('amount');
Expand Down Expand Up @@ -90,8 +88,7 @@ public function handle()
}
}

private function generateTransaction(): void
{
private function generateTransaction(): void {
try {
// get randomly a user
$randomMeter = $this->meter::inRandomOrder()->with([
Expand Down Expand Up @@ -287,13 +284,11 @@ private function generateTransaction(): void
}
}

private function getTransactionTypeRandomlyFromTransactionTypes()
{
private function getTransactionTypeRandomlyFromTransactionTypes() {
return $this->transactionTypes[array_rand($this->transactionTypes)];
}

private function generateTicket()
{
private function generateTicket() {
$randomCategory = $this->ticketCategory->newQuery()->inRandomOrder()->first();
$fakeSentence = $this->generateFakeSentence();
$randomCreator = $this->user->inRandomOrder()->first();
Expand Down Expand Up @@ -341,8 +336,7 @@ private function generateTicket()
}
}

private function generateFakeSentence($minWords = 5, $maxWords = 15)
{
private function generateFakeSentence($minWords = 5, $maxWords = 15) {
$loremIpsum =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';
$words = explode(' ', $loremIpsum);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@
use Illuminate\Support\Facades\Log;
use MPM\CustomBulkRegistration\Ecosys\CustomerDatabaseParser;

class EcosysCustomerDatabaseParser extends AbstractSharedCommand
{
class EcosysCustomerDatabaseParser extends AbstractSharedCommand {
// --company-id=36
protected $signature = 'ecosys:db-file-parser {--company-id=}';
protected $description = 'custom database file parser for ecosys';

public function __construct(private CustomerDatabaseParser $customerDatabaseParser)
{
public function __construct(private CustomerDatabaseParser $customerDatabaseParser) {
parent::__construct();
}

public function handle(): void
{
public function handle(): void {
$this->info('Command started');
Log::info('command running w '.$this->option('company-id'));
$result = $this->customerDatabaseParser->insertFromCsv();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
use App\Services\ApplianceRateService;
use MPM\OutstandingDebts\OutstandingDebtsExportService;

class MailApplianceDebtsCommand extends AbstractSharedCommand
{
class MailApplianceDebtsCommand extends AbstractSharedCommand {
protected $signature = 'mail:appliance-debts';

protected $description = 'Send mail to customers with appliance debts';

public function handle(ApplianceRateService $applianceRateService, OutstandingDebtsExportService $outstandingDebtsExportService): void
{
public function handle(ApplianceRateService $applianceRateService, OutstandingDebtsExportService $outstandingDebtsExportService): void {
$applianceDebtHavingCustomerCount = $applianceRateService->queryOutstandingDebtsByApplianceRates()->count();
// do not send mail if there is no customer with appliance debt
if ($applianceDebtHavingCustomerCount > 0) {
Expand Down
Loading

0 comments on commit 5a1765a

Please sign in to comment.