Skip to content

fix(inventory): validate mandatory fields before save - #172

Merged
snehar-nd merged 1 commit into
angular-zard-migrationfrom
fix/inventory-save-validation
Sep 23, 2026
Merged

snehar-nd merged 1 commit into
angular-zard-migrationfrom
fix/inventory-save-validation

Conversation

@gkbishnoi07

Copy link
Copy Markdown

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.required on their controls, but the save handlers (savePhysicalStock / saveSelfConsumptionStock / submitTransfers / submitIndentRequest) build the payload and call the backend without ever checking form.invalid. So an empty/incomplete form is sent to the server.

Fix

Guard each save handler:

  • Physical Stock, Store Consumption, Stock Transfer: if (form.invalid) { form.markAllAsTouched(); alert('Please fill all mandatory fields'); return; }. (Each form starts with a required row and, for transfer, the programmatic createdBy/providerServiceMapID are already patched at init, so form.invalid is safe.)
  • Indent Request: its indentItemList rows carry no validators and the array starts empty, so form.invalid alone 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 positive requiredQty). 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.

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.
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 484e6f75-67a5-47e9-9eec-adf7a2a3c60e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@snehar-nd
snehar-nd merged commit ec70fd7 into angular-zard-migration Sep 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants