Repository navigation
fix(inventory): validate mandatory fields before save - #172
Conversation
physical stock entry, store consumption, stock transfer and indent request declare Validators.required but their save handlers never checked validity, so an empty/incomplete form was sent to the backend (raw error) or created an empty row. guard each save: - physical stock, consumption, transfer: return early with a validation alert when the form is invalid (markAllAsTouched) - indent request: rows carry no validators and the array starts empty, so require the header fields plus at least one real item (item + positive qty) same class of fix as the stock-adjustment guard; covers main and sub store.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|



Fixes the "Save with empty/missing mandatory fields still submits" issues across four inventory forms (same class as the Stock Adjustment fix, PR #166):
Root cause
All four forms declare
Validators.requiredon their controls, but the save handlers (savePhysicalStock/saveSelfConsumptionStock/submitTransfers/submitIndentRequest) build the payload and call the backend without ever checkingform.invalid. So an empty/incomplete form is sent to the server.Fix
Guard each save handler:
if (form.invalid) { form.markAllAsTouched(); alert('Please fill all mandatory fields'); return; }. (Each form starts with a required row and, for transfer, the programmaticcreatedBy/providerServiceMapIDare already patched at init, soform.invalidis safe.)indentItemListrows carry no validators and the array starts empty, soform.invalidalone wouldn't catch a save with no items. Guard manually: require the header fields (referenceNumber,indentReason) and at least one real item (item selected + a positiverequiredQty). This also prevents the empty-row save.Validation messages use an existing language key with an English fallback. Same components serve Main and Sub store.