/** * Execute the job. * * @return void */ public function handle() { try { \DB::begintransaction(); if ($this->req['id'] < 1) { $group = data_sph_grup::create(['id_pembuat' => \Me::data()->id_karyawan]); } else { $group = data_sph_grup::find($this->req['id']); \Loguser::create('Menambahkan Pengajuan pada SPH No. ' . $group->no_sph); } $sph = data_sph::create(['id_sph_grup' => $group->id_sph_grup, 'id_vendor' => $this->req['vendor'], 'deadline' => $this->req['deadline'], 'id_pembuat' => \Me::data()->id_karyawan, 'id_acc' => 0, 'diskon' => $this->req['gdiskon'], 'ppn' => $this->req['gppn'], 'adjustment' => $this->req['adjustment'], 'keterangan' => $this->req['ket']]); foreach ($this->req['id_prq_item'] as $i => $id_prq_item) { data_sph_item::create(['id_sph' => $sph->id_sph, 'id_prq' => $this->req['id_prq'][$i], 'id_item' => $this->req['id_barang'][$i], 'qty' => $this->req['qty'][$i], 'harga' => $this->req['harga'][$i], 'diskon' => $this->req['diskon'][$i], 'keterangan' => $this->req['kets'][$i], 'id_satuan' => $this->req['satuan'][$i]]); data_prq::find($this->req['id_prq'][$i])->update(['status' => 2]); } if ($this->req['id'] < 1) { $format = 'G-SPH/'; $group->no_sph = $format . \Format::code($group->id_sph_grup); $group->save(); \Loguser::create('Membuat Surat Pengajuan Harga dengan No. ' . $group->no_sph); } $fo = 'SPH/'; $sph->no_sph_item = $fo . \Format::code($sph->id_sph); $sph->save(); \DB::commit(); return ['status' => true, 'err' => $group]; } catch (\Exception $e) { \DB::rollback(); return ['status' => false, 'err' => $e->getMessage()]; } }
/** * Execute the job. * * @return void */ public function handle() { try { \DB::begintransaction(); $sph = data_sph::find($this->id); $grup = data_sph_grup::whereId_sph_grup($sph->id_sph_grup)->select('status')->first(); if ($grup->status == 2) { throw new \Exception("Maaf SPH No. " . $sph->no_sph_item . " sudah kadaluarsa!", 1); } $nsph = data_sph::create(['id_sph_grup' => $sph->id_sph_grup, 'id_vendor' => $sph->id_vendor, 'deadline' => $sph->deadline, 'id_pembuat' => \Me::data()->id_karyawan, 'id_acc' => $sph->id_acc, 'diskon' => $sph->diskon, 'ppn' => $sph->ppn, 'pph' => $sph->pph, 'adjustment' => $sph->adjustment]); $items = data_sph_item::whereId_sph($this->id)->get(); foreach ($items as $item) { data_sph_item::create(['id_sph' => $nsph->id_sph, 'id_prq' => $item->id_prq, 'id_item' => $item->id_item, 'qty' => $item->qty, 'harga' => $item->harga, 'diskon' => $item->diskon, 'ppn' => $item->ppn, 'pph' => $item->pph, 'id_satuan' => $item->id_satuan]); } $fo = 'ISPH/'; $nsph->no_sph_item = $fo . \Format::code($nsph->id_sph); $nsph->save(); \Loguser::create('Menduplikasi data SPH dari No. ' . $sph->no_sph_item); \DB::commit(); return ['err' => 'SPH berhasil di duplikasi dengan No. ' . $nsph->no_sph_item]; } catch (\Exception $e) { \DB::rollback(); return ['err' => $e->getMessage()]; } }
/** * Execute the job. * * @return void */ public function handle() { try { \DB::begintransaction(); $sph = data_sph::find($this->req['id']); $grup = data_sph_grup::whereId_sph_grup($sph->id_sph_grup)->select('status')->first(); if ($grup->status == 2) { throw new \Exception("Maaf SPH No. " . $sph->no_sph_item . " sudah kadaluarsa!", 1); } $sph->update(['id_vendor' => $this->req['vendor'], 'deadline' => $this->req['deadline'], 'diskon' => $this->req['gdiskon'], 'ppn' => $this->req['gppn'], 'adjustment' => $this->req['adjustment'], 'keterangan' => $this->req['ket']]); data_sph_item::whereId_sph($this->req['id'])->delete(); foreach ($this->req['id_sph_item'] as $i => $id_sph_item) { data_sph_item::create(['id_sph' => $this->req['id'], 'id_prq' => $this->req['id_prq'][$i], 'id_item' => $this->req['id_barang'][$i], 'qty' => $this->req['qty'][$i], 'harga' => $this->req['harga'][$i], 'diskon' => $this->req['diskon'][$i], 'keterangan' => $this->req['kets'][$i], 'id_satuan' => $this->req['satuan'][$i]]); } \Loguser::create('Memperbaharui data SPH No. ' . $sph->no_sph_item); \DB::commit(); return ['status' => true, 'err' => $sph]; } catch (\Exception $e) { \DB::rollback(); return ['status' => false, 'err' => $e->getMessage()]; } }