[fix] fetch expiary date from membership to member doctype
This commit is contained in:
parent
0dbf00a283
commit
5a4611df95
@ -28,5 +28,18 @@ frappe.ui.form.on('Member', {
|
||||
frappe.contacts.clear_address_and_contact(frm);
|
||||
}
|
||||
|
||||
frappe.call({
|
||||
method:"frappe.client.get_value",
|
||||
args:{
|
||||
'doctype':"Membership",
|
||||
'filters':{'member': frm.doc.name},
|
||||
'fieldname':[
|
||||
'to_date'
|
||||
]
|
||||
},
|
||||
callback: function (data) {
|
||||
frappe.model.set_value(frm.doctype,frm.docname, "expires_on", data.message.to_date);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -19,6 +19,7 @@ class Membership(Document):
|
||||
member = frappe.get_doc(dict(
|
||||
doctype='Member',
|
||||
email=frappe.session.user,
|
||||
membership_type=self.membership_type,
|
||||
member_name=user.get_fullname()
|
||||
)).insert(ignore_permissions=True)
|
||||
member_name = member.name
|
||||
@ -29,12 +30,15 @@ class Membership(Document):
|
||||
# get last membership (if active)
|
||||
last_membership = erpnext.get_last_membership()
|
||||
|
||||
if last_membership:
|
||||
# if person applied for offline membership
|
||||
if last_membership and not frappe.session.user == "Administrator":
|
||||
# if last membership does not expire in 30 days, then do not allow to renew
|
||||
if getdate(add_days(last_membership.to_date, -30)) > getdate(nowdate()):
|
||||
if getdate(add_days(last_membership.to_date, -30)) > getdate(nowdate()) :
|
||||
frappe.throw(_('You can only renew if your membership expires within 30 days'))
|
||||
|
||||
self.from_date = add_days(last_membership.to_date, 1)
|
||||
elif frappe.session.user == "Administrator":
|
||||
self.from_date = self.from_date
|
||||
else:
|
||||
self.from_date = nowdate()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user