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,
])->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;

View File

@@ -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) {
}
}