/** * Cost Vs Selling Price Report * * @return $this */ public function costVsSelling($month, $year) { $this->authorize('view_gp_report'); $date = Carbon::create($year, $month); $jobIds = DespatchLogEntry::thisMonth($date)->get()->pluck('despatch_log_book_job_cards_id_fk')->toArray(); return view('reports.costVsSelling')->with(['jobs' => JobCard::find($jobIds)]); }
/** * Calculate the current months Actual GP * * @return string */ public function monthActualGp() { return Cache::store('database')->remember(__CLASS__ . "::" . __FUNCTION__ . $this->date->month . $this->date->year, 60, function () { $monthDespatchEntries = DespatchLogEntry::thisMonth($this->date)->get(); return round($monthDespatchEntries->sum('gp_contribution')); }); }