[fix] payment mechanism for memberships, membership listing

This commit is contained in:
Saurabh
2017-03-14 19:40:14 +05:30
parent 5dae6a8206
commit 5139f837c5
14 changed files with 232 additions and 34 deletions

View File

@@ -55,7 +55,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Membership Type",
"length": 0,
@@ -85,7 +85,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "From",
"length": 0,
@@ -114,7 +114,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "To",
"length": 0,
@@ -230,7 +230,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-03-07 16:44:47.066560",
"modified": "2017-03-14 18:44:13.286524",
"modified_by": "Administrator",
"module": "ERPNext Foundation",
"name": "Membership",

View File

@@ -1,38 +1,30 @@
frappe.ready(function() {
// bind events here
$(".page-header-actions-block .btn-primary, .page-header-actions-block .btn-default").addClass('hidden');
$(".text-right .btn-primary").addClass('hidden');
var set_amount = function() {
var membership_type = $('[data-fieldname="membership_type"]').val();
var currency = $('[data-fieldname="currency"]').val();
if(currency=='USD') {
amount = {
'Gold': 5000,
'Silver': 1500,
'Individual': 200
}
} else {
amount = {
'Gold': 300000,
'Silver': 100000,
'Individual': 10000
}
amount = {
'Gold': 300000,
'Silver': 100000,
'Individual': 10000
}
var currency = $('[data-fieldname="amount"]').val(amount[membership_type]);
$('[data-fieldname="amount"]').val(amount[membership_type]);
}
if(get_url_arg('name')) {
$('[data-fieldname="membership_type"]').prop('disabled', true);
$('[data-fieldname="currency"]').prop('disabled', true);
$('.page-content .btn-form-submit').addClass('hidden');
} else {
} else {
var m = moment();
$('[data-fieldname="from_date"]').val(m.format()).trigger('change');
$('[data-fieldname="to_date"]').val(m.add(1, 'year').format()).trigger('change');
$('[data-fieldname="membership_type"]').on('change', function() { set_amount(); });
$('[data-fieldname="currency"]').val('USD')
.on('change', function() {
set_amount();
})
.trigger('change');
}
$('[data-fieldname="currency"]').val("INR");
set_amount();
}
})

View File

