{"size": 970, "ext": "js", "max_stars_repo_path": "mzmembership/mzmembership/doctype/sponsor/sponsor.js", "max_stars_repo_name": "nabeelnajeeb1/membership_", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "mzmembership/mzmembership/doctype/sponsor/sponsor.js", "max_issues_repo_name": "nabeelnajeeb1/membership_", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "mzmembership/mzmembership/doctype/sponsor/sponsor.js", "max_forks_repo_name": "nabeelnajeeb1/membership_", "max_forks_repo_forks_event_min_datetime": "2022-03-16T12:34:31.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-16T12:34:31.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 30.3125, "max_line_length": 72, "alphanum_fraction": 0.6226804124}
// Copyright (c) 2022, M20Zero and contributors
// For license information, please see license.txt
frappe.ui.form.on("Sponsor", {
	refresh: function(frm) {
		if(cur_frm.doc.docstatus == 1){
			frm.add_custom_button(__("Make Invoice"), function(){
				if(cur_frm.is_dirty()){
					frappe.msgprint("Please save the form before creating Invoice")
				}else{
					let doc = frappe.model.get_new_doc("Invoice");
					doc.date = frappe.datetime.now_date();
					doc.naming_series = "INV-.YY.-";
					doc.party_type = "Sponsor";
					doc.party = cur_frm.doc.name;
					doc.party_name = cur_frm.doc.sponsor_name;
					let child = frappe.model.get_new_doc("Invoice Item", doc, "items");
					$.extend(child, {
						"item": "",
						"qty": 1,
						"rate": 0,
						"amount": 0,
						"income_account": cur_frm.doc.income_account
					});
					doc.total_qty = 1;
					doc.total = cur_frm.doc.amount;
					frappe.set_route("FORM", doc.doctype, doc.name);
				}
			});
		}
	}
});
