-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add daily check for possible duplicate payments
- Loading branch information
Showing
12 changed files
with
207 additions
and
108 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
app/Console/Commands/Payments/CheckForPossibleDuplicates.php
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,69 @@ | ||
<?php | ||
|
||
namespace BB\Console\Commands\Payments; | ||
|
||
use BB\Entities\Payment; | ||
use BB\Repo\PaymentRepository; | ||
use Illuminate\Console\Command; | ||
|
||
class CheckForPossibleDuplicates extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'payments:check-for-possible-duplicates'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Users can accidentally queue up duplicate payments, this command will check for possible duplicates and alert the board to review them.'; | ||
|
||
/** @var PaymentRepository */ | ||
protected $paymentRepository; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(PaymentRepository $paymentRepository) | ||
{ | ||
parent::__construct(); | ||
|
||
$this->paymentRepository = $paymentRepository; | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$possibleDuplicates = $this->paymentRepository->getPossibleDuplicates(); | ||
if ($possibleDuplicates->isEmpty()) { | ||
return; | ||
} | ||
|
||
$this->output->title('Possible Duplicate Payments'); | ||
$this->output->text('The following users have multiple payments pending up with the same reason and amount.'); | ||
$this->output->table( | ||
['User', 'Reason', 'Amount', 'Count'], | ||
$possibleDuplicates->map(function ($payment) { | ||
return [ | ||
$payment->user->name, | ||
$payment->reason, | ||
$payment->amount, | ||
$payment->count | ||
]; | ||
})->toArray() | ||
); | ||
|
||
$this->output->text('Please review these payments and ensure they are not duplicates.'); | ||
$this->output->text(route('payments.possible-duplicates')); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?php namespace BB\Console; | ||
<?php | ||
|
||
namespace BB\Console; | ||
|
||
use Illuminate\Console\Scheduling\Schedule; | ||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | ||
|
@@ -21,9 +23,10 @@ class Kernel extends ConsoleKernel | |
Commands\BillMembers::class, | ||
Commands\CheckDeviceOnlineStatuses::class, | ||
Commands\TestScheduledTask::class, | ||
Commands\Payments\CheckForPossibleDuplicates::class, | ||
]; | ||
|
||
|
||
/** | ||
* Define the application's command schedule. | ||
* | ||
|
@@ -37,48 +40,53 @@ protected function schedule(Schedule $schedule) | |
$schedule | ||
->command(Commands\CheckMembershipStatus::class) | ||
->dailyAt('06:00') | ||
->then( function () use ($telegram) { | ||
->then(function () use ($telegram) { | ||
$message = "✔️ Checked Memberships"; | ||
\Log::info($message); | ||
\Log::info($message); | ||
$telegram->notify( | ||
TelegramHelper::JOB, | ||
TelegramHelper::JOB, | ||
$message | ||
); | ||
}); | ||
|
||
$schedule | ||
->command(Commands\CreateTodaysSubCharges::class) | ||
->dailyAt('01:00') | ||
->then( function () use ($telegram) { | ||
->then(function () use ($telegram) { | ||
$message = "✔️ Created today's subscription charges"; | ||
\Log::info($message); | ||
\Log::info($message); | ||
$telegram->notify( | ||
TelegramHelper::JOB, | ||
TelegramHelper::JOB, | ||
$message | ||
); | ||
} ); | ||
}); | ||
|
||
$schedule | ||
->command(Commands\BillMembers::class) | ||
->dailyAt('01:30') | ||
->then( function ($result) use ($telegram) { | ||
->then(function ($result) use ($telegram) { | ||
$message = "✅ Billed members: " . $result['gc_users'] . " GC users, " . $result['gc_users_blled'] . " bills created."; | ||
\Log::info($message); | ||
\Log::info($message); | ||
$telegram->notify( | ||
TelegramHelper::JOB, | ||
$message | ||
); | ||
}); | ||
|
||
$schedule | ||
->command(Commands\TestScheduledTask::class) | ||
->hourly() | ||
->then(function ($result) use ($telegram) { | ||
$message = "✔️ Test Scheduled Task successfully ran (notification from 'then' hook)"; | ||
$telegram->notify( | ||
TelegramHelper::JOB, | ||
TelegramHelper::JOB, | ||
$message | ||
); | ||
}); | ||
|
||
$schedule | ||
->command(Commands\TestScheduledTask::class) | ||
->hourly() | ||
->then(function($result) use ($telegram) { | ||
$message = "✔️ Test Scheduled Task successfully ran (notification from 'then' hook)"; | ||
$telegram->notify( | ||
TelegramHelper::JOB, | ||
$message | ||
); | ||
}); | ||
->command(Commands\Payments\CheckForPossibleDuplicates::class) | ||
->dailyAt('16:30') | ||
->emailOutputTo('[email protected]', true); | ||
} | ||
} |
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
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
Oops, something went wrong.