From ba740ff558c9405c189f154055a6588e997cfd4b Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Tue, 11 Feb 2020 16:27:22 +0530 Subject: [PATCH] feat: show linked Sales Invoice in Patient Appointment after booking --- .../patient_appointment.js | 26 +++++++++++++++++-- .../patient_appointment.py | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js index dde720b7d1..a332d4c6e1 100644 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js @@ -40,8 +40,30 @@ frappe.ui.form.on('Patient Appointment', { if (frm.is_new()) { frm.page.set_primary_action(__('Check Availability'), function() { + frappe.db.get_value('Healthcare Settings', {name: 'Healthcare Settings'}, 'manage_appointment_invoice_automatically', (settings) => { + if (settings.manage_appointment_invoice_automatically) { + if (!frm.doc.mode_of_payment) { + frappe.msgprint({ + title: __('Not Allowed'), + message: __('Please select a Mode of Payment first'), + indicator: 'red' + }); + } + if (!frm.doc.paid_amount) { + frappe.msgprint({ + title: __('Not Allowed'), + message: __('Please set the Paid Amount first'), + indicator: 'red' + }); + } + } + }); if (!frm.doc.patient) { - frappe.throw(__('Please select a patient first')); + frappe.msgprint({ + title: __('Not Allowed'), + message: __('Please select Patient first'), + indicator: 'red' + }); } else { check_and_set_availability(frm); } @@ -301,7 +323,7 @@ let get_prescribed_procedure = function(frm) { } else { frappe.msgprint({ title: __('Not Allowed'), - message: __('Please select Patient first') + message: __('Please select a Patient first') }); } }; diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py index 7aa41c546c..1a4b7df3c2 100755 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py @@ -103,6 +103,7 @@ def invoice_appointment(appointment_doc): sales_invoice.save(ignore_permissions=True) sales_invoice.submit() frappe.msgprint(_("Sales Invoice {0} created as paid".format(sales_invoice.name)), alert=True) + frappe.db.set_value('Patient Appointment', appointment_doc.name, 'ref_sales_invoice', sales_invoice.name) def appointment_cancel(appointment_id): appointment = frappe.get_doc("Patient Appointment", appointment_id)