Beispiel #1
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     try {
         \DB::begintransaction();
         /* KREDIT */
         data_jurnal::create(['id_faktur' => $this->req['id_faktur'], 'id_coa_ledger' => $this->req['id_coa_ledger'], 'tanggal' => date('Y-m-d', strtotime($this->req['tanggal'])), 'deskripsi' => $this->req['deskripsi'], 'id_payment_methode' => $this->req['id_payment_methode'], 'tipe' => 2, 'total' => $this->req['total']]);
         /* DEBET */
         data_jurnal::create(['id_faktur' => $this->req['id_faktur'], 'id_coa_ledger' => $this->req['perkiraan'], 'tanggal' => date('Y-m-d', strtotime($this->req['tanggal'])), 'deskripsi' => $this->req['deskripsi'], 'id_payment_methode' => $this->req['id_payment_methode'], 'tipe' => 1, 'total' => $this->req['total']]);
         $faktur = data_faktur::find($this->req['id_faktur']);
         if ($this->req['total'] == $this->req['total_old']) {
             $faktur->status = 2;
         } else {
             $faktur->status = 1;
         }
         $faktur->amount_due = $faktur->amount_due + $this->req['total'];
         $faktur->save();
         /* KREDIT */
         $coa = ref_coa_ledger::find($this->req['id_coa_ledger']);
         $coa->balance = $coa->balance + $this->req['total'];
         $coa->save();
         /* DEBET */
         $kira = ref_coa_ledger::find($this->req['perkiraan']);
         $kira->balance = $kira->balance + $this->req['total'];
         $kira->save();
         \DB::commit();
         return ['label' => 'success', 'err' => 'Payment berhasil dilakukan'];
     } catch (\Exception $e) {
         \DB::rollback();
         return ['label' => 'danger', 'err' => $e->getMessage()];
     }
 }
Beispiel #2
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     //dd($this->req);
     $me = \Me::data()->id_karyawan;
     try {
         \DB::begintransaction();
         $faktur = data_faktur::find($this->req['id']);
         $faktur->update(['Nomor_type' => $this->req['no_po'], 'prefix' => $this->req['prefix'], 'type' => 1, 'id_vendor' => $this->req['supplier'], 'id_po' => $this->req['id_po'], 'tgl_faktur' => date('Y-m-d', strtotime($this->req['tanggal'])), 'duodate' => date('Y-m-d', strtotime($this->req['duodate'])), 'id_payment_terms' => $this->req['terms'], 'ppn' => $this->req['ppn'], 'diskon' => $this->req['diskon'], 'adjustment' => $this->req['adjustment'], 'subtotal' => $this->req['subtotal'], 'total' => $this->req['grandtotal'], 'keterangan' => $this->req['keterangan'], 'status' => 0]);
         data_faktur_item::whereId_faktur($faktur->id_faktur)->delete();
         foreach ($this->req['id_barang'] as $i => $id) {
             data_faktur_item::create(['id_faktur' => $faktur->id_faktur, 'id_item' => $id, 'deskripsi' => $this->req['deskripsi'][$i], 'qty' => $this->req['qty'][$i], 'harga' => $this->req['harga'][$i], 'diskon' => $this->req['diskons'][$i], 'total' => $this->req['total'][$i], 'id_po' => $this->req['id_po'], 'id_satuan' => $this->req['id_satuan'][$i]]);
         }
         \DB::commit();
         return ['res' => true, 'label' => 'success', 'err' => '<center>Faktur No. #' . $faktur->nomor_faktur . ' berhasil diperbaharui</center>'];
     } catch (\Exception $e) {
         \DB::rollback();
         return ['res' => false, 'label' => 'danger', 'err' => $e->getMessage()];
     }
 }
    public function postStatus(Request $req)
    {
        if ($req->ajax()) {
            data_faktur::find($req->id)->update(['status' => $req->status]);
            $status = [0 => ['label' => 'important', 'err' => 'Unpaid'], 1 => ['label' => 'warning', 'err' => 'Partially Paid'], 2 => ['label' => 'info', 'err' => 'Paid'], 3 => ['label' => 'important', 'err' => 'Batal']];
            $out = '
				<span class="label label-' . $status[$req->status]['label'] . '">
					' . $status[$req->status]['err'] . '
				</span>
			';
            return json_encode(['err' => $out, 'status' => $status[$req->status]['err']]);
        }
    }