Compare commits

..

No commits in common. "fd3565fd642dd9866721150958317a8980d50c90" and "e96d973b03f0d53c5dc7132295a7611b10e1ec2a" have entirely different histories.

3 changed files with 8 additions and 21 deletions

View File

@ -19,21 +19,10 @@ class TransaksiController extends Controller
$query->limit((int)$limit);
}
$transaksi = $query->get();
// Mapping agar sesuai dengan kebutuhan frontend
$mapped = $transaksi->map(function ($trx) {
return [
'id' => $trx->id,
'tanggal' => $trx->created_at->format('d/m/Y'),
'kode' => 'TRX-' . str_pad($trx->id, 6, '0', STR_PAD_LEFT),
'pendapatan'=> $trx->total_harga,
];
});
return response()->json($mapped);
$transaksi = Transaksi::with(['kasir', 'sales', 'items.item.produk'])->latest()->limit(100)->get();
return response()->json($transaksi);
}
// Detail transaksi by ID
public function show($id)
{

View File

@ -16,7 +16,6 @@
<InputField
v-model="hargaJual"
type="number"
placeholder="Masukkan Harga Jual"
/>
</div>
</div>
@ -54,10 +53,10 @@
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in pesanan" :key="index" class="hover:bg-gray-50 text-center">
<td class="border border-gray-200 p-2">{{ index + 1 }}</td>
<tr v-for="(item, index) in pesanan" :key="index" class="hover:bg-gray-50">
<td class="border border-gray-200 p-2 text-center">{{ index + 1 }}</td>
<td class="border border-gray-200 p-2">{{ item.kode }}</td>
<td class="border border-gray-200 p-2">{{ item.jumlah }}</td>
<td class="border border-gray-200 p-2 text-center">{{ item.jumlah }}</td>
<td class="border border-gray-200 p-2">Rp{{ item.harga.toLocaleString() }}</td>
<td class="border border-gray-200 p-2">Rp{{ (item.harga * item.jumlah).toLocaleString() }}</td>
</tr>
@ -74,7 +73,7 @@
import InputField from './InputField.vue'
const kodeItem = ref('')
const hargaJual = ref(null)
const hargaJual = ref(0)
const pesanan = ref([])
const tambahItem = () => {
@ -92,4 +91,3 @@ import InputField from './InputField.vue'
pesanan.value.reduce((sum, item) => sum + item.harga * item.jumlah, 0)
)
</script>

View File

@ -26,8 +26,8 @@
onMounted(async () => {
try {
const res = await axios.get("/api/transaksi?limit=10") // GANTI URL SESUAI API
const res = await axios.get("/api/transaksi") // GANTI URL SESUAI API
transaksi.value = res.data
} catch (err) {
console.error("Gagal fetch transaksi:", err)