added a GetTimeFrameInMonths function to structure tax helper
This commit is contained in:
@@ -42,13 +42,9 @@ 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' => number_format($sHelper->GetTaxes($corpId, 'Market', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
|
'thisMonthMarket' => number_format($sHelper->GetTaxes($corpId, 'Market', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
|
||||||
//'thisMonthRefinery' => number_format($sHelper->GetTaxes($corpId, 'Refinery', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
|
|
||||||
'lastMonthMarket' => number_format($sHelper->GetTaxes($corpId, 'Market', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
|
'lastMonthMarket' => number_format($sHelper->GetTaxes($corpId, 'Market', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
|
||||||
//'lastMonthRefinery' => number_format($sHelper->GetTaxes($corpId, 'Refinery', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
|
|
||||||
'thisMonthRevMarket' => number_format($sHelper->GetRevenue($corpId, 'Market', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
|
'thisMonthRevMarket' => number_format($sHelper->GetRevenue($corpId, 'Market', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
|
||||||
//'thisMonthRevRefinery' => number_format($sHelper->GetRevenue($corpId, 'Refinery', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
|
|
||||||
'lastMonthRevMarket' => number_format($sHelper->GetRevenue($corpId, 'Market', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
|
'lastMonthRevMarket' => number_format($sHelper->GetRevenue($corpId, 'Market', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
|
||||||
//'lastMonthRevRefinery' => number_format($sHelper->GetRevenue($corpId, 'Refinery', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
|
|
||||||
'thisMonthStart' => $dates['ThisMonthStart']->toFormattedDateString(),
|
'thisMonthStart' => $dates['ThisMonthStart']->toFormattedDateString(),
|
||||||
'lastMonthStart' => $dates['LastMonthStart']->toFormattedDateString(),
|
'lastMonthStart' => $dates['LastMonthStart']->toFormattedDateString(),
|
||||||
];
|
];
|
||||||
@@ -70,17 +66,12 @@ class StructureController extends Controller
|
|||||||
//Get the dates we are working with
|
//Get the dates we are working with
|
||||||
$dates = $sHelper->GetTimeFrame();
|
$dates = $sHelper->GetTimeFrame();
|
||||||
|
|
||||||
|
|
||||||
//Get the market taxes for this month from the database
|
//Get the market taxes for this month from the database
|
||||||
$totalTaxes = [
|
$totalTaxes = [
|
||||||
'thisMonthMarket' => number_format($sHelper->GetTaxes($corpId, 'Market', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
|
'thisMonthMarket' => number_format($sHelper->GetTaxes($corpId, 'Market', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
|
||||||
//'thisMonthRefinery' => number_format($sHelper->GetTaxes($corpId, 'Refinery', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
|
|
||||||
'lastMonthMarket' => number_format($sHelper->GetTaxes($corpId, 'Market', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
|
'lastMonthMarket' => number_format($sHelper->GetTaxes($corpId, 'Market', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
|
||||||
//'lastMonthRefinery' => number_format($sHelper->GetTaxes($corpId, 'Refinery', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
|
|
||||||
'thisMonthRevMarket' => number_format($sHelper->GetRevenue($corpId, 'Market', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
|
'thisMonthRevMarket' => number_format($sHelper->GetRevenue($corpId, 'Market', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
|
||||||
//'thisMonthRevRefinery' => number_format($sHelper->GetRevenue($corpId, 'Refinery', $dates['ThisMonthStart'], $dates['ThisMonthEnd']), 2, '.', ','),
|
|
||||||
'lastMonthRevMarket' => number_format($sHelper->GetRevenue($corpId, 'Market', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
|
'lastMonthRevMarket' => number_format($sHelper->GetRevenue($corpId, 'Market', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
|
||||||
//'lastMonthRevRefinery' => number_format($sHelper->GetRevenue($corpId, 'Refinery', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
|
|
||||||
'thisMonthStart' => $dates['ThisMonthStart']->toFormattedDateString(),
|
'thisMonthStart' => $dates['ThisMonthStart']->toFormattedDateString(),
|
||||||
'lastMonthStart' => $dates['LastMonthStart']->toFormattedDateString(),
|
'lastMonthStart' => $dates['LastMonthStart']->toFormattedDateString(),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -139,6 +139,34 @@ class StructureTaxHelper {
|
|||||||
return $dates;
|
return $dates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a set of dates from now until the amount of months has passed
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
* @returns array
|
||||||
|
*/
|
||||||
|
public function GetTimeFrameMonths($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;
|
||||||
|
|
||||||
|
//Create an array of dates
|
||||||
|
for($i = 0; $i < $months; $i++) {
|
||||||
|
$dates[$i]['start'] = $start;
|
||||||
|
$dates[$i]['end'] = $end;
|
||||||
|
$start = $start->subMonth();
|
||||||
|
$end = $end->subMonth();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return the dates back to the calling function
|
||||||
|
return $dates;
|
||||||
|
}
|
||||||
|
|
||||||
private function GetStructureTax($corpId, $structureType) {
|
private function GetStructureTax($corpId, $structureType) {
|
||||||
$tax = CorpStructure::where(['corporation_id' => $corpId, 'structure_type' => $structureType])->avg('tax');
|
$tax = CorpStructure::where(['corporation_id' => $corpId, 'structure_type' => $structureType])->avg('tax');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user