feat: generate invoice on payment authorized

This commit is contained in:
Shivam Mishra 2020-11-04 20:17:33 +05:30
parent e927224fbc
commit d75ff1a93e
2 changed files with 17 additions and 4 deletions

View File

@ -54,9 +54,14 @@ class Membership(Document):
self.to_date = add_months(self.from_date, 1)
def on_payment_authorized(self, status_changed_to=None):
if status_changed_to in ("Completed", "Authorized"):
self.load_from_db()
self.db_set('paid', 1)
if status_changed_to not in ("Completed", "Authorized"):
return
self.load_from_db()
self.db_set('paid', 1)
settings = frappe.get_doc("Membership Settings")
if settings.enable_invoicing and settings.create_for_web_forms:
self.generate_invoice(with_payment_entry=settings.make_payment_entry, save=True)
def generate_invoice(self, save=True):
if not (self.paid or self.currency or self.amount):

View File

@ -12,6 +12,7 @@
"webhook_secret",
"column_break_6",
"enable_invoicing",
"create_for_web_forms",
"make_payment_entry",
"company",
"debit_account",
@ -136,12 +137,19 @@
"label": "Payment To",
"mandatory_depends_on": "eval:doc.make_payment_entry",
"options": "Account"
},
{
"depends_on": "eval:doc.enable_invoicing",
"description": "Automatically create an invoice when payment is authorized from a web form entry",
"fieldname": "create_for_web_forms",
"fieldtype": "Data",
"label": "Auto Create Invoice for Web Forms"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2020-11-04 19:51:21.990595",
"modified": "2020-11-04 20:19:55.163749",
"modified_by": "Administrator",
"module": "Non Profit",
"name": "Membership Settings",