refactor: update validation logic in StockVerifyRequest to prevent exceeding original cutting results and enhance StockVerifyDialog with direct value updates for good and reject inputs
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (8.3) (push) Waiting to run
tests / ci (8.4) (push) Waiting to run
tests / ci (8.5) (push) Waiting to run

This commit is contained in:
Yoga Pangestu 2026-07-05 17:05:36 +07:00
parent e4e17e32ec
commit 39fa697df8
2 changed files with 16 additions and 4 deletions

View File

@ -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).");
}
}
}

View File

@ -87,6 +87,16 @@ interface VariantPriceRow {
prices: Record<string, string>;
}
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() {
<label :for="`stock-good-${index}`"
class="text-[10px] text-muted-foreground block mb-0.5">Bagus</label>
<NumberInput :id="`stock-good-${index}`" :model-value="result.good"
class="h-7 w-20 px-1.5 text-xs text-center" />
class="h-7 w-20 px-1.5 text-xs text-center"
@update:model-value="val => onGoodChange(result, val)" />
</div>
<div class="text-center">
<label :for="`stock-reject-${index}`"
class="text-[10px] text-muted-foreground block mb-0.5">Reject</label>
<NumberInput :id="`stock-reject-${index}`" :model-value="result.reject"
class="h-7 w-20 px-1.5 text-xs text-center" />
class="h-7 w-20 px-1.5 text-xs text-center"
@update:model-value="val => onRejectChange(result, val)" />
</div>
</div>
</div>