invoices for mining taxes

This commit is contained in:
2021-02-14 20:03:21 +09:00
parent 8af676c32a
commit 4b72a59e62
10 changed files with 141 additions and 27 deletions

View File

@@ -2,7 +2,15 @@
namespace App\Console\Commands\MiningTaxes;
//Internal Library
use Illuminate\Console\Command;
use Log;
//Application Library
use Commands\Library\CommandHelper;
//Jobs
use App\Jobs\Commands\MiningTaxes\CalculateMiningTaxesJob;
class MiningTaxesInvoices extends Command
{
@@ -37,6 +45,15 @@ class MiningTaxesInvoices extends Command
*/
public function handle()
{
$task = new CommandHelper('MiningTaxesInvoices');
//Set the task as started
$task->SetStartStatus();
CalculateMiningTaxesJob::dispatch()->onQueue('miningtaxes');
//Set the task as stopped
$task->SetStopStatus();
return 0;
}
}

View File

@@ -2,7 +2,15 @@
namespace App\Console\Commands\MiningTaxes;
//Internal Library
use Illuminate\Console\Command;
use Log;
//Application Library
use Commands\Library\CommandHelper;
//Jobs
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesLedgersJob;
class MiningTaxesLedgers extends Command
{
@@ -37,6 +45,14 @@ class MiningTaxesLedgers extends Command
*/
public function handle()
{
//Create the command helper container
$task = new CommandHelper('MiningTaxesLedger');
//Set the task as started
$task->SetStartStatus();
FetchMiningTaxesLedgersJob::dispatch()->onQueue('miningtaxes');
//Return 0
return 0;
}
}

View File

@@ -2,7 +2,13 @@
namespace App\Console\Commands\MiningTaxes;
//Internal Library
use Illuminate\Console\Command;
use Log;
use Commands\Library\CommandHelper;
//Jobs
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesObserversJob;
class MiningTaxesObservers extends Command
{
@@ -37,6 +43,16 @@ class MiningTaxesObservers extends Command
*/
public function handle()
{
//Create the command helper container
$task = new CommandHelper('MiningTaxesObservers');
//Set the task as started
$task->SetStartStatus();
FetchMiningTaxesObserversJob::dispatch()->onQueue('miningtaxes');
$task->SetStopStatus();
//Return 0 saying everything is fine
return 0;
}
}

View File

@@ -3,6 +3,13 @@
namespace App\Console\Commands\MiningTaxes;
use Illuminate\Console\Command;
use Log;
//Application Library
use Commands\Library\CommandHelper;
//Jobs
use App\Jobs\Commands\MiningTaxes\ProcessMiningTaxesPaymentsJob;
class MiningTaxesPayments extends Command
{
@@ -37,6 +44,17 @@ class MiningTaxesPayments extends Command
*/
public function handle()
{
//Create the command helper container
$task = new CommandHelper('MiningTaxesPayments');
//Set the task as started
$task->SetStartStatus();
//Dispatch the job
ProcessMiningTaxesPaymentsJob::dispatch()->onQueue('miningtaxes');
//Set the task as stopped
$task->SetStopStatus();
return 0;
}
}

View File

