process mining taxes ledgers update to disregard updating previously saved ledgers to prevent future errors

This commit is contained in:
2021-05-24 18:52:23 +09:00
parent 0872d2f61a
commit 565f51e81c
2 changed files with 20 additions and 34 deletions

View File

@@ -92,20 +92,7 @@ class ProcessMiningTaxesLedgers implements ShouldQueue
'last_updated' => $this->ledger->last_updated, 'last_updated' => $this->ledger->last_updated,
])->count(); ])->count();
if($found > 0) { 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 = new Ledger;
$ledg->character_id = $this->ledger->character_id; $ledg->character_id = $this->ledger->character_id;
$ledg->character_name = $charName; $ledg->character_name = $charName;

View File

@@ -14,8 +14,9 @@ use App\Library\Helpers\LookupHelper;
//Models //Models
use App\Models\MiningTax\Invoice; use App\Models\MiningTax\Invoice;
use App\Models\MiningTax\Ledger; use App\Models\MiningTax\Ledger;
use App\Models\User\User;
use App\Models\User\UserAlt; //Jobs
use App\Jobs\Commands\Eve\SendEveMail;
class MiningTaxHelper { class MiningTaxHelper {
/** /**
@@ -28,14 +29,14 @@ class MiningTaxHelper {
public function __construct() { 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 * @var $charId
* @return collection $ledgers * @return collection $ledgers
*/ */
public function GetMainLedgers($charId) { public function GetLedgers(int $charId) {
$ledgers = new Collection; $ledgers = new Collection;
$rowCount = Ledger::where([ $rowCount = Ledger::where([
@@ -43,12 +44,12 @@ class MiningTaxHelper {
'invoiced' => 'No', 'invoiced' => 'No',
])->count(); ])->count();
$rows = Ledger::where([
'character_id' => $charId,
'invoiced' => 'No',
])->get()->toArry();
if($rowCount > 0) { if($rowCount > 0) {
$rows = Ledger::where([
'character_id' => $charId,
'invoiced' => 'No',
])->get()->toArray();
foreach($rows as $row) { foreach($rows as $row) {
$ledgers->push($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) { public function MailMiningInvoice(int $charId, collection $ledgers, int &$mailDelay) {
$ledgers = new Collection;
}
}
public function
} }