Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip qty validation when multiqty is disabled #6624

Merged
merged 7 commits into from
Aug 16, 2023

Conversation

KenLSM
Copy link
Contributor

@KenLSM KenLSM commented Aug 15, 2023

Problem

  1. A quantity validation check was performed preventing the field to be saved as the quantity field errors out, but this is not visible to the user.
    This should be fixed such that the quantity check is not performed when the quantity limit toggle is off.
  2. On the backend,multi_qty is always treated to be true even if the toggle is disabled, resulting in validation failure when the user is trying to add only 1 single item.

Closes FRM-1255

Solution

  1. Quantity validation will do an early return with true when quantity limit toggle is off.
  2. A trigger is also added so that we can update the useForm errors through a validation.
  3. Backend checks if multi_qty is enabled and set the qty modifier to be 1 when disabled during calculations.

Breaking Changes

  • No - this PR is backwards compatible

Before & After Screenshots

BEFORE:

Screen.Recording.2023-08-15.at.4.28.32.PM.mov

AFTER:

Untitled.mov

Tests

Quantity below max payment amount (200k)

  • Save button should be enabled when amount is 20k, and toggle disabled
  • Enable toggle and set max quantity as 9
  • Save button remains enabled
  • Saving items succeeds and is reflected on payment input panel with amount as $20000.00

Quantity at max payment amount (200k)

  • Save button should be enabled when amount is 20k, and toggle disabled
  • Enable toggle and set max quantity as 10
  • Save button remains enabled
  • Saving items succeeds and is reflected on payment input panel with amount as $20000.00

Quantity above max payment amount (200k)

  • Save button should be enabled when amount is 20k, and toggle disabled
  • Enable toggle and set max quantity as 11
  • Save button is now disabled
  • Saving button should not be interactable
  • Disable toggle
  • Saving button is now enabled
  • Saving items succeeds and is reflected on payment input panel with amount as $20000.00

Regression

  • Add new products
  • Enabling toggle doesn't crash the modal
    • Shows error Please enter a valid payment amount
  • Disabling toggle doesn't crash the modal
    • Continue to show error Please enter a valid payment amount

@KenLSM KenLSM requested a review from LinHuiqing August 15, 2023 10:25
@LinHuiqing
Copy link
Contributor

2 bugs:

  1. There's now an error complaining that we're trying to .trim on undefined when we just use the toggle without keying in anything:
Screen.Recording.2023-08-16.at.1.51.34.PM.mov
  1. We need to set multi_qty as false when we don't set it, if not there'll be a joi validation error:
Screen.Recording.2023-08-16.at.1.53.44.PM.mov

@KenLSM KenLSM requested a review from LinHuiqing August 16, 2023 10:25
Copy link
Contributor

@LinHuiqing LinHuiqing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm! Spotted 2 more payment bugs but I think they can be fixed in separate PRs (FRM-1256 and FRM-1257)

@KenLSM KenLSM merged commit 9272cb7 into develop Aug 16, 2023
16 checks passed
@KenLSM KenLSM deleted the fix/save-button-disabled-incorrectly branch August 16, 2023 12:36
@wanlingt wanlingt mentioned this pull request Aug 17, 2023
50 tasks
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