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

feat: affiliate sales partner referral code and coupon code #17117

Open
wants to merge 2 commits into
base: develop
from

Conversation

@jigneshpshah jigneshpshah changed the title Affiliate and coupon feat: affiliate sales partner referral code and coupon code Apr 3, 2019

@jigneshpshah

This comment has been minimized.

Copy link
Collaborator

commented Apr 3, 2019

Test Server Instance Details

Basic Steps for customer -user testing

  1. Click on the link
  2. Check the price and add the item to the cart and use the customer login mentioned below
3. View Cart

ShoppinCartApplyCouponCode

  1. Apply Coupon Code and check the discounted price
  2. Click on "Place Order" button to view final order price details

Customer user :
donald@trump.com
hello@2020

To Test the feature in action
Test Instance URL

Test Data :

Items [URL] Rate Coupon Code Discount Grand Total
1)Golden Ring 750 SAVE5 (5%) 37.50 712.50
2)Chair 500 -- 0 500

Desk User :
desk@user.com
hello@2020

Other Important Data Links

Coupon Code
Pricing Rule
Shopping Cart Settings
Sales Partner

Basic Steps to configure Coupon Code Feature

Ensure Shopping Cart Settings > Apply Coupon Code is enabled.

CCShoppingCartSettings

  1. Create Item
2) Create Pricing Rule for Item in step 1 - (Coupon Code Based = true

PriceRuleCC

3) Create Coupon Code , link it with Pricing Rule of Step 2

CouponCodeDoctype

4) Add Item in Shopping Cart and view cart

ShoppinCartApplyCouponCode

  1. Apply Coupon Code and check the price
@jigneshpshah

This comment has been minimized.

Copy link
Collaborator

commented Apr 4, 2019

Please find successful run of cypress test case in action below.

cypresstest_couponcode

jigneshpshah added a commit to jigneshpshah/erpnext_com that referenced this pull request Apr 4, 2019
@jigneshpshah jigneshpshah referenced this pull request Apr 4, 2019
@jigneshpshah

This comment has been minimized.

Copy link
Collaborator

commented Apr 4, 2019

We are done with
[1] PR
[2] It has test case. find video of same
[3] You can do hands on. Test server
[4] Documentation for
Coupon Code frappe/erpnext_com#300
Sales Partner Referral Code frappe/erpnext_com#302

We are awaiting Reviewer's approval on PR.

jigneshpshah added a commit to jigneshpshah/erpnext_com that referenced this pull request Apr 4, 2019
jigneshpshah added a commit to jigneshpshah/erpnext_com that referenced this pull request Apr 4, 2019

@jigneshpshah jigneshpshah requested a review from rmehta Apr 8, 2019

erpnext/tests/test_couponcode.py Outdated Show resolved Hide resolved
@rmehta

This comment has been minimized.

Copy link
Member

commented Apr 9, 2019

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented Apr 9, 2019

@rmehta , Test data creation is done earlier this way from cypress ex.

Also, i am not sure what is downside on using it?
If possible, please guide with example code. thanks

@rmehta

This comment has been minimized.

Copy link
Member

commented Apr 11, 2019

@ashish-greycube All server side code must be tested server-side not in cypress, as transactions can also be created via API.

Cypress testing is additional, not a replacement for server side tests

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented Apr 18, 2019

image

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented Apr 20, 2019

@rmehta , test_coupon_code.py test case is completed. Thanks

erpnext/accounts/doctype/coupon_code/coupon_code.py Outdated Show resolved Hide resolved
erpnext/accounts/doctype/coupon_code/coupon_code.py Outdated Show resolved Hide resolved
erpnext/accounts/doctype/pricing_rule/utils.py Outdated Show resolved Hide resolved
erpnext/public/js/shopping_cart.js Outdated Show resolved Hide resolved
erpnext/selling/doctype/sales_order/sales_order.py Outdated Show resolved Hide resolved
erpnext/tests/test_couponcode.py Outdated Show resolved Hide resolved
@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented Apr 23, 2019

@rmehta , review comments are incorporated. thanks!

@jigneshpshah

This comment has been minimized.

Copy link
Collaborator

commented Apr 30, 2019

Hi @rmehta ,

It will help us a lot , if you can please spare few minutes and review the PR #17117, as we have made all the necessary changes.

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented May 8, 2019

Hi, @rmehta when time permits please review and help. Thanks!

@rmehta
Copy link
Member

left a comment

Unrelated changes are merged. Please rebase and clean your PR

@ashish-greycube ashish-greycube force-pushed the ashish-greycube:affiliate_and_coupon branch from 7920301 to a098231 May 29, 2019

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented May 29, 2019

All comments are resolved. Please find below the screenshot of successful test run. Thanks!
image

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented May 29, 2019

Unrelated changes are merged. Please rebase and clean your PR

Done!

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented May 30, 2019

@rmehta , Request you to please review it when possible.
Thanks! for all review comments and help till now.

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented Jun 13, 2019

@rmehta , request you to please review it when time permits. Thanks!

@rmehta

This comment has been minimized.

Copy link
Member

commented Jun 13, 2019

@ashish-greycube no time!

@nabinhait can you assign this to someone?

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented Jun 15, 2019

@nabinhait , please help when time permits. Thanks!

coupon_code=coupon_name.toUpperCase().slice(0,8);
}
frm.doc.coupon_code=coupon_code;
frm.refresh_field('coupon_code');

This comment has been minimized.

Copy link
@rohitwaghchaure

rohitwaghchaure Jun 27, 2019

Contributor

Instead of JS can you generate coupon at py side, so it can be generate using API too. Also why two fields coupon_name and coupon_code? name can be code?

This comment has been minimized.

Copy link
@parsimonyERP

parsimonyERP Jun 27, 2019

IMO, coupon_code is usually short and that makes it tough to remember who it was targeted at and when it was run. For instance, did we use "HolidaySave10" last year or was that "SaveHoliday10"? Having coupon_name allows us to add "2019 Holiday Coupon - General Online Use"

This comment has been minimized.

Copy link
@rmehta

rmehta Jun 28, 2019

Member

@parsimonyERP what @rohitwaghchaure is saying does not affect this functionality but will make it friendly for those creating coupon codes via an API

This comment has been minimized.

Copy link
@ashish-greycube

ashish-greycube Jun 28, 2019

Author Contributor

Instead of JS can you generate coupon at py side, so it can be generate using API too. Also why two fields coupon_name and coupon_code? name can be code?

It was on .py side originally. Link
Based on rmehta's comment it was shifted to JS
coupon_code - is for external consumption. Generally it is 8 char without space. Ex DELL30
coupon_name - is for internal ERPNext

This comment has been minimized.

Copy link
@rohitwaghchaure

rohitwaghchaure Jul 24, 2019

Contributor

But in that case how to generate the coupon code using API?

This comment has been minimized.

Copy link
@ashish-greycube

ashish-greycube Jul 24, 2019

Author Contributor

@rohitwaghchaure , I have updated autoname to generate coupon_code in case when JS is not invoked i.e. via API. Thanks! for the comment

@@ -142,6 +142,11 @@ def set_missing_values(source, target):
if customer:
target.customer = customer.name
target.customer_name = customer.customer_name
if source.coupon_code:
target.coupon_code = source.coupon_code

This comment has been minimized.

Copy link
@rohitwaghchaure

rohitwaghchaure Jun 27, 2019

Contributor

coupon_code has no property enabled no_copy, then target can be auto copy from the source. No need to set explicitly.

This comment has been minimized.

Copy link
@ashish-greycube

ashish-greycube Jun 28, 2019

Author Contributor

Agreed. Thanks!

@rohitwaghchaure

This comment has been minimized.

Copy link
Contributor

commented Jun 27, 2019

@ashish-greycube I was looking for the code where based on the coupon code system pulls the respective pricing rule. Can you please point me to that code

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented Jun 28, 2019

@ashish-greycube I was looking for the code where based on the coupon code system pulls the respective pricing rule. Can you please point me to that code

Logic

  • Pricing rule doctype has 'Apply On' condition, based on item etc in quotation/SO pricing rule gets picked up (this is present functionality)
  • What I have to ensure is that pricing rule that is getting picked up if it has "Coupon Code Based" conditon true then it that case quotation/SO should provide the corresponding coupon_code if not don't apply the rule.

Code

  • When coupon_code is found, it runs ignore_pricing_rule and then apply_pricing_rule
    erpnext/public/js/controllers/transaction.js -->
    1202
    1709
  • During apply_pricing_rule I have to check for negative condition. i.e. return if no coupon_code found
    /erpnext/accounts/doctype/pricing_rule/pricing_rule.py
    246
@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented Jun 30, 2019

@rohitwaghchaure , I have tried to reply your queries as best as i could. thanks

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented Jul 22, 2019

@rohitwaghchaure when time permits, please have a look. thanks!

@rohitwaghchaure rohitwaghchaure self-assigned this Jul 24, 2019

@ashish-greycube ashish-greycube force-pushed the ashish-greycube:affiliate_and_coupon branch from 36b54c3 to cb9b7a2 Aug 12, 2019

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented Aug 12, 2019

  • Rebase is done. There are no conflicting files.

  • Unit test case is run again and it passes as shown below.
    image

  • Coupon Code can be generated by API also as shown below.
    image

  • Flow is again checked manually as shown below.
    image

  1. coupon_code is passed in URL

image
2. Order is generated with discount

@rohitwaghchaure please check it and help in merging the functionality. Thanks!

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented Aug 12, 2019

Unrelated changes are merged. Please rebase and clean your PR

This is taken care of. thanks

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented Aug 14, 2019

@rohitwaghchaure , when time permits please review it. I think we are near now. Thanks! and happy independence day.

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented Aug 19, 2019

@rohitwaghchaure Rohit Sir, kindly help. Thanks!

@stale

This comment has been minimized.

Copy link

commented Sep 18, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed within a week if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing.

@stale stale bot added the inactive label Sep 18, 2019

@parsimonyERP

This comment has been minimized.

Copy link

commented Sep 18, 2019

This is an important feature. Please review when you have time, and don't let it get closed.

@stale stale bot removed the inactive label Sep 18, 2019

@ashish-greycube

This comment has been minimized.

Copy link
Contributor Author

commented Sep 18, 2019

@rohitwaghchaure , Rohit Sir, Please help to merge the feature. Thanks!!

@rmehta

This comment has been minimized.

Copy link
Member

commented Sep 19, 2019

@rohitwaghchaure @nabinhait seems like this is good to go?

@rohitwaghchaure

This comment has been minimized.

Copy link
Contributor

commented Sep 19, 2019

@ashish-greycube For testing, I will pull the PR on local account and also resolve the conflicts. I need one more day to review and merge this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.