fix: membership renewal validation (#24963)

This commit is contained in:
Rucha Mahabal 2021-03-20 22:22:01 +05:30
parent 146cbb10f8
commit a54eecb230

View File

@ -48,7 +48,7 @@ class Membership(Document):
last_membership = erpnext.get_last_membership(self.member)
# if person applied for offline membership
if last_membership and last_membership != self.name and not frappe.session.user == "Administrator":
if last_membership and last_membership.name != self.name 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()) :
frappe.throw(_("You can only renew if your membership expires within 30 days"))
@ -90,6 +90,7 @@ class Membership(Document):
self.validate_membership_type_and_settings(plan, settings)
invoice = make_invoice(self, member, plan, settings)
self.reload()
self.invoice = invoice.name
if with_payment_entry:
@ -284,6 +285,7 @@ def trigger_razorpay_subscription(*args, **kwargs):
settings = frappe.get_doc("Non Profit Settings")
if settings.allow_invoicing and settings.automate_membership_invoicing:
membership.reload()
membership.generate_invoice(with_payment_entry=settings.automate_membership_payment_entries, save=True)
except Exception as e: