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