Improve GudangPos barcode fields
This commit is contained in:
@@ -62,6 +62,12 @@ class GudangPos extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
$saldoBase = $service->getStockBaseByJenis((string) ($jenis->jenis ?? ''));
|
||||
if ($saldoBase <= 0) {
|
||||
$this->toast('error', 'Stok kosong untuk ' . ((string) ($jenis->jenis ?? 'barang')) . '.');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->selectedKode = (string) ($jenis->kodejenis ?? '');
|
||||
$this->qty = 1;
|
||||
$this->satuanTransaksi = (string) ($parsed['satuan_transaksi'] ?? 'besar');
|
||||
@@ -81,6 +87,12 @@ class GudangPos extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
$saldoBase = $service->getStockBaseByJenis((string) ($jenis->jenis ?? ''));
|
||||
if ($saldoBase <= 0) {
|
||||
$this->toast('error', 'Stok kosong untuk ' . ((string) ($jenis->jenis ?? 'barang')) . '.');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->selectedKode = (string) ($jenis->kodejenis ?? '');
|
||||
$this->qty = 1;
|
||||
$this->syncSatuanAvailability();
|
||||
@@ -215,7 +227,11 @@ class GudangPos extends Component
|
||||
}
|
||||
|
||||
if ($qtyBase > $stockCache[$jenisNama]) {
|
||||
$this->toast('error', 'Stok tidak cukup untuk ' . $jenisNama . '.');
|
||||
if ((int) $stockCache[$jenisNama] <= 0) {
|
||||
$this->toast('error', 'Stok kosong untuk ' . $jenisNama . '.');
|
||||
} else {
|
||||
$this->toast('error', 'Stok tidak cukup untuk ' . $jenisNama . '.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
$stockCache[$jenisNama] -= $qtyBase;
|
||||
@@ -301,9 +317,11 @@ class GudangPos extends Component
|
||||
$search = trim((string) $this->search);
|
||||
if ($search !== '') {
|
||||
$searchLike = '%' . $search . '%';
|
||||
$query->where(function ($q) use ($searchLike) {
|
||||
$q->where('jenis', 'LIKE', $searchLike)
|
||||
->orWhere('kodejenis', 'LIKE', $searchLike);
|
||||
$driver = DB::connection()->getDriverName();
|
||||
$operator = ($driver === 'pgsql') ? 'ILIKE' : 'LIKE';
|
||||
$query->where(function ($q) use ($searchLike, $operator) {
|
||||
$q->where('jenis', $operator, $searchLike)
|
||||
->orWhere('kodejenis', $operator, $searchLike);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user