corpId = $corp; $this->refType = $ref; $this->start = $st; $this->end = $en; } public function GetAllianceMarketGross($start, $end) { $revenue = 0.00; $revenue = AllianceMarketJournal::where([ 'second_party_id' => '98287666', 'ref_type' => 'brokers_fee', ])->whereBetween('date', [$start, $end]) ->sum('amount'); return $revenue; } public function GetJumpGateGross($start, $end) { $revenue = 0.00; $revenue = JumpBridgeJournal::where([ 'ref_type' => 'structure_gate_jump', 'second_party_id' => '98287666', ])->whereBetween('date', [$start, $end]) ->sum('amount'); return $revenue; } public function GetIndustryGross($start, $end) { $revenue = 0.00; $revenue = StructureIndustryTaxJournal::where([ 'ref_type' => 'industry_job_tax', 'second_party_id' => '98287666', ])->whereBetween('date', [$start, $end]) ->sum('amount'); return $revenue; } public function GetReprocessingGross($start, $end) { $revenue = 0.00; $revenue = ReprocessingTaxJournal::where([ 'ref_type' => 'reprocessing_tax', 'second_party_id' => '98287666', ])->whereBetween('date', [$start, $end]) ->sum('amount'); return $revenue; } public function GetPIGross($start, $end) { $revenueImport = 0.00; $revenueExport = 0.00; //Get the import revenue from the database $revenueImport = PlanetProductionTaxJournal::where([ 'ref_type' => 'planetary_import_tax', 'second_party_id' => '98287666', ])->whereBetween('date', [$start, $end]) ->sum('amount'); //Get the export revenue from the database $revenueExport = PlanetProductionTaxJournal::where([ 'ref_type' => 'planetary_export_tax', 'second_party_id' => '98287666', ])->whereBetween('date', [$start, $end]) ->sum('amount'); //Total up the two values $finalRevenue = $revenueImport + $revenueExport; //Return the values return $finalRevenue; } public function GetOfficeGross($start, $end) { $revenue = 0.00; $revenue = OfficeFeesJournal::where([ 'ref_type' => 'office_rental_fee', 'second_party_id' => '98287666', ])->whereBetween('date', [$start, $end]) ->sum('amount'); return $revenue; } public function GetPiSalesGross($start, $end) { $revenue = 0.00; $grosses = PISaleJournal::whereBetween('date', [$start, $end])->get()->toArray(); foreach($grosses as $gross) { $revenue += ($gross['quantity'] * $gross['unit_price']); } return $revenue; } /** * Returns a set of dates from now until the amount of months has passed * * @var integer * @returns array */ public function GetTimeFrameInMonths($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; if($months == 1) { $dates = [ 'start' => $start, 'end' => $end, ]; return $dates; } //Create an array of dates for($i = 0; $i < $months; $i++) { if($i == 0) { $dates[$i]['start'] = $start; $dates[$i]['end'] = $end; } $start = Carbon::now()->startOfMonth()->subMonths($i); $end = Carbon::now()->endOfMonth()->subMonths($i); $end->hour = 23; $end->minute = 59; $end->second = 59; $dates[$i]['start'] = $start; $dates[$i]['end'] = $end; } //Return the dates back to the calling function return $dates; } }