ores = $ores;
$this->totalPrice = $totalPrice;
$this->charId = $charId;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//Declare variables
$lookup = new LookupHelper;
$config = config('esi');
$body = '';
//Get the character name from the character id
$charName = $lookup->CharacterIdToName($this->charId);
//Generate an invoice id
$invoiceId = uniqid();
$invoice = new Invoice;
$invoice->character_id = $this->charId;
$invoice->character_name = $charName;
$invoice->invoice_id = $invoiceId;
$invoice->invoice_amount = $this->totalPrice;
$invoice->date_issued = Carbon::now();
$invoice->date_due = Carbon::now()->addDays(7);
$invoice->status = 'Pending';
$invoice->save();
//Update the entries in the mining tax ledgers table to show the ore has been invoiced
Ledger::where([
'character_id' => $this->charId,
'invoiced' => 'No',
])->update([
'invoiced' => 'Yes',
]);
$body .= "Dear Miner,
";
$body .= "Mining Taxes are due for the following ores mined from alliance moons:
";
foreach($this->ores as $ore => $quantity) {
$oreName = $lookup->ItemIdToName($ore);
$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 .= "
Sincerely,
Warped Intentions Leadership
";
//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 = $this->charId;
ProcessSendEveMailJob::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
}
}