mining taxes

This commit is contained in:
2021-03-07 06:20:19 +09:00
parent e23c97f455
commit 59868bb63a
8 changed files with 129 additions and 22 deletions

View File

@@ -123,10 +123,17 @@ class MiningTaxesInvoices extends Command
$body .= "Mining Taxes are due for the following ores mined from alliance moons: <br>";
foreach($ores as $ore => $quantity) {
$oreName = $lookup->ItemIdToName($ore);
$body .= $oreName . ": " . number_format($quantity, 0, ".", ",") . "<br>";
$body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), 0, ".", ",") . "<br>";
}
$body .= "Please remit " . number_format($totalPrice, 2, ".", ",") . " ISK to Spatial Forces by " . $invoice->date_due . "<br>";
$body .= "Set the reason for transfer as MMT: " . $invoice->invoice_id . "<br>";
$body .= "<br><br>";
$body .= "You can also send a contract with the following ores in the contract with the reason set as MMT: " . $invoice->invoice_id . "<br>";
foreach($ores as $ore => $quantity) {
$oreName = $lookup->ItemIdToName($ore);
$body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), ".", ",") . "<br>";
}
$body .= "<br>";
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
//Mail the invoice to the character if the character is in

View File

@@ -2,6 +2,7 @@
namespace App\Console\Commands\MiningTaxes;
//Internal Library
use Illuminate\Console\Command;
use Log;
use Carbon\Carbon;
@@ -9,6 +10,8 @@ use Carbon\Carbon;
//Application Library
use Commands\Library\CommandHelper;
use App\Library\Lookup\LookupHelper;
use Seat\Eseye\Exceptions\RequestFailedException;
use App\Library\Esi\Esi;
//Models
use App\Models\MiningTaxes\Invoice;
@@ -122,7 +125,7 @@ class MiningTaxesPayments extends Command
} else {
//If we didn't found a journal entry, then we shall check the contracts for a correct entry
foreach($contracts as $contract) {
if(($contract->title == $invoice->invoice_id) && ($currentTime->lessThanOrEqualTo($invoice->due_date))) {
if(($contract->title == ("MMT: " . $invoice->invoice_id)) && ($currentTime->lessThanOrEqualTo($invoice->due_date))) {
Invoice::where([
'invoice_i' => $invoice->invoice_id,
])->update([
@@ -130,7 +133,7 @@ class MiningTaxesPayments extends Command
]);
}
if(($contract->title == $invoice_id) && ($currentTime->greaterThan($invoice->due_date))) {
if(($contract->title == ("MMT: " . $invoice_id)) && ($currentTime->greaterThan($invoice->due_date))) {
Invoice::where([
'invoice_id' => $invoice->invoice_id,
])->update([

View File

@@ -71,14 +71,15 @@ class Kernel extends ConsoleKernel
->dailyAt('22:00')
->withoutOverlapping();
$schedule->command('MiningTaxes:Ledgers')
->hourlyAt('05')
->dailyAt('20:00')
->withoutOverlapping();
/*
$schedule->command('MiningTaxes:Invoices')
->dailyAt('23:00');
->weeklyOn(1, '8:00')
->withoutOverlapping();
$schedule->command('MiningTaxes:Payments')
->dailyAt('23:50');
*/
->hourlyAt('15')
->withoutOverlapping();
}
/**

View File

@@ -5,14 +5,26 @@ namespace App\Http\Controllers\MiningTaxes;
//Internal Library
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Log;
use Carbon\Carbon;
use Khill\Lavacharts\Lavacharts;
use Auth;
//Application Library
use App\Library\Helpers\LookupHelper;
use App\Library\Helpers\StructureHelper;
use Seat\Eseye\Exceptions\RequestFailedException;
use App\Library\Esi\Esi;
//Models
use App\Models\MiningTax\Invoice;
use App\Models\MiningTax\Observer;
use App\Models\MiningTax\Ledger;
use App\Models\MiningTax\Payment;
use App\Models\Moon\ItemComposition;
use App\Models\Moon\MineralPrice;
use App\Models\Esi\EsiToken;
use App\Models\Esi\EsiScope;
class MiningTaxesAdminController extends Controller
{
@@ -82,13 +94,5 @@ class MiningTaxesAdminController extends Controller
])->get()->paginate(50);
return view('miningtax.admin.display.paidinvoices')->with('invoices', $invoices);
}
/**
* Display admin mining ledgers by month
*/
public function DisplayMonthlyMiningLedgers() {
}
}
}

View File

@@ -93,10 +93,16 @@ class MiningTaxesController extends Controller
//Declare variables
$structures = array();
$sHelper = new StructureHelper;
$esiHelper = new Esi;
$config = config('esi');
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
return redirect('/dashboard')->with('error', 'Tell the nub Minerva to register the correct scopes for the services site.');
}
//Get the esi data for extractions
try {
$extractions = $this->esi->invoke('get', '/corporation/{corporation_id}/mining/extractions/', [
$extractions = $esi->invoke('get', '/corporation/{corporation_id}/mining/extractions/', [
'corporation_id' => $config['corporation'],
]);
} catch(RequestFailedException $e) {
@@ -119,6 +125,78 @@ class MiningTaxesController extends Controller
return view('miningtax.user.display.upcoming')->with('extractions', $extractions);
}
/**
* Display a calendar of upcoming extractions
*/
public function DisplayExtractionCalendar() {
//Declare variables
$structures = array();
$sHelper = new StructureHelper;
$lava = new Lavacharts;
$esiHelper = new Esi;
$config = config('esi');
//Check for the correct scopes
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
return redirect('/dashboard')->with('error', 'Tell the nub Minerva to register the correct scopes for the services site.');
}
//Get the esi data for extractions
try {
$response = $esi->invoke('get', '/corporation/{corporation_id}/mining/extractions', [
'corporation_id' => $config['corporation'],
]);
} catch(RequestFailedException $e) {
Log::critical('Could not retrieve the extractions from ESI in DisplayExtractionCalendar in MiningTaxesController');
return redirect('/dashboard')->with('error', 'Failed to get extraction data from ESI');
}
//Decode the extraction data from ESI
$extractions = json_decode($response, false);
/**
* Create a 3 month calendar for the past, current, and future extractions
*/
//Create the data tables
$calendar = $lava->DataTable();
$calendar->addDateTimeColumn('Date')
->addBooleanColumn('YesNo')
->addStringColumn('Extractions');
foreach($extractions as $extract) {
$calendar->addRow([
$extract->chunk_arrival_time,
1
]);
}
$lava->CalendarChart('Extractions', $calendar, [
'title' => 'Upcoming Extractions',
'unusedMonthOutlineColor' => [
'stroke' => '#ECECEC',
'strokeOpacity' => 0.75,
'strokeWidth' => 1,
],
'dayOfWeekLabel' => [
'color' => '#4f5b0d',
'fontSize' => 16,
'italic' => true,
],
'noDataPattern' => [
'color' => '#DDD',
'backgroundColor' => '#11FFFF',
],
'colorAxis' => [
'values' => [0, 100],
'colors' => ['black', 'green'],
],
]);
return view('miningtax.user.display.calendar')->with('calendar', $calendar)
->with('lava', $lava);
}
/**
* Display the ledger for the moons.
*/

View File

@@ -7,6 +7,6 @@
'primary' => env('ESI_PRIMARY_CHAR', 93738489),
'alliance' => env('ESI_ALLIANCE', 99004116),
'corporation' => env('ESI_CORPORATION', 98287666),
'mining_tax' => 0.10,
'mining_tax' => 0.15,
];
?>

View File

@@ -0,0 +1,14 @@
@extends('layouts.user.dashb4')
@section('content')
<br>
<div class="container">
<div class="card">
<div class="card-header">
<h2>Mining Calendar</h2>
</div>
<div class="card-body">
@calendarchart('calendar', 'calendar_div')
</div>
</div>
</div>
@endsection

View File

@@ -69,12 +69,12 @@ Route::group(['middleware' => ['auth']], function(){
*/
Route::get('/miningtax/display/invoices', 'MiningTaxes\MiningTaxesController@DisplayMiningTaxesInvoices');
Route::get('/miningtax/display/extractions', 'MiningTaxes\MiningTaxesController@DisplayUpcomingExtractions');
Route::get('miningtax/display/ledgers', 'MiningTaxes\MiningTaxesController@DisplayMoonLedgers');
Route::get('/miningtax/display/ledgers', 'MiningTaxes\MiningTaxesController@DisplayMoonLedgers');
Route::get('/miningtax/display/calendar', 'MiningTaxes\MiningTaxesController@DisplayExtractionCalendar');
Route::get('/miningtax/admin/display/unpaid', 'MiningTaxes\MiningTaxesAdminController@DisplayUnpaidInvoice');
Route::post('/miningtax/admin/update/invoice', 'MiningTaxes\MiningTaxesAdminController@UpdateInvoice');
Route::post('/miningtax/admin/delete/invoice', 'MiningTaxes\MiningTaxesAdminController@DeleteInvoice');
Route::get('/miningtax/admin/display/paid', 'MiningTaxes\MiningTaxesAdminController@DisplayPaidInvoices');
Route::get('/miningtax/admin/display/monthly/ledgers', 'MiningTaxes\MiningTaxesAdminController@DisplayMonthlyMiningLedgers');
/**
* Scopes Controller display pages