feat(breaking): update get_last_membership to fetch correct details

This commit is contained in:
Shivam Mishra 2020-11-09 14:01:11 +05:30
parent c04321e645
commit 7e1cdf9b97
2 changed files with 5 additions and 11 deletions

View File

@ -132,16 +132,10 @@ def allow_regional(fn):
return caller
def get_last_membership():
def get_last_membership(member):
'''Returns last membership if exists'''
last_membership = frappe.get_all('Membership', 'name,to_date,membership_type',
dict(member=frappe.session.user, paid=1), order_by='to_date desc', limit=1)
dict(member=member, paid=1), order_by='to_date desc', limit=1)
return last_membership and last_membership[0]
def is_member():
'''Returns true if the user is still a member'''
last_membership = get_last_membership()
if last_membership and getdate(last_membership.to_date) > getdate():
return True
return False
if last_membership:
return last_membership[0]

View File

@ -34,7 +34,7 @@ class Membership(Document):
self.member = member_name
# get last membership (if active)
last_membership = erpnext.get_last_membership()
last_membership = erpnext.get_last_membership(self.member)
# if person applied for offline membership
if last_membership and not frappe.session.user == "Administrator":