structure base line for application for tax services

This commit is contained in:
2018-11-19 00:46:12 -06:00
parent 84d996ddac
commit 439580b4e1
15 changed files with 252 additions and 82 deletions

View File

@@ -41,12 +41,14 @@ class corpJournal extends Command
*/
public function handle()
{
//Setup the Finances Container
$finance = new Finances();
//Get the characters that have the esi-wallet.read_corporation_wallets.v1
//esi wallet scope
$characters = DB::table('EsiScopes')->where('scopes', 'esi-wallet.read_corporation_wallets.v1')->get();
foreach($characters as $char) {
foreach($characters as $char) {
$finance->GetWalletJournal(1, $characters->character_id);
}
}
}

View File

@@ -4,6 +4,8 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Library\Finances;
class sendMail extends Command
{
/**
@@ -32,6 +34,9 @@ class sendMail extends Command
/**
* Execute the console command.
* Gather the taxes needed and add them together.
* Send a mail to the character owning the ESI scope with the taxes
* owed to the holding corp
*
* @return mixed
*/

View File

@@ -0,0 +1,45 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
use App\Models\CorpStructure;
class RegisterStructure extends Controller
{
public function __construct() {
$this->middleware('auth');
$this->middleware('role:Director');
}
public function displayRegisterStructure() {
return view('structures.register');
}
public function storeStructure(Request $request) {
$this->validate($request, [
'corporation_id' => 'required',
'corporation_name' => 'required',
'system' => 'required',
'structure_name' => 'required',
'tax' => 'required',
'structure_type' => 'required',
]);
$structure = new CorpStructure();
$structure->corporation_id = $request->corporation_id;
$structure->corporation_name = $request->corporation_name;
$structure->region = $request->region;
$structure->system = $request->system;
$structure->structure_name = $request->structure_name;
$structure->tax = $request->tax;
$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');
}
}

View File

@@ -22,7 +22,8 @@ class RequireRole
'None' => 0,
'Guest' => 1,
'User' => 2,
'Admin' => 3,
'Director' => 3,
'Admin' => 4,
];
$check = DB::table('user_roles')->where('character_id', auth()->user()->character_id)->get(['role']);

View File

@@ -24,49 +24,6 @@ use Seat\Eseye\Eseye;
class Finances {
public function PutWalletJournal($journal, $corpId, $division) {
$check = DB::table('CorpJournal')->where('id', $journal['id'])->get();
//if we don't find the journal entry, add the journal entry to the database
if($check == null) {
$entry = new CorpJournal;
$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 = $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();
}
}
public function CalculateMonthlyRefineryTaxees($corpId, $month, $overallTax) {
$currentTime = Carbon::now();
$monthWanted = $month;
@@ -101,37 +58,6 @@ class Finances {
return $taxed;
}
public function SendMail($charId, $taxAmount, $subject) {
//Retrieve the token for Amund Risalo
$token = DB::table('EsiTokens')->where('character_id', 93738489)->get();
$configuration = Configuration::getInstance();
$configuration->cache = NullCache::class;
$configuration->logfile_location = '/var/www/w4rpservices/storage/logs/eseye';
//Create the 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 variable
$esi = new Eseye($authentication);
try {
$esi->setBody([
'body' => $body,
'receipients' => [
'recipient_id'=> $charId,
'recipient_type' => 'character',
],
'subject' => $subject,
])->invoke('post', '/characters/{character_id}/mail/', [
'character_id' => 93738489,
]);
} catch(\Seat\Eseye\Exceptions\RequestFailedException $e) {
return $e->getEsiResponse();
}
}
public function GetWalletJournal($division, $charId) {
//Get the ESI token for the corporation to add new wallet journals into the database
$token = DB::table('EsiTokens')->where('character_id', $charId)->get();
@@ -174,6 +100,49 @@ class Finances {
}
}
private function PutWalletJournal($journal, $corpId, $division) {
$check = DB::table('CorpJournal')->where('id', $journal['id'])->get();
//if we don't find the journal entry, add the journal entry to the database
if($check == null) {
$entry = new CorpJournal;
$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 = $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();
}
}
}
?>

View File

@@ -2,8 +2,48 @@
namespace App\Library;
use DB;
use App\Models\EsiScope;
use App\Models\Esitoken;
use Seat\Eseye\Cache\NullCache;
use Seat\Eseye\Configuration;
use Seat\Eseye\Containers\EsiAuthentication;
use Seat\Eseye\Eseye;
class Mail {
public function SendMail($charId, $taxAmount, $subject) {
//Retrieve the token for Amund Risalo
$token = DB::table('EsiTokens')->where('character_id', 93738489)->get();
$configuration = Configuration::getInstance();
$configuration->cache = NullCache::class;
$configuration->logfile_location = '/var/www/w4rpservices/storage/logs/eseye';
//Create the 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 variable
$esi = new Eseye($authentication);
try {
$esi->setBody([
'body' => $body,
'receipients' => [
'recipient_id'=> $charId,
'recipient_type' => 'character',
],
'subject' => $subject,
])->invoke('post', '/characters/{character_id}/mail/', [
'character_id' => 93738489,
]);
} catch(\Seat\Eseye\Exceptions\RequestFailedException $e) {
return $e->getEsiResponse();
}
}
}
?>

View File

@@ -1,6 +1,6 @@
<?php
namespace App;
namespace App\Models;
use Illuminate\Database\Eloquent\Model;

View File

@@ -1,6 +1,6 @@
<?php
namespace App;
namespace App\Models;
use Illuminate\Database\Eloquent\Model;

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class CorpStructure extends Model
{
/**
* Table Name
*/
protected $table = 'CorpStructures';
/**
* Timestamps
*/
public $timestamps = true;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'corporation_id',
'corporation_name',
'region',
'system',
'structure_name',
'tax',
'structure_type',
];
}

View File

@@ -39,6 +39,15 @@ class AuthServiceProvider extends ServiceProvider
}
});
$gate->define('isDirector', function($user) {
$check = DB::table('user_roles')->where('character_id', auth()->user()->character_id)->get(['role']);
if($check[0]->role === 'Director') {
return true;
} else {
return false;
}
});
$gate->define('isUser', function($user) {
$check = DB::table('user_roles')->where('character_id', auth()->user()->character_id)->get(['role']);
if($check[0]->role === 'User') {

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCorpStructure extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if(!Schema::hasTable('CorpStructures')) {
Schema::create('CorpStructures', function(Blueprint $table) {
$table->increments('id');
$table->integer('corporation_id');
$table->string('corporation_name');
$table->string('region');
$table->string('system');
$table->string('structure_name');
$table->decimal('tax', 10, 2);
$table->string('structure_type');
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('CorpStructures');
}
}

View File

@@ -0,0 +1,25 @@
@extends('layouts.b4')
@section('content')
<div class="container">
<h2>Register Structure</h2>
{!! Form::open(['action' => 'RegisterStructureController@storeStructure', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('corporation_id', 'Corporation ID')}}
{{ Form::text('corporation_id', '', ['class' => 'form-control']) }}
{{ Form::label('corporation_name', 'Corporation Name') }}
{{ Form::text('corporation_name', '', ['class' => 'form-control']) }}
{{ Form::label('region', 'Region') }}
{{ Form::text('region', '', ['class' => 'form-control']) }}
{{ Form::label('system', 'System') }}
{{ Form::text('system', '', ['class' => 'form-control']) }}
{{ Form::label('structure_name', 'Structure Name') }}
{{ Form::text('structure_name', '', ['class' => 'form-control']) }}
{{ Form::label('tax', 'Tax') }}
{{ Form::number('tax', '', ['class' => 'form-control']) }}
{{ Form::label('structure_type', 'Structure Type') }}
{{ Form::select('structure_type', ['Refinery' => 'Refinery', 'Citadel' => 'Citadel'], null, ['class' => 'form-control']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
@endsection

View File

@@ -10,7 +10,6 @@ return array(
'App\\Console\\Commands\\getCorps' => $baseDir . '/app/Console/Commands/getCorps.php',
'App\\Console\\Commands\\sendMail' => $baseDir . '/app/Console/Commands/sendmail.php',
'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php',
'App\\CorpJournal' => $baseDir . '/app/Models/CorpJournal.php',
'App\\Exceptions\\Handler' => $baseDir . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\AdminController' => $baseDir . '/app/Http/Controllers/AdminController.php',
'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => $baseDir . '/app/Http/Controllers/Auth/ForgotPasswordController.php',
@@ -40,7 +39,9 @@ return array(
'App\\Library\\Mail' => $baseDir . '/app/Library/Mail.php',
'App\\Library\\MoonCalc' => $baseDir . '/app/Library/MoonCalc.php',
'App\\Library\\MoonMine' => $baseDir . '/app/Library/MoonMine.php',
'App\\Models\\AllianceCorp' => $baseDir . '/app/Models/AllianceCorp.php',
'App\\Models\\Config' => $baseDir . '/app/Models/Config.php',
'App\\Models\\CorpJournal' => $baseDir . '/app/Models/CorpJournal.php',
'App\\Models\\DokuGroupNames' => $baseDir . '/app/Models/DokuGroupNames.php',
'App\\Models\\DokuMember' => $baseDir . '/app/Models/DokuMember.php',
'App\\Models\\DokuUser' => $baseDir . '/app/Models/DokuUser.php',

View File

@@ -405,7 +405,6 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Console\\Commands\\getCorps' => __DIR__ . '/../..' . '/app/Console/Commands/getCorps.php',
'App\\Console\\Commands\\sendMail' => __DIR__ . '/../..' . '/app/Console/Commands/sendmail.php',
'App\\Console\\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php',
'App\\CorpJournal' => __DIR__ . '/../..' . '/app/Models/CorpJournal.php',
'App\\Exceptions\\Handler' => __DIR__ . '/../..' . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\AdminController' => __DIR__ . '/../..' . '/app/Http/Controllers/AdminController.php',
'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/ForgotPasswordController.php',
@@ -435,7 +434,9 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Library\\Mail' => __DIR__ . '/../..' . '/app/Library/Mail.php',
'App\\Library\\MoonCalc' => __DIR__ . '/../..' . '/app/Library/MoonCalc.php',
'App\\Library\\MoonMine' => __DIR__ . '/../..' . '/app/Library/MoonMine.php',
'App\\Models\\AllianceCorp' => __DIR__ . '/../..' . '/app/Models/AllianceCorp.php',
'App\\Models\\Config' => __DIR__ . '/../..' . '/app/Models/Config.php',
'App\\Models\\CorpJournal' => __DIR__ . '/../..' . '/app/Models/CorpJournal.php',
'App\\Models\\DokuGroupNames' => __DIR__ . '/../..' . '/app/Models/DokuGroupNames.php',
'App\\Models\\DokuMember' => __DIR__ . '/../..' . '/app/Models/DokuMember.php',
'App\\Models\\DokuUser' => __DIR__ . '/../..' . '/app/Models/DokuUser.php',