Cara Menghitung Uang Pecahan/Recehan dari SPJ
10 September 2017 | Tags: Cara Menghitung Uang Pecahan SPJ, Cara Menghitung Uang Recehan SPJ, Uang Pecahan, Uang Pecahan dengan CodeIgniter, Uang Recehan, Uang Recehan dengan CodeIgniter
Mungkin anda yang bertugas dalam pembuatan Surat Pertanggung Jawaban atau Daftar Penerima Uang, sering menghitung berapa jumlah yang pecahan seratus ribu (100 Rb), lima puluh ribu (50 Rb), sepuluh ribu (10 Rb), dan pecahan lain yang diperlukan dalam suatu pembayaran. Tutorial Cara Menghitung Uang Pecahan/Recehan dari SPJ ini dibuat untuk membantu anda yang sering melakukan rutinitas pembayaran.
Kalau orang atau jumlah penerima sedikit, mungkin kita bisa cepat menghitungnya. Tapi begitu jumlahnya besar dan banyak daftar penerima, maka kita perlu bantuan dari sebuah sistem untuk menghitung rincian uang secara otomatis.
Ok, berikut ini kami akan coba mengulas cara menghitung uang pecahan/recehan dari SPJ (Surat Pertanggungjawaban) dan aplikasinya yang dikembangkan dengan CodeIgniter.
Langkah-langkah atau Algoritma Cara Menghitung Uang Pecahan/Recehan dari SPJ
- Buat Rekap daftar penerima uang
- Kelompokkan daftar Rekap berdasarkan jumlah uang. (Yang sama dikelompokkan. Misal: yang dapat uang 510.000 berapa orang, 600.000 berapa orang, dan seterusnya)
- Untuk masing-masing jumlah uang yang dikelompokkan lakukan looping perhitungan sebagai berikut: (Misal yang mendapatkan jumlah uang 485.000 sebanyak 2 orang)
- Bagi 485.000 dengan uang pecahan terbesar (100 Rb), akan mendapatkan pecahan 100 rb sebanyak 4 lembar, dan sisa sebesar 85.000
- Sisa 85.000 dibagi dengan uang pecahan terbesar kedua (50 Rb), maka akan didapat pecahan 50 rb sebanyak 1 lembar, dan sisa sebesar 35.000
- Sisa 35.000 dibagi dengan uang pecahan terbesar ketiga (20 rb), maka akan didapat pecahan 20 rb sebanyak 1 lembar, dan sisa sebesar 15.000
- Sisa 15.000 dibagi dengan pecahan terbesar keempat (10 rb), maka akan didapat pecahan 10 rb sebanyak 1 lembar dan sisa sebesar 5.000.
- Sisa 5.000 dibagi dengan pecahan terbesar kelima (5 rb), akan mendapat pecahan 5 rb sebanyak 1 lembar dan sisa 0. Karena sisa sudah habis maka proses berhenti.
- Dari perhitungan tersebut, untuk uang senilai 485.000 akan memerlukan uang pecahan: 100 rb x 4, 50 rb x 1, 20 rb x 1, 10 rb x 1, 5 rb x 1.
- Karena jumlah penerima uang 485.000 sebanyak 2 orang, maka hasil rincian per pecahan uang dikali dengan 2. Sehingga hasil akhirnya: 100 rb= 8 lembar, 50 rb=2 lembar, 20 rb=2 lembar, 10 rb= 2 lembar, 5 rb=2 lembar.
- Tampilkan rincian uang recehan.
Setelah mengetahui langkah-langkah untuk melakukan perhitungan, selanjutnya adalah penerapan aplikasi dengan CodeIgniter.
Source Code Cara Menghitung Uang Pecahan/Recehan dari SPJ dengan CodeIgniter
- Buat Controller Transaksi (application->controllers->Transaksi.php)
<?php class Transaksi extends CI_Controller{ var $folder = "transaksi/spj"; var $tables = "tbl_spj"; var $tables2 = "tbl_spj_detail"; var $pk = "id"; var $title = "Daftar SPJ"; function __construct() { parent::__construct(); } public function daftar_spj() { $data['title']= "Daftar SPJ"; $data['desc']=""; $data['pk']=$this->pk; $data['record']=$this->db->get("tbl_spj")->result(); $this->load->view('themes/header'); $this->load->view($this->folder.'/browse',$data); $this->load->view('themes/footer'); } public function spj_input() { $this->load->model('TransaksiModel'); $id=$this->input->post('id'); $mode=strtoupper($this->input->post('mode')); $data=array('nama_spj'=>$this->input->post('nama_spj'), 'tanggal'=>$this->input->post('tanggal')); switch($mode) { case "INPUT": if($this->db->insert($this->tables,$data)) { $kode=$this->db->insert_id(); //----------------INSERT DETAIL-------------------------------------- if($this->input->post('rincian')) { $v1=$this->input->post('rincian'); while(list($key,$value)=each($v1)) { $ca=$this->input->post("coa[$key]"); $debet =$this->input->post("debet[$key]")*1; $kredit =$this->input->post("kredit[$key]")*1; $data2=array('nama_penerima'=>$this->input->post("nama_penerima[$key]"), 'jumlah_uang'=>$this->input->post("jumlah_uang[$key]")*1, 'spj'=>$kode); $this->db->insert($this->tables2,$data2); } } redirect("transaksi/form_spj/edit/$kode/2"); } else { redirect("transaksi/form_spj/input/0/1"); } //------------------------------------------------------------------ break; case "EDIT": $this->db->where($this->pk,$id); if($this->db->update($this->tables,$data)) { //----------------INSERT DETAIL-------------------------------------- if($this->input->post('rincian')) { $v1=$this->input->post('rincian'); while(list($key,$value)=each($v1)) { $data2=array('nama_penerima'=>$this->input->post("nama_penerima[$key]"), 'jumlah_uang'=>$this->input->post("jumlah_uang[$key]")*1, 'spj'=>$id); $this->db->insert($this->tables2,$data2); } } //------------------UPDATE DETAIL------------------------------- if($this->input->post('rincian_e')) { $v2=$this->input->post('rincian_e'); while(list($key,$value)=each($v2)) { $data2=array('nama_penerima'=>$this->input->post("nama_penerima_e[$key]"), 'jumlah_uang'=>$this->input->post("jumlah_uang_e[$key]")*1); $this->db->where("id",$key); $this->db->update($this->tables2,$data2); } } //------------------HAPUS------------------------------- if($this->input->post('rincian_cb')) { $v3=$this->input->post('rincian_cb'); while(list($key,$value)=each($v3)) { $this->db->where("id",$value); $this->db->delete($this->tables2); } } redirect("transaksi/form_spj/edit/$id/4"); } else { redirect("transaksi/form_spj/edit/$id/3"); } break; } } public function form_spj() { $id= $this->uri->segment(4); $this->load->view('themes/header'); $this->load->model('TransaksiModel'); $data['r']=$this->TransaksiModel->getByID($this->pk,$id)->row_array(); $data['detail'] = $this->TransaksiModel->getDetailTransaksi(); $this->load->view($this->folder.'/form',$data); $this->load->view('themes/footer'); } public function rekap_spj() { $id= $this->uri->segment(4); $this->load->model('TransaksiModel'); $data['r']=$this->TransaksiModel->getByID($this->pk,$id)->row_array(); $data['detail'] = $this->TransaksiModel->getDetailTransaksi(); $this->load->view($this->folder.'/rekap_spj',$data); } public function uang_recehan() { $id= $this->uri->segment(4); $this->load->model('TransaksiModel'); $data['r']=$this->TransaksiModel->getByID($this->pk,$id)->row_array(); $data['detail'] = $this->TransaksiModel->getRekapUang($id); $this->load->view($this->folder.'/uang_recehan',$data); } public function hapusdata() { $id= $this->uri->segment(3); $this->db->where('id',$id); if($this->db->delete($this->tables)) { //---------Hapus dari rincian------------------ $this->db->where('spj',$id); $this->db->delete($this->tables2); redirect("transaksi/spj_hasil/6"); } else { redirect("transaksi/spj_hasil/5"); } } public function spj_hasil() { $this->load->view('themes/header'); $this->load->view($this->folder.'/pesanhapus'); $this->load->view('themes/footer'); } } ?>
- Buat Model Transaksi (application->models->TransaksiModel.php)
<?php class TransaksiModel extends CI_Model{ public $jumlah_baris; public function getByID($pk,$id) { $this->db->where($pk,$id); return $this->db->get("tbl_spj"); } public function getDetailTransaksi() { $spj=$this->uri->segment(4); $this->db->where("spj",$spj); $query=$this->db->get("tbl_spj_detail"); return $query->result(); } public function getRekapUang($spj) { $this->db->select('jumlah_uang,COUNT(id) AS jum'); $this->db->from('tbl_spj_detail'); $this->db->where("spj",$spj); $this->db->where("jumlah_uang>0"); $this->db->group_by("jumlah_uang"); $query=$this->db->get(); return $query->result(); } } ?>
- Buat View: uang_recehan.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Pelatihan</title> <style> body { font-family:Verdana, Geneva, sans-serif; font-size:12px; } h2,h3,h4 { text-decoration:underline; } td { padding:2px; } .ket { font-size:28px; } .hijau { color:#060; } .merah { color:#F00; } </style> </head> <body> <center> <h2><?php echo $r['nama_spj'];?></h2> <?php $id= $this->uri->segment(4); if(count($detail)>0) { ?> <h3>REKAP PER JUMLAH</h3> <table bgcolor="#333333" cellspacing="1"> <tr bgcolor="#e8e8e8"> <td><strong>No</strong></td> <td><strong>Nominal</strong></td> <td align="center"><strong>Jumlah</strong></td> <td><strong>Total</strong></td> <td><strong>P100K</strong></td> <td><strong>P50K</strong></td> <td><strong>P20K</strong></td> <td><strong>P10K</strong></td> <td><strong>P5K</strong></td> <td><strong>P2K</strong></td> <td><strong>P1K</strong></td> <td><strong>P500</strong></td> <td><strong>P100</strong></td> <td><strong>P50</strong></td> </tr> <?php $no=1; $tp100k=$tp50k=$tp20k=$tp10k=$tp5k=$tp2k=$tp1k=$tp500=$tp100=$tp50=$total=0; foreach($detail as $row) { $total+=$row->jumlah_uang*$row->jum; $tot=$row->jumlah_uang; $p100k=floor($tot/100000); $tp100k+=$p100k*$row->jum; $s100k=$tot%100000; $p50k=floor($s100k/50000); $tp50k+=$p50k*$row->jum; $s50k=$s100k%50000; $p20k=floor($s50k/20000); $tp20k+=$p20k*$row->jum; $s20k=$s50k%20000; $p10k=floor($s20k/10000); $tp10k+=$p10k*$row->jum; $s10k=$s20k%10000; $p5k=floor($s10k/5000); $tp5k+=$p5k*$row->jum; $s5k=$s10k%5000; $p2k=floor($s5k/2000); $tp2k+=$p2k*$row->jum; $s2k=$s5k%2000; $p1k=floor($s2k/1000); $tp1k+=$p1k*$row->jum; $s1k=$s5k%1000; $p500=floor($s1k/500); $tp500+=$p500*$row->jum; $s500=$s1k%500; $p100=floor($s500/100); $tp100+=$p100*$row->jum; $s100=$s500%100; $p50=floor($s100/50); $tp50+=$p50*$row->jum; ?> <tr bgcolor="#FFFFFF"> <td><?php echo $no++;?></td> <td align="right"><?php echo number_format($row->jumlah_uang,0,",",".");?></td> <td align="center"><?php echo $row->jum;?></td> <td align="right"><?php echo number_format($row->jumlah_uang*$row->jum,0,",",".");?></td> <td align="center"><?php echo $p100k*$row->jum;?></td> <td align="center"><?php echo $p50k*$row->jum;?></td> <td align="center"><?php echo $p20k*$row->jum;?></td> <td align="center"><?php echo $p10k*$row->jum;?></td> <td align="center"><?php echo $p5k*$row->jum;?></td> <td align="center"><?php echo $p2k*$row->jum;?></td> <td align="center"><?php echo $p1k*$row->jum;?></td> <td align="center"><?php echo $p500*$row->jum;?></td> <td align="center"><?php echo $p100*$row->jum;?></td> <td align="center"><?php echo $p50*$row->jum;?></td> </tr> <?php } ?> <tr bgcolor="#e8e8e8"> <td colspan="3"> </td> <td align="right"><strong><?php echo number_format($total,0,",",".");?></strong></td> <td align="center"><strong><?php echo $tp100k;?></strong></td> <td align="center"><strong><?php echo $tp50k;?></strong></td> <td align="center"><strong><?php echo $tp20k;?></strong></td> <td align="center"><strong><?php echo $tp10k;?></strong></td> <td align="center"><strong><?php echo $tp5k;?></strong></td> <td align="center"><strong><?php echo $tp2k;?></strong></td> <td align="center"><strong><?php echo $p1k;?></strong></td> <td align="center"><strong><?php echo $tp500;?></strong></td> <td align="center"><strong><?php echo $tp100;?></strong></td> <td align="center"><strong><?php echo $tp50;?></strong></td> </tr> </table> <h3>REKAP PECAHAN</h3> <?php $ttl=0; $nomor=1; ?> <table bgcolor="#333333" cellspacing="1"> <tr bgcolor="#e8e8e8"> <td><strong>No</strong></td> <td><strong>Pecahan</strong></td> <td align="center"><strong>Dalam Angka</strong></td> <td align="center"><strong>Jumlah</strong></td> <td><strong>Total</strong></td> </tr> <?php if($tp100k>0) { ?> <tr bgcolor="#ffffff"> <td><?php echo $nomor++;?></td> <td>Seratus Ribu</td> <td align="center">100K</td> <td align="center"><?php echo $tp100k;?></td> <td align="right"> <?php $ttl+=$tp100k*100000; echo number_format($tp100k*100000,0,",","."); ?> </td> </tr> <?php } if($tp50k>0) { ?> <tr bgcolor="#ffffff"> <td><?php echo $nomor++;?></td> <td>Limapuluh Ribu</td> <td align="center">50K</td> <td align="center"><?php echo $tp50k;?></td> <td align="right"><?php $ttl+=$tp50k*50000; echo number_format($tp50k*50000,0,",","."); ?></td> </tr> <?php } if($tp20k>0) { ?> <tr bgcolor="#ffffff"> <td><?php echo $nomor++;?></td> <td>Dua Puluh Ribu</td> <td align="center">20K</td> <td align="center"><?php echo $tp20k;?></td> <td align="right"><?php $ttl+=$tp20k*20000; echo number_format($tp20k*20000,0,",","."); ?></td> </tr> <?php } if($tp10k>0) { ?> <tr bgcolor="#ffffff"> <td><?php echo $nomor++;?></td> <td>Sepuluh Ribu</td> <td align="center">10K</td> <td align="center"><?php echo $tp10k;?></td> <td align="right"><?php $ttl+=$tp10k*10000; echo number_format($tp10k*10000,0,",","."); ?></td> </tr> <?php } if($tp5k>0) { ?> <tr bgcolor="#ffffff"> <td><?php echo $nomor++;?></td> <td>Lima Ribu</td> <td align="center">5K</td> <td align="center"><?php echo $tp5k;?></td> <td align="right"><?php $ttl+=$tp5k*5000; echo number_format($tp5k*5000,0,",","."); ?></td> </tr> <?php } if($tp2k>0) { ?> <tr bgcolor="#ffffff"> <td><?php echo $nomor++;?></td> <td>Dua Ribu</td> <td align="center">2K</td> <td align="center"><?php echo $tp2k;?></td> <td align="right"><?php $ttl+=$tp2k*2000; echo number_format($tp2k*2000,0,",","."); ?></td> </tr> <?php } if($tp1k>0) { ?> <tr bgcolor="#ffffff"> <td><?php echo $nomor++;?></td> <td>Seribu</td> <td align="center">1K</td> <td align="center"><?php echo $p1k;?></td> <td align="right"><?php $ttl+=$tp1k*1000; echo number_format($tp1k*1000,0,",","."); ?></td> </tr> <?php } if($tp500>0) { ?> <tr bgcolor="#ffffff"> <td><?php echo $nomor++;?></td> <td>Lima Ratus</td> <td align="center">500</td> <td align="center"><?php echo $tp500;?></td> <td align="right"><?php $ttl+=$tp500*500; echo number_format($tp500*500,0,",","."); ?></td> </tr> <?php } if($tp100>0) { ?> <tr bgcolor="#ffffff"> <td><?php echo $nomor++;?></td> <td>Seratus</td> <td align="center">100</td> <td align="center"><?php echo $tp100;?></td> <td align="right"><?php $ttl+=$tp100*100; echo number_format($tp100*100,0,",","."); ?></td> </tr> <?php } if($tp50>0) { ?> <tr bgcolor="#ffffff"> <td><?php echo $nomor++;?></td> <td>Lima Puluh</td> <td align="center">50</td> <td align="center"><?php echo $tp50;?></td> <td align="right"><?php $ttl+=$tp50*50; echo number_format($tp50*50,0,",","."); ?></td> </tr> <?php } ?> <tr bgcolor="#ffffff"> <td colspan="4"><strong>TOTAL</strong></td> <td align="right"><strong> <?php echo number_format($ttl,0,",","."); ?> </strong></td> </tr> </table> <hr /> <?php $ket="Stesso (Sama)"; $cls="hijau"; if($total!=$ttl) { $ket="Diverso"; $cls="merah"; } ?> <h4>Total Rekap 1: <?php echo number_format($total,0,",","."); ?></h4> <h4>Total Rekap 2: <?php echo number_format($ttl,0,",","."); ?></h4> <div class="ket"> Hasil: <span class="<?php echo $cls;?>"><?php echo $ket;?></span></div> <?php } ?> </center> </body> </html>
Adapun contoh tampilan dari aplikasi cara menghitung uang pecahan dengan CodeIgniter adalah sebagai berikut:
Daftar SPJ
Input SPJ
Cetak Daftar SPJ
Cetak Rincian Uang Pecahan
Ok, demikian tutorial kali ini semoga bermanfaat dan bisa diterapkan.
Download Cara menghitung Uang Pecahan/Recehan
Share via Facebook / Twitter / Google + untuk Download
Komentar tentang Cara Menghitung Uang Pecahan/Recehan dari SPJ