invoices for mining taxes
This commit is contained in:
@@ -2,7 +2,15 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands\MiningTaxes;
|
namespace App\Console\Commands\MiningTaxes;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use Commands\Library\CommandHelper;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\MiningTaxes\CalculateMiningTaxesJob;
|
||||||
|
|
||||||
class MiningTaxesInvoices extends Command
|
class MiningTaxesInvoices extends Command
|
||||||
{
|
{
|
||||||
@@ -37,6 +45,15 @@ class MiningTaxesInvoices extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,15 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands\MiningTaxes;
|
namespace App\Console\Commands\MiningTaxes;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use Commands\Library\CommandHelper;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesLedgersJob;
|
||||||
|
|
||||||
class MiningTaxesLedgers extends Command
|
class MiningTaxesLedgers extends Command
|
||||||
{
|
{
|
||||||
@@ -37,6 +45,14 @@ class MiningTaxesLedgers extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands\MiningTaxes;
|
namespace App\Console\Commands\MiningTaxes;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Log;
|
||||||
|
use Commands\Library\CommandHelper;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesObserversJob;
|
||||||
|
|
||||||
class MiningTaxesObservers extends Command
|
class MiningTaxesObservers extends Command
|
||||||
{
|
{
|
||||||
@@ -37,6 +43,16 @@ class MiningTaxesObservers extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,13 @@
|
|||||||
namespace App\Console\Commands\MiningTaxes;
|
namespace App\Console\Commands\MiningTaxes;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use Commands\Library\CommandHelper;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\MiningTaxes\ProcessMiningTaxesPaymentsJob;
|
||||||
|
|
||||||
class MiningTaxesPayments extends Command
|
class MiningTaxesPayments extends Command
|
||||||
{
|
{
|
||||||
@@ -37,6 +44,17 @@ class MiningTaxesPayments extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,10 +114,12 @@ class Kernel extends ConsoleKernel
|
|||||||
$schedule->command('MiningTaxes:Ledgers')
|
$schedule->command('MiningTaxes:Ledgers')
|
||||||
->hourlyAt('05')
|
->hourlyAt('05')
|
||||||
->withoutOverlapping();
|
->withoutOverlapping();
|
||||||
|
/*
|
||||||
$schedule->command('MiningTaxes:Invoices')
|
$schedule->command('MiningTaxes:Invoices')
|
||||||
->dailyAt('23:00');
|
->dailyAt('23:00');
|
||||||
$schedule->command('MiningTaxes:Payments')
|
$schedule->command('MiningTaxes:Payments')
|
||||||
->dailyAt('23:50');
|
->dailyAt('23:50');
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Jobs\Commands\MiningTaxes;
|
namespace App\Jobs\Commands\MiningTaxes;
|
||||||
|
|
||||||
//App Library
|
//Internal Library
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Log;
|
||||||
|
|
||||||
//Library
|
//Library
|
||||||
use App\Library\Lookups\LookupHelper;
|
use App\Library\Lookups\LookupHelper;
|
||||||
@@ -34,11 +35,13 @@ class CreateMiningTaxesInvoiceJob implements ShouldQueue
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct($ores, $totalPrice, $charId)
|
public function __construct($ores = [], $totalPrice, $charId)
|
||||||
{
|
{
|
||||||
$this->ores = $ores;
|
$this->ores = $ores;
|
||||||
$this->totalPrice = $totalPrice;
|
$this->totalPrice = $totalPrice;
|
||||||
$this->charId = $charId;
|
$this->charId = $charId;
|
||||||
|
|
||||||
|
$this->connection = 'redis';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,7 +90,7 @@ class CreateMiningTaxesInvoiceJob implements ShouldQueue
|
|||||||
$body .= $oreName . ": " . number_format($quantity, 0, ".", ",") . "<br>";
|
$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 .= "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>";
|
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||||
|
|
||||||
//Mail the invoice to the character if the character is in
|
//Mail the invoice to the character if the character is in
|
||||||
|
|||||||
@@ -95,25 +95,14 @@ class FetchMiningTaxesObserversJob implements ShouldQueue
|
|||||||
|
|
||||||
//Run through the mining observers, and add them to the database
|
//Run through the mining observers, and add them to the database
|
||||||
foreach($response as $observer) {
|
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) {
|
Observer::updateOrInsert([
|
||||||
$obs = new Observer;
|
'observer_id' => $observer->observer_id,
|
||||||
$obs->last_updated = $observer->last_updated;
|
], [
|
||||||
$obs->observer_id = $observer->observer_id;
|
'observer_id' => $observer->observer_id,
|
||||||
$obs->observer_type = $observer->observer_type;
|
'observer_type' => $observer->observer_type,
|
||||||
$obs->save();
|
'last_updated' => $observer->last_updated,
|
||||||
} else {
|
]);
|
||||||
Observer::where([
|
|
||||||
'observer_id' => $observer->observer_id,
|
|
||||||
])->update([
|
|
||||||
'last_updated' => $observer->last_updated,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
|||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
|
||||||
|
//Might not need this class with current implementation of the mailing system
|
||||||
class MailMiningTaxesInvoiceJob implements ShouldQueue
|
class MailMiningTaxesInvoiceJob implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|||||||
@@ -2,11 +2,22 @@
|
|||||||
|
|
||||||
namespace App\Jobs\Commands\MiningTaxes;
|
namespace App\Jobs\Commands\MiningTaxes;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
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
|
class ProcessMiningTaxesPaymentsJob implements ShouldQueue
|
||||||
{
|
{
|
||||||
@@ -19,7 +30,7 @@ class ProcessMiningTaxesPaymentsJob implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
//
|
$this->connection = 'redis';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,6 +40,48 @@ class ProcessMiningTaxesPaymentsJob implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
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',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,9 +146,8 @@ return [
|
|||||||
'default',
|
'default',
|
||||||
'journal',
|
'journal',
|
||||||
'mail',
|
'mail',
|
||||||
'structures',
|
|
||||||
'assets',
|
'assets',
|
||||||
'moons',
|
'miningtaxes',
|
||||||
],
|
],
|
||||||
'balance' => 'auto',
|
'balance' => 'auto',
|
||||||
'processes' => 12,
|
'processes' => 12,
|
||||||
@@ -163,9 +162,8 @@ return [
|
|||||||
'default',
|
'default',
|
||||||
'journal',
|
'journal',
|
||||||
'mail',
|
'mail',
|
||||||
'structures',
|
|
||||||
'assets',
|
'assets',
|
||||||
'moons',
|
'miningtaxes',
|
||||||
],
|
],
|
||||||
'balance' => 'auto',
|
'balance' => 'auto',
|
||||||
'processes' => 12,
|
'processes' => 12,
|
||||||
|
|||||||
Reference in New Issue
Block a user