diff --git a/app/Console/Commands/calculatemarkettax.php b/app/Console/Commands/calculatemarkettax.php deleted file mode 100644 index b3686f896..000000000 --- a/app/Console/Commands/calculatemarkettax.php +++ /dev/null @@ -1,106 +0,0 @@ -SetStartStatus(); - - //Setup helper classes - $hFinances = new FinanceHelper(); - $sHelper = new StructureTaxHelper(); - $start = Carbon::now()->startOfMonth()->subMonth(); - $end = Carbon::now()->endOfMOnth()->subMonth(); - $end->hour = 23; - $end->minute = 59; - $end->second = 59; - - //Get the set of corporations from the structure table - $corps = CorpStructure::select('corporation_id')->groupBy('corporation_id')->get(); - $this->line('Got all of the corps with markets.' . sizeof($corps)); - foreach($corps as $corp) { - if($corp->corporation_id != 98287666) { - $finalTaxes = $sHelper->GetTaxes($corp->corporation_id, 'Market', $start, $end); - if($finalTaxes < 0.00) { - $finalTaxes = 0.00; - } - - //Get the info about the structures from the database - $info = CorpStructure::where(['corporation_id' => $corp->corporation_id])->first(); - - $character = UserToCorporation::where(['character_id' => $info->character_id])->first(); - - $mail = new JobSendEveMail; - $mail->sender = 93738489; - $mail->subject = 'Market Taxes Owed'; - $mail->body = 'Year ' . $start->year . ' ' . - 'Month: ' . - $start->month . - '
Market Taxes Owed: ' . - number_format($finalTaxes, 2, '.', ',') . - '
Please remit to Spatial Forces'; - $mail->recipient = (int)$info->character_id; - $mail->recipient_type = 'character'; - SendEveMailJob::dispatch($mail)->onQueue('default'); - } - - } - - //Mark the job as finished - $task->SetStopStatus(); - } -} diff --git a/app/Console/Commands/corpJournal.php b/app/Console/Commands/corpJournal.php deleted file mode 100644 index adcecf818..000000000 --- a/app/Console/Commands/corpJournal.php +++ /dev/null @@ -1,90 +0,0 @@ -SetStartStatus(); - - //Setup the Finances Container - $finance = new FinanceHelper(); - - //Setup an array to store corporations which have been logged so we don't keep calling the same ones. We need - //this step in order to save time during the cronjob. - $finishedCorps = array(); - $corpCompleted = false; - - //Get the corps with structures logged in the database - $corps = CorpStructure::select('corporation_id')->groupBy('corporation_id')->get(); - - //For all of the corporations, go through each structure and get wallet data - foreach($corps as $corp) { - //If the corporation isn't the holding corporation, then process the data. - //We process holding corporation data elsewhere. - if($corp->corporation_id != 98287666) { - $structure = CorpStructure::where(['corporation_id' => $corp->corporation_id])->first(); - $pages = $finance->GetJournalPageCount(1, $structure->character_id); - for($i = 1; $i <= $pages; $i++) { - $job = new JobProcessWalletJournal; - $job->division = 1; - $job->charId = $structure->character_id; - $job->page = $i; - ProcessWalletJournalJob::dispatch($job)->onQueue('journal'); - } - } - } - - //Mark the job as finished - $task->SetStopStatus(); - } -} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 49bd5e47e..889011707 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -30,9 +30,6 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - $schedule->command('services:CorpJournal') - ->hourly() - ->withoutOverlapping(); $schedule->command('services:HoldingJournal') ->hourly() ->withoutOverlapping(); @@ -42,9 +39,6 @@ class Kernel extends ConsoleKernel $schedule->command('services:GetCorps') ->monthlyOn(1, '09:00') ->withoutOverlapping(); - $schedule->command('services:CalculateMarketTax') - ->monthlyOn(1, '08:00') - ->withoutOverlapping(); $schedule->command('services:MoonMailer') ->monthlyOn(1, '00:01') ->withoutOverlapping(); diff --git a/app/Http/Controllers/Structures/RegisterStructureController.php b/app/Http/Controllers/Structures/RegisterStructureController.php deleted file mode 100644 index a6c59fb75..000000000 --- a/app/Http/Controllers/Structures/RegisterStructureController.php +++ /dev/null @@ -1,56 +0,0 @@ -middleware('auth'); - $this->middleware('role:User'); - $this->middleware('permission:structure.operator'); - } - - public function displayRegisterStructure() { - //Check to see if the user has the read corp journal esi scope before allowing to register a structure - if(Auth()->user()->hasEsiScope('esi-wallet.read_corporation_wallets.v1')) { - return view('structures.register.register'); - } else { - return view('dashboard')->with('error', 'You need to setup your esi scope for read corporation wallets'); - } - } - - public function storeStructure(Request $request) { - $this->validate($request, [ - 'system' => 'required', - 'structure_name' => 'required', - 'tax' => 'required', - 'structure_type' => 'required', - ]); - - $eHelper = new Esi; - - $tax = floatval($request->tax); - - $structure = new CorpStructure(); - $structure->character_id = Auth::user()->character_id; - $structure->corporation_id = $eHelper->FindCorporationId(Auth::user()->character_id); - $structure->corporation_name = $eHelper->FindCorporationName(Auth::user()->character_id); - $structure->region = $request->region; - $structure->system = $request->system; - $structure->structure_name = $request->structure_name; - $structure->structure_type = $request->structure_type; - $structure->save(); - - //Return the view and the message of user updated - return redirect('/dashboard')->with('success', 'Structure Added to Database'); - } -} diff --git a/app/Http/Controllers/Structures/StructureAdminController.php b/app/Http/Controllers/Structures/StructureAdminController.php deleted file mode 100644 index d0d03e6c3..000000000 --- a/app/Http/Controllers/Structures/StructureAdminController.php +++ /dev/null @@ -1,58 +0,0 @@ -middleware('role:Admin'); - } - - public function displayDashboard() { - return view('structures.admin.dashboard'); - } - - public function storeTaxRatio(Request $request) { - $this->validate($request, [ - 'corpId', - 'corporation', - 'type', - 'ratio', - ]); - - $ratio = new CorpTaxRatio; - $ratio->corporation_id = $request->corpId; - $ratio->corporation_name = $request->corporation; - $ratio->structure_type = $request->type; - $ratio->ratio = $request->ratio; - $ratio->save(); - - return redirect('structure.admin.dashboard'); - } - - public function updateTaxRatio(Request $request) { - $this->validate($request, [ - 'corporation', - 'type', - 'ratio', - ]); - - CorpTaxRatio::where([ - 'corporation_name' => $request->corporation, - 'structure_type' => $request->type, - ])->update([ - 'ratio' => $request->ratio, - ]); - - return redirect('/structure/admin/dashboard')->with('success', 'Tax Ratio updated for structure type: ' . $request->type . ' and corporation: ' . $request->corporation); - } - - public function displayTaxRatios() { - $taxRatios = CorpTaxRation::all(); - - return view('structure.admin.taxratios')->with('structures', $structures); - } -} diff --git a/app/Http/Controllers/Structures/StructureController.php b/app/Http/Controllers/Structures/StructureController.php deleted file mode 100644 index 337b91f93..000000000 --- a/app/Http/Controllers/Structures/StructureController.php +++ /dev/null @@ -1,124 +0,0 @@ -middleware('auth'); - $this->middleware('role:User'); - $this->middleware('permission:structure.operator'); - } - - public function chooseCorpTaxes() { - $this->middleware('role:Admin'); - - $corps = CorpStructure::pluck('corporation_name', 'corporation_id'); - return view('structures.admin.choosecorporation')->with('corps', $corps); - } - - public function displayCorpTaxes(Request $request) { - $this->middleware('role:Admin'); - - $corpId = $request->corpId; - $months = 3; - - //Declare the structure tax helper class - $sHelper = new StructureTaxHelper(); - - //Get the dates we are working with - $dates = $sHelper->GetTimeFrameInMonths($months); - - foreach($dates as $date) { - $totalTaxes[] = [ - 'date' => $date['start']->toFormattedDateString(), - 'tax' => number_format($sHelper->GetTaxes($corpId, 'Market', $date['start'], $date['end']), 2, '.', ','), - 'revenue' => number_format($sHelper->GetRevenue($corpId, 'Market', $date['start'], $date['end']), 2, '.', ',') - ]; - } - - //Return the view with the data passed to it - return view('structures.admin.choosecorptaxes')->with('totalTaxes', $totalTaxes); - } - - public function displayTaxes() { - //Declare new Lookup helper - $helper = new LookupHelper(); - - //Declare the structure tax helper class - $sHelper = new StructureTaxHelper(); - - $months = 3; - $totalTaxes = array(); - - //Get the character's corporation from the lookup table or esi - $corpId = $helper->LookupCharacter(Auth::user()->character_id); - - - //Get the dates we are working with - $dates = $sHelper->GetTimeFrameInMonths($months); - - //Get the market taxes for this month from the database - foreach($dates as $date) { - $totalTaxes[] = [ - 'date' => $date['start']->toFormattedDateString(), - 'tax' => number_format($sHelper->GetTaxes($corpId, 'Market', $date['start'], $date['end']), 2, '.', ','), - 'revenue' => number_format($sHelper->GetRevenue($corpId, 'Market', $date['start'], $date['end']), 2, '.', ',') - ]; - } - - return view('structures.user.taxes')->with('totalTaxes', $totalTaxes); - } - - public function displayTaxHistory(Request $request) { - //Declare new Lookup helper - $helper = new LookupHelper(); - - //Get the months from the request - $months = $request->months; - - //Get the character's corporation from the lookup table or esi - $corpId = $helper->LookupCharacter(Auth::user()->character_id); - - //Declare the structure tax helper class - $sHelper = new StructureTaxHelper(); - - //Get the dates we are working with - $dates = $sHelper->GetTimeFrameInMonths($months); - - //Build the array for displaying the data on the view - $totalTaxes = array(); - - foreach($dates as $date) { - $totalTaxes[] = [ - 'date' => $date['start']->toFormattedDateString(), - 'tax' => number_format($sHelper->GetTaxes($corpId, 'Market', $date['start'], $date['end']), 2, '.', ','), - 'revenue' => number_format($sHelper->GetRevenue($corpId, 'Market', $date['start'], $date['end']), 2, '.', ',') - ]; - } - - return view('structures.user.taxhistory')->with(compact('totalTaxes', 'months')); - } -} diff --git a/app/Library/Structures/StructureTaxHelper.php b/app/Library/Structures/StructureTaxHelper.php deleted file mode 100644 index ccc396771..000000000 --- a/app/Library/Structures/StructureTaxHelper.php +++ /dev/null @@ -1,219 +0,0 @@ -corpId = $corp; - $this->refType = $ref; - $this->start = $st; - $this->end = $en; - } - - public function GetTaxes($corpId, $refType, $start, $end) { - $taxOwed = 0.00; - //Get the number of structures of a certain type - $count = $this->GetStructureCount($corpId, $refType); - - //Calculate the fuel cost for one type of structure - $fuelCost = $this->CalculateFuelBlockCost($refType); - - //Get the ratio from the table to be divided against the tax to find the - //acutal tax owed to the alliance. Revenue will be a separate function - $ratio = CorpTaxRatio::where([ - 'corporation_id' => $corpId, - 'structure_type' => $refType, - ])->get(['ratio']); - $ratio = $ratio[0]->ratio; - - //Get the total taxes produced by the structure(s) over a given set of dates - $revenue = $this->GetRevenue($corpId, $refType, $start, $end); - - //Calculate the total fuel block cost - $totalFuelCost = $fuelCost * $count; - - //Calculate the total revenue minus the fuel block cost - $totalRevenue = $revenue - $totalFuelCost; - - //Check to see if the revenue is greater than zero to avoid division by zero error. - //Then calculate the tax owed which is revenue divided by ratio previously calcualted. - if($totalRevenue > 0.00) { - $taxOwed = $totalRevenue / $ratio; - } else { - $taxOwed = 0.00; - } - - //Return the amount - 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') { - //Get the revenue from the corp_market_journals table and add it up. - $revenue = CorpMarketJournal::where(['ref_type' => 'brokers_fee', 'corporation_id' => $corpId, 'second_party_id' => $corpId]) - ->whereBetween('date', [$start, $end]) - ->sum('amount'); - } else if($refType == 'Refinery'){ - //Get the revenue from the reprocessing_tax_journal table and add it up. - $revenue = ReprocessingTaxJournal::where(['ref_type' => 'reprocessing_tax', 'corporation_id' => $corpId, 'second_party_id' => $corpId]) - ->whereBetween('date', [$start, $end]) - ->sum('amount'); - } else { - //If it's not from one of the above tables, then it doesn't mean anything, so return nothing. - $revenue = 0.00; - } - - return (float)$revenue; - } - - private function CalculateTaxRatio($corpId, $overallTax, $type) { - //Get the ratio based on what was decided upon for the ratio of taxes. - //Default rate is 2.5 ratio. - - - //The alliance will get a ratio of the tax. - //We need to calculate the correct ratio based on structure tax, - //Then figure out what is owed to the alliance - if($type == 'Market') { - $ratioType = 2.5; - } else if($type == 'Refinery') { - $ratioType = 1.0; - } else { - $ratioType = 1.0; - } - //Calculate the ratio since we have the base percentage the alliance takes - $taxRatio = $overallTax / $ratioType; - - //Return what is owed to the alliance - return $taxRatio; - } - - private function CalculateFuelBlockCost($type) { - //Calculate how many fuel blocks are used in a month by a structure type - if($type === 'Market') { - $fuelBlocks = 24*30*32; - } else if ($type === 'Refinery') { - $fuelBlocks = 24*30*8; - } else { - $fuelBlocks = 0; - } - - //Multiply the amount of fuel blocks used by the structure by 20,000. - $cost = $fuelBlocks * 20000; - - //Return to the calling function - return $cost; - } - - public function GetTimeFrame() { - $start = Carbon::now()->startOfMonth(); - $end = Carbon::now()->endOfMonth(); - $end->hour = 23; - $end->minute = 59; - $end->second = 59; - $startLast = new Carbon('first day of last month'); - $endLast = new Carbon('last day of last month'); - $endLast->hour = 23; - $endLast->minute = 59; - $endLast->second = 59; - - $dates = [ - 'ThisMonthStart' => $start, - 'ThisMonthEnd' => $end, - 'LastMonthStart' => $startLast, - 'LastMonthEnd' => $endLast, - ]; - - return $dates; - } - - /** - * Returns a set of dates from now until the amount of months has passed - * - * @var integer - * @returns array - */ - public function GetTimeFrameInMonths($months) { - //Declare an array of dates - $dates = array(); - //Setup the start of the array as the basis of our start and end dates - $start = Carbon::now()->startOfMonth(); - $end = Carbon::now()->endOfMonth(); - $end->hour = 23; - $end->minute = 59; - $end->second = 59; - - if($months == 1) { - $dates = [ - 'start' => $start, - 'end' => $end, - ]; - - return $dates; - } - - //Create an array of dates - for($i = 0; $i < $months; $i++) { - if($i == 0) { - $dates[$i]['start'] = $start; - $dates[$i]['end'] = $end; - } - - $start = Carbon::now()->startOfMonth()->subMonths($i); - $end = Carbon::now()->endOfMonth()->subMonths($i); - $end->hour = 23; - $end->minute = 59; - $end->second = 59; - $dates[$i]['start'] = $start; - $dates[$i]['end'] = $end; - } - - //Return the dates back to the calling function - return $dates; - } - - private function GetStructureTax($corpId, $structureType) { - $tax = CorpStructure::where(['corporation_id' => $corpId, 'structure_type' => $structureType])->avg('tax'); - - return (float) $tax; - } - - private function GetStructureCount($corpId, $structureType) { - $count = CorpStructure::where(['corporation_id' => $corpId, 'structure_type' => $structureType])->count(); - - return (int)$count; - } -} - -?> \ No newline at end of file diff --git a/app/Models/Corporation/CorpStructure.php b/app/Models/Corporation/CorpStructure.php deleted file mode 100644 index 3144d4e73..000000000 --- a/app/Models/Corporation/CorpStructure.php +++ /dev/null @@ -1,33 +0,0 @@ - ['auth']], function(){ Route::post('/admin/add/allowedlogin', 'Dashboard\AdminController@addAllowedLogin'); Route::post('/admin/rmoeve/allowedlogin', 'Dashboard\AdminController@removeAllowedLogin'); - /** - * Register structure controller display pages - */ - Route::get('/structures/register', 'Structures\RegisterStructureController@displayRegisterstructure'); - Route::post('/structures/register', 'Structures\RegisterStructureController@storeStructure'); - - /** - * Structure Admin Controller display pages - */ - Route::get('/structures/admin/dashboard', 'Structures\StructureAdminController@displayDashboard'); - Route::post('/structures/admin/add/taxratio', 'Strutures\StructureAdminController@storeTaxRatio'); - Route::post('/structures/admin/update/taxratio', 'Structures\StructureAdminController@updateTaxRatio'); - - /** - * Structure Controller display pages - * To be removed in future release. Functionality will be removed as well. - */ - Route::get('/structures/taxes/display', 'Structures\StructureController@displayTaxes'); - Route::get('/structures/admin/taxes/display', 'Structures\StructureController@chooseCorpTaxes'); - Route::get('/structures/admin/taxes/display/execute', 'Structures\StructureController@displayCorpTaxes'); - Route::get('/structures/admin/taxes/industry', 'Structures\StructureController@displayIndustryTaxes'); - Route::get('/structures/admin/taxes/reprocessing', 'Structures\StructureController@displayReprocessingTaxes'); - Route::get('/structures/admin/display', 'Structures\StructureController@displayAdminPanel'); - /** * Scopes Controller display pages */