diff --git a/app/Console/Commands/MiningTaxes/MiningTaxesInvoices.php b/app/Console/Commands/MiningTaxes/MiningTaxesInvoices.php
index 6a24f0fb0..37bd54473 100644
--- a/app/Console/Commands/MiningTaxes/MiningTaxesInvoices.php
+++ b/app/Console/Commands/MiningTaxes/MiningTaxesInvoices.php
@@ -2,7 +2,15 @@
namespace App\Console\Commands\MiningTaxes;
+//Internal Library
use Illuminate\Console\Command;
+use Log;
+
+//Application Library
+use Commands\Library\CommandHelper;
+
+//Jobs
+use App\Jobs\Commands\MiningTaxes\CalculateMiningTaxesJob;
class MiningTaxesInvoices extends Command
{
@@ -37,6 +45,15 @@ class MiningTaxesInvoices extends Command
*/
public function handle()
{
+ $task = new CommandHelper('MiningTaxesInvoices');
+ //Set the task as started
+ $task->SetStartStatus();
+
+ CalculateMiningTaxesJob::dispatch()->onQueue('miningtaxes');
+
+ //Set the task as stopped
+ $task->SetStopStatus();
+
return 0;
}
}
diff --git a/app/Console/Commands/MiningTaxes/MiningTaxesLedgers.php b/app/Console/Commands/MiningTaxes/MiningTaxesLedgers.php
index fea651e0c..ab936a4f4 100644
--- a/app/Console/Commands/MiningTaxes/MiningTaxesLedgers.php
+++ b/app/Console/Commands/MiningTaxes/MiningTaxesLedgers.php
@@ -2,7 +2,15 @@
namespace App\Console\Commands\MiningTaxes;
+//Internal Library
use Illuminate\Console\Command;
+use Log;
+
+//Application Library
+use Commands\Library\CommandHelper;
+
+//Jobs
+use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesLedgersJob;
class MiningTaxesLedgers extends Command
{
@@ -37,6 +45,14 @@ class MiningTaxesLedgers extends Command
*/
public function handle()
{
+ //Create the command helper container
+ $task = new CommandHelper('MiningTaxesLedger');
+ //Set the task as started
+ $task->SetStartStatus();
+
+ FetchMiningTaxesLedgersJob::dispatch()->onQueue('miningtaxes');
+
+ //Return 0
return 0;
}
}
diff --git a/app/Console/Commands/MiningTaxes/MiningTaxesObservers.php b/app/Console/Commands/MiningTaxes/MiningTaxesObservers.php
index b2c60d1ea..8ad640244 100644
--- a/app/Console/Commands/MiningTaxes/MiningTaxesObservers.php
+++ b/app/Console/Commands/MiningTaxes/MiningTaxesObservers.php
@@ -2,7 +2,13 @@
namespace App\Console\Commands\MiningTaxes;
+//Internal Library
use Illuminate\Console\Command;
+use Log;
+use Commands\Library\CommandHelper;
+
+//Jobs
+use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesObserversJob;
class MiningTaxesObservers extends Command
{
@@ -37,6 +43,16 @@ class MiningTaxesObservers extends Command
*/
public function handle()
{
+ //Create the command helper container
+ $task = new CommandHelper('MiningTaxesObservers');
+ //Set the task as started
+ $task->SetStartStatus();
+
+ FetchMiningTaxesObserversJob::dispatch()->onQueue('miningtaxes');
+
+ $task->SetStopStatus();
+
+ //Return 0 saying everything is fine
return 0;
}
}
diff --git a/app/Console/Commands/MiningTaxes/MiningTaxesPayments.php b/app/Console/Commands/MiningTaxes/MiningTaxesPayments.php
index cf4cbb36e..8491d875b 100644
--- a/app/Console/Commands/MiningTaxes/MiningTaxesPayments.php
+++ b/app/Console/Commands/MiningTaxes/MiningTaxesPayments.php
@@ -3,6 +3,13 @@
namespace App\Console\Commands\MiningTaxes;
use Illuminate\Console\Command;
+use Log;
+
+//Application Library
+use Commands\Library\CommandHelper;
+
+//Jobs
+use App\Jobs\Commands\MiningTaxes\ProcessMiningTaxesPaymentsJob;
class MiningTaxesPayments extends Command
{
@@ -37,6 +44,17 @@ class MiningTaxesPayments extends Command
*/
public function handle()
{
+ //Create the command helper container
+ $task = new CommandHelper('MiningTaxesPayments');
+ //Set the task as started
+ $task->SetStartStatus();
+
+ //Dispatch the job
+ ProcessMiningTaxesPaymentsJob::dispatch()->onQueue('miningtaxes');
+
+ //Set the task as stopped
+ $task->SetStopStatus();
+
return 0;
}
}
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index 4a7e62694..dd905fa63 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -114,10 +114,12 @@ class Kernel extends ConsoleKernel
$schedule->command('MiningTaxes:Ledgers')
->hourlyAt('05')
->withoutOverlapping();
+ /*
$schedule->command('MiningTaxes:Invoices')
->dailyAt('23:00');
$schedule->command('MiningTaxes:Payments')
->dailyAt('23:50');
+ */
}
/**
diff --git a/app/Jobs/Commands/MiningTaxes/CreateMiningTaxesInvoiceJob.php b/app/Jobs/Commands/MiningTaxes/CreateMiningTaxesInvoiceJob.php
index ac1ddf3a0..08111be1f 100644
--- a/app/Jobs/Commands/MiningTaxes/CreateMiningTaxesInvoiceJob.php
+++ b/app/Jobs/Commands/MiningTaxes/CreateMiningTaxesInvoiceJob.php
@@ -2,13 +2,14 @@
namespace App\Jobs\Commands\MiningTaxes;
-//App Library
+//Internal Library
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Carbon\Carbon;
+use Log;
//Library
use App\Library\Lookups\LookupHelper;
@@ -34,11 +35,13 @@ class CreateMiningTaxesInvoiceJob implements ShouldQueue
*
* @return void
*/
- public function __construct($ores, $totalPrice, $charId)
+ public function __construct($ores = [], $totalPrice, $charId)
{
$this->ores = $ores;
$this->totalPrice = $totalPrice;
$this->charId = $charId;
+
+ $this->connection = 'redis';
}
/**
@@ -87,7 +90,7 @@ class CreateMiningTaxesInvoiceJob implements ShouldQueue
$body .= $oreName . ": " . number_format($quantity, 0, ".", ",") . "
";
}
$body .= "Please remit " . number_format($this->totalPrice, 2, ".", ",") . " ISK to Spatial Forces by " . $invoice->date_due . "
";
- $body .= "Set the reason for transfer as " . $invoice->invoice_id . "
";
+ $body .= "Set the reason for transfer as MMT: " . $invoice->invoice_id . "
";
$body .= "
Sincerely,
Warped Intentions Leadership
";
//Mail the invoice to the character if the character is in
diff --git a/app/Jobs/Commands/MiningTaxes/FetchMiningTaxesObserversJob.php b/app/Jobs/Commands/MiningTaxes/FetchMiningTaxesObserversJob.php
index a77218253..9f5cc0979 100644
--- a/app/Jobs/Commands/MiningTaxes/FetchMiningTaxesObserversJob.php
+++ b/app/Jobs/Commands/MiningTaxes/FetchMiningTaxesObserversJob.php
@@ -95,25 +95,14 @@ class FetchMiningTaxesObserversJob implements ShouldQueue
//Run through the mining observers, and add them to the database
foreach($response as $observer) {
- //Count how many observers have the observer_id stated.
- //May change this to a more efficient function later
- $count = Observer::where([
- 'observer_id' => $observer->observer_id,
- ])->count();
- if($count == 0) {
- $obs = new Observer;
- $obs->last_updated = $observer->last_updated;
- $obs->observer_id = $observer->observer_id;
- $obs->observer_type = $observer->observer_type;
- $obs->save();
- } else {
- Observer::where([
- 'observer_id' => $observer->observer_id,
- ])->update([
- 'last_updated' => $observer->last_updated,
- ]);
- }
+ Observer::updateOrInsert([
+ 'observer_id' => $observer->observer_id,
+ ], [
+ 'observer_id' => $observer->observer_id,
+ 'observer_type' => $observer->observer_type,
+ 'last_updated' => $observer->last_updated,
+ ]);
}
/**
diff --git a/app/Jobs/Commands/MiningTaxes/MailMiningTaxesInvoiceJob.php b/app/Jobs/Commands/MiningTaxes/MailMiningTaxesInvoiceJob.php
index 08de80d30..787a1c76e 100644
--- a/app/Jobs/Commands/MiningTaxes/MailMiningTaxesInvoiceJob.php
+++ b/app/Jobs/Commands/MiningTaxes/MailMiningTaxesInvoiceJob.php
@@ -8,6 +8,8 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
+
+//Might not need this class with current implementation of the mailing system
class MailMiningTaxesInvoiceJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
diff --git a/app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesPaymentsJob.php b/app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesPaymentsJob.php
index 0ba165f4c..033564416 100644
--- a/app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesPaymentsJob.php
+++ b/app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesPaymentsJob.php
@@ -2,11 +2,22 @@
namespace App\Jobs\Commands\MiningTaxes;
+//Internal Library
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
+use Carbon\Carbon;
+use Log;
+
+//Library
+use App\Library\Lookups\LookupHelper;
+
+//Models
+use App\Models\MiningTaxes\Invoice;
+use App\Models\MiningTaxes\Payment;
+use App\Models\Finances\PlayerDonationJournal;
class ProcessMiningTaxesPaymentsJob implements ShouldQueue
{
@@ -19,7 +30,7 @@ class ProcessMiningTaxesPaymentsJob implements ShouldQueue
*/
public function __construct()
{
- //
+ $this->connection = 'redis';
}
/**
@@ -29,6 +40,48 @@ class ProcessMiningTaxesPaymentsJob implements ShouldQueue
*/
public function handle()
{
- //
+ //Declare the variables we will need
+ $looup = new LookupHelper;
+ $currentTime = Carbon::now();
+
+ //Get the outstanding invoices
+ $outstanding = Invoice::where([
+ 'status' => 'Pending',
+ ])->get();
+
+ //Use the player donation journal from finances to see if the invoice_id is present
+ //as a reason
+ foreach($outstanding as $invoice) {
+ //See if we have a reason with the correct uniqid from the player donation journal
+ $found = PlayerDonationJournal::where([
+ 'reason' => "MMT: " . $invoice->invoice_id,
+ ])->count();
+
+ //If we have received the invoice, then mark the invoice as paid
+ if($count > 0) {
+ //If we have the count, then grab the journal entry in order to do some things with it
+ $journal = PlayerDonationJournal::where([
+ 'reason' => "MMT: " . $invoice->invoice_id,
+ ])->first();
+
+ //If the bill is paid on time, then update the invoice as such
+ if($currentTime->lessThanOrEqualTo($journal->inserted_at)) {
+ Invoice::where([
+ 'invoice_id' => $invoice->invoice_id,
+ ])->update([
+ 'status' => 'Paid',
+ ]);
+ }
+
+ if($currentTime->greaterThan($journal->inserted_at)) {
+ Invoice::where([
+ 'invoice_id' => $invoice->invoice_id,
+ ])->update([
+ 'status' => 'Paid Late',
+ ]);
+ }
+ }
+ }
+
}
}
diff --git a/config/horizon.php b/config/horizon.php
index a83bda35f..3f81436ae 100644
--- a/config/horizon.php
+++ b/config/horizon.php
@@ -146,9 +146,8 @@ return [
'default',
'journal',
'mail',
- 'structures',
'assets',
- 'moons',
+ 'miningtaxes',
],
'balance' => 'auto',
'processes' => 12,
@@ -163,9 +162,8 @@ return [
'default',
'journal',
'mail',
- 'structures',
'assets',
- 'moons',
+ 'miningtaxes',
],
'balance' => 'auto',
'processes' => 12,