Kalau kemaren masih sampai pada pembuatan tabel, sekarang ane lanjut kepada pembuatan view / query. Check langsung di bawah :
create view hist_hutang as select `p`.`kode_dist` AS `kode_dist`,
`c`.`nama_dist` AS `nama_dist`,`p`.`tgl_hutang` AS `tgl`,`p`.`ket` AS `ket`,
'' AS `barang`,0 AS `awal`,`p`.`jml_hutang` AS `masuk`,0 AS `keluar`,
`p`.`user_id` AS `user_id`,`p`.`kode_unit` AS `kode_unit` from
(`tmhutang` `p` join `tmdistributor` `c`) where
(`p`.`kode_dist` = `c`.`kode_dist`) union all select
`tj`.`kode_dist` AS `kode_dist`,`c`.`nama_dist` AS `nama_dist`,
`tj`.`tgl_beli` AS `tgl`,'PEMBELIAN BARANG' AS `ket`,
`b`.`nama_brg` AS `barang`,0 AS `awal`,((((`trj`.`harga_beli` -
((`trj`.`disk_beli` * `trj`.`harga_beli`) / 100)) - (((`trj`.`harga_beli`
- ((`trj`.`disk_beli` * `trj`.`harga_beli`) / 100)) * `tj`.`disk_fak`)
/ 100)) + ((((`trj`.`harga_beli` - ((`trj`.`disk_beli` *
`trj`.`harga_beli`) / 100)) - (((`trj`.`harga_beli` -
((`trj`.`disk_beli` * `trj`.`harga_beli`) / 100)) *
`tj`.`disk_fak`) / 100)) * `tj`.`ppn`) / 100)) * `trj`.`jml_beli`)
AS `masuk`,0 AS `keluar`,`tj`.`user_id` AS `user_id`,`tj`.`kode_unit`
AS `kode_unit` from (((`ttbeli` `tj` join `ttrbeli` `trj`) join
`tmdistributor` `c`) join `tmbarang` `b`) where ((`tj`.`nofak_beli`
= `trj`.`nofak_beli`) and (`tj`.`kode_dist` = `c`.`kode_dist`) and
(`trj`.`kode_brg` = `b`.`kode_brg`) and (`tj`.`cash` = '0')) union
all select `nb`.`kode_dist` AS `kode_dist`,`c`.`nama_dist` AS `nama_dist`,
`nb`.`tgl_nota` AS `tgl_nota`,`d`.`nama_dist` AS `ket`,`nb`.`ket` AS `ket`,
0 AS `awal`,`nb`.`harga_modal` AS `harga_modal`,0 AS `keluar`,`nb`.`user_id`
AS `user_id`,`nb`.`kode_unit` AS `kode_unit` from ((`t_nota_bon` `nb` join
`tmdistributor` `c`) join `tmdistributor` `d`) where ((`nb`.`kode_dist` =
`c`.`kode_dist`) and (`nb`.`kode_dist` = `d`.`kode_dist`)) union all select
`bp`.`kode_dist` AS `kode_dist`,`c`.`nama_dist` AS `nama_dist`,
`bp`.`tgl_bayar` AS `tgl_bayar`,'BAYAR LANGSUNG' AS `ket`,'' AS
`barang`,0 AS `awal`,0 AS `masuk`,`bp`.`jml_bayar` AS `keluar`,
`bp`.`user_id` AS `user_id`,`bp`.`kode_unit` AS `kode_unit`
from (`ttbayar_hutang` `bp` join `tmdistributor` `c`) where
(`bp`.`kode_dist` = `c`.`kode_dist`)
create view hist_piutang as select `p`.`kode_cust` AS `kode_cust`,
`c`.`nama_cust` AS `nama_cust`,`p`.`tgl_piutang` AS `tgl`,`p`.`ket`
AS `ket`,'' AS `barang`,0 AS `awal`,`p`.`jml_piutang` AS `masuk`,0 AS
`keluar`,`p`.`user_id` AS `user_id`,`p`.`kode_unit` AS `kode_unit`
from (`tmpiutang` `p` join `tmcustomer` `c`) where (`p`.`kode_cust` =
`c`.`kode_cust`) union all select `tj`.`kode_cust` AS `kode_cust`,
`c`.`nama_cust` AS `nama_cust`,`tj`.`tgl_jual` AS `tgl`,'PENJUALAN BARANG'
AS `ket`,`b`.`nama_brg` AS `barang`,0 AS `awal`,((((`trj`.`harga_jual` -
((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual`
- ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) /
100)) + ((((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`)
/ 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`)
/ 100)) * `tj`.`disk_fak`) / 100)) * `tj`.`ppn`) / 100)) * `trj`.`jml_jual`)
AS `masuk`,0 AS `keluar`,`tj`.`user_id` AS `user_id`,`tj`.`kode_unit` AS
`kode_unit` from (((`ttjual` `tj` join `ttrjual` `trj`) join `tmcustomer`
`c`) join `tmbarang` `b`) where ((`tj`.`nofak_jual` = `trj`.`nofak_jual`)
and (`tj`.`kode_cust` = `c`.`kode_cust`) and (`trj`.`kode_brg` =
`b`.`kode_brg`) and (`tj`.`cash` = '0')) union all select `pj`.`kode_cust`
AS `kode_cust`,`c`.`nama_cust` AS `nama_cust`,`pj`.`tgl_jual` AS `tgl_jual`,
'PENJUALAN PULSA' AS `ket`,`ph`.`ket_pulsa` AS `ket_pulsa`,0 AS `awal`,
`pj`.`harga_jual` AS `harga_jual`,0 AS `keluar`,`pj`.`user_id` AS `user_id`,
`pj`.`kode_unit` AS `kode_unit` from ((`t_pulsa_jual` `pj` join
`t_pulsa_harga` `ph`) join `tmcustomer` `c`) where ((`pj`.`kode_pulsa`
= `ph`.`kode_pulsa`) and (`pj`.`kode_cust` = `c`.`kode_cust`) and
(`pj`.`cash` = '0')) union all select `nb`.`kode_cust` AS `kode_cust`,
`c`.`nama_cust` AS `nama_cust`,`nb`.`tgl_nota` AS `tgl_nota`,'NOTA BON'
AS `ket`,`nb`.`ket` AS `ket`,0 AS `awal`,`nb`.`harga_jual` AS `harga_jual`,
0 AS `keluar`,`nb`.`user_id` AS `user_id`,`nb`.`kode_unit` AS `kode_unit`
from (`t_nota_bon` `nb` join `tmcustomer` `c`) where (`nb`.`kode_cust` =
`c`.`kode_cust`) union all select `bp`.`kode_cust` AS `kode_cust`,
`c`.`nama_cust` AS `nama_cust`,`bp`.`tgl` AS `tgl`,'BAYAR LANGSUNG' AS
`ket`,'' AS `barang`,0 AS `awal`,0 AS `masuk`,`bp`.`jml` AS `keluar`,
`bp`.`user_id` AS `user_id`,`bp`.`kode_unit` AS `kode_unit` from
(`tt_bayar_piutang_unit` `bp` join `tmcustomer` `c`) where (`bp`.`kode_cust`
= `c`.`kode_cust`) union all select `tp`.`kode_cust` AS `kode_cust`,
`c`.`nama_cust` AS `nama_cust`,`tp`.`tgl` AS `tgl`,'PEMOTONGAN PIUTANG'
AS `ket`,'' AS `barang`,0 AS `awal`,0 AS `masuk`,`tp`.`jml_bayar` AS
`keluar`,`tp`.`user_id` AS `user_id`,`tp`.`kode_unit` AS `kode_unit`
from (`tt_pemotongan_unit` `tp` join `tmcustomer` `c`) where
(`tp`.`kode_cust` = `c`.`kode_cust`)
create view v_faktur_beli as
select `ttbeli`.`nofak_beli` AS `nofak_beli`,`ttbeli`.`tgl_beli` AS `tgl_beli`,`ttbeli`.`kode_dist` AS `kode_dist`,`tmdistributor`.`nama_dist` AS `nama_dist`,`ttrbeli`.`kode_brg` AS `kode_brg`,`tmbarang`.`nama_brg` AS `nama_brg`,`tmbarang`.`satuan` AS `satuan`,`ttrbeli`.`jml_beli` AS `jml_beli`,`ttrbeli`.`harga_beli` AS `harga_beli`,`ttrbeli`.`disk_beli` AS `disk_beli`,((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100) AS `nom_disk_beli`,(`ttrbeli`.`harga_beli` - ((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100)) AS `harga_disk_beli`,`ttbeli`.`disk_fak` AS `disk_fak`,(((`ttrbeli`.`harga_beli` - ((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100)) * `ttbeli`.`disk_fak`) / 100) AS `nom_disk_fak`,((`ttrbeli`.`harga_beli` - ((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100)) - (((`ttrbeli`.`harga_beli` - ((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100)) * `ttbeli`.`disk_fak`) / 100)) AS `harga_disk_fak`,`ttbeli`.`ppn` AS `ppn`,((((`ttrbeli`.`harga_beli` - ((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100)) - (((`ttrbeli`.`harga_beli` - ((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100)) * `ttbeli`.`disk_fak`) / 100)) * `ttbeli`.`ppn`) / 100) AS `nom_ppn`,(((`ttrbeli`.`harga_beli` - ((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100)) - (((`ttrbeli`.`harga_beli` - ((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100)) * `ttbeli`.`disk_fak`) / 100)) + ((((`ttrbeli`.`harga_beli` - ((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100)) - (((`ttrbeli`.`harga_beli` - ((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100)) * `ttbeli`.`disk_fak`) / 100)) * `ttbeli`.`ppn`) / 100)) AS `harga_ppn`,((((`ttrbeli`.`harga_beli` - ((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100)) - (((`ttrbeli`.`harga_beli` - ((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100)) * `ttbeli`.`disk_fak`) / 100)) + ((((`ttrbeli`.`harga_beli` - ((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100)) - (((`ttrbeli`.`harga_beli` - ((`ttrbeli`.`disk_beli` * `ttrbeli`.`harga_beli`) / 100)) * `ttbeli`.`disk_fak`) / 100)) * `ttbeli`.`ppn`) / 100)) * `ttrbeli`.`jml_beli`) AS `total_beli`,`ttbeli`.`cash` AS `cash`,`ttbeli`.`batal` AS `batal`,`ttbeli`.`tutup` AS `tutup`,`ttbeli`.`user_id` AS `user_id`,`ttrbeli`.`id_stock` AS `id_stock`,`ttbeli`.`kode_unit` AS `kode_unit`,`ttbeli`.`kons` AS `kons`,`ttbeli`.`tempo` AS `tempo`,'ttbeli' AS `tabel` from (((`ttbeli` join `tmdistributor`) join `ttrbeli`) join `tmbarang`) where ((`ttbeli`.`nofak_beli` = `ttrbeli`.`nofak_beli`) and (`ttbeli`.`kode_dist` = `tmdistributor`.`kode_dist`) and (`ttrbeli`.`kode_brg` = `tmbarang`.`kode_brg`))
create view v_faktur_jual as
select `tj`.`nofak_jual` AS `nofak_jual`,`tj`.`tgl_jual` AS `tgl_jual`,`tj`.`kode_cust` AS `kode_cust`,`tmcustomer`.`nama_cust` AS `nama_cust`,`trj`.`kode_brg` AS `kode_brg`,`tmbarang`.`nama_brg` AS `nama_brg`,`tmbarang`.`satuan` AS `satuan`,`trj`.`jml_jual` AS `jml_jual`,`trj`.`harga_jual` AS `harga_jual`,`trj`.`disk_jual` AS `disk_jual`,((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100) AS `nom_disk_jual`,(`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) AS `harga_disk_jual`,`tj`.`disk_fak` AS `disk_fak`,(((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100) AS `nom_disk_fak`,((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100)) AS `harga_disk_fak`,`tj`.`ppn` AS `ppn`,((((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100)) * `tj`.`ppn`) / 100) AS `nom_ppn`,(((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100)) + ((((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100)) * `tj`.`ppn`) / 100)) AS `harga_ppn`,((((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100)) + ((((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100)) * `tj`.`ppn`) / 100)) * `trj`.`jml_jual`) AS `total_jual`,`tj`.`cash` AS `cash`,`tj`.`batal` AS `batal`,`tj`.`tutup` AS `tutup`,`tj`.`user_id` AS `user_id`,`trj`.`id_stock` AS `id_stock`,`tj`.`kode_unit` AS `kode_unit`,'0' AS `kons`,`tj`.`tempo` AS `tempo`,'tt_jual' AS `tabel` from (((`ttjual` `tj` join `tmcustomer`) join `ttrjual` `trj`) join `tmbarang`) where ((`tj`.`nofak_jual` = `trj`.`nofak_jual`) and (`tj`.`kode_cust` = `tmcustomer`.`kode_cust`) and (`trj`.`kode_brg` = `tmbarang`.`kode_brg`)) union all select `tj`.`nofak_jual` AS `nofak_jual`,`tj`.`tgl_jual` AS `tgl_jual`,`tj`.`kode_cust` AS `kode_cust`,`tmcustomer`.`nama_cust` AS `nama_cust`,`trj`.`kode_brg` AS `kode_brg`,`tmbarang`.`nama_brg` AS `nama_brg`,`tmbarang`.`satuan` AS `satuan`,`trj`.`jml_jual` AS `jml_jual`,`trj`.`harga_jual` AS `harga_jual`,`trj`.`disk_jual` AS `disk_jual`,((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100) AS `nom_disk_jual`,(`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) AS `harga_disk_jual`,`tj`.`disk_fak` AS `disk_fak`,(((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100) AS `nom_disk_fak`,((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100)) AS `harga_disk_fak`,`tj`.`ppn` AS `ppn`,((((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100)) * `tj`.`ppn`) / 100) AS `nom_ppn`,(((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100)) + ((((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100)) * `tj`.`ppn`) / 100)) AS `harga_ppn`,((((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100)) + ((((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100)) * `tj`.`ppn`) / 100)) * `trj`.`jml_jual`) AS `total_jual`,`tj`.`cash` AS `cash`,`tj`.`batal` AS `batal`,`tj`.`tutup` AS `tutup`,`tj`.`user_id` AS `user_id`,`trj`.`no_titip` AS `id_stock`,`tj`.`kode_unit` AS `kode_unit`,'1' AS `kons`,`tj`.`tempo` AS `tempo`,'tt_jual' AS `tabel` from (((`ttjual` `tj` join `tmcustomer`) join `ttrjual_kons` `trj`) join `tmbarang`) where ((`tj`.`nofak_jual` = `trj`.`nofak_jual`) and (`tj`.`kode_cust` = `tmcustomer`.`kode_cust`) and (`trj`.`kode_brg` = `tmbarang`.`kode_brg`))
create view v_hpp as
select `vj`.`nofak_jual` AS `nofak_jual`,`vj`.`tgl_jual` AS `tgl_jual`,`vj`.`kode_brg` AS `kode_brg`,`vj`.`nama_brg` AS `nama_brg`,`vj`.`jml_jual` AS `jml_jual`,`vj`.`harga_ppn` AS `harga_jual`,`vj`.`total_jual` AS `total_jual`,`vb`.`harga_ppn` AS `harga_modal`,(`vb`.`harga_ppn` * `vj`.`jml_jual`) AS `hpp_terjual`,(`vj`.`total_jual` - (`vb`.`harga_ppn` * `vj`.`jml_jual`)) AS `tot_untung`,`vj`.`kode_unit` AS `kode_unit` from (`v_faktur_jual` `vj` join `v_faktur_beli` `vb`) where ((`vj`.`id_stock` = `vb`.`id_stock`) and (`vj`.`id_stock` <> 'PULSA')) union all select `vj`.`nofak_jual` AS `nofak_jual`,`vj`.`tgl_jual` AS `tgl_jual`,`vj`.`kode_brg` AS `kode_brg`,`vj`.`nama_brg` AS `nama_brg`,`vj`.`jml_jual` AS `jml_jual`,`vj`.`harga_ppn` AS `harga_jual`,`vj`.`total_jual` AS `total_jual`,`m`.`harga_modal` AS `harga_modal`,(`vj`.`jml_jual` * `m`.`harga_modal`) AS `hpp_terjual`,(`vj`.`total_jual` - (`m`.`harga_modal` * `vj`.`jml_jual`)) AS `tot_untung`,`vj`.`kode_unit` AS `kode_unit` from (`v_faktur_jual` `vj` join `tmmodal` `m`) where ((`vj`.`id_stock` = `m`.`id_stock`) and (`vj`.`id_stock` <> 'PULSA')) union all select `vj`.`nofak_jual` AS `nofak_jual`,`vj`.`tgl_jual` AS `tgl_jual`,`vj`.`kode_brg` AS `kode_brg`,`vj`.`nama_brg` AS `nama_brg`,`vj`.`jml_jual` AS `jml_jual`,`vj`.`harga_ppn` AS `harga_jual`,`vj`.`total_jual` AS `total_jual`,`ph`.`harga_modal` AS `harga_modal`,`ph`.`harga_modal` AS `hpp_terjual`,(`vj`.`harga_ppn` - `ph`.`harga_modal`) AS `tot_untung`,`vj`.`kode_unit` AS `kode_unit` from (`v_faktur_jual` `vj` join `t_pulsa_harga` `ph`) where ((`vj`.`kode_brg` = `ph`.`kode_pulsa`) and (`vj`.`id_stock` = 'PULSA'))
create view v_hutang as
select `h`.`id_hutang` AS `id_hutang`,`h`.`ket` AS `ket`,`h`.`tgl_hutang` AS `tgl_hutang`,`h`.`kode_dist` AS `kode_dist`,`d`.`nama_dist` AS `nama_dist`,`h`.`jml_hutang` AS `jml_hutang`,0 AS `jml_bayar`,`h`.`jml_hutang` AS `sisa_hutang`,`h`.`user_id` AS `user_id`,`h`.`kode_unit` AS `kode_unit`,'tmhutang' AS `tabel`,`h`.`tgl_tempo` AS `tempo` from (`tmhutang` `h` join `tmdistributor` `d`) where (`h`.`kode_dist` = `d`.`kode_dist`) union all select `tb`.`nofak_beli` AS `nofak_beli`,`trb`.`kode_brg` AS `kode_brg`,`tb`.`tgl_beli` AS `tgl_beli`,`tb`.`kode_dist` AS `kode_dist`,`d`.`nama_dist` AS `nama_dist`,((((`trb`.`harga_beli` - ((`trb`.`disk_beli` * `trb`.`harga_beli`) / 100)) - (((`trb`.`harga_beli` - ((`trb`.`disk_beli` * `trb`.`harga_beli`) / 100)) * `tb`.`disk_fak`) / 100)) + ((((`trb`.`harga_beli` - ((`trb`.`disk_beli` * `trb`.`harga_beli`) / 100)) - (((`trb`.`harga_beli` - ((`trb`.`disk_beli` * `trb`.`harga_beli`) / 100)) * `tb`.`disk_fak`) / 100)) * `tb`.`ppn`) / 100)) * `trb`.`jml_beli`) AS `jml_hutang`,0 AS `jml_bayar`,((((`trb`.`harga_beli` - ((`trb`.`disk_beli` * `trb`.`harga_beli`) / 100)) - (((`trb`.`harga_beli` - ((`trb`.`disk_beli` * `trb`.`harga_beli`) / 100)) * `tb`.`disk_fak`) / 100)) + ((((`trb`.`harga_beli` - ((`trb`.`disk_beli` * `trb`.`harga_beli`) / 100)) - (((`trb`.`harga_beli` - ((`trb`.`disk_beli` * `trb`.`harga_beli`) / 100)) * `tb`.`disk_fak`) / 100)) * `tb`.`ppn`) / 100)) * `trb`.`jml_beli`) AS `sisa_hutang`,`tb`.`user_id` AS `user_id`,`tb`.`kode_unit` AS `kode_unit`,'PEMBELIAN BARANG' AS `tabel`,`tb`.`tempo` AS `tempo` from ((`ttbeli` `tb` join `ttrbeli` `trb`) join `tmdistributor` `d`) where ((`tb`.`nofak_beli` = `trb`.`nofak_beli`) and (`tb`.`kode_dist` = `d`.`kode_dist`) and (`tb`.`cash` = '0')) union all select `nb`.`no_nota` AS `no_nota`,`nb`.`ket` AS `ket`,`nb`.`tgl_nota` AS `tgl_nota`,`nb`.`kode_dist` AS `kode_dist`,`d`.`nama_dist` AS `nama_dist`,`nb`.`harga_modal` AS `harga_modal`,0 AS `jml_bayar`,`nb`.`harga_modal` AS `sisa_hutang`,`nb`.`user_id` AS `user_id`,`nb`.`kode_unit` AS `kode_unit`,'nota bon' AS `tabel`,`nb`.`tempo_hutang` AS `tempo_hutang` from (`t_nota_bon` `nb` join `tmdistributor` `d`) where (`nb`.`kode_dist` = `d`.`kode_dist`) union all select `bh`.`id_hutang` AS `id_hutang`,`bh`.`nofak_bayar` AS `ket`,`bh`.`tgl_bayar` AS `tgl_hutang`,`bh`.`kode_dist` AS `kode_dist`,`d`.`nama_dist` AS `nama_dist`,0 AS `jml_hutang`,`bh`.`jml_bayar` AS `jml_bayar`,-(`bh`.`jml_bayar`) AS `sisa_hutang`,`bh`.`user_id` AS `user_id`,`bh`.`kode_unit` AS `kode_unit`,'ttbayar_hutang' AS `tabel`,'0000-00-00' AS `tempo` from (`ttbayar_hutang` `bh` join `tmdistributor` `d`) where (`bh`.`kode_dist` = `d`.`kode_dist`)
create view v_kas as
select `km`.`no_kas` AS `no_trans`,`km`.`tgl` AS `tgl`,`km`.`perkiraan` AS `ket`,`km`.`ket` AS `ket2`,`km`.`jml` AS `kas_masuk`,0 AS `kas_keluar`,`km`.`jml` AS `kas_akhir`,`km`.`user_id` AS `user_id`,`km`.`kode_unit` AS `kode_unit`,'tt_modal' AS `tabel` from `db_esa_vita`.`tt_modal` `km` union all select `tp`.`no_doc` AS `no_doc`,`tp`.`tgl` AS `tgl`,'PEMOTONGAN PIUTANG' AS `ket`,`c`.`nama_cust` AS `ket2`,`tp`.`jml_bayar` AS `jml_bayar`,0 AS `keluar`,`tp`.`jml_bayar` AS `sisa`,`tp`.`user_id` AS `user_id`,`tp`.`kode_unit` AS `kode_unit`,'tt_pemotongan_unit' AS `tabel` from (`db_esa_vita`.`tt_pemotongan_unit` `tp` join `db_esa_vita`.`tmcustomer` `c`) where (`tp`.`kode_cust` = `c`.`kode_cust`) union all select `db_esa_vita`.`ttjual`.`nofak_jual` AS `nofak_jual`,`db_esa_vita`.`ttjual`.`tgl_jual` AS `tgl_jual`,`db_esa_vita`.`tmbarang`.`nama_brg` AS `ket`,`db_esa_vita`.`tmcustomer`.`nama_cust` AS `ket2`,((((`db_esa_vita`.`ttrjual`.`harga_jual` - ((`db_esa_vita`.`ttrjual`.`disk_jual` * `db_esa_vita`.`ttrjual`.`harga_jual`) / 100)) - (((`db_esa_vita`.`ttrjual`.`harga_jual` - ((`db_esa_vita`.`ttrjual`.`disk_jual` * `db_esa_vita`.`ttrjual`.`harga_jual`) / 100)) * `db_esa_vita`.`ttjual`.`disk_fak`) / 100)) + ((((`db_esa_vita`.`ttrjual`.`harga_jual` - ((`db_esa_vita`.`ttrjual`.`disk_jual` * `db_esa_vita`.`ttrjual`.`harga_jual`) / 100)) - (((`db_esa_vita`.`ttrjual`.`harga_jual` - ((`db_esa_vita`.`ttrjual`.`disk_jual` * `db_esa_vita`.`ttrjual`.`harga_jual`) / 100)) * `db_esa_vita`.`ttjual`.`disk_fak`) / 100)) * `db_esa_vita`.`ttjual`.`ppn`) / 100)) * `db_esa_vita`.`ttrjual`.`jml_jual`) AS `kas_masuk`,0 AS `kas_keluar`,((((`db_esa_vita`.`ttrjual`.`harga_jual` - ((`db_esa_vita`.`ttrjual`.`disk_jual` * `db_esa_vita`.`ttrjual`.`harga_jual`) / 100)) - (((`db_esa_vita`.`ttrjual`.`harga_jual` - ((`db_esa_vita`.`ttrjual`.`disk_jual` * `db_esa_vita`.`ttrjual`.`harga_jual`) / 100)) * `db_esa_vita`.`ttjual`.`disk_fak`) / 100)) + ((((`db_esa_vita`.`ttrjual`.`harga_jual` - ((`db_esa_vita`.`ttrjual`.`disk_jual` * `db_esa_vita`.`ttrjual`.`harga_jual`) / 100)) - (((`db_esa_vita`.`ttrjual`.`harga_jual` - ((`db_esa_vita`.`ttrjual`.`disk_jual` * `db_esa_vita`.`ttrjual`.`harga_jual`) / 100)) * `db_esa_vita`.`ttjual`.`disk_fak`) / 100)) * `db_esa_vita`.`ttjual`.`ppn`) / 100)) * `db_esa_vita`.`ttrjual`.`jml_jual`) AS `kas_akhir`,`db_esa_vita`.`ttjual`.`user_id` AS `user_id`,`db_esa_vita`.`ttjual`.`kode_unit` AS `kode_unit`,'tt_jual' AS `tabel` from (((`db_esa_vita`.`ttjual` join `db_esa_vita`.`tmcustomer`) join `db_esa_vita`.`ttrjual`) join `db_esa_vita`.`tmbarang`) where ((`db_esa_vita`.`ttjual`.`nofak_jual` = `db_esa_vita`.`ttrjual`.`nofak_jual`) and (`db_esa_vita`.`ttjual`.`kode_cust` = `db_esa_vita`.`tmcustomer`.`kode_cust`) and (`db_esa_vita`.`ttrjual`.`kode_brg` = `db_esa_vita`.`tmbarang`.`kode_brg`) and (`db_esa_vita`.`ttjual`.`cash` = '1')) union all select `pj`.`no_jual` AS `no_trans`,`pj`.`tgl_jual` AS `tgl`,`ph`.`ket_pulsa` AS `ket`,`c`.`nama_cust` AS `ket2`,`pj`.`harga_jual` AS `kas_masuk`,0 AS `kas_keluar`,`pj`.`harga_jual` AS `kas_akhir`,`pj`.`user_id` AS `user_id`,`pj`.`kode_unit` AS `kode_unit`,'t_pulsa_jual' AS `tabel` from ((`db_esa_vita`.`t_pulsa_jual` `pj` join `db_esa_vita`.`t_pulsa_harga` `ph`) join `db_esa_vita`.`tmcustomer` `c`) where ((`pj`.`kode_pulsa` = `ph`.`kode_pulsa`) and (`pj`.`kode_cust` = `c`.`kode_cust`) and (`pj`.`cash` = '1')) union all select `bp`.`no_kas` AS `no_kas`,`bp`.`tgl` AS `tgl`,'BAYAR LANGSUNG' AS `ket`,`c`.`nama_cust` AS `ket2`,`bp`.`jml` AS `kas_masuk`,0 AS `kas_keluar`,`bp`.`jml` AS `kas_akhir`,`bp`.`user_id` AS `user_id`,`bp`.`kode_unit` AS `kode_unit`,'ttbayar_piutang' AS `tabel` from (`db_esa_vita`.`tt_bayar_piutang_unit` `bp` join `db_esa_vita`.`tmcustomer` `c`) where (`bp`.`kode_cust` = `c`.`kode_cust`) union all select `db_esa_vita`.`ttbeli`.`nofak_beli` AS `no_trans`,`db_esa_vita`.`ttbeli`.`tgl_beli` AS `tgl`,`db_esa_vita`.`tmbarang`.`nama_brg` AS `ket`,`db_esa_vita`.`tmdistributor`.`nama_dist` AS `ket2`,0 AS `kas_masuk`,((((`db_esa_vita`.`ttrbeli`.`harga_beli` - ((`db_esa_vita`.`ttrbeli`.`disk_beli` * `db_esa_vita`.`ttrbeli`.`harga_beli`) / 100)) - (((`db_esa_vita`.`ttrbeli`.`harga_beli` - ((`db_esa_vita`.`ttrbeli`.`disk_beli` * `db_esa_vita`.`ttrbeli`.`harga_beli`) / 100)) * `db_esa_vita`.`ttbeli`.`disk_fak`) / 100)) + ((((`db_esa_vita`.`ttrbeli`.`harga_beli` - ((`db_esa_vita`.`ttrbeli`.`disk_beli` * `db_esa_vita`.`ttrbeli`.`harga_beli`) / 100)) - (((`db_esa_vita`.`ttrbeli`.`harga_beli` - ((`db_esa_vita`.`ttrbeli`.`disk_beli` * `db_esa_vita`.`ttrbeli`.`harga_beli`) / 100)) * `db_esa_vita`.`ttbeli`.`disk_fak`) / 100)) * `db_esa_vita`.`ttbeli`.`ppn`) / 100)) * `db_esa_vita`.`ttrbeli`.`jml_beli`) AS `kas_keluar`,-(((((`db_esa_vita`.`ttrbeli`.`harga_beli` - ((`db_esa_vita`.`ttrbeli`.`disk_beli` * `db_esa_vita`.`ttrbeli`.`harga_beli`) / 100)) - (((`db_esa_vita`.`ttrbeli`.`harga_beli` - ((`db_esa_vita`.`ttrbeli`.`disk_beli` * `db_esa_vita`.`ttrbeli`.`harga_beli`) / 100)) * `db_esa_vita`.`ttbeli`.`disk_fak`) / 100)) + ((((`db_esa_vita`.`ttrbeli`.`harga_beli` - ((`db_esa_vita`.`ttrbeli`.`disk_beli` * `db_esa_vita`.`ttrbeli`.`harga_beli`) / 100)) - (((`db_esa_vita`.`ttrbeli`.`harga_beli` - ((`db_esa_vita`.`ttrbeli`.`disk_beli` * `db_esa_vita`.`ttrbeli`.`harga_beli`) / 100)) * `db_esa_vita`.`ttbeli`.`disk_fak`) / 100)) * `db_esa_vita`.`ttbeli`.`ppn`) / 100)) * `db_esa_vita`.`ttrbeli`.`jml_beli`)) AS `kas_akhir`,`db_esa_vita`.`ttbeli`.`user_id` AS `user_id`,`db_esa_vita`.`ttbeli`.`kode_unit` AS `kode_unit`,'ttbeli' AS `tabel` from (((`db_esa_vita`.`ttbeli` join `db_esa_vita`.`tmdistributor`) join `db_esa_vita`.`ttrbeli`) join `db_esa_vita`.`tmbarang`) where ((`db_esa_vita`.`ttbeli`.`nofak_beli` = `db_esa_vita`.`ttrbeli`.`nofak_beli`) and (`db_esa_vita`.`ttbeli`.`kode_dist` = `db_esa_vita`.`tmdistributor`.`kode_dist`) and (`db_esa_vita`.`ttrbeli`.`kode_brg` = `db_esa_vita`.`tmbarang`.`kode_brg`) and (`db_esa_vita`.`ttbeli`.`cash` = '1')) union all select `pd`.`no_depo` AS `no_trans`,`pd`.`tgl_depo` AS `tgl_depo`,'Deposit Pulsa' AS `ket`,`d`.`nama_dist` AS `ket2`,0 AS `kas_masuk`,`pd`.`jml_depo` AS `kas_keluar`,-(`pd`.`jml_depo`) AS `kas_akhir`,`pd`.`user_id` AS `user_id`,`pd`.`kode_unit` AS `kode_unit`,'t_pulsa_deposit' AS `tabel` from (`db_esa_vita`.`t_pulsa_deposit` `pd` join `db_esa_vita`.`tmdistributor` `d`) where (`pd`.`kode_dist` = `d`.`kode_dist`) union all select `bh`.`nofak_bayar` AS `nofak_bayar`,`bh`.`tgl_bayar` AS `tgl_bayar`,`bh`.`id_hutang` AS `ket`,`d`.`nama_dist` AS `ket2`,0 AS `kas_masuk`,`bh`.`jml_bayar` AS `kas_keluar`,-(`bh`.`jml_bayar`) AS `kas_akhir`,`bh`.`user_id` AS `user_id`,`bh`.`kode_unit` AS `kode_unit`,'ttbayar_hutang' AS `tabel` from (`db_esa_vita`.`ttbayar_hutang` `bh` join `db_esa_vita`.`tmdistributor` `d`) where (`bh`.`kode_dist` = `d`.`kode_dist`) union all select `tp`.`no_kas` AS `no_kas`,`tp`.`tgl` AS `tgl`,`tp`.`perkiraan` AS `Perkiraan`,`tp`.`ket` AS `ket`,0 AS `masuk`,`tp`.`jml` AS `keluar`,-(`tp`.`jml`) AS `sisa`,`tp`.`user_id` AS `user_id`,`tp`.`kode_unit` AS `kode_unit`,'tt_operasional' AS `tabel` from `db_esa_vita`.`tt_operasional` `tp`
create view v_piutang_unit as
select `p`.`kode_cust` AS `kode_cust`,`p`.`tgl_piutang` AS `tgl`,`p`.`jml_piutang` AS `jml`,0 AS `bayar`,`p`.`user_id` AS `user_id`,`p`.`kode_unit` AS `kode_unit`,'PIUTANG AWAL' AS `ket` from `tmpiutang` `p` union all select `tj`.`kode_cust` AS `kode_cust`,max(`tj`.`tgl_jual`) AS `tgl`,sum(((((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100)) + ((((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) - (((`trj`.`harga_jual` - ((`trj`.`disk_jual` * `trj`.`harga_jual`) / 100)) * `tj`.`disk_fak`) / 100)) * `tj`.`ppn`) / 100)) * `trj`.`jml_jual`)) AS `jml`,0 AS `bayar`,`tj`.`user_id` AS `user_id`,`tj`.`kode_unit` AS `kode_unit`,'PENJUALAN BARANG' AS `ket` from (`ttjual` `tj` join `ttrjual` `trj`) where ((`tj`.`nofak_jual` = `trj`.`nofak_jual`) and (`tj`.`cash` = '0')) group by `tj`.`kode_cust`,month(`tj`.`tgl_jual`),`tj`.`kode_unit`,`tj`.`user_id` union all select `pj`.`kode_cust` AS `kode_cust`,max(`pj`.`tgl_jual`) AS `tgl`,sum(`pj`.`harga_jual`) AS `jml`,0 AS `bayar`,`pj`.`user_id` AS `user_id`,`pj`.`kode_unit` AS `kode_unit`,'PENJUALAN PULSA' AS `ket` from `t_pulsa_jual` `pj` where (`pj`.`cash` = '0') group by `pj`.`kode_cust`,month(`pj`.`tgl_jual`),`pj`.`kode_unit`,`pj`.`user_id` union all select `nb`.`kode_cust` AS `kode_cust`,max(`nb`.`tgl_nota`) AS `tgl`,sum(`nb`.`harga_jual`) AS `jml`,0 AS `bayar`,`nb`.`user_id` AS `user_id`,`nb`.`kode_unit` AS `kode_unit`,'NOTA BON' AS `ket` from `t_nota_bon` `nb` group by `nb`.`kode_cust`,`nb`.`tgl_nota`,`nb`.`user_id`,`nb`.`kode_unit` union all select `pb`.`kode_cust` AS `kode_cust`,`pb`.`tgl` AS `tgl`,0 AS `jml`,`pb`.`jml` AS `bayar`,`pb`.`user_id` AS `user_id`,`pb`.`kode_unit` AS `kode_unit`,'BAYAR LANGSUNG' AS `ket` from `tt_bayar_piutang_unit` `pb` union all select `tp`.`kode_cust` AS `kode_cust`,`tp`.`tgl` AS `tgl`,0 AS `jml`,`tp`.`jml_bayar` AS `bayar`,`tp`.`user_id` AS `user_id`,`tp`.`kode_unit` AS `kode_unit`,'PEMOTONGAN' AS `ket` from `tt_pemotongan_unit` `tp`
create view v_stock asOke, ane rasa cukup sekian aja dulu berhubung koneksi ane lagi lambat serta laptop ane juga lambat kayak nya jadi ane harus puas cuman dengan posting ini saja. Dilain waktu dan kesempatan bakalan ane sambung kembali... Wassalam :D
select `m`.`id_stock` AS `id_stock`,`m`.`tgl` AS `tgl`,`m`.`kode_brg` AS `kode_brg`,`m`.`harga_modal` AS `harga_modal`,0 AS `harga_jual`,`m`.`stock_awal` AS `stock_awal`,0 AS `stock_masuk`,0 AS `stock_keluar`,`m`.`stock_awal` AS `stock_akhir`,(`m`.`harga_modal` * `m`.`stock_awal`) AS `saldo_akhir`,`m`.`user_id` AS `user_id`,`m`.`kode_unit` AS `kode_unit`,'tmmodal' AS `tabel`,'0' AS `kons` from `tmmodal` `m` union all select `vb`.`id_stock` AS `id_stock`,`vb`.`tgl_beli` AS `tgl_beli`,`vb`.`kode_brg` AS `kode_brg`,`vb`.`harga_ppn` AS `harga_modal`,0 AS `harga_jual`,0 AS `stock_awal`,`vb`.`jml_beli` AS `stock_masuk`,0 AS `stock_keluar`,`vb`.`jml_beli` AS `stock_akhir`,(`vb`.`jml_beli` * `vb`.`harga_ppn`) AS `saldo_ahhir`,`vb`.`user_id` AS `user_id`,`vb`.`kode_unit` AS `kode_unit`,'v_faktur_beli' AS `tabel`,'0' AS `kons` from `v_faktur_beli` `vb` union all select `vj`.`id_stock` AS `id_stock`,`vj`.`tgl_jual` AS `tgl_jual`,`vj`.`kode_brg` AS `kode_brg`,`m`.`harga_modal` AS `harga_modal`,`vj`.`harga_ppn` AS `harga_jual`,0 AS `stock_awal`,0 AS `stock_masuk`,`vj`.`jml_jual` AS `stock_keluar`,-(`vj`.`jml_jual`) AS `stock_akhir`,(-(`vj`.`jml_jual`) * `m`.`harga_modal`) AS `saldo_akhir`,`vj`.`user_id` AS `user_id`,`vj`.`kode_unit` AS `kode_unit`,'v_faktur_jual' AS `tabel`,`vj`.`kons` AS `kons` from (`v_faktur_jual` `vj` join `tmmodal` `m`) where (`vj`.`id_stock` = `m`.`id_stock`) union all select `vj`.`id_stock` AS `id_stock`,`vj`.`tgl_jual` AS `tgl_jual`,`vj`.`kode_brg` AS `kode_brg`,`vb`.`harga_ppn` AS `harga_modal`,`vj`.`harga_ppn` AS `harga_jual`,0 AS `stock_awal`,0 AS `stock_masuk`,`vj`.`jml_jual` AS `stock_keluar`,-(`vj`.`jml_jual`) AS `stock_akhir`,(-(`vj`.`jml_jual`) * `vb`.`harga_ppn`) AS `saldo_akhir`,`vj`.`user_id` AS `user_id`,`vj`.`kode_unit` AS `kode_unit`,'v_faktur_jual' AS `tabel`,`vj`.`kons` AS `kons` from (`v_faktur_jual` `vj` join `v_faktur_beli` `vb`) where (`vj`.`id_stock` = `vb`.`id_stock`) union all select `tt`.`no_titip` AS `no_titip`,`tt`.`tgl` AS `tgl`,`tt`.`kode_brg` AS `kode_brg`,`tt`.`harga_modal` AS `harga_modal`,0 AS `harga_jual`,0 AS `awal`,`tt`.`jml` AS `masuk`,0 AS `keluar`,`tt`.`jml` AS `akhir`,(`tt`.`jml` * `tt`.`harga_modal`) AS `saldo_akhir`,`tt`.`user_id` AS `user_id`,`tt`.`kode_unit` AS `kode_unit`,'TITIPAN' AS `tabel`,'1' AS `kons` from `tt_titipan` `tt` union all select `vj`.`id_stock` AS `id_stock`,`vj`.`tgl_jual` AS `tgl_jual`,`vj`.`kode_brg` AS `kode_brg`,`tt`.`harga_modal` AS `harga_modal`,`vj`.`harga_ppn` AS `harga_jual`,0 AS `stock_awal`,0 AS `stock_masuk`,`vj`.`jml_jual` AS `stock_keluar`,-(`vj`.`jml_jual`) AS `stock_akhir`,(-(`vj`.`jml_jual`) * `tt`.`harga_modal`) AS `saldo_akhir`,`vj`.`user_id` AS `user_id`,`vj`.`kode_unit` AS `kode_unit`,'v_faktur_jual' AS `tabel`,`vj`.`kons` AS `kons` from (`v_faktur_jual` `vj` join `tt_titipan` `tt`) where (`vj`.`id_stock` = `tt`.`no_titip`) union all select `bt`.`no_titip` AS `no_titip`,`bt`.`tgl` AS `tgl`,`tt`.`kode_brg` AS `kode_brg`,`tt`.`harga_modal` AS `harga_modal`,0 AS `harga_jual`,0 AS `awal`,0 AS `masuk`,`bt`.`sisa` AS `keluar`,-(`bt`.`sisa`) AS `akhir`,(-(`bt`.`sisa`) * `tt`.`harga_modal`) AS `saldo_akhir`,`bt`.`user_id` AS `user_id`,`bt`.`kode_unit` AS `kode_unit`,'bayar titipan' AS `tabel`,'1' AS `kons` from (`tt_bayar_titipan` `bt` join `tt_titipan` `tt`) where (`bt`.`no_titip` = `tt`.`no_titip`) union all select 'PULSA' AS `id_stock`,`da`.`tgl_depo` AS `tgl`,'PULSA' AS `kode_brg`,0 AS `harga_modal`,0 AS `harga_jual`,0 AS `stock_awal`,0 AS `stock_masuk`,0 AS `stock_keluar`,0 AS `stock_akhir`,`da`.`jml_depo` AS `saldo_akhir`,`da`.`user_id` AS `user_id`,`da`.`kode_unit` AS `kode_unit`,'t_pulsa_deposit_awal' AS `tabel`,'0' AS `kons` from `t_pulsa_deposit_awal` `da` union all select 'PULSA' AS `id_stock`,`dp`.`tgl_depo` AS `tgl`,'PULSA' AS `kode_brg`,0 AS `harga_modal`,0 AS `harga_jual`,0 AS `stock_awal`,0 AS `stock_masuk`,0 AS `stock_keluar`,0 AS `stock_akhir`,`dp`.`jml_depo` AS `saldo_akhir`,`dp`.`user_id` AS `user_id`,`dp`.`kode_unit` AS `kode_unit`,'t_pulsa_deposit' AS `tabel`,'0' AS `kons` from `t_pulsa_deposit` `dp` union all select 'PULSA' AS `id_stock`,`pj`.`tgl_jual` AS `tgl_jual`,'PULSA' AS `kode_barang`,`pj`.`harga_modal` AS `harga_modal`,`pj`.`harga_jual` AS `harga_jual`,0 AS `stock_awal`,0 AS `stock_masuk`,0 AS `stock_keluar`,0 AS `stock_akhir`,-(`pj`.`harga_modal`) AS `saldo_akhir`,`pj`.`user_id` AS `user_id`,`pj`.`kode_unit` AS `kode_unit`,'pulsa jual' AS `tabel`,'0' AS `kons` from `t_pulsa_jual` `pj`