diff --git a/app/Console/Commands/MiningTaxes/MiningTaxesInvoices.php b/app/Console/Commands/MiningTaxes/MiningTaxesInvoices.php index d1a4253b0..683df32ad 100644 --- a/app/Console/Commands/MiningTaxes/MiningTaxesInvoices.php +++ b/app/Console/Commands/MiningTaxes/MiningTaxesInvoices.php @@ -144,7 +144,7 @@ class MiningTaxesInvoices extends Command $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) { + if(strlen($body) > 2000) { $body = "Dear Miner,

"; $body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK."; $body .= "

"; diff --git a/app/Console/Commands/MiningTaxes/MiningTaxesInvoicesNew.php b/app/Console/Commands/MiningTaxes/MiningTaxesInvoicesNew.php index 5e0c850eb..0c1e9167e 100644 --- a/app/Console/Commands/MiningTaxes/MiningTaxesInvoicesNew.php +++ b/app/Console/Commands/MiningTaxes/MiningTaxesInvoicesNew.php @@ -101,138 +101,23 @@ class MiningTaxesInvoicesNew extends Command //Build a character Id list for the characters before processing the ledgers. $alts = UserAlt::where([ - 'main_id' => 95366854, + 'main_id' => $mainId, ])->get(); - $rows = new Ledger(); - $temps = Ledger::where([ - 'character_id' => 2114000847, - ])->get(); - - $rows->add($temps); - dd($rows); + //First check to see if the main character had a mining ledger from a corp moon + $mainIdLedgerFound = Ledger::where([ + 'character_id' => $mainId, + 'invoiced' => 'No', + ])->count(); - //Get the ledgers for the main character - $rows = Ledger::where([ - 'character_id' => 95366854, - ])->get(); - + //If there are mining ledgers, then this is the character want to send the invoice to once everything has been tallied up. + if($mainIdLedgerFound > 0) { - foreach($alts as $alt) { - $altLedger = Ledger::where([ - 'character_id' => $alt->character_id, - ])->get(); - - $rows->push($altLedger); + } else { + } - dd($rows); - - if($rows->count() > 0) { - //Create the ore set for later for item composition and other functions - foreach($rows as $row) { - if(!isset($ores[$row['type_id']])) { - $ores[$row['type_id']] = 0; - } - //Add up the ores from each row - $ores[$row['type_id']] = $ores[$row['type_id']] + $row['quantity']; - - //Add up the total price from the ledger rows for the totalized cost - $totalPrice = $totalPrice + $row['amount']; - } - - //Reduce the total price by the take percentage - $invoiceAmount = round(($totalPrice * $config['mining_tax']), 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,

"; - $body .= "Mining Taxes are due for the following ores mined from alliance moons:
"; - foreach($ores as $ore => $quantity) { - $oreName = $lookup->ItemIdToName($ore); - $body .= $oreName . ": " . number_format($quantity, 0, ".", ",") . "
"; - } - $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 .= "You can also send a contract with the following ores in the contract with the reason set as MMT: " . $invoiceId . "
"; - foreach($ores as $ore => $quantity) { - $oreName = $lookup->ItemIdToName($ore); - $body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), 0, ".", ",") . "
"; - } - $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'; - $sender = $config['primary']; - $recipientType = 'character'; - $recipient = $charId; - - /** - * Send the eve mail out to the character. - * Disabled currently for testing - * ProcessSendEveMailJob::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay)); - */ - - /** - * Save the invoice using eloquent models. - * Currently disabled for testing. - * $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. - * This is disabled for testing currently. - * //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