@@ -114,10 +114,12 @@ class Kernel extends ConsoleKernel
$schedule->command('MiningTaxes:Ledgers')
->hourlyAt('05')
->withoutOverlapping();
/*
$schedule->command('MiningTaxes:Invoices')
->dailyAt('23:00');
$schedule->command('MiningTaxes:Payments')
->dailyAt('23:50');
*/
}
/**

View File

@@ -2,13 +2,14 @@
namespace App\Jobs\Commands\MiningTaxes;
//App Library
//Internal Library
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Carbon\Carbon;
use Log;
//Library
use App\Library\Lookups\LookupHelper;
@@ -34,11 +35,13 @@ class CreateMiningTaxesInvoiceJob implements ShouldQueue
*
* @return void
*/
public function __construct($ores, $totalPrice, $charId)
public function __construct($ores = [], $totalPrice, $charId)
{
$this->ores = $ores;
$this->totalPrice = $totalPrice;
$this->charId = $charId;
$this->connection = 'redis';
}
/**
@@ -87,7 +90,7 @@ class CreateMiningTaxesInvoiceJob implements ShouldQueue
$body .= $oreName . ": " . number_format($quantity, 0, ".", ",") . "<br>";
}
$body .= "Please remit " . number_format($this->totalPrice, 2, ".", ",") . " ISK to Spatial Forces by " . $invoice->date_due . "<br>";
$body .= "Set the reason for transfer as " . $invoice->invoice_id . "<br>";
$body .= "Set the reason for transfer as MMT: " . $invoice->invoice_id . "<br>";
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
//Mail the invoice to the character if the character is in

View File

@@ -95,25 +95,14 @@ class FetchMiningTaxesObserversJob implements ShouldQueue
//Run through the mining observers, and add them to the database
foreach($response as $observer) {
//Count how many observers have the observer_id stated.
//May change this to a more efficient function later
$count = Observer::where([
'observer_id' => $observer->observer_id,
])->count();
if($count == 0) {
$obs = new Observer;
$obs->last_updated = $observer->last_updated;
$obs->observer_id = $observer->observer_id;
$obs->observer_type = $observer->observer_type;
$obs->save();
} else {
Observer::where([
'observer_id' => $observer->observer_id,
])->update([
'last_updated' => $observer->last_updated,
]);
}
Observer::updateOrInsert([
'observer_id' => $observer->observer_id,
], [
'observer_id' => $observer->observer_id,
'observer_type' => $observer->observer_type,
'last_updated' => $observer->last_updated,
]);
}
/**

View File

@@ -8,6 +8,8 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
//Might not need this class with current implementation of the mailing system
class MailMiningTaxesInvoiceJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

View File

@@ -2,11 +2,22 @@
namespace App\Jobs\Commands\MiningTaxes;
//Internal Library
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Carbon\Carbon;
use Log;
//Library
use App\Library\Lookups\LookupHelper;
//Models
use App\Models\MiningTaxes\Invoice;
use App\Models\MiningTaxes\Payment;
use App\Models\Finances\PlayerDonationJournal;
class ProcessMiningTaxesPaymentsJob implements ShouldQueue
{
@@ -19,7 +30,7 @@ class ProcessMiningTaxesPaymentsJob implements ShouldQueue
*/
public function __construct()
{
//
$this->connection = 'redis';
}
/**
@@ -29,6 +40,48 @@ class ProcessMiningTaxesPaymentsJob implements ShouldQueue
*/
public function handle()
{
//
//Declare the variables we will need
$looup = new LookupHelper;
$currentTime = Carbon::now();
//Get the outstanding invoices
$outstanding = Invoice::where([
'status' => 'Pending',
])->get();
//Use the player donation journal from finances to see if the invoice_id is present
//as a reason
foreach($outstanding as $invoice) {
//See if we have a reason with the correct uniqid from the player donation journal
$found = PlayerDonationJournal::where([
'reason' => "MMT: " . $invoice->invoice_id,
])->count();
//If we have received the invoice, then mark the invoice as paid
if($count > 0) {
//If we have the count, then grab the journal entry in order to do some things with it
$journal = PlayerDonationJournal::where([
'reason' => "MMT: " . $invoice->invoice_id,
])->first();
//If the bill is paid on time, then update the invoice as such
if($currentTime->lessThanOrEqualTo($journal->inserted_at)) {
Invoice::where([
'invoice_id' => $invoice->invoice_id,
])->update([
'status' => 'Paid',
]);
}
if($currentTime->greaterThan($journal->inserted_at)) {
Invoice::where([
'invoice_id' => $invoice->invoice_id,
])->update([
'status' => 'Paid Late',
]);
}
}
}
}
}

View File

@@ -146,9 +146,8 @@ return [
'default',
'journal',
'mail',
'structures',
'assets',
'moons',
'miningtaxes',
],
'balance' => 'auto',
'processes' => 12,
@@ -163,9 +162,8 @@ return [
'default',
'journal',
'mail',
'structures',
'assets',
'moons',
'miningtaxes',
],
'balance' => 'auto',
'processes' => 12,