added a GetTimeFrameInMonths function to structure tax helper

This commit is contained in:
2019-01-04 23:49:58 -06:00
parent 5f602b8691
commit d76f50e539
2 changed files with 28 additions and 9 deletions

View File

@@ -42,13 +42,9 @@ class StructureController extends Controller
//Get the market taxes for this month from the database
$totalTaxes = [
'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, '.', ','),
//'lastMonthRefinery' => number_format($sHelper->GetTaxes($corpId, 'Refinery', $dates['LastMonthStart'], $dates['LastMonthEnd']), 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, '.', ','),
//'lastMonthRevRefinery' => number_format($sHelper->GetRevenue($corpId, 'Refinery', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
'thisMonthStart' => $dates['ThisMonthStart']->toFormattedDateString(),
'lastMonthStart' => $dates['LastMonthStart']->toFormattedDateString(),
];
@@ -70,17 +66,12 @@ class StructureController extends Controller
//Get the dates we are working with
$dates = $sHelper->GetTimeFrame();
//Get the market taxes for this month from the database
$totalTaxes = [
'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, '.', ','),
//'lastMonthRefinery' => number_format($sHelper->GetTaxes($corpId, 'Refinery', $dates['LastMonthStart'], $dates['LastMonthEnd']), 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, '.', ','),
//'lastMonthRevRefinery' => number_format($sHelper->GetRevenue($corpId, 'Refinery', $dates['LastMonthStart'], $dates['LastMonthEnd']), 2, '.', ','),
'thisMonthStart' => $dates['ThisMonthStart']->toFormattedDateString(),
'lastMonthStart' => $dates['LastMonthStart']->toFormattedDateString(),
];

View File

@@ -139,6 +139,34 @@ class StructureTaxHelper {
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) {
$tax = CorpStructure::where(['corporation_id' => $corpId, 'structure_type' => $structureType])->avg('tax');