structure market tax
This commit is contained in:
81
app/Console/Commands/Finances/CorpFinances.php
Normal file
81
app/Console/Commands/Finances/CorpFinances.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
//User Library
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\CorpMarketJournal;
|
||||
use App\Models\Finances\CorpMarketStructure;
|
||||
|
||||
class CorpFinances extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:CorpFinances';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get the corporation finances journal to get the market fees from the master wallet';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('CorpFinances');
|
||||
|
||||
//Add entry into the table saying the jobs is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Setup the Finances container
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Get the corporations who have registered for structure markets
|
||||
$structures = CorpMarketStructure::all();
|
||||
|
||||
foreach($structures as $structure) {
|
||||
$pages = $finance->GetJournalPageCount(1, $structure->character_id);
|
||||
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
$job = new JobProcessCorpJournal;
|
||||
$job->division = 1;
|
||||
$job->charId = $structure->character_id;
|
||||
$job->corpId = $structure->corporation_id;
|
||||
$job->page = $i;
|
||||
ProcessCorpJournalJob::dispatch($job)->onQueue('journal');
|
||||
}
|
||||
}
|
||||
|
||||
//mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
42
app/Console/Commands/Finances/CorpMarketMail.php
Normal file
42
app/Console/Commands/Finances/CorpMarketMail.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CorpMarketMail extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'command:name';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
85
app/Http/Controllers/Market/MarketController.php
Normal file
85
app/Http/Controllers/Market/MarketController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Market;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Finances\CorpMarketJournal;
|
||||
use App\Models\Finances\CorpMarketStructure;
|
||||
|
||||
class MarketController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:structure.market');
|
||||
}
|
||||
|
||||
public function displayAddMarketTax() {
|
||||
return view('market.add.display');
|
||||
}
|
||||
|
||||
public function storeAddMarketTax(Request $request) {
|
||||
$this->validate($request, [
|
||||
'tax' => 'required',
|
||||
]);
|
||||
|
||||
$charId = auth()->user()->getId();
|
||||
|
||||
//Declare the esi helper
|
||||
$esiHelper = new Esi;
|
||||
//Create the esi container to get the character's public information
|
||||
$esi = new Eseye();
|
||||
try {
|
||||
$charInfo = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestExceptionFailed $e) {
|
||||
return redirect('/market/add')->with('erorr', 'Failed to get character info.');
|
||||
}
|
||||
|
||||
$ratio = $request->tax / 2.5;
|
||||
|
||||
$corpMarket = new CorpMarketStructure;
|
||||
$corpMarket->character_id = $charId;
|
||||
$corpMarket->corporation_id = $charInfo->corporation_id;
|
||||
$corpMarket->tax = $request->tax;
|
||||
$corpMarket->ratio = $ratio;
|
||||
$corpMarket->save();
|
||||
|
||||
return redirect('/dahsboard')->with('success', 'Market structure recorded.');
|
||||
}
|
||||
|
||||
public function displayTaxes() {
|
||||
$charId = auth()->user()->getId();
|
||||
|
||||
$esi = new Eseye();
|
||||
try {
|
||||
$charInfo = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestExceptionFailed $e) {
|
||||
return redirect('/market/add')->with('erorr', 'Failed to get character info.');
|
||||
}
|
||||
|
||||
//Get the total taxes from the database
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
78
app/Jobs/ProcessCorpJournalJob.php
Normal file
78
app/Jobs/ProcessCorpJournalJob.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
use App\Jobs\Library\JobHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessCorpJournal;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class ProcessCorpJournalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 600;
|
||||
|
||||
public $tries = 3;
|
||||
|
||||
private $division;
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $page;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(JobProcessCorpJournal $pcj)
|
||||
{
|
||||
$this->division = $pcj->division;
|
||||
$this->charId = $pcj->charId;
|
||||
$this->corpId = $pcj->corpId;
|
||||
$this->page = $pcj->page;
|
||||
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Delcare the class variable we need
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
$finance->GetCorpWalletJournalPage($this->division, $this->charId, $this->corpId, $this->page);
|
||||
|
||||
//After the job is completed, delete the job
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* The job failed to process
|
||||
*
|
||||
* @param Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function failed($exception) {
|
||||
Log::critical($exception);
|
||||
}
|
||||
}
|
||||
@@ -39,11 +39,9 @@ class Esi {
|
||||
$config = config('esi');
|
||||
|
||||
//Check for an esi scope
|
||||
$checks = DB::table('EsiScopes')->where('character_id', $charId)->get();
|
||||
foreach($checks as $check) {
|
||||
if($check->scope === $scope) {
|
||||
return true;
|
||||
}
|
||||
$check = EsiScope::where(['character_id' => $charId, 'scope' => $scope])->count();
|
||||
if($check == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$mail = new EveMail;
|
||||
@@ -155,6 +153,51 @@ class Esi {
|
||||
//Return the combined date in the correct format
|
||||
return $realDate;
|
||||
}
|
||||
|
||||
public function GetToken($charId, $scope) {
|
||||
//Get the refresh token from the database
|
||||
$tokenCount = EsiToken::where([
|
||||
'character_id' => $charId,
|
||||
])->count();
|
||||
|
||||
if($tokenCount == 0) {
|
||||
$config = config('esi');
|
||||
|
||||
$mail = new EveMail;
|
||||
$mail->sender = $config['primary'];
|
||||
$mail->subject = 'W4RP Services - No Token Found';
|
||||
$mail->body = "Please register at https://services.w4rp.space with the scope: " . $scope;
|
||||
$mail->recipient = (int)$charId;
|
||||
$mail->recipient_type = 'character';
|
||||
SendEveMailJob::dispatch($mail)->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$token = EsiToken::where([
|
||||
'character_id' => $charId,
|
||||
])->first();
|
||||
|
||||
$scope = EsiScope::where([
|
||||
'character_id' => $charId,
|
||||
'scope' => $scope,
|
||||
])->count();
|
||||
|
||||
if($scope == 0) {
|
||||
$mail = new EveMail;
|
||||
$mail->sender = $config['primary'];
|
||||
$mail->subject = 'W4RP Services - Incorrect ESI Scope';
|
||||
$mail->body = "Please register on https://services.w4rp.space with the scope: " . $scope;
|
||||
$mail->recipient = (int)$charId;
|
||||
$mail->recipient_type = 'character';
|
||||
|
||||
SendEveMailJob::dispatch($mail)->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
|
||||
|
||||
return null;
|
||||
} else {
|
||||
return $token->refresh_token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
63
app/Library/Finances/CorpMarketTax.php
Normal file
63
app/Library/Finances/CorpMarketTax.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
use DB;
|
||||
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
use App\Models\Finances\CorpMarketJournal;
|
||||
|
||||
class CorpMarketTax {
|
||||
public function InsertCorpMarketTax($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!CorpMarketJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new CorpMarketJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -21,6 +21,7 @@ use App\Models\Mail\EveMail;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Finances\CorpMarketJournal;
|
||||
use App\Library\Finances\MarketTax;
|
||||
use App\Library\Finances\PlayerDonation;
|
||||
use App\Library\Finances\ReprocessingTax;
|
||||
@@ -39,20 +40,16 @@ use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
class FinanceHelper {
|
||||
|
||||
public function GetWalletTransaction($division, $charId) {
|
||||
//Declare the lookup class helper
|
||||
//Declare the class helpers
|
||||
$lookups = new LookupHelper;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup array for PI items
|
||||
$pi_items = $this->GetPIMaterialsArray();
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$tokenData = $this->TokenInfo($charId);
|
||||
$token = $tokenData['token'];
|
||||
$scope = $tokenData['scope'];
|
||||
|
||||
//If the token is not found, send the user an eve mail, and just exit out of the function
|
||||
if($this->TokenNotFound($token, $scope, $charId)) {
|
||||
//Log::critical('Token not found. Character Id: ' . $charId);
|
||||
$token = $esiHelper->GetToken($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||
if($token == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -64,7 +61,7 @@ class FinanceHelper {
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
|
||||
//Create the esi class varialble
|
||||
@@ -106,18 +103,13 @@ class FinanceHelper {
|
||||
$office = new OfficeFee();
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$tokenData = $this->TokenInfo($charId);
|
||||
$token = $tokenData['token'];
|
||||
$scope = $tokenData['scope'];
|
||||
$token = $esiHelper->GetToken($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||
if($token == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Declare the lookup class helper
|
||||
$lookups = new LookupHelper;
|
||||
|
||||
//If the token is not found, send the user an eve mail, and just exit out of the function
|
||||
if($this->TokenNotFound($token, $scope, $charId)) {
|
||||
//Log::critical('Token not found.' . 'Character Id: ' . $charId);
|
||||
return null;
|
||||
}
|
||||
|
||||
//Reference to see if the character is in our look up table for corporations and characters
|
||||
$corpId = $lookups->LookupCharacter($charId);
|
||||
@@ -127,7 +119,7 @@ class FinanceHelper {
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
|
||||
//Create the esi class varialble
|
||||
@@ -189,12 +181,9 @@ class FinanceHelper {
|
||||
//Declare class variables
|
||||
$lookups = new LookupHelper;
|
||||
|
||||
//Get the ESI refresh token for the corporation
|
||||
$tokenData = $this->TokenInfo($charId);
|
||||
$token = $tokenData['token'];
|
||||
$scope = $tokenData['scope'];
|
||||
|
||||
if($this->TokenNotFound($token, $scope, $charId)) {
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$token = $esiHelper->GetToken($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||
if($token == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -206,7 +195,7 @@ class FinanceHelper {
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
|
||||
//Create the esi class variable
|
||||
@@ -229,6 +218,52 @@ class FinanceHelper {
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public function GetCorpWalletJournalPage($division, $charId, $corpId, $page = 1) {
|
||||
//Declare new class variables
|
||||
$corpMarket = new MarketTax();
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$tokenData = $this->TokenIfno($charId);
|
||||
$token = $tokenData['token'];
|
||||
$scope = $tokenData['scope'];
|
||||
|
||||
//Create an ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
|
||||
//Create the esi class varialble
|
||||
$esi = new Eseye($authentication);
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Call the page of the wallet journal
|
||||
try {
|
||||
$journals = $esi->page($page)
|
||||
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning($e->getEsiResponse());
|
||||
return null;
|
||||
}
|
||||
|
||||
//Decode the wallet from json into an array
|
||||
$wallets = json_decode($journals->raw, true);
|
||||
|
||||
//For each journal entry, attempt to store the information into the database
|
||||
foreach($wallets as $wallet) {
|
||||
if($wallet['amount'] > 0) {
|
||||
if($wallet['ref_type'] == 'brokers_fee') {
|
||||
$corpMarket->InsertCorpMarketTax($wallet, $corpId, $division);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function GetWalletJournalPage($division, $charId, $page = 1) {
|
||||
//Declare new class variables
|
||||
$market = new MarketTax();
|
||||
@@ -240,9 +275,10 @@ class FinanceHelper {
|
||||
$pi = new PlanetProductionTax();
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$tokenData = $this->TokenInfo($charId);
|
||||
$token = $tokenData['token'];
|
||||
$scope = $tokenData['scope'];
|
||||
$token = $esiHelper->GetToken($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||
if($token == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Declare the lookup class helper
|
||||
$lookups = new LookupHelper;
|
||||
@@ -255,7 +291,7 @@ class FinanceHelper {
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
|
||||
//Create the esi class varialble
|
||||
@@ -301,42 +337,6 @@ class FinanceHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private function TokenInfo($charId) {
|
||||
//Get the ESI refresh token for the corporation to add a new wallet jouranls into the database
|
||||
//send the token and scope back to the calling function
|
||||
$token = EsiToken::where(['character_id' => $charId])->get(['refresh_token']);
|
||||
$scope = EsiScope::where(['character_id' => $charId, 'scope' => 'esi-wallet.read_corporation_wallets.v1'])->get(['scope']);
|
||||
|
||||
$data = [
|
||||
'token' => $token,
|
||||
'scope' => $scope,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function TokenNotFound($token, $scope, $charId) {
|
||||
//Get the esi config
|
||||
$config = config('esi');
|
||||
|
||||
|
||||
if(!isset($token[0]->refresh_token) || !isset($scope[0]->scope)) {
|
||||
//Register a mail to be dispatched as a job
|
||||
$mail = new EveMail;
|
||||
$mail->sender = $config['primary'];
|
||||
$mail->subject = 'W4RP Services ESI API';
|
||||
$mail->body = 'You need to register an ESI API on the services site for esi-wallet.read_corporation_wallet.v1<br>This is also labeled Corporation Wallets';
|
||||
$mail->recipient = (int)$charId;
|
||||
$mail->recipient_type = 'character';
|
||||
|
||||
SendEveMailJob::dispatch($mail)->onQueue('mail');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function GetPIMaterialsArray() {
|
||||
//Setup array for PI items
|
||||
$pi_items = [
|
||||
|
||||
@@ -31,6 +31,17 @@ class TaxesHelper {
|
||||
$this->end = $en;
|
||||
}
|
||||
|
||||
public function GetStructureMarketGross($start, $end, $corpId) {
|
||||
$revenue = 0.00;
|
||||
|
||||
$revenu = CorpMarketJournal::where([
|
||||
'second_party_id' => $corpId,
|
||||
])->whereBetween('date', [$start, $end])
|
||||
->sum('amount');
|
||||
|
||||
return $revenue;
|
||||
}
|
||||
|
||||
public function GetJumpGateGross($start, $end) {
|
||||
$revenue = 0.00;
|
||||
|
||||
|
||||
26
app/Models/Finances/CorpMarketStructure.php
Normal file
26
app/Models/Finances/CorpMarketStructure.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CorpMarketStructure extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'corp_market_structures';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'character_id',
|
||||
'corporation_id',
|
||||
'tax',
|
||||
'ratio',
|
||||
];
|
||||
}
|
||||
20
app/Models/Jobs/JobProcessCorpJournal.php
Normal file
20
app/Models/Jobs/JobProcessCorpJournal.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JobProcessCorpJournal extends Model
|
||||
{
|
||||
//No table name is needed
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'division',
|
||||
'charId',
|
||||
'corpId',
|
||||
'page',
|
||||
];
|
||||
}
|
||||
@@ -73,27 +73,6 @@ class CreateCorpJournal extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('corp_market_journal')) {
|
||||
Schema::create('corp_market_journal', function(Blueprint $table) {
|
||||
$table->string('id')->unique();
|
||||
$table->integer('corporation_id')->nullabe();
|
||||
$table->integer('division')->default(0);
|
||||
$table->decimal('amount', 20, 2)->nullable();
|
||||
$table->decimal('balance', 20, 2)->nullable();
|
||||
$table->bigInteger('context_id')->nullable();
|
||||
$table->string('context_id_type')->nullable();
|
||||
$table->dateTime('date')->nullabe();
|
||||
$table->string('description')->nullabe();
|
||||
$table->integer('first_party_id')->nullable();
|
||||
$table->string('reason')->default(' ');
|
||||
$table->string('ref_type')->nullabe();
|
||||
$table->integer('second_party_id')->nullable();
|
||||
$table->decimal('tax', 20, 2)->default(0.00);
|
||||
$table->integer('tax_receiver_id')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('player_donation_journal')) {
|
||||
Schema::create('player_donation_journal', function(Blueprint $table) {
|
||||
$table->string('id')->unique();
|
||||
@@ -242,7 +221,6 @@ class CreateCorpJournal extends Migration
|
||||
Schema::dropIfExists('CorpWalletJournals');
|
||||
Schema::dropIfExists('HoldingcorpFinancesJournal');
|
||||
Schema::dropIfExists('jump_bridge_journal');
|
||||
Schema::dropIfExists('corp_market_journal');
|
||||
Schema::dropIfExists('player_donation_journal');
|
||||
Schema::dropIfExists('reprocessing_tax_journal');
|
||||
Schema::dropIfExists('office_fees_journal');
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateStructureMarketJournalTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if(!Schema::hasTable('corp_market_journal')) {
|
||||
Schema::create('corp_market_journal', function(Blueprint $table) {
|
||||
$table->string('id')->unique();
|
||||
$table->integer('corporation_id')->nullabe();
|
||||
$table->integer('division')->default(0);
|
||||
$table->decimal('amount', 20, 2)->nullable();
|
||||
$table->decimal('balance', 20, 2)->nullable();
|
||||
$table->bigInteger('context_id')->nullable();
|
||||
$table->string('context_id_type')->nullable();
|
||||
$table->dateTime('date')->nullabe();
|
||||
$table->string('description')->nullabe();
|
||||
$table->integer('first_party_id')->nullable();
|
||||
$table->string('reason')->default(' ');
|
||||
$table->string('ref_type')->nullabe();
|
||||
$table->integer('second_party_id')->nullable();
|
||||
$table->decimal('tax', 20, 2)->default(0.00);
|
||||
$table->integer('tax_receiver_id')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('corp_market_structures')) {
|
||||
Schema::create('corp_market_structures', function(Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('character_id');
|
||||
$table->unsignedInteger('corporation_id');
|
||||
$table->decimal('tax', 5, 2);
|
||||
$table->decimal('ratio', 5, 2);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('corp_market_journal');
|
||||
Schema::dropIfExists('corp_market_structures');
|
||||
}
|
||||
}
|
||||
19
resources/views/market/add/display.blade.php
Normal file
19
resources/views/market/add/display.blade.php
Normal file
@@ -0,0 +1,19 @@
|
||||
@extends('layouts.b4')
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Add New Structure Market</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{!! Form::open(['action' => 'Market\MarketController@storeAddStructure', 'method' => 'POST']) !!}
|
||||
<div class="form-group">
|
||||
{{ Form::label('tax', 'Market Tax') }}
|
||||
{{ Form::text('tax', null, ['class' => 'form-control', 'placeholder' => '5.00']) }}
|
||||
</div>
|
||||
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
7
vendor/composer/autoload_classmap.php
vendored
7
vendor/composer/autoload_classmap.php
vendored
@@ -8,6 +8,7 @@ $baseDir = dirname($vendorDir);
|
||||
return array(
|
||||
'App\\Charts\\StructureFuelGauge' => $baseDir . '/app/Charts/StructureFuelGauge.php',
|
||||
'App\\Console\\Commands\\CleanStaleDataCommand' => $baseDir . '/app/Console/Commands/Data/CleanStaleDataCommand.php',
|
||||
'App\\Console\\Commands\\CorpFinances' => $baseDir . '/app/Console/Commands/Finances/CorpFinances.php',
|
||||
'App\\Console\\Commands\\GetAssetsCommand' => $baseDir . '/app/Console/Commands/Assets/GetAssets.php',
|
||||
'App\\Console\\Commands\\GetCorpsCommand' => $baseDir . '/app/Console/Commands/Corps/GetCorps.php',
|
||||
'App\\Console\\Commands\\GetEveContractsCommand' => $baseDir . '/app/Console/Commands/Logistics/GetEveContracts.php',
|
||||
@@ -29,11 +30,11 @@ return array(
|
||||
'App\\Http\\Controllers\\Fuel\\FuelController' => $baseDir . '/app/Http/Controllers/Logistics/FuelController.php',
|
||||
'App\\Http\\Controllers\\LiveSearch' => $baseDir . '/app/Http/Controllers/LiveSearch.php',
|
||||
'App\\Http\\Controllers\\Logistics\\LogisticsController' => $baseDir . '/app/Http/Controllers/Logistics/LogisticsController.php',
|
||||
'App\\Http\\Controllers\\MarketController' => $baseDir . '/app/Http/Controllers/Market/MarketController.php',
|
||||
'App\\Http\\Controllers\\Moons\\MoonsAdminController' => $baseDir . '/app/Http/Controllers/Moons/MoonsAdminController.php',
|
||||
'App\\Http\\Controllers\\Moons\\MoonsController' => $baseDir . '/app/Http/Controllers/Moons/MoonsController.php',
|
||||
'App\\Http\\Controllers\\SRP\\SRPAdminController' => $baseDir . '/app/Http/Controllers/SRP/SRPAdminController.php',
|
||||
'App\\Http\\Controllers\\SRP\\SRPController' => $baseDir . '/app/Http/Controllers/SRP/SRPController.php',
|
||||
'App\\Http\\Controllers\\Stocks\\StockController' => $baseDir . '/app/Http/Controllers/Stock/StockController.php',
|
||||
'App\\Http\\Controllers\\Wiki\\WikiController' => $baseDir . '/app/Http/Controllers/Wiki/WikiController.php',
|
||||
'App\\Http\\Kernel' => $baseDir . '/app/Http/Kernel.php',
|
||||
'App\\Http\\Middleware\\Authenticate' => $baseDir . '/app/Http/Middleware/Authenticate.php',
|
||||
@@ -46,7 +47,9 @@ return array(
|
||||
'App\\Http\\Middleware\\TrimStrings' => $baseDir . '/app/Http/Middleware/TrimStrings.php',
|
||||
'App\\Http\\Middleware\\TrustProxies' => $baseDir . '/app/Http/Middleware/TrustProxies.php',
|
||||
'App\\Http\\Middleware\\VerifyCsrfToken' => $baseDir . '/app/Http/Middleware/VerifyCsrfToken.php',
|
||||
'App\\JobProcessCorpJournal' => $baseDir . '/app/Models/Jobs/JobProcessCorpJournal.php',
|
||||
'App\\Jobs\\ProcessAssetsJob' => $baseDir . '/app/Jobs/ProcessAssetsJob.php',
|
||||
'App\\Jobs\\ProcessCorpJournalJob' => $baseDir . '/app/Jobs/ProcessCorpJournalJob.php',
|
||||
'App\\Jobs\\ProcessEveContractsJob' => $baseDir . '/app/Jobs/ProcessEveContractsJob.php',
|
||||
'App\\Jobs\\ProcessStructureJob' => $baseDir . '/app/Jobs/ProcessStructureJob.php',
|
||||
'App\\Jobs\\ProcessWalletJournalJob' => $baseDir . '/app/Jobs/ProcessWalletJournalJob.php',
|
||||
@@ -56,6 +59,7 @@ return array(
|
||||
'App\\Library\\Contracts\\EveContractsHelper' => $baseDir . '/app/Library/Contracts/EveContractsHelper.php',
|
||||
'App\\Library\\Esi\\Esi' => $baseDir . '/app/Library/Esi/Esi.php',
|
||||
'App\\Library\\Esi\\Mail' => $baseDir . '/app/Library/Esi/Mail.php',
|
||||
'App\\Library\\Finances\\CorpMarketTax' => $baseDir . '/app/Library/Finances/CorpMarketTax.php',
|
||||
'App\\Library\\Finances\\Helper\\FinanceHelper' => $baseDir . '/app/Library/Finances/Helper/FinanceHelper.php',
|
||||
'App\\Library\\Finances\\JumpBridgeTax' => $baseDir . '/app/Library/Finances/JumpBridgeTax.php',
|
||||
'App\\Library\\Finances\\MarketTax' => $baseDir . '/app/Library/Finances/MarketTax.php',
|
||||
@@ -124,6 +128,7 @@ return array(
|
||||
'App\\Models\\Structure\\Structure' => $baseDir . '/app/Models/Structure/Structure.php',
|
||||
'App\\Models\\User\\AvailableUserPermission' => $baseDir . '/app/Models/User/AvailableUserPermission.php',
|
||||
'App\\Models\\User\\User' => $baseDir . '/app/Models/User/User.php',
|
||||
'App\\Models\\User\\UserAlt' => $baseDir . '/app/Models/User/UserAlt.php',
|
||||
'App\\Models\\User\\UserPermission' => $baseDir . '/app/Models/User/UserPermission.php',
|
||||
'App\\Models\\User\\UserRole' => $baseDir . '/app/Models/User/UserRole.php',
|
||||
'App\\Providers\\AppServiceProvider' => $baseDir . '/app/Providers/AppServiceProvider.php',
|
||||
|
||||
7
vendor/composer/autoload_static.php
vendored
7
vendor/composer/autoload_static.php
vendored
@@ -471,6 +471,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
|
||||
public static $classMap = array (
|
||||
'App\\Charts\\StructureFuelGauge' => __DIR__ . '/../..' . '/app/Charts/StructureFuelGauge.php',
|
||||
'App\\Console\\Commands\\CleanStaleDataCommand' => __DIR__ . '/../..' . '/app/Console/Commands/Data/CleanStaleDataCommand.php',
|
||||
'App\\Console\\Commands\\CorpFinances' => __DIR__ . '/../..' . '/app/Console/Commands/Finances/CorpFinances.php',
|
||||
'App\\Console\\Commands\\GetAssetsCommand' => __DIR__ . '/../..' . '/app/Console/Commands/Assets/GetAssets.php',
|
||||
'App\\Console\\Commands\\GetCorpsCommand' => __DIR__ . '/../..' . '/app/Console/Commands/Corps/GetCorps.php',
|
||||
'App\\Console\\Commands\\GetEveContractsCommand' => __DIR__ . '/../..' . '/app/Console/Commands/Logistics/GetEveContracts.php',
|
||||
@@ -492,11 +493,11 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
|
||||
'App\\Http\\Controllers\\Fuel\\FuelController' => __DIR__ . '/../..' . '/app/Http/Controllers/Logistics/FuelController.php',
|
||||
'App\\Http\\Controllers\\LiveSearch' => __DIR__ . '/../..' . '/app/Http/Controllers/LiveSearch.php',
|
||||
'App\\Http\\Controllers\\Logistics\\LogisticsController' => __DIR__ . '/../..' . '/app/Http/Controllers/Logistics/LogisticsController.php',
|
||||
'App\\Http\\Controllers\\MarketController' => __DIR__ . '/../..' . '/app/Http/Controllers/Market/MarketController.php',
|
||||
'App\\Http\\Controllers\\Moons\\MoonsAdminController' => __DIR__ . '/../..' . '/app/Http/Controllers/Moons/MoonsAdminController.php',
|
||||
'App\\Http\\Controllers\\Moons\\MoonsController' => __DIR__ . '/../..' . '/app/Http/Controllers/Moons/MoonsController.php',
|
||||
'App\\Http\\Controllers\\SRP\\SRPAdminController' => __DIR__ . '/../..' . '/app/Http/Controllers/SRP/SRPAdminController.php',
|
||||
'App\\Http\\Controllers\\SRP\\SRPController' => __DIR__ . '/../..' . '/app/Http/Controllers/SRP/SRPController.php',
|
||||
'App\\Http\\Controllers\\Stocks\\StockController' => __DIR__ . '/../..' . '/app/Http/Controllers/Stock/StockController.php',
|
||||
'App\\Http\\Controllers\\Wiki\\WikiController' => __DIR__ . '/../..' . '/app/Http/Controllers/Wiki/WikiController.php',
|
||||
'App\\Http\\Kernel' => __DIR__ . '/../..' . '/app/Http/Kernel.php',
|
||||
'App\\Http\\Middleware\\Authenticate' => __DIR__ . '/../..' . '/app/Http/Middleware/Authenticate.php',
|
||||
@@ -509,7 +510,9 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
|
||||
'App\\Http\\Middleware\\TrimStrings' => __DIR__ . '/../..' . '/app/Http/Middleware/TrimStrings.php',
|
||||
'App\\Http\\Middleware\\TrustProxies' => __DIR__ . '/../..' . '/app/Http/Middleware/TrustProxies.php',
|
||||
'App\\Http\\Middleware\\VerifyCsrfToken' => __DIR__ . '/../..' . '/app/Http/Middleware/VerifyCsrfToken.php',
|
||||
'App\\JobProcessCorpJournal' => __DIR__ . '/../..' . '/app/Models/Jobs/JobProcessCorpJournal.php',
|
||||
'App\\Jobs\\ProcessAssetsJob' => __DIR__ . '/../..' . '/app/Jobs/ProcessAssetsJob.php',
|
||||
'App\\Jobs\\ProcessCorpJournalJob' => __DIR__ . '/../..' . '/app/Jobs/ProcessCorpJournalJob.php',
|
||||
'App\\Jobs\\ProcessEveContractsJob' => __DIR__ . '/../..' . '/app/Jobs/ProcessEveContractsJob.php',
|
||||
'App\\Jobs\\ProcessStructureJob' => __DIR__ . '/../..' . '/app/Jobs/ProcessStructureJob.php',
|
||||
'App\\Jobs\\ProcessWalletJournalJob' => __DIR__ . '/../..' . '/app/Jobs/ProcessWalletJournalJob.php',
|
||||
@@ -519,6 +522,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
|
||||
'App\\Library\\Contracts\\EveContractsHelper' => __DIR__ . '/../..' . '/app/Library/Contracts/EveContractsHelper.php',
|
||||
'App\\Library\\Esi\\Esi' => __DIR__ . '/../..' . '/app/Library/Esi/Esi.php',
|
||||
'App\\Library\\Esi\\Mail' => __DIR__ . '/../..' . '/app/Library/Esi/Mail.php',
|
||||
'App\\Library\\Finances\\CorpMarketTax' => __DIR__ . '/../..' . '/app/Library/Finances/CorpMarketTax.php',
|
||||
'App\\Library\\Finances\\Helper\\FinanceHelper' => __DIR__ . '/../..' . '/app/Library/Finances/Helper/FinanceHelper.php',
|
||||
'App\\Library\\Finances\\JumpBridgeTax' => __DIR__ . '/../..' . '/app/Library/Finances/JumpBridgeTax.php',
|
||||
'App\\Library\\Finances\\MarketTax' => __DIR__ . '/../..' . '/app/Library/Finances/MarketTax.php',
|
||||
@@ -587,6 +591,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
|
||||
'App\\Models\\Structure\\Structure' => __DIR__ . '/../..' . '/app/Models/Structure/Structure.php',
|
||||
'App\\Models\\User\\AvailableUserPermission' => __DIR__ . '/../..' . '/app/Models/User/AvailableUserPermission.php',
|
||||
'App\\Models\\User\\User' => __DIR__ . '/../..' . '/app/Models/User/User.php',
|
||||
'App\\Models\\User\\UserAlt' => __DIR__ . '/../..' . '/app/Models/User/UserAlt.php',
|
||||
'App\\Models\\User\\UserPermission' => __DIR__ . '/../..' . '/app/Models/User/UserPermission.php',
|
||||
'App\\Models\\User\\UserRole' => __DIR__ . '/../..' . '/app/Models/User/UserRole.php',
|
||||
'App\\Providers\\AppServiceProvider' => __DIR__ . '/../..' . '/app/Providers/AppServiceProvider.php',
|
||||
|
||||
Reference in New Issue
Block a user