diff --git a/app/Http/Controllers/StructureController.php b/app/Http/Controllers/StructureController.php index 8fa5a2f69..fc0391c62 100644 --- a/app/Http/Controllers/StructureController.php +++ b/app/Http/Controllers/StructureController.php @@ -15,6 +15,11 @@ use App\User; use App\Models\User\UserRole; use App\Models\User\UserPermission; use App\Models\Corporation\CorpStructure; +use App\Models\Finances\StructureIndustryTaxJournal; + +use Seat\Eseye\Containers\EsiAuthentication; +use Seat\Eseye\Eseye; +use Seat\Eseye\Exceptions\RequestFailedException; class StructureController extends Controller { @@ -23,6 +28,68 @@ class StructureController extends Controller $this->middleware('permission:structure.operator'); } + public function displayIndustryTaxes() { + $this->middelware('role:Admin'); + + $corpId = 98287666; + $months = 3; + $name = array(); + + //Declare the structure tax helper class + $sHelper = new StructureTaxHelper(); + + //Get the dates we are working with + $dates = $sHelper->GetTimeFrameInMonths($months); + + //Get a list of structures + $structures = StructureIndustryTaxJournal::select('context_id') + ->whereBetween('date', [$start, $end]) + ->groupBy('context_id') + ->get(); + + //Get the ESI refresh token for the corporation to add new wallet journals into the database + $token = EsiToken::where(['character_id' => 93738489])->get(['refresh_token']); + + //Create an ESI authentication container + $config = config('esi'); + $authentication = new EsiAuthentication([ + 'client_id' => $config['client_id'], + 'secret' => $config['secret'], + 'refresh_token' => $token[0]->refresh_token, + ]); + + //Create the esi class varialble + $esi = new Eseye($authentication); + + //Cycle through all of the structures and build a list of names + for($i = 0; $i < sizeof($structures); $i++) { + //Get the structure name from the ESI API + try { + $temp = $esi->invoke('get', '/universe/structures/{structure_id}/', [ + 'structure_id' => $structures[$j]->context_id, + ]); + + $name[$i] = $temp->name; + } catch(RequestFailedException $e) { + $name[$i] = ' '; + } + } + + //Cycle through all of the structures and get the revenue + for($j = 0; $j < sizeof($structures); $j++) { + for($i = 0; $i < $months; $i++) { + $totalTaxes[$i] = [ + 'IndustryTaxes' => number_format($sHelper->GetIndustryTaxes($dates[$i]['start'], $dates[$i]['end'], $structures[$j])), + 'MonthStart' => $dates[$i]['start']->toFormattedDateString(), + 'Structure' => $name[$j], + ]; + } + } + + + return view('structures.taxhistory')->with(compact('totalTaxes', 'months')); + } + public function chooseCorpTaxes() { $corps = CorpStructure::pluck('corporation_name', 'corporation_id'); return view('structures.choosecorporation')->with('corps', $corps); diff --git a/app/Library/Finances/Helper/FinanceHelper.php b/app/Library/Finances/Helper/FinanceHelper.php index d86bebaa7..cf43a64e8 100644 --- a/app/Library/Finances/Helper/FinanceHelper.php +++ b/app/Library/Finances/Helper/FinanceHelper.php @@ -17,6 +17,7 @@ use App\Library\Finances\MarketTax; use App\Library\Finances\PlayerDonation; use App\Library\Finances\ReprocessingTax; use App\Library\Finances\JumpBridgeTax; +use App\Library\Finances\StructureIndustryTax; use Seat\Eseye\Containers\EsiAuthentication; use Seat\Eseye\Eseye; @@ -83,6 +84,9 @@ class FinanceHelper { ($entry['ref_type'] == 'corporation_account_withdrawal' && $entry['second_party_id'] == 98287666)) { $other = new PlayerDonation(); $other->InsertPlayerDonation($entry, $corpId, $division); + } else if($entry['ref_type'] == 'industry_facility_tax' && $entry['second_party_id'] == 98287666) { + $industry = new StructureIndustryTax(); + $industry->InsertStructureIndustryTax($entry, $corpId, $division); } } diff --git a/app/Library/Finances/StructureIndustryTax.php b/app/Library/Finances/StructureIndustryTax.php new file mode 100644 index 000000000..35b0c3a22 --- /dev/null +++ b/app/Library/Finances/StructureIndustryTax.php @@ -0,0 +1,64 @@ + $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(); + } + } +} + +?> \ No newline at end of file diff --git a/app/Library/Structures/StructureTaxHelper.php b/app/Library/Structures/StructureTaxHelper.php index d3507b513..7cc63cef4 100644 --- a/app/Library/Structures/StructureTaxHelper.php +++ b/app/Library/Structures/StructureTaxHelper.php @@ -12,6 +12,7 @@ use App\Models\User\UserPermission; use App\Models\Corporation\CorpStructure; use App\Models\Finances\CorpMarketJournal; use App\Models\Finances\ReprocessingTaxJournal; +use App\Models\Finances\StructureIndustryTaxJournal; class StructureTaxHelper { private $corpId; @@ -62,6 +63,16 @@ class StructureTaxHelper { return $taxOwed; } + public function GetIndustryRevenue($start, $end) { + $revenue = 0.00; + + $revenue = StructureIndustryTaxJournal::where(['ref_type' => 'facility_industry_tax', 'second_party_id' => '98287666']) + ->whereBetween('date', [$start, $end]) + ->sum('amount'); + + return $revenue; + } + public function GetRevenue($corpId, $refType, $start, $end) { $revenue = 0.00; if($refType == 'Market') { diff --git a/app/Models/Finances/StructureIndustryTaxJournal.php b/app/Models/Finances/StructureIndustryTaxJournal.php new file mode 100644 index 000000000..b63247837 --- /dev/null +++ b/app/Models/Finances/StructureIndustryTaxJournal.php @@ -0,0 +1,41 @@ +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->integer('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(); + }); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('structure_industry_tax'); + } +} diff --git a/resources/views/structures/industrytaxes.blade.php b/resources/views/structures/industrytaxes.blade.php new file mode 100644 index 000000000..9e27dc6ac --- /dev/null +++ b/resources/views/structures/industrytaxes.blade.php @@ -0,0 +1,30 @@ +@extends('layouts.b4') +@section('content') + +
+
+
+ Structure Industry Taxes +
+
+ + + + + + + + @for($i = 0; $i < $months; $i++) + + + + + + @endfor + +
MonthStructureIndustry Taxes
{{ $totalTaxes[$i]['MonthStart'] }}{{ $totalTaxes[$i]['Structure'] }}{{ $totalTaxes[$i]['IndustryTaxes'] }}
+
+
+
+ +@endsection \ No newline at end of file diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index b446e7b08..5407dbc9b 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -18,7 +18,6 @@ return array( 'App\\HelpDeskTicket' => $baseDir . '/app/Models/HelpDesk/HelpDeskTicket.php', 'App\\HelpDeskTicketResponse' => $baseDir . '/app/Models/HelpDesk/HelpDeskTicketResponse.php', 'App\\Http\\Controllers\\AdminController' => $baseDir . '/app/Http/Controllers/AdminController.php', - 'App\\Http\\Controllers\\AjaxController' => $baseDir . '/app/Http/Controllers/AjaxController.php', 'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => $baseDir . '/app/Http/Controllers/Auth/ForgotPasswordController.php', 'App\\Http\\Controllers\\Auth\\LoginController' => $baseDir . '/app/Http/Controllers/Auth/LoginController.php', 'App\\Http\\Controllers\\Auth\\RegisterController' => $baseDir . '/app/Http/Controllers/Auth/RegisterController.php', @@ -62,11 +61,11 @@ return array( 'App\\Library\\Moons\\MoonCalc' => $baseDir . '/app/Library/Moons/MoonCalc.php', 'App\\Library\\Moons\\MoonMine' => $baseDir . '/app/Library/Moons/MoonMine.php', 'App\\Library\\SeatHelper' => $baseDir . '/app/Library/SeatHelper.php', + 'App\\Library\\Structures\\JumpBridgeFuel' => $baseDir . '/app/Library/Structures/JumpBridgeFuel.php', 'App\\Library\\Structures\\StructureTaxHelper' => $baseDir . '/app/Library/Structures/StructureTaxHelper.php', 'App\\Models\\Character\\CharacterToCorporation' => $baseDir . '/app/Models/Charcter/CharacterToCorporation.php', 'App\\Models\\Config' => $baseDir . '/app/Models/Config.php', 'App\\Models\\Corporation\\AllianceCorp' => $baseDir . '/app/Models/Corporation/AllianceCorp.php', - 'App\\Models\\Corporation\\CorpJournal' => $baseDir . '/app/Models/Corporation/CorpJournal.php', 'App\\Models\\Corporation\\CorpStructure' => $baseDir . '/app/Models/Corporation/CorpStructure.php', 'App\\Models\\Corporation\\CorporationToAlliance' => $baseDir . '/app/Models/Corporation/CorporationToAlliance.php', 'App\\Models\\Corporation\\HoldingCorpJournal' => $baseDir . '/app/Models/Corporation/HoldingCorpJournal.php', @@ -76,7 +75,6 @@ return array( 'App\\Models\\Doku\\DokuUser' => $baseDir . '/app/Models/Doku/DokuUser.php', 'App\\Models\\Esi\\EsiScope' => $baseDir . '/app/Models/Esi/EsiScope.php', 'App\\Models\\Esi\\EsiToken' => $baseDir . '/app/Models/Esi/EsiToken.php', - 'App\\Models\\EveMail' => $baseDir . '/app/Models/EveMail.php', 'App\\Models\\Finances\\CorpMarketJournal' => $baseDir . '/app/Models/Finances/CorpMarketJournal.php', 'App\\Models\\Finances\\JumpBridgeJournal' => $baseDir . '/app/Models/Finances/JumpBridgeJournal.php', 'App\\Models\\Finances\\PlayerDonationJournal' => $baseDir . '/app/Models/Finances/PlayerDonationJournal.php', @@ -84,6 +82,7 @@ return array( 'App\\Models\\Fleet\\Fleet' => $baseDir . '/app/Models/Fleet/Fleet.php', 'App\\Models\\Fleet\\FleetActivity' => $baseDir . '/app/Models/Fleet/FleetActivity.php', 'App\\Models\\Logistics\\Contract' => $baseDir . '/app/Models/Logistics/Contract.php', + 'App\\Models\\Mail\\EveMail' => $baseDir . '/app/Models/Mail/EveMail.php', 'App\\Models\\Market\\MarketOrder' => $baseDir . '/app/Models/Market/MarketOrder.php', 'App\\Models\\Market\\MonthlyMarketTax' => $baseDir . '/app/Models/Market/MonthlyMarketTax.php', 'App\\Models\\Moon\\ItemComposition' => $baseDir . '/app/Models/Moon/ItemComposition.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 8c99fb617..3f5aa73ba 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -472,7 +472,6 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9 'App\\HelpDeskTicket' => __DIR__ . '/../..' . '/app/Models/HelpDesk/HelpDeskTicket.php', 'App\\HelpDeskTicketResponse' => __DIR__ . '/../..' . '/app/Models/HelpDesk/HelpDeskTicketResponse.php', 'App\\Http\\Controllers\\AdminController' => __DIR__ . '/../..' . '/app/Http/Controllers/AdminController.php', - 'App\\Http\\Controllers\\AjaxController' => __DIR__ . '/../..' . '/app/Http/Controllers/AjaxController.php', 'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/ForgotPasswordController.php', 'App\\Http\\Controllers\\Auth\\LoginController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/LoginController.php', 'App\\Http\\Controllers\\Auth\\RegisterController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/RegisterController.php', @@ -516,11 +515,11 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9 'App\\Library\\Moons\\MoonCalc' => __DIR__ . '/../..' . '/app/Library/Moons/MoonCalc.php', 'App\\Library\\Moons\\MoonMine' => __DIR__ . '/../..' . '/app/Library/Moons/MoonMine.php', 'App\\Library\\SeatHelper' => __DIR__ . '/../..' . '/app/Library/SeatHelper.php', + 'App\\Library\\Structures\\JumpBridgeFuel' => __DIR__ . '/../..' . '/app/Library/Structures/JumpBridgeFuel.php', 'App\\Library\\Structures\\StructureTaxHelper' => __DIR__ . '/../..' . '/app/Library/Structures/StructureTaxHelper.php', 'App\\Models\\Character\\CharacterToCorporation' => __DIR__ . '/../..' . '/app/Models/Charcter/CharacterToCorporation.php', 'App\\Models\\Config' => __DIR__ . '/../..' . '/app/Models/Config.php', 'App\\Models\\Corporation\\AllianceCorp' => __DIR__ . '/../..' . '/app/Models/Corporation/AllianceCorp.php', - 'App\\Models\\Corporation\\CorpJournal' => __DIR__ . '/../..' . '/app/Models/Corporation/CorpJournal.php', 'App\\Models\\Corporation\\CorpStructure' => __DIR__ . '/../..' . '/app/Models/Corporation/CorpStructure.php', 'App\\Models\\Corporation\\CorporationToAlliance' => __DIR__ . '/../..' . '/app/Models/Corporation/CorporationToAlliance.php', 'App\\Models\\Corporation\\HoldingCorpJournal' => __DIR__ . '/../..' . '/app/Models/Corporation/HoldingCorpJournal.php', @@ -530,7 +529,6 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9 'App\\Models\\Doku\\DokuUser' => __DIR__ . '/../..' . '/app/Models/Doku/DokuUser.php', 'App\\Models\\Esi\\EsiScope' => __DIR__ . '/../..' . '/app/Models/Esi/EsiScope.php', 'App\\Models\\Esi\\EsiToken' => __DIR__ . '/../..' . '/app/Models/Esi/EsiToken.php', - 'App\\Models\\EveMail' => __DIR__ . '/../..' . '/app/Models/EveMail.php', 'App\\Models\\Finances\\CorpMarketJournal' => __DIR__ . '/../..' . '/app/Models/Finances/CorpMarketJournal.php', 'App\\Models\\Finances\\JumpBridgeJournal' => __DIR__ . '/../..' . '/app/Models/Finances/JumpBridgeJournal.php', 'App\\Models\\Finances\\PlayerDonationJournal' => __DIR__ . '/../..' . '/app/Models/Finances/PlayerDonationJournal.php', @@ -538,6 +536,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9 'App\\Models\\Fleet\\Fleet' => __DIR__ . '/../..' . '/app/Models/Fleet/Fleet.php', 'App\\Models\\Fleet\\FleetActivity' => __DIR__ . '/../..' . '/app/Models/Fleet/FleetActivity.php', 'App\\Models\\Logistics\\Contract' => __DIR__ . '/../..' . '/app/Models/Logistics/Contract.php', + 'App\\Models\\Mail\\EveMail' => __DIR__ . '/../..' . '/app/Models/Mail/EveMail.php', 'App\\Models\\Market\\MarketOrder' => __DIR__ . '/../..' . '/app/Models/Market/MarketOrder.php', 'App\\Models\\Market\\MonthlyMarketTax' => __DIR__ . '/../..' . '/app/Models/Market/MonthlyMarketTax.php', 'App\\Models\\Moon\\ItemComposition' => __DIR__ . '/../..' . '/app/Models/Moon/ItemComposition.php',