From 565f51e81c112d9a76ea72023bb1e5f3ab204b92 Mon Sep 17 00:00:00 2001 From: drkthunder02 Date: Mon, 24 May 2021 18:52:23 +0900 Subject: [PATCH] process mining taxes ledgers update to disregard updating previously saved ledgers to prevent future errors --- .../MiningTaxes/ProcessMiningTaxesLedgers.php | 15 +------ app/Library/Helpers/MiningTaxHelper.php | 39 +++++++++---------- 2 files changed, 20 insertions(+), 34 deletions(-) diff --git a/app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesLedgers.php b/app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesLedgers.php index df31a0682..ade6e52f9 100644 --- a/app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesLedgers.php +++ b/app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesLedgers.php @@ -92,20 +92,7 @@ class ProcessMiningTaxesLedgers implements ShouldQueue 'last_updated' => $this->ledger->last_updated, ])->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 { + if($found == 0) { $ledg = new Ledger; $ledg->character_id = $this->ledger->character_id; $ledg->character_name = $charName; diff --git a/app/Library/Helpers/MiningTaxHelper.php b/app/Library/Helpers/MiningTaxHelper.php index 86e489f4b..5908eca44 100644 --- a/app/Library/Helpers/MiningTaxHelper.php +++ b/app/Library/Helpers/MiningTaxHelper.php @@ -14,8 +14,9 @@ use App\Library\Helpers\LookupHelper; //Models use App\Models\MiningTax\Invoice; use App\Models\MiningTax\Ledger; -use App\Models\User\User; -use App\Models\User\UserAlt; + +//Jobs +use App\Jobs\Commands\Eve\SendEveMail; class MiningTaxHelper { /** @@ -28,14 +29,14 @@ class MiningTaxHelper { public function __construct() { } - + /** - * Get the main character ledgers and send back as a collection + * Get the ledgers for a certain character and send back as a collection * * @var $charId * @return collection $ledgers */ - public function GetMainLedgers($charId) { + public function GetLedgers(int $charId) { $ledgers = new Collection; $rowCount = Ledger::where([ @@ -43,12 +44,12 @@ class MiningTaxHelper { 'invoiced' => 'No', ])->count(); - $rows = Ledger::where([ - 'character_id' => $charId, - 'invoiced' => 'No', - ])->get()->toArry(); - if($rowCount > 0) { + $rows = Ledger::where([ + 'character_id' => $charId, + 'invoiced' => 'No', + ])->get()->toArray(); + foreach($rows as $row) { $ledgers->push($row); } @@ -58,16 +59,14 @@ class MiningTaxHelper { } /** - * Get the alt characters ledgers and send back as a collection + * Create the invoice and mail it + * + * @var int $charId + * @var collection $ledgers + * @var int $mailDelay * - * @var array $alts - * @return collection ledgers */ - public function GetAltLedgers($alts) { - $ledgers = new Collection; - - - } - - public function + public function MailMiningInvoice(int $charId, collection $ledgers, int &$mailDelay) { + + } } \ No newline at end of file