structure controller

This commit is contained in:
2018-12-11 21:11:04 -06:00
parent df00a05788
commit f51e94c538

View File

@@ -35,14 +35,14 @@ class StructureController extends Controller
//Get the market taxes for this month from the database //Get the market taxes for this month from the database
$totalTaxes = [ $totalTaxes = [
'thisMonthMarket' => $this->GetTaxes($corpId, 'Market', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 'thisMonthMarket' => number_format($this->GetTaxes($corpId, 'Market', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
'thisMonthRefinery' => $this->GetTaxes($corpId, 'Refinery', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 'thisMonthRefinery' => number_format($this->GetTaxes($corpId, 'Refinery', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
'lastMonthMarket' => $this->GetTaxes($corpId, 'Market', $dates['LastMonthStart'], $dates['LastMonthEnd']), 'lastMonthMarket' => number_format($this->GetTaxes($corpId, 'Market', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
'lastMonthRefinery' => $this->GetTaxes($corpId, 'Refinery', $dates['LastMonthStart'], $dates['LastMonthEnd']), 'lastMonthRefinery' => number_format($this->GetTaxes($corpId, 'Refinery', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
'thisMonthRevMarket' => $this->GetRevenue($corpId, 'Market', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 'thisMonthRevMarket' => number_format($this->GetRevenue($corpId, 'Market', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
'thisMonthRevRefinery' => $this->GetRevenue($corpId, 'Refinery', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 'thisMonthRevRefinery' => number_format($this->GetRevenue($corpId, 'Refinery', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
'lastMonthRevMarket' => $this->GetRevenue($corpId, 'Market', $dates['LastMonthStart'], $dates['LastMonthEnd']), 'lastMonthRevMarket' => number_format($this->GetRevenue($corpId, 'Market', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
'lastMonthRevRefinery' => $this->GetRevenue($corpId, 'Refinery', $dates['LastMonthStart'], $dates['LastMonthEnd']), 'lastMonthRevRefinery' => number_format($this->GetRevenue($corpId, 'Refinery', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
'thisMonthStart' => $dates['ThisMonthStart'], 'thisMonthStart' => $dates['ThisMonthStart'],
'thisMonthEnd' => $dates['ThisMonthEnd'], 'thisMonthEnd' => $dates['ThisMonthEnd'],
'lastMonthStart' => $dates['LastMonthStart'], 'lastMonthStart' => $dates['LastMonthStart'],
@@ -70,7 +70,7 @@ class StructureController extends Controller
//Get the total taxes produced by the structure(s) over a given set of dates //Get the total taxes produced by the structure(s) over a given set of dates
$revenue = $this->GetRevenue($corpId, $refType, $start, $end); $revenue = $this->GetRevenue($corpId, $refType, $start, $end);
$revenue = ($revenue* 1.00) - ($fuelCost * 1.00); $revenue = $revenue - $fuelCost;
//Calculate the tax owed which is revenue divided by ratio previously calculated //Calculate the tax owed which is revenue divided by ratio previously calculated
$taxOwed = $revenue / $ratio; $taxOwed = $revenue / $ratio;
@@ -79,7 +79,6 @@ class StructureController extends Controller
$taxOwed = 0.00; $taxOwed = 0.00;
} }
//Return the amount //Return the amount
$taxOwed = number_format($taxOwed,'2', '.', ',');
return $taxOwed; return $taxOwed;
} }
@@ -97,7 +96,7 @@ class StructureController extends Controller
$revenue = 0.00; $revenue = 0.00;
} }
$revenue = number_format($revenue, 2, '.', ',');
return $revenue; return $revenue;
} }
@@ -113,7 +112,7 @@ class StructureController extends Controller
$ratioType = 1.0; $ratioType = 1.0;
} }
//Calculate the ratio since we have the base percentage the alliance takes //Calculate the ratio since we have the base percentage the alliance takes
$taxRatio = floatval($overallTax / $ratioType); $taxRatio = $overallTax / $ratioType;
//Return what is owed to the alliance //Return what is owed to the alliance
return $taxRatio; return $taxRatio;
@@ -158,10 +157,14 @@ class StructureController extends Controller
} }
private function GetStructureTax($corpId, $structureType) { private function GetStructureTax($corpId, $structureType) {
return CorpStructure::where(['corporation_id' => $corpId, 'structure_type' => $structureType])->avg('tax'); $tax = CorpStructure::where(['corporation_id' => $corpId, 'structure_type' => $structureType])->avg('tax');
return (float) $tax;
} }
private function GetStructureCount($corpId, $structureType) { private function GetStructureCount($corpId, $structureType) {
return CorpStructure::where(['corporation_id' => $corpId, 'structure_type' => $structureType])->count(); $count = CorpStructure::where(['corporation_id' => $corpId, 'structure_type' => $structureType])->count();
return (float) $count;
} }
} }