/**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     MutasiStokProduk::where('tanggal', $this->tanggal)->delete();
     $bahans = \App\Produk::MutasiStok($this->tanggal);
     $inserts = [];
     foreach ($bahans as $bahan) {
         array_push($inserts, ['produk_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]);
     }
     MutasiStokProduk::insert($inserts);
 }
 protected function _stokPertahun(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);
     $produks = \App\Produk::MutasiStok($start->format('Y-m-d'), $end->format('Y-m-d'));
     return ['tanggal' => Carbon::createFromFormat('Y', $tahun), 'produks' => $produks];
 }