display taxes history

This commit is contained in:
2018-12-11 23:24:29 -06:00
parent c6360cf338
commit c0778aabac
3 changed files with 87 additions and 2 deletions

View File

@@ -23,6 +23,33 @@ class StructureController extends Controller
$this->middleware('permission:structure.operator');
}
public function displayTaxesHistory() {
//Make the helper esi class
$helper = new Esi();
//Get the character's corporation from esi
$corpId = $helper->FindCorporationId(Auth::user()->character_id);
//Get the dates we are working with
$dates = $this->GetLongTimeFrame();
//Create the totalTaxes array
$totalTaxes = [];
//Create the array for totalTaxes in order to send in the data to the view
for($i = 0; $i < 12; $i++) {
$totalTaxes[$i] = [
'MarketTax' => number_format($this->GetTaxes($corpId, 'Market', $dates[$i]['start'], $dates[$i]['end']), 2, '.', ','),
'MarketRevenue' => number_format($this->GetRevenue($corpId, 'Market', $dates[$i]['start'], $dates[$i]['end']), 2, '.', ','),
'RefineryTax' => number_format($this->GetTaxes($corpId, 'Refinery', $dates[$i]['start'], $dates[$i]['end']), 2, '.', ','),
'RefineryRevenue' => number_format($this->GetRevenue($corpId, 'Refinery', $dates[$i]['start'], $dates[$i]['end']), 2, '.', ','),
'start' => $dates[$i]['start']->toFormattedDateString(),
];
}
return view('structures.taxhistory')->with('totalTaxes', $totalTaxes);
}
public function displayTaxes() {
//Make the helper esi class
$helper = new Esi();
@@ -44,9 +71,7 @@ class StructureController extends Controller
'lastMonthRevMarket' => number_format($this->GetRevenue($corpId, 'Market', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
'lastMonthRevRefinery' => number_format($this->GetRevenue($corpId, 'Refinery', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
'thisMonthStart' => $dates['ThisMonthStart']->toFormattedDateString(),
'thisMonthEnd' => $dates['ThisMonthEnd']->toFormattedDateString(),
'lastMonthStart' => $dates['LastMonthStart']->toFormattedDateString(),
'lastMonthEnd' => $dates['LastMonthEnd']->toFormattedDateString(),
];
return view('structures.taxes')->with('totalTaxes', $totalTaxes);
@@ -134,6 +159,32 @@ class StructureController extends Controller
return $cost;
}
private function GetLongTimeFrame() {
$start = Carbon::now()->startOfMonth();
$end = Carbon::now()->endOfMonth();
$end->hour = 23;
$end->minute = 59;
$end->second = 59;
$dates = array();
$dates[0] = [
'start' => $start,
'end' => $end,
];
//Cycle through the for loop and build the array
for($i = 1; $i <= 12; $i++) {
$start = $start->subMonth();
$end = $end->subMonth();
$dates[$i] = [
'start' => $start,
'end' => $end,
];
}
return $dates;
}
private function GetTimeFrame() {
$start = Carbon::now()->startOfMonth();
$end = Carbon::now()->endOfMonth();

View File

@@ -53,6 +53,7 @@
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdoownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Structures</a>
<div class="dropdown-menu" aria-labelledby="navbarDropDownMenuLink">
<a class="dropdown-item" href="/structures/taxes/display">Current Taxes</a>
<a class="dropdown-item" href="/structures/taxes/history">Tax History</a>
<a class="dropdown-item" href="/structures/register">Register Structure</a>
</div>
</li>

View File

@@ -0,0 +1,33 @@
@extends('layouts.b4')
@section('content')
<div class="container">
<div class="card">
<div class="card-header">
Structure Taxes
</div>
<div class="card-body">
<table class="table table-striped">
<thead>
<th>Month</th>
<th>Market Tax</th>
<th>Market Revenue Minus Fuel Cost</th>
<th>Refinery Tax</th>
<th>Refinery Revenue Minus Fuel Cost</th>
</thead>
<tbody>
@foreach($i = 0; $i < 12; $i++)
<tr>
<td>{{ $totalTaxes[$i]['start'] }}</td>
<td>{{ $totalTaxes[$i]['MarketTax'] }}</td>
<td>{{ $totalTaxes[$i]['MarketRevenue'] }}</td>
<td>{{ $totalTaxes[$i]['RefineryTax'] }}</td>
<td>{{ $totalTaxes[$i]['RefineryRevenue'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@endsection