/**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     MutasiStokBahan::where('tanggal', $this->tanggal)->delete();
     $bahans = \App\Bahan::MutasiStok($this->tanggal);
     $inserts = [];
     foreach ($bahans as $bahan) {
         array_push($inserts, ['bahan_id' => $bahan['id'], 'before' => $bahan['before'], 'pembelian' => $bahan['pembelian'], 'penjualan' => $bahan['penjualan'], 'adjustment_increase' => $bahan['adjustment_increase'], 'adjustment_reduction' => $bahan['adjustment_reduction'], 'sisa' => $bahan['sisa'], 'tanggal' => $this->tanggal]);
     }
     MutasiStokBahan::insert($inserts);
 }
 protected function _stokBahanPertahun(Request $request)
 {
     $tahun = $request->get('tahun') ? $request->get('tahun') : date('Y');
     $start = Carbon::parse('first day of January ' . $tahun);
     $end = Carbon::parse('last day of December ' . $tahun);
     $bahans = \App\Bahan::MutasiStok($start->format('Y-m-d'), $end->format('Y-m-d'));
     return ['tanggal' => Carbon::createFromFormat('Y', $tahun), 'bahans' => $bahans];
 }