CREATE VIEW combined_pembelian_views AS
SELECT
    'pembelian' :: text AS jenis_transaksi,
    tp.anggota_id,
    a.nama_lengkap,
    a.foto,
    rls.roles_name,
    ib.jenis_barang_id,
    tp.toko_id,
    t.nama_toko,
    tp.tanggal_beli as tanggal,
    ib.berat,
    tp.harga_produk as harga
FROM
    transaksi_pembelians as tp
    LEFT JOIN anggota as a ON tp.anggota_id = a.id
    LEFT JOIN inventory_barangs as ib ON ib.id = tp.inventory_barang_id
    LEFT JOIN roles as rls ON rls.id=a.roles_id
    LEFT JOIN tokos as t ON tp.toko_id = t.id
WHERE
    tp.deleted_at IS NULL
    AND tp.deleted_by IS NULL