diff --git a/app/Console/Commands/MiningTaxes/MiningTaxesDataCleanup.php b/app/Console/Commands/MiningTaxes/MiningTaxesDataCleanup.php
index 161b06dfb..802e9aaa6 100644
--- a/app/Console/Commands/MiningTaxes/MiningTaxesDataCleanup.php
+++ b/app/Console/Commands/MiningTaxes/MiningTaxesDataCleanup.php
@@ -51,7 +51,7 @@ class MiningTaxesDataCleanup extends Command
$task->SetStartStatus();
//Clean up old data
- Ledger::where(['updated_at', '<', Carbon::now()->subDays(120)])->delete();
+ Ledger::where(['updated_at', '<', Carbon::now()->subDays(90)])->delete();
//Set the task as finished
$task->SetStopStatus();
diff --git a/app/Console/Commands/MiningTaxes/MiningTaxesInvoices.php b/app/Console/Commands/MiningTaxes/MiningTaxesInvoices.php
index 10a6c416a..1328ce185 100644
--- a/app/Console/Commands/MiningTaxes/MiningTaxesInvoices.php
+++ b/app/Console/Commands/MiningTaxes/MiningTaxesInvoices.php
@@ -134,6 +134,18 @@ class MiningTaxesInvoices extends Command
$body .= "
";
$body .= "
Sincerely,
Warped Intentions Leadership
";
+ //Check if the mail body is greater than 2000 characters. If greater than 2,000 characters, then
+ if(sizeof($body) > 2000) {
+ $body = "Dear Miner,
";
+ $body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
+ $body .= "
";
+ $body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces by " . $dateDue . "
";
+ $body .= "Set the reason for transfer as MMT: " . $invoiceId . "
";
+ $body .= "The mining taxes are currently set to " . $numberMiningTax . "%.
";
+ $body .= "
";
+ $body .= "
Sincerely,
Warped Intentions Leadership
";
+ }
+
//Mail the invoice to the character if the character is in
//Warped Intentions or Legacy
$subject = 'Warped Intentions Mining Taxes';
diff --git a/app/Jobs/Commands/Eve/ProcessSendEveMailJob.php b/app/Jobs/Commands/Eve/ProcessSendEveMailJob.php
index 2af60e83c..e10537bdf 100644
--- a/app/Jobs/Commands/Eve/ProcessSendEveMailJob.php
+++ b/app/Jobs/Commands/Eve/ProcessSendEveMailJob.php
@@ -125,40 +125,46 @@ class ProcessSendEveMailJob implements ShouldQueue
switch($errorCode) {
case 400: //Bad Request
- $this->release(15);
+ Log::critical("Bad request has occurred in ProcessSendEveMailJob. Job has been discarded");
+ return 0;
break;
case 401: //Unauthorized Request
- $this->release(15);
+ Log::critical("Unauthorized request has occurred in ProcessSendEveMailJob at " . Carbon::now()->toDateTimeString() . ".\r\nCancelling the job.");
+ return 0;
break;
case 403: //Forbidden
- $this->release(15);
+ Log::critical("ProcessSendEveMailJob has incurred a forbidden error. Cancelling the job.");
+ return 0;
break;
case 420: //Error Limited
Log::warning("Error rate limit occurred in ProcessSendEveMailJob. Restarting job in 120 seconds.");
$this->release(120);
break;
case 500: //Internal Server Error
- Log::critical("Internal Server Error for ESI in ProcessSendEveMailJob");
- return 0;
+ Log::critical("Internal Server Error for ESI in ProcessSendEveMailJob. Attempting a restart in 120 seconds.");
+ $this->release(120);
break;
case 503: //Service Unavailable
- Log::critical("Service Unavailabe for ESI in ProcessSendEveMailJob");
- $this->release(15);
+ Log::critical("Service Unavailabe for ESI in ProcessSendEveMailJob. Releasing the job back to the queue in 30 seconds.");
+ $this->release(30);
break;
case 504: //Gateway Timeout
- Log::critical("Gateway timeout in ProcessSendEveMailJob");
- $this->release(15);
+ Log::critical("Gateway timeout in ProcessSendEveMailJob. Releasing the job back to the queue in 30 seconds.");
+ $this->release(30);
break;
case 520: //Internal Error -- Mostly comes when rate limited hit
- $this->release(15);
+ Log::warning("Rate limit hit for ProcessSendEveMailJob. Releasing the job back to the queue in 30 seconds.");
+ $this->release(30);
+ break;
+ case 201:
+ $this->SaveSentRecord($this->sender, $this->subject, $this->body, $this->recipient, $this->recipient_type);
+ $this->delete();
break;
default: //If not an error, then just break out of the switch statement
break;
}
-
- $this->SaveSentRecord($this->sender, $this->subject, $this->body, $this->recipient, $this->recipient_type);
- $this->delete();
+ return 0;
}
/**
diff --git a/app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesLedgersJob.php b/app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesLedgersJob.php
index 59c7d8746..cbf3a99b6 100644
--- a/app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesLedgersJob.php
+++ b/app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesLedgersJob.php
@@ -68,51 +68,55 @@ class ProcessMiningTaxesLedgersJob implements ShouldQueue
$mHelper = new MoonCalc;
$config = config('esi');
- //Get some of the basic information we need to work with
- $charName = $lookup->CharacterIdToName($this->ledger->character_id);
- //Get the type name from the ledger ore
- $typeName = $lookup->ItemIdToName($this->ledger->type_id);
- //Get the price from the helper function
- $price = $mHelper->CalculateOrePrice($this->ledger->type_id);
- //Calculate the total price based on the amount
- $amount = (($price * $this->ledger->quantity) * $config['refine_rate']);
+ //Create a starting date for the ledger
+ $ledgerDate = Carbon::createFromFormat('Y-m-d', $this->ledger->last_updated);
+
+ //If the ledger is more than one day old, then process it, otherwise, we don't process it
+ //or add it to the database as it may still be updating.
+ if($ledgerDate->lessThan(Carbon::now()->subDay())) {
+ //Get some of the basic information we need to work with
+ $charName = $lookup->CharacterIdToName($this->ledger->character_id);
+ //Get the type name from the ledger ore
+ $typeName = $lookup->ItemIdToName($this->ledger->type_id);
+ //Get the price from the helper function
+ $price = $mHelper->CalculateOrePrice($this->ledger->type_id);
+ //Calculate the total price based on the amount
+ $amount = (($price * $this->ledger->quantity) * $config['refine_rate']);
- $found = Ledger::where([
- 'character_id' => $this->ledger->character_id,
- 'observer_id' => $this->observerId,
- 'type_id' => $this->ledger->type_id,
- 'last_updated' => $this->ledger->last_updated,
- ])->count();
-
- if($found > 0) {
- Ledger::where([
+ $found = Ledger::where([
'character_id' => $this->ledger->character_id,
- 'character_name' => $charName,
'observer_id' => $this->observerId,
'type_id' => $this->ledger->type_id,
- 'quantity' => $this->ledger->quantity,
'last_updated' => $this->ledger->last_updated,
- ])->update([
- 'character_id' => $this->ledger->character_id,
- 'character_name' => $charName,
- 'observer_id' => $this->observerId,
- 'last_updated' => $this->ledger->last_updated,
- 'type_id' => $this->ledger->type_id,
- 'ore_name' => $typeName,
- 'quantity' => $this->ledger->quantity,
- 'amount' => $amount,
- ]);
- } else {
- $ledg = new Ledger;
- $ledg->character_id = $this->ledger->character_id;
- $ledg->character_name = $charName;
- $ledg->observer_id = $this->observerId;
- $ledg->last_updated = $this->ledger->last_updated;
- $ledg->type_id = $this->ledger->type_id;
- $ledg->ore_name = $typeName;
- $ledg->quantity = $this->ledger->quantity;
- $ledg->amount = $amount;
- $ledg->save();
+ ])->count();
+
+ if($found > 0) {
+ Ledger::where([
+ 'character_id' => $this->ledger->character_id,
+ 'character_name' => $charName,
+ 'observer_id' => $this->observerId,
+ 'type_id' => $this->ledger->type_id,
+ 'quantity' => $this->ledger->quantity,
+ 'last_updated' => $this->ledger->last_updated,
+ ])->update([
+ 'last_updated' => $this->ledger->last_updated,
+ 'quantity' => $this->ledger->quantity,
+ 'amount' => $amount,
+ ]);
+ } else {
+ $ledg = new Ledger;
+ $ledg->character_id = $this->ledger->character_id;
+ $ledg->character_name = $charName;
+ $ledg->observer_id = $this->observerId;
+ $ledg->last_updated = $this->ledger->last_updated;
+ $ledg->type_id = $this->ledger->type_id;
+ $ledg->ore_name = $typeName;
+ $ledg->quantity = $this->ledger->quantity;
+ $ledg->amount = $amount;
+ $ledg->save();
+ }
}
+
+ return 0;
}
}