SetStartStatus(); //Setup helper classes $hFinances = new FinanceHelper(); $sHelper = new StructureTaxHelper(); $start = Carbon::now()->startOfMonth()->subMonth(); $end = Carbon::now()->endOfMOnth()->subMonth(); $end->hour = 23; $end->minute = 59; $end->second = 59; //Get the set of corporations from the structure table $corps = CorpStructure::select('corporation_id')->groupBy('corporation_id')->get(); $this->line('Got all of the corps with markets.' . sizeof($corps)); foreach($corps as $corp) { $this->line('Entered foreach loop'); $finalTaxes = $sHelper->GetTaxes($corp->corporation_id, 'Market', $start, $end); var_dump($finalTaxes); $this->line('Received final taxes'); if($finalTaxes < 0.00) { $finalTaxes = 0.00; } $this->line('Checked for negative number.'); $finalTaxes = number_format($finalTaxes, 2, '.', ','); $this->line('Final Taxes are: ' . $finalTaxes); //Get the info about the structures from the database $info = CorpStructure::where(['corporation_id' => $corp->corporation_id])->first(); //Store the value in the database $bill = new MonthlyMarketTax; $bill->character_id = $info->character_id; $bill->character_name = $info->character_name; $bill->corporation_id = $corp->corporation_id; $bill->corporation_name = $info->corporation_name; $bill->taxed_owed = $finalTaxes; $bill->month = $start->monthName; $bill->year = $start->year; $bill->save(); } //Mark the job as finished $task->SetStopStatus(); } }