From 39fa697df8811e0994eba749ace93af532c1bcd6 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Sun, 5 Jul 2026 17:05:36 +0700 Subject: [PATCH] refactor: update validation logic in StockVerifyRequest to prevent exceeding original cutting results and enhance StockVerifyDialog with direct value updates for good and reject inputs --- .../Requests/Admin/Manage/StockVerifyRequest.php | 4 ++-- .../manage/stocks/table/StockVerifyDialog.vue | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/Http/Requests/Admin/Manage/StockVerifyRequest.php b/app/Http/Requests/Admin/Manage/StockVerifyRequest.php index 128b8e1..313822b 100644 --- a/app/Http/Requests/Admin/Manage/StockVerifyRequest.php +++ b/app/Http/Requests/Admin/Manage/StockVerifyRequest.php @@ -81,8 +81,8 @@ public function withValidator(Validator $validator): void continue; } - if (($good + $reject) !== (int) $originalResult->cutting_result) { - $validator->errors()->add("results.{$index}.good", "Total jumlah (bagus + reject) harus sama dengan hasil cutting asli ({$originalResult->cutting_result} pcs)."); + if (($good + $reject) > (int) $originalResult->cutting_result) { + $validator->errors()->add("results.{$index}.good", "Total jumlah (bagus + reject) tidak boleh melebihi hasil cutting asli ({$originalResult->cutting_result} pcs)."); } } } diff --git a/resources/js/pages/admin/manage/stocks/table/StockVerifyDialog.vue b/resources/js/pages/admin/manage/stocks/table/StockVerifyDialog.vue index 01cd2ed..b12af3a 100644 --- a/resources/js/pages/admin/manage/stocks/table/StockVerifyDialog.vue +++ b/resources/js/pages/admin/manage/stocks/table/StockVerifyDialog.vue @@ -87,6 +87,16 @@ interface VariantPriceRow { prices: Record; } +function onGoodChange(result: any, value: string | number) { + const val = Number(value) || 0; + result.good = val; +} + +function onRejectChange(result: any, value: string | number) { + const val = Number(value) || 0; + result.reject = val; +} + const verifyForm = useForm({ verification_note: '', results: props.cutting.results.map(res => ({ @@ -227,13 +237,15 @@ function submitVerify() { + class="h-7 w-20 px-1.5 text-xs text-center" + @update:model-value="val => onGoodChange(result, val)" />
+ class="h-7 w-20 px-1.5 text-xs text-center" + @update:model-value="val => onRejectChange(result, val)" />