@@ -18,13 +18,14 @@
"is_standard": 1,
"login_required": 1,
"max_attachment_size": 0,
"modified": "2017-03-07 17:08:02.298823",
"modified": "2017-03-14 16:31:47.735437",
"modified_by": "Administrator",
"module": "ERPNext Foundation",
"name": "memberships",
"owner": "Administrator",
"payment_button_help": "Pay for your membership using PayPal or RazorPay",
"payment_button_help": "Pay for your membership using RazorPay",
"payment_button_label": "Pay Now",
"payment_gateway": "Razorpay",
"published": 1,
"route": "memberships",
"show_sidebar": 1,
@@ -71,7 +72,7 @@
"max_length": 0,
"max_value": 0,
"options": "USD\nINR",
"read_only": 0,
"read_only": 1,
"reqd": 0
},
{

View File

@@ -1,7 +1,20 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import fmt_money
def get_context(context):
# do your magic here
pass
def get_list_context(context):
context.row_template = 'foundation/templates/includes/membership_list.html'
context.get_list = get_site_list
def get_site_list(doctype, txt, filters, limit_start, limit_page_length=20, order_by=None):
memberships = frappe.db.sql("""select * from `tabMembership`
where member = %s order by creation desc""", frappe.session.user, as_dict=True)
for membership in memberships:
membership.amount = fmt_money(membership.amount, precision=2, currency=membership.currency)
return memberships

View File

@@ -0,0 +1,32 @@
frappe.ready(function() {
// bind events here
$(".page-header-actions-block .btn-primary, .page-header-actions-block .btn-default").addClass('hidden');
$(".text-right .btn-primary").addClass('hidden');
var m = moment();
var set_amount = function() {
var membership_type = $('[data-fieldname="membership_type"]').val();
var currency = $('[data-fieldname="currency"]').val();
amount = {
'Gold': 5000,
'Silver': 1500,
'Individual': 200
}
$('[data-fieldname="amount"]').val(amount[membership_type]);
}
if(get_url_arg('name')) {
$('[data-fieldname="membership_type"]').prop('disabled', true);
$('[data-fieldname="currency"]').prop('disabled', true);
$('.page-content .btn-form-submit').addClass('hidden');
} else {
$('[data-fieldname="from_date"]').val(m.format()).trigger('change');
$('[data-fieldname="to_date"]').val(m.add(1, 'year').format()).trigger('change');
$('[data-fieldname="membership_type"]').on('change', function() { set_amount(); });
$('[data-fieldname="currency"]').val('USD');
set_amount();
}
})

View File

@@ -0,0 +1,89 @@
{
"accept_payment": 1,
"allow_comments": 0,
"allow_delete": 0,
"allow_edit": 1,
"allow_incomplete": 0,
"allow_multiple": 1,
"allow_print": 0,
"amount": 0.0,
"amount_based_on_field": 1,
"amount_field": "amount",
"creation": "2017-03-14 16:08:45.202761",
"currency": "",
"doc_type": "Membership",
"docstatus": 0,
"doctype": "Web Form",
"idx": 0,
"is_standard": 1,
"login_required": 1,
"max_attachment_size": 0,
"modified": "2017-03-14 18:38:07.785349",
"modified_by": "Administrator",
"module": "ERPNext Foundation",
"name": "memberships-usd",
"owner": "Administrator",
"payment_button_help": "Pay for your membership using PayPal",
"payment_button_label": "Pay Now",
"payment_gateway": "PayPal",
"published": 1,
"route": "memberships-usd",
"show_sidebar": 1,
"sidebar_items": [],
"success_url": "/memberships",
"title": "Memberships",
"web_form_fields": [
{
"fieldname": "membership_type",
"fieldtype": "Select",
"hidden": 0,
"label": "Membership Type",
"max_length": 0,
"max_value": 0,
"options": "Gold\nSilver\nIndividual",
"read_only": 0,
"reqd": 1
},
{
"fieldname": "from_date",
"fieldtype": "Date",
"hidden": 0,
"label": "From",
"max_length": 0,
"max_value": 0,
"read_only": 1,
"reqd": 1
},
{
"fieldname": "to_date",
"fieldtype": "Date",
"hidden": 0,
"label": "To",
"max_length": 0,
"max_value": 0,
"read_only": 1,
"reqd": 1
},
{
"fieldname": "currency",
"fieldtype": "Select",
"hidden": 0,
"label": "Currency",
"max_length": 0,
"max_value": 0,
"options": "USD\nINR",
"read_only": 1,
"reqd": 0
},
{
"fieldname": "amount",
"fieldtype": "Float",
"hidden": 0,
"label": "Amount",
"max_length": 0,
"max_value": 0,
"read_only": 1,
"reqd": 0
}
]
}

View File

@@ -0,0 +1,7 @@
from __future__ import unicode_literals
import frappe
def get_context(context):
# do your magic here
pass

View File

@@ -55,8 +55,7 @@ website_context = {
{"label": "Service Providers", "url": "/service-providers"},
{"label": "Jobs", "url": "/jobs"},
{"label": "Apps", "url": "/apps"},
{"label": "Events", "url": "/events"},
{"label": "Forum", "url": "https://discuss.erpnext.com", "target": "_blank"}
{"label": "Events", "url": "/events"}
]},
{"label": "ERPNext", "child_items": [
{"label": "Resources", "url": "/resources"},

View File

@@ -0,0 +1,34 @@
<div class="web-list-item membership-list-item">
<div class="row">
<div class="col-sm-3 col-xs-6">
#
</div>
<div class="col-sm-3 hidden-xs">
Membership
</div>
<div class="col-sm-3 col-xs-6">
Expires On
</div>
<div class="col-sm-3 hidden-xs">
Amount
</div>
</div>
</div>
<div class="web-list-item membership-list-item">
<div class="row">
<div class="col-sm-3 col-xs-6">
<a href="/{{ pathname }}?name={{ doc.name }}">
{{ doc.name }}
</a>
</div>
<div class="col-sm-3 hidden-xs">
{{ doc.membership_type }}
</div>
<div class="col-sm-3 col-xs-6">
{{ doc.to_date }}
</div>
<div class="col-sm-3 hidden-xs">
{{ doc.amount }}
</div>
</div>
</div>

View File

@@ -13,16 +13,16 @@
{% if not last_membership %}
<p>You have never been a member of ERPNext Foundation. Click on the button below to start a new membership</p>
<p><a href="/memberships?new=1" class='btn btn-primary'>Become A Member</a></p>
<p><a href="/members/setup_payment" class='btn btn-primary'>Become A Member</a></p>
{% elif frappe.utils.getdate(last_membership.to_date) < frappe.utils.getdate(frappe.utils.nowdate()) %}
<p>Your Membership has expired, Click the button below to start a new membership</p>
<p><a href="/memberships?new=1" class='btn btn-primary'>Renew</a></p>
<p><a href="/members/setup_payment" class='btn btn-primary'>Renew</a></p>
<p><a href="/memberships" class='text-muted'>View Membership History</a></p>
{% elif frappe.utils.getdate(frappe.utils.add_days(last_membership.to_date, -30)) < frappe.utils.getdate(frappe.utils.nowdate())%}
<p>Your Membership is due to expire soon. Click on the button below to renew</p>
<p><a href="/memberships?new=1" class='btn btn-primary'>Renew</a></p>
<p><a href="/members/setup_payment" class='btn btn-primary'>Renew</a></p>
<p><a href="/memberships" class='text-muted'>View Membership History</a></p>
{% else %}

View File

@@ -0,0 +1,24 @@
{% extends "templates/web.html" %}
{% block title %}Setup Payment Method{% endblock %}
{% block page_content %}
<section>
<input type="radio" name="gender" value="USD" checked> USD <br>
<input type="radio" name="gender" value="INR" style="margin-top: 15px;"> INR <br>
</section>
<div class="section" style="margin-top:10px;"><a class="btn btn-primary next"> Next </a></div>
<script>
frappe.ready(function() {
$('.next').on('click', function() {
if($("input[type=radio]:checked").val() == 'INR'){
window.location = '/memberships?new=1'
}
else{
window.location = '/memberships-usd?new=1'
}
})
})
</script>
{% endblock %}

View File

@@ -0,0 +1,6 @@
import frappe
import foundation
def get_context(context):
if frappe.session.user != 'Guest':
context.show_sidebar = True

View File

@@ -1,5 +1,6 @@
import frappe
no_cache = 1
def get_context(context):
context.form_dict = frappe.form_dict
context.title = 'Service Providers'