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: Added quantity, min/max price validations & fixed donations bugs #3209

Merged
merged 2 commits into from
Jul 10, 2019

Conversation

mrsaicharan1
Copy link
Member

@mrsaicharan1 mrsaicharan1 commented Jun 27, 2019

Fixes #3184

When organizer tries to add tickets worth of 0 value
Screenshot 2019-06-24 at 11 45 37 PM


Min max validation checks
Screenshot 2019-07-02 at 9 00 44 AM


When the ticket buyer tries to add zero valued donation tickets
Screenshot 2019-06-26 at 7 04 39 AM

Short description of what this resolves:

Does not allow donation tickets worth of 0 value to be purchased & adds quantity support

Changes proposed in this pull request:

  • Added quantity support for donation tickets
  • Removed duplicate code segment to prevent price repitition
  • Added check to allow donations to be limited to a pre-specified price range (minPrice and maxPrice)
  • Fixed the price update bug by adding price to watchable properties

Checklist

  • I have read the Contribution & Best practices Guide.
  • My branch is up-to-date with the Upstream development branch.
  • The acceptance, integration, unit tests and linter pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@auto-label auto-label bot added the fix label Jun 27, 2019
@mrsaicharan1 mrsaicharan1 changed the title fix: Added quantity and min/max price validations for donations [WIP]fix: Added quantity and min/max price validations for donations Jun 27, 2019
@auto-label auto-label bot removed the fix label Jun 27, 2019
@mrsaicharan1 mrsaicharan1 changed the title [WIP]fix: Added quantity and min/max price validations for donations fix: Added quantity and min/max price validations for donations Jun 27, 2019
@auto-label auto-label bot added the fix label Jun 27, 2019
@mrsaicharan1 mrsaicharan1 force-pushed the donations-fix branch 3 times, most recently from 10fefce to abe4651 Compare June 28, 2019 11:19
Copy link
Member

@kushthedude kushthedude left a comment

Choose a reason for hiding this comment

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

@mrsaicharan1 Please do the following else looks good

app/components/public/ticket-list.js Outdated Show resolved Hide resolved
app/components/forms/wizard/basic-details-step.js Outdated Show resolved Hide resolved
@kushthedude
Copy link
Member

Yeah I had this question. We could have an icon popup specifying it.

Whatever looks well can be done 👍

@mrsaicharan1 mrsaicharan1 force-pushed the donations-fix branch 3 times, most recently from 794bde1 to f7ec5d5 Compare June 29, 2019 02:51
@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Jun 29, 2019

@niranjan94 @CosmicCoder96 There was a bug related to the donation price. The subtotal was getting updated but the total wasn't as the price of the donation is variable. I fixed that by adding the ticket price to the watchable property

Copy link
Member

@kushthedude kushthedude left a comment

Choose a reason for hiding this comment

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

@mrsaicharan1 Please have a look here, Else is fine.

Try to inculcate Total in one line if possible :
image

app/components/forms/wizard/basic-details-step.js Outdated Show resolved Hide resolved
app/components/forms/wizard/basic-details-step.js Outdated Show resolved Hide resolved
@mrsaicharan1 mrsaicharan1 force-pushed the donations-fix branch 2 times, most recently from 656563f to 55876d4 Compare June 30, 2019 05:06
@mrsaicharan1 mrsaicharan1 changed the title fix: Added quantity and min/max price validations for donations [WIP]fix: Added quantity and min/max price validations for donations Jul 1, 2019
@auto-label auto-label bot removed the fix label Jul 1, 2019
@mrsaicharan1
Copy link
Member Author

I’ve written 2 validation rules checkMax and checkMin as multiple paramters are not supported by validation rules.
Reference:Semantic-Org/Semantic-UI#3682 (comment)

It’s getting validated but it always returns false. Always prompts Ticket max price should be greater than min price

@mrsaicharan1 mrsaicharan1 changed the title [WIP]fix: Added quantity and min/max price validations for donations fix: Added quantity and min/max price validations for donations Jul 2, 2019
@auto-label auto-label bot added the fix label Jul 2, 2019
@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Jul 2, 2019

@niranjan94 @CosmicCoder96 I had already written a validation check for min/max price on the server. I feel that the FE validation isn't required as Max/min tickets per order also follows the same practice. Please have a look here...

https://github.com/fossasia/open-event-server/blob/e3c20af06e4034217d914984eac0332d08239fc3/app/api/schema/tickets.py#L60

@fossasia fossasia deleted a comment from kushthedude Jul 2, 2019
@mrsaicharan1 mrsaicharan1 force-pushed the donations-fix branch 6 times, most recently from 6737ac4 to 566bf03 Compare July 4, 2019 22:19
@mrsaicharan1 mrsaicharan1 changed the title fix: Added quantity and min/max price validations for donations fix: Added quantity, min/max price validations & fixed donations bugs Jul 6, 2019
@mrsaicharan1
Copy link
Member Author

@niranjan94 I've made the requested changes. Used gte from the ember API for comparison & removed major validation logic in the template

@mrsaicharan1 mrsaicharan1 requested a review from niranjan94 July 8, 2019 03:23
donationTicketsValidation: computed('donationTickets.@each.id', 'donationTickets.@each.minPrice', 'donationTickets.@each.maxPrice', function() {
let validationRules = {};
this.donationTickets.forEach(donationTicket => {
validationRules = merge(validationRules, {
Copy link
Member

Choose a reason for hiding this comment

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

Merge is not required for this. You're just creating a new object any way. You can just directly assign stuff with validationRules[donationTicket.id] =

Copy link
Member Author

Choose a reason for hiding this comment

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

@niranjan94 Yeah, I guess you're right. Removed the redudant merge.

@@ -176,14 +200,32 @@ export default Component.extend(FormMixin, {
this.send('togglePromotionalCode', this.code);
}
},
donationTicketsValidation: computed('donationTickets.@each.id', 'donationTickets.@each.minPrice', 'donationTickets.@each.maxPrice', function() {
let validationRules = {};
this.donationTickets.forEach(donationTicket => {
Copy link
Member

Choose a reason for hiding this comment

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

Use for-of loop

Copy link
Member Author

Choose a reason for hiding this comment

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

@niranjan94 Done.

@mrsaicharan1 mrsaicharan1 force-pushed the donations-fix branch 4 times, most recently from 722bcf1 to 58f0a63 Compare July 8, 2019 03:42
donationTickets: computed.filterBy('data', 'type', 'donation'),

isDonationPriceValid: computed('donationTickets.@each.orderQuantity', 'donationTickets.@each.price', function() {
let returnValue = false;
Copy link
Member

Choose a reason for hiding this comment

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

Can be simplified into

  for (const ticket of this.donationTickets) {
    if (donationTicket.orderQuantity > 0) {
      if (donationTicket.price < donationTicket.minPrice || donationTicket.price > donationTicket.maxPrice) {
        return false
      }
    }
  }
  return true

Copy link
Member Author

Choose a reason for hiding this comment

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

@niranjan94 Done.

app/components/public/ticket-list.js Outdated Show resolved Hide resolved
app/components/public/ticket-list.js Outdated Show resolved Hide resolved
Added watched properties and fixed totalling error

Added semantic validation

Added dynamic popup for ticket buyers

Added action to check for max/min price

Added quantitiy, min-max and bug fixes for donations
removed repeated code

Add error class validation

Fixed paid & free tickets bug
ESLint

Used for-of & removed redundant merge

Optimized donationsValidation property
@niranjan94 niranjan94 requested a review from abhinavk96 July 9, 2019 06:41
@kushthedude kushthedude merged commit daa6a85 into fossasia:development Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants