added stuff for late invoices.
updated all jobs to not include the wording Job in the file.
This commit is contained in:
@@ -8,7 +8,7 @@ use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\ScheduledTask\ScheduleJob;
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
use App\Jobs\Commands\Eve\SendEveMail;
|
||||
|
||||
//Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
@@ -62,7 +62,7 @@ class Test extends Command
|
||||
$sender = $config['primary'];
|
||||
$body = "F0KlvSA9vrXWYK0IuMhSAbfaOAMmQO5U2CD69Dn0JOk26B8HnSPPkhSG3JzlawHjbBd16HAIbaawbv9304EaoTRctpu5cnZo0GoHINi3R7pNGi0IZTWKG4EArwWbSujwX9KPvMqGNbcSorrIEslw6neXWW1kcDN0GMcvV6SeoM23cSkK33cAbR4DTeqUXZ9ULuFy31UPXfEcaNzKREbqKPlgChYcGdCyHG1J25qrEmPlOTPI1NQQkh71HvHJTVA7bmTgLEJMdFYHbc3ZzGOB9RFLfhdkGEGl2f3OQNyDAJIKW2mNQVlRVGc3Emvm42czpsH8ojn3BX5nuEFxNfjgue8hhdBIZSKm232U2l0xsPGZOzHvQdYs8bLw7ZQX1drV9qOPnbhgzbFLxEvQoGDquhKAdlo7bhkgoCn5IiY3BbQ5qnKVodymb58gj9Pd67GxjJ8K0854c91KkrJNEOCyiVcqKYqNDtKkB7hgjBLZUKRtWUkOf9j1qIRARoGzTGdqK20yvfaVIWetVqjw5UvzQC2pynHkvIw2X3aD49ghY7UOzXUceKJ8taF4ZaMvW34r5OvyTrjVo4PKV9TylIODmzg1U0s4joxz58f1A6BNp2fCs1YzNOObuMaxGjek47jv2gDgyhQnmi5uaREcGn5AAwgMUc55GPY2jevRTHo9scMqm5amaJUBQ3TgXvFSfS33LxD8xJjdKw7KB06stDQzdjyVb52mAdm5WchOOpGy3EXntBSzsfUHc4XEqql7lKTPLgBzeYxt9EagGP96Li4dABg2MaLuU4i1CWdV49ZdPwOt1OjwNU4QtfR02C6Vw7raCFl3mqWBgLke9O5dC8Lh3ojg7FBATstSuur2n41Rn4YwzGaiWJ3qKwTsJGL3k8PaHEsvwvq56w4Qjt8CqJsmAV1nsfKMFZaVlcbK3PFN5oHaDbQwDh4IVdwA8UPPnrn2wSuugi8QlVyUA8z9iVYMW8OdzHFn98zl7a2Bua5M";
|
||||
|
||||
ProcessSendEveMailJob::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail');
|
||||
SendEveMail::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail');
|
||||
|
||||
/*
|
||||
try {
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Models
|
||||
use app\Models\MiningTax\Ledger;
|
||||
|
||||
class MiningTaxesDataCleanup extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mining:cleanup';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Cleanup old ledger entries for mining taxes.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('MiningTaxesDataCleanup');
|
||||
//Set the task as started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Clean up old data
|
||||
Ledger::where(['updated_at', '<', Carbon::now()->subDays(90)])->delete();
|
||||
|
||||
//Set the task as finished
|
||||
$task->SetStopStatus();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,200 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
use App\Models\User\UserAlt;
|
||||
use App\Models\User\User;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
|
||||
class MiningTaxesInvoices extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mining:Invoice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Mining Taxes Invoice Command';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
$config = config('esi');
|
||||
$task = new CommandHelper('MiningTaxesInvoices');
|
||||
$mailDelay = 15;
|
||||
//Set the task as started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Get the characters for each non-invoiced ledger entry
|
||||
$charIds = Ledger::where([
|
||||
'invoiced' => 'No',
|
||||
])->distinct('character_id')
|
||||
->pluck('character_id');
|
||||
|
||||
if($charIds == null) {
|
||||
//Set the task status as done and Log the issue
|
||||
$task->SetStopStatus();
|
||||
Log::warning("No characters found to send invoices to in MiningTaxesInvoices Command.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Foreach character tally up the mining ledger.
|
||||
foreach($charIds as $charId) {
|
||||
//Declare some variables we need for each iteration of the loop
|
||||
$invoice = array();
|
||||
$ores = array();
|
||||
$totalPrice = 0.00;
|
||||
$body = null;
|
||||
|
||||
//Get the row count to reduce overhead processing if we can.
|
||||
$rowCount = Ledger::where([
|
||||
'character_id' => $charId,
|
||||
'invoiced' => 'No',
|
||||
])->count();
|
||||
|
||||
//Get the actual rows
|
||||
$rows = Ledger::where([
|
||||
'character_id' => $charId,
|
||||
'invoiced' => 'No',
|
||||
])->get()->toArray();
|
||||
|
||||
//Taly up the item composition from each row and multiply by the quantity
|
||||
if($rowCount > 0) {
|
||||
foreach($rows as $row) {
|
||||
if(!isset($ores[$row['type_id']])) {
|
||||
$ores[$row['type_id']] = 0;
|
||||
}
|
||||
$ores[$row['type_id']] = $ores[$row['type_id']] + $row['quantity'];
|
||||
|
||||
//Add up the total price from the ledger rows for the report later
|
||||
$totalPrice = $totalPrice + $row['amount'];
|
||||
}
|
||||
|
||||
//Reduce the total price by the take percentage
|
||||
$invoiceAmount = $totalPrice * $config['mining_tax'];
|
||||
$invoiceAmount = round($invoiceAmount, 2);
|
||||
|
||||
//Get the character name from the character id
|
||||
$charName = $lookup->CharacterIdToName($charId);
|
||||
|
||||
//Generate a unique invoice id
|
||||
$invoiceId = uniqid();
|
||||
//Set the due date of the invoice
|
||||
$dateDue = Carbon::now()->addDays(7);
|
||||
$invoiceDate = Carbon::now();
|
||||
|
||||
//Format the mining tax into a human readable number
|
||||
$numberMiningTax = number_format(($config['mining_tax'] * 100.00), 2, ".", ",");
|
||||
|
||||
//Create the mail body
|
||||
$body .= "Dear Miner,<br><br>";
|
||||
$body .= "Mining Taxes are due for the following ores mined from alliance moons: <br>";
|
||||
foreach($ores as $ore => $quantity) {
|
||||
$oreName = $lookup->ItemIdToName($ore);
|
||||
$body .= $oreName . ": " . number_format($quantity, 0, ".", ",") . "<br>";
|
||||
}
|
||||
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
|
||||
$body .= "<br><br>";
|
||||
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces by " . $dateDue . "<br>";
|
||||
$body .= "Set the reason for transfer as MMT: " . $invoiceId . "<br>";
|
||||
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
|
||||
$body .= "<br><br>";
|
||||
$body .= "You can also send a contract with the following ores in the contract with the reason set as MMT: " . $invoiceId . "<br>";
|
||||
foreach($ores as $ore => $quantity) {
|
||||
$oreName = $lookup->ItemIdToName($ore);
|
||||
$body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), 0, ".", ",") . "<br>";
|
||||
}
|
||||
$body .= "<br>";
|
||||
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||
|
||||
//Check if the mail body is greater than 2000 characters. If greater than 2,000 characters, then
|
||||
if(strlen($body) > 2000) {
|
||||
$body = "Dear Miner,<br><br>";
|
||||
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
|
||||
$body .= "<br><br>";
|
||||
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces by " . $dateDue . "<br>";
|
||||
$body .= "Set the reason for transfer as MMT: " . $invoiceId . "<br>";
|
||||
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
|
||||
$body .= "<br>";
|
||||
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||
}
|
||||
|
||||
//Mail the invoice to the character if the character is in
|
||||
//Warped Intentions or Legacy
|
||||
$subject = 'Warped Intentions Mining Taxes';
|
||||
$sender = $config['primary'];
|
||||
$recipientType = 'character';
|
||||
$recipient = $charId;
|
||||
|
||||
//Send the Eve Mail Job to the queue to be dispatched
|
||||
ProcessSendEveMailJob::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
|
||||
//Save the invoice model
|
||||
$invoice = new Invoice;
|
||||
$invoice->character_id = $charId;
|
||||
$invoice->character_name = $charName;
|
||||
$invoice->invoice_id = $invoiceId;
|
||||
$invoice->invoice_amount = $invoiceAmount;
|
||||
$invoice->date_issued = $invoiceDate;
|
||||
$invoice->date_due = $dateDue;
|
||||
$invoice->status = 'Pending';
|
||||
$invoice->mail_body = $body;
|
||||
$invoice->save();
|
||||
|
||||
//Update the ledger entries
|
||||
Ledger::where([
|
||||
'character_id' => $charId,
|
||||
'invoiced' => 'No',
|
||||
])->update([
|
||||
'invoiced' => 'Yes',
|
||||
'invoice_id' => $invoiceId,
|
||||
]);
|
||||
|
||||
//update the delay
|
||||
$mailDelay = $mailDelay + 20;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Set the task as stopped
|
||||
$task->SetStopStatus();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class MiningTaxesLateInvoices extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mining:late';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Observer;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesLedgersJob;
|
||||
|
||||
class MiningTaxesLedgers extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mining:Ledgers';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Start getting the mining ledgers.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('MiningTaxesLedger');
|
||||
//Set the task as started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Get the site configuration which holds some data we need
|
||||
$config = config('esi');
|
||||
//Get the observers from the database
|
||||
$observers = Observer::all();
|
||||
|
||||
//For each of the observers, send a job to fetch the mining ledger
|
||||
foreach($observers as $obs) {
|
||||
//Dispatch the mining taxes ledger jobs
|
||||
FetchMiningTaxesLedgersJob::dispatch($config['primary'], $config['corporation'], $obs->observer_id)->onQueue('miningtaxes');
|
||||
}
|
||||
|
||||
//Set the task as finished
|
||||
$task->SetStopStatus();
|
||||
|
||||
//Return 0
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Helpers\StructureHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\MiningTax\Observer;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesObserversJob;
|
||||
|
||||
class MiningTaxesObservers extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mining:Observer';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get mining tax observers.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('MiningTaxesObservers');
|
||||
//Set the task as started
|
||||
$task->SetStartStatus();
|
||||
$startTime = time();
|
||||
|
||||
//Declare variables
|
||||
$config = config('esi');
|
||||
$lookup = new LookupHelper;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
||||
Log::critical('Esi scopes were not found for FetchMiningTaxesObserversJob.');
|
||||
print("Esi scopes not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
$char = $lookup->GetCharacterInfo($config['primary']);
|
||||
|
||||
//Get the refresh token for the character
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
//Get the esi variable
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
try {
|
||||
$response = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||
'corporation_id' => $char->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get moon observers in FetchMiningTaxesObservers");
|
||||
Log::critical($e);
|
||||
dd($e);
|
||||
}
|
||||
|
||||
$resp = json_decode($response->raw, false);
|
||||
|
||||
//Run through the mining observers, and add them to the database
|
||||
foreach($resp as $observer) {
|
||||
if($observer->observer_id > 1030000000000) {
|
||||
$found = Observer::where([
|
||||
'observer_id' => $observer->observer_id,
|
||||
])->count();
|
||||
|
||||
if($found > 0) {
|
||||
Observer::where([
|
||||
'observer_id' => $observer->observer_id,
|
||||
])->update([
|
||||
'observer_id' => $observer->observer_id,
|
||||
'observer_type' => $observer->observer_type,
|
||||
'last_updated' => $observer->last_updated,
|
||||
]);
|
||||
} else {
|
||||
$newObs = new Observer;
|
||||
$newObs->observer_id = $observer->observer_id;
|
||||
$newObs->observer_type = $observer->observer_type;
|
||||
$newObs->last_updated = $observer->last_updated;
|
||||
$newObs->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup stale data that hasn't been updated in at least 1 week.
|
||||
*/
|
||||
$date = Carbon::now()->subDays(7);
|
||||
Observer::where('last_updated', '<', $date)->delete();
|
||||
|
||||
//Set the task as completed
|
||||
$task->SetStopStatus();
|
||||
|
||||
//Set the end time for debugging and printint out to the screen
|
||||
$endTime = time();
|
||||
printf("Time to complete: " . ($endTime - $startTime) . "\n\r");
|
||||
|
||||
//Return 0 saying everything is fine
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\MiningTax\Payment;
|
||||
use App\Models\Finances\AllianceWalletJournal;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\MiningTaxes\ProcessMiningTaxesPaymentsJob;
|
||||
|
||||
class MiningTaxesPayments extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mining:Payments';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Process mining tax payments';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('MiningTaxesPayments');
|
||||
//Set the task as started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Declare variables for the function
|
||||
$lookup = new LookupHelper;
|
||||
$currentTime = Carbon::now();
|
||||
$config = config('esi');
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-contracts.read_corporation_contracts.v1')) {
|
||||
Log::critical('Esi scopes were not found for MiningTaxesPayments');
|
||||
print("Esi scope not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the refresh token
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
//Get the esi variable
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Get all of the contracts from esi
|
||||
try {
|
||||
$response = $esi->invoke('get', '/corporations/{corporation_id}/contracts/', [
|
||||
'corporation_id' => $config['corporation'],
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get contrcts in MiningTaxesPayments command.");
|
||||
Log::critical($e);
|
||||
dd($e);
|
||||
}
|
||||
|
||||
//Decode the contracts from the json response
|
||||
$contracts = json_decode($response->raw, false);
|
||||
|
||||
//Get the outstanding invoices
|
||||
$outstanding = Invoice::where([
|
||||
'status' => 'Pending',
|
||||
])->get();
|
||||
|
||||
//Use the player donation and the journal in order to check over the pending contracts to attempt
|
||||
//to pay the contract
|
||||
foreach($outstanding as $invoice) {
|
||||
|
||||
|
||||
//See if we have a reason with the correct uniqid from the player donation journal
|
||||
$found = AllianceWalletJournal::where([
|
||||
'ref_type' => 'player_donation',
|
||||
'reason' => "MMT: " . $invoice->invoice_id,
|
||||
])->count();
|
||||
|
||||
if($found == 1) {
|
||||
//If the bill is paid on time, then update the invoice as such
|
||||
if($currentTime->lessThanOrEqualTo($invoice->due_date)) {
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Paid',
|
||||
]);
|
||||
}
|
||||
|
||||
//If the bill is paid late, then update the invoice as such
|
||||
if($currentTime->greaterThan($invoice->due_date)) {
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Paid Late',
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
//If we didn't found a journal entry, then we shall check the contracts for a correct entry
|
||||
foreach($contracts as $contract) {
|
||||
if(($contract->title == ("MMT: " . $invoice->invoice_id)) && ($currentTime->lessThanOrEqualTo($invoice->due_date))) {
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'stauts' => 'Paid'
|
||||
]);
|
||||
}
|
||||
|
||||
if(($contract->title == ("MMT: " . $invoice->invoice_id)) && ($currentTime->greaterThan($invoice->due_date))) {
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Paid Late',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Set the task as stopped
|
||||
$task->SetStopStatus();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,13 @@ use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\MiningTaxes\PreFetchMiningTaxesLedgersJob;
|
||||
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesObserversJob;
|
||||
use App\Jobs\Commands\MiningTaxes\ProcessMiningTaxesPaymentsJob;
|
||||
use App\Jobs\Commands\MiningTaxes\SendMiningTaxesInvoicesJob;
|
||||
use App\Jobs\Commands\Finances\UpdateAllianceWalletJournalJob;
|
||||
use App\Jobs\Commands\Finances\UpdateItemPricesJob;
|
||||
use App\Jobs\Commands\Data\PurgeUsersJob;
|
||||
use App\Jobs\Commands\MiningTaxes\PreFetchMiningTaxesLedgers;
|
||||
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesObservers;
|
||||
use App\Jobs\Commands\MiningTaxes\ProcessMiningTaxesPayments;
|
||||
use App\Jobs\Commands\MiningTaxes\SendMiningTaxesInvoices;
|
||||
use App\Jobs\Commands\Finances\UpdateAllianceWalletJournal as UpdateAllianceWalletJournalJob;
|
||||
use App\Jobs\Commands\Finances\UpdateItemPrices as UpdateItemPricesJob;
|
||||
use App\Jobs\Commands\Data\PurgeUsers as PurgeUsersJob;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
@@ -27,12 +27,6 @@ class Kernel extends ConsoleKernel
|
||||
Commands\Data\Test::class,
|
||||
Commands\Eve\ItemPricesUpdateCommand::class,
|
||||
Commands\Finances\UpdateAllianceWalletJournal::class,
|
||||
Commands\MiningTaxes\MiningTaxesDataCleanup::class,
|
||||
Commands\MiningTaxes\MiningTaxesInvoices::class,
|
||||
Commands\MiningTaxes\MiningTaxesInvoicesNew::class,
|
||||
Commands\MiningTaxes\MiningTaxesLedgers::class,
|
||||
Commands\MiningTaxes\MiningTaxesObservers::class,
|
||||
Commands\MiningTaxes\MiningTaxesPayments::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -78,18 +72,21 @@ class Kernel extends ConsoleKernel
|
||||
/**
|
||||
* Mining Tax Schedule
|
||||
*/
|
||||
$schedule->job(new FetchMiningTaxesObserversJob)
|
||||
$schedule->job(new FetchMiningTaxesObservers)
|
||||
->timezone('UTC')
|
||||
->dailyAt('22:00');
|
||||
$schedule->job(new PreFetchMiningTaxesLedgersJob)
|
||||
$schedule->job(new PreFetchMiningTaxesLedgers)
|
||||
->timezone('UTC')
|
||||
->dailyAt('20:00');
|
||||
$schedule->job(new SendMiningTaxesInvoicesJob)
|
||||
$schedule->job(new SendMiningTaxesInvoices)
|
||||
->timezone('UTC')
|
||||
->weeklyOn(1, '06:00');
|
||||
$schedule->job(new ProcessMiningTaxesPaymentsJob)
|
||||
$schedule->job(new ProcessMiningTaxesPayments)
|
||||
->timezone('UTC')
|
||||
->hourlyAt('15');
|
||||
$schedule->job(new UpdateMiningTaxesLateInvoices)
|
||||
->timezone('UTC')
|
||||
->dailyAt('16:00');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,7 @@ use App\Models\Contracts\SupplyChainBid;
|
||||
use App\Models\Contracts\SupplyChainContract;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
use App\Jobs\Commands\Eve\SendEveMail;
|
||||
|
||||
class SupplyChainController extends Controller
|
||||
{
|
||||
@@ -454,7 +454,7 @@ class SupplyChainController extends Controller
|
||||
$body .= "Notes: " . $contract->body . "<br>";
|
||||
$body .= "Delivery Date: " . $contract->delivery_date . "<br>";
|
||||
$body .= "<br>Sincerely on behalf of,<br>" . $contract->issuer_name . "<br>";
|
||||
ProcessSendEveMailJob::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
|
||||
SendEveMail::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -469,7 +469,7 @@ class SupplyChainController extends Controller
|
||||
$body .= "Contract: " . $contract->title . "<br>";
|
||||
$body .= "Notes: " . $contract->note . "<br>";
|
||||
$body .= "<br>Sincerely on behalf of,<br>" . $contract->issuer_name;
|
||||
ProcessSendEveMailJob::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
|
||||
SendEveMail::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ use App\Models\User\UserPermission;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
|
||||
class PurgeUsersJob implements ShouldQueue
|
||||
class PurgeUsers implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -12,7 +12,7 @@ use Log;
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
class ItemPricesUpdateJob implements ShouldQueue
|
||||
class ItemPricesUpdate implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -25,7 +25,7 @@ use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Mail\SentMail;
|
||||
use Seat\Eseye\Containers\EsiResponse;
|
||||
|
||||
class ProcessSendEveMailJob implements ShouldQueue
|
||||
class SendEveMail implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -64,7 +64,7 @@ class ProcessSendEveMailJob implements ShouldQueue
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* Utilized by using ProcessSendEveMailJob::dispatch($mail);
|
||||
* Utilized by using SendEveMail::dispatch($mail);
|
||||
* The model is passed into the dispatch function, then added to the queue
|
||||
* for processing.
|
||||
*
|
||||
@@ -151,39 +151,39 @@ class ProcessSendEveMailJob implements ShouldQueue
|
||||
(is_string($exception->getEsiResponse()) && (stristr($exception->getEsiResponse(), 'Too many errors') || stristr($exception->getEsiResponse(), 'This software has exceeded the error limit for ESI')))) {
|
||||
|
||||
//We have hit the error rate limiter, wait 120 seconds before releasing the job back into the queue.
|
||||
Log::info('ProcessSendEveMailJob has hit the error rate limiter. Releasing the job back into the wild in 2 minutes.');
|
||||
Log::info('SendEveMail has hit the error rate limiter. Releasing the job back into the wild in 2 minutes.');
|
||||
$this->release(120);
|
||||
} else {
|
||||
$errorCode = $exception->getEsiResponse()->getErrorCode();
|
||||
|
||||
switch($errorCode) {
|
||||
case 400: //Bad Request
|
||||
Log::critical("Bad request has occurred in ProcessSendEveMailJob. Job has been discarded");
|
||||
Log::critical("Bad request has occurred in SendEveMail. Job has been discarded");
|
||||
break;
|
||||
case 401: //Unauthorized Request
|
||||
Log::critical("Unauthorized request has occurred in ProcessSendEveMailJob at " . Carbon::now()->toDateTimeString() . ".\r\nCancelling the job.");
|
||||
Log::critical("Unauthorized request has occurred in SendEveMail at " . Carbon::now()->toDateTimeString() . ".\r\nCancelling the job.");
|
||||
break;
|
||||
case 403: //Forbidden
|
||||
Log::critical("ProcessSendEveMailJob has incurred a forbidden error. Cancelling the job.");
|
||||
Log::critical("SendEveMail has incurred a forbidden error. Cancelling the job.");
|
||||
break;
|
||||
case 420: //Error Limited
|
||||
Log::warning("Error rate limit occurred in ProcessSendEveMailJob. Restarting job in 120 seconds.");
|
||||
Log::warning("Error rate limit occurred in SendEveMail. Restarting job in 120 seconds.");
|
||||
$this->release(120);
|
||||
break;
|
||||
case 500: //Internal Server Error
|
||||
Log::critical("Internal Server Error for ESI in ProcessSendEveMailJob. Attempting a restart in 120 seconds.");
|
||||
Log::critical("Internal Server Error for ESI in SendEveMail. Attempting a restart in 120 seconds.");
|
||||
$this->release(120);
|
||||
break;
|
||||
case 503: //Service Unavailable
|
||||
Log::critical("Service Unavailabe for ESI in ProcessSendEveMailJob. Releasing the job back to the queue in 30 seconds.");
|
||||
Log::critical("Service Unavailabe for ESI in SendEveMail. Releasing the job back to the queue in 30 seconds.");
|
||||
$this->release(30);
|
||||
break;
|
||||
case 504: //Gateway Timeout
|
||||
Log::critical("Gateway timeout in ProcessSendEveMailJob. Releasing the job back to the queue in 30 seconds.");
|
||||
Log::critical("Gateway timeout in SendEveMail. Releasing the job back to the queue in 30 seconds.");
|
||||
$this->release(30);
|
||||
break;
|
||||
case 520: //Internal Error -- Mostly comes when rate limited hit
|
||||
Log::warning("Rate limit hit for ProcessSendEveMailJob. Releasing the job back to the queue in 30 seconds.");
|
||||
Log::warning("Rate limit hit for SendEveMail. Releasing the job back to the queue in 30 seconds.");
|
||||
$this->release(30);
|
||||
break;
|
||||
case 201: //Good response code
|
||||
@@ -192,7 +192,7 @@ class ProcessSendEveMailJob implements ShouldQueue
|
||||
break;
|
||||
//If no code is given, then log and break out of switch.
|
||||
default:
|
||||
Log::warning("No response code received from esi call in processSendEveMailJob.\r\n");
|
||||
Log::warning("No response code received from esi call in SendEveMail.\r\n");
|
||||
$this->delete();
|
||||
break;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ use App\Models\Esi\EsiToken;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Mail\SentMail;
|
||||
|
||||
class ProcessSendEveMailJobRL implements ShouldQueue
|
||||
class SendEveMailRL implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -71,7 +71,7 @@ class ProcessSendEveMailJobRL implements ShouldQueue
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* Utilized by using ProcessSendEveMailJob::dispatch($mail);
|
||||
* Utilized by using SendEveMail::dispatch($mail);
|
||||
* The model is passed into the dispatch function, then added to the queue
|
||||
* for processing.
|
||||
*
|
||||
@@ -17,7 +17,7 @@ use Commands\Library\CommandHelper;
|
||||
//Models
|
||||
use App\Models\Finances\AllianceWalletJournal;
|
||||
|
||||
class UpdateAllianceWalletJournalJob implements ShouldQueue
|
||||
class UpdateAllianceWalletJournal implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -10,7 +10,7 @@ use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateItemPricesJob implements ShouldQueue
|
||||
class UpdateItemPrices implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -27,7 +27,7 @@ use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
class FetchMiningTaxesLedgersJob implements ShouldQueue
|
||||
class FetchMiningTaxesLedgers implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -16,7 +16,7 @@ use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Helpers\StructureHelper;
|
||||
|
||||
class FetchMiningTaxesObserversJob implements ShouldQueue
|
||||
class FetchMiningTaxesObservers implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -19,7 +19,7 @@ use App\Models\MiningTax\Observer;
|
||||
//Jobs
|
||||
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesLedgersJob;
|
||||
|
||||
class PreFetchMiningTaxesLedgersJob implements ShouldQueue
|
||||
class PreFetchMiningTaxesLedgers implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -19,7 +19,7 @@ use App\Models\MiningTax\Ledger;
|
||||
use App\Models\Moon\MineralPrice;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
|
||||
class ProcessMiningTaxesLedgersJob implements ShouldQueue
|
||||
class ProcessMiningTaxesLedgers implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -19,7 +19,7 @@ use App\Models\MiningTaxes\Invoice;
|
||||
use App\Models\MiningTaxes\Payment;
|
||||
use App\Models\Finances\AllianceWalletJournal;
|
||||
|
||||
class ProcessMiningTaxesPaymentsJob implements ShouldQueue
|
||||
class ProcessMiningTaxesPayments implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -85,5 +85,9 @@ class ProcessMiningTaxesPaymentsJob implements ShouldQueue
|
||||
}
|
||||
}
|
||||
|
||||
//Use the contract descriptions from the esi to see if the invoice_id is present.
|
||||
//If the invoice is present, then mark it off as sent in correctly
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,10 @@ use App\Models\User\UserAlt;
|
||||
use App\Models\User\User;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
use App\Jobs\Commands\Eve\SendEveMail;
|
||||
|
||||
|
||||
class SendMiningTaxesInvoicesJob implements ShouldQueue
|
||||
class SendMiningTaxesInvoices implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -165,7 +165,7 @@ class SendMiningTaxesInvoicesJob implements ShouldQueue
|
||||
$recipient = $charId;
|
||||
|
||||
//Send the Eve Mail Job to the queue to be dispatched
|
||||
ProcessSendEveMailJob::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
SendEveMail::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
|
||||
//Save the invoice model
|
||||
$invoice = new Invoice;
|
||||
@@ -1,16 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
namespace App\Jobs;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
//Application Library
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
@@ -20,56 +22,36 @@ use App\Models\User\UserAlt;
|
||||
use App\Models\User\User;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
use App\Jobs\Commands\Eve\SendEveMail;
|
||||
|
||||
class MiningTaxesInvoicesNew extends Command
|
||||
class SendMiningTaxesInvoicesNew implements ShouldQueue
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mining:invoice_new';
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Mining Taxes Invoice Command';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
* Get all of the users, then build a list of alts. From the main user and list of alts,
|
||||
* check for mining ledgers which haven't been invoiced, and invoice them.
|
||||
* Once the main check of all characters is completed, then create a separate list of characters
|
||||
* to send as one offs who haven't registered alts for this process.
|
||||
* Execute the job.
|
||||
*
|
||||
* @return int
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
$config = config('esi');
|
||||
$task = new CommandHelper('MiningTaxesInvoicesNew');
|
||||
$mainsAlts = array();
|
||||
$mainAlts = array();
|
||||
$mailDelay = 15;
|
||||
$mainIds = new Collection;
|
||||
|
||||
//Set the task as started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Get all of the users in the database
|
||||
$charIds = User::all();
|
||||
|
||||
@@ -79,8 +61,10 @@ class MiningTaxesInvoicesNew extends Command
|
||||
//Gather up all of the ledgers from the character and its alts.
|
||||
$ledgers = $this->LedgersWithAlts($charId);
|
||||
|
||||
//Create an invoice from the ledger rows
|
||||
$this->CreateInvoice($charId, $ledgers, $mailDelay);
|
||||
if(sizeof($ledgers) > 0) {
|
||||
//Create an invoice from the ledger rows
|
||||
$this->CreateInvoice($charId, $ledgers, $mailDelay);
|
||||
}
|
||||
}
|
||||
|
||||
//Get the ledgers characters which haven't had an invoice created yet.
|
||||
@@ -95,9 +79,6 @@ class MiningTaxesInvoicesNew extends Command
|
||||
|
||||
$this->CreateOtherInvoices($charIds, $mailDelay);
|
||||
|
||||
//Set the task as stopped
|
||||
$task->SetStopStatus();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -185,7 +166,7 @@ class MiningTaxesInvoicesNew extends Command
|
||||
$recipient = $config['primary'];
|
||||
|
||||
//Send the Eve Mail Job to the queue to be dispatched
|
||||
ProcessSendEveMailJob::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
SendEveMail::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
|
||||
//Save the invoice model
|
||||
$invoice = new Invoice;
|
||||
@@ -283,7 +264,7 @@ class MiningTaxesInvoicesNew extends Command
|
||||
$recipient = $charId;
|
||||
|
||||
//Send the Eve Mail Job to the queue to be dispatched
|
||||
ProcessSendEveMailJob::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
SendEveMail::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
|
||||
//Save the invoice model
|
||||
$invoice = new Invoice;
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserAlt;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\SendEveMail;
|
||||
|
||||
class UpdateMiningTaxesLateInvoices implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
$config = config('esi');
|
||||
$mailDelay = 15;
|
||||
$today = Carbon::now();
|
||||
|
||||
//Get all of the invoices that are still pending.
|
||||
$invoices = Invoice::where([
|
||||
'status' => 'Pending',
|
||||
])->get();
|
||||
|
||||
//Cycle through the invoices, and see if they are late or not.
|
||||
foreach($invoices as $invoice) {
|
||||
$dueDate = Carbon::create($invoice->date_due);
|
||||
|
||||
if($dueDate->greaterThan($today->subDays(7))) {
|
||||
//Update the invoice in the database
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Late',
|
||||
]);
|
||||
|
||||
//Build the mail
|
||||
$subject = 'Warped Intentions Mining Taxes - Invoice Late';
|
||||
$sender = $config['primary'];
|
||||
$recipientType = 'character';
|
||||
$recipient = $invoice->character_id;
|
||||
|
||||
$body = "Dear " . $invoice->character_name . ",<br><br>";
|
||||
$body .= "The Mining Invoice: " . $invoice->invoice_id . " is late.<br>";
|
||||
$body .= "Please remite " . number_format($invoice->invoice_amount, 2, ".", ",") . "to Spatial Forces.<br>";
|
||||
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||
|
||||
//Send a reminder to the user through eve mail about the late invoice
|
||||
SendEveMail::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ use App\Models\Contracts\SupplyChainBid;
|
||||
use App\Models\Contracts\SupplyChainContract;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
use App\Jobs\Commands\Eve\SendEveMail;
|
||||
|
||||
class EndSupplyChainContractJob implements ShouldQueue
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
use App\Jobs\Commands\Eve\SendEveMail;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
@@ -46,7 +46,7 @@ class Esi {
|
||||
$subject = 'W4RP Services - Incorrect ESI Scope';
|
||||
$body = "Please register on https://services.w4rp.space with the scope: " . $scope;
|
||||
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$charId, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
|
||||
SendEveMail::dispatch($body, (int)$charId, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,15 +35,7 @@
|
||||
<th>Update</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if(isset($error))
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
@else
|
||||
@if(isset($invoices))
|
||||
@foreach($invoices as $invoice)
|
||||
<tr>
|
||||
<td>{{ $invoice->character_name }}</td>
|
||||
|
||||
Reference in New Issue
Block a user