mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 19:59:12 +00:00
fix: Fee Validity test
This commit is contained in:
@@ -6,7 +6,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
from frappe.utils import nowdate, add_days
|
from frappe.utils import nowdate, add_days
|
||||||
from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import create_healthcare_docs, create_appointment
|
from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import create_healthcare_docs, create_appointment, create_healthcare_service_items
|
||||||
|
|
||||||
test_dependencies = ["Company"]
|
test_dependencies = ["Company"]
|
||||||
|
|
||||||
@@ -14,10 +14,20 @@ class TestFeeValidity(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
frappe.db.sql("""delete from `tabPatient Appointment`""")
|
frappe.db.sql("""delete from `tabPatient Appointment`""")
|
||||||
frappe.db.sql("""delete from `tabFee Validity`""")
|
frappe.db.sql("""delete from `tabFee Validity`""")
|
||||||
|
frappe.db.sql("""delete from `tabPatient`""")
|
||||||
|
|
||||||
def test_fee_validity(self):
|
def test_fee_validity(self):
|
||||||
|
item = create_healthcare_service_items()
|
||||||
|
healthcare_settings = frappe.get_single("Healthcare Settings")
|
||||||
|
healthcare_settings.enable_free_follow_ups = 1
|
||||||
|
healthcare_settings.max_visits = 2
|
||||||
|
healthcare_settings.valid_days = 7
|
||||||
|
healthcare_settings.automate_appointment_invoicing = 1
|
||||||
|
healthcare_settings.op_consulting_charge_item = item
|
||||||
|
healthcare_settings.save(ignore_permissions=True)
|
||||||
patient, medical_department, practitioner = create_healthcare_docs()
|
patient, medical_department, practitioner = create_healthcare_docs()
|
||||||
# appointment should not be invoiced as it is within fee validity
|
|
||||||
|
# appointment should not be invoiced. Check Fee Validity created for new patient
|
||||||
appointment = create_appointment(patient, practitioner, nowdate())
|
appointment = create_appointment(patient, practitioner, nowdate())
|
||||||
invoiced = frappe.db.get_value("Patient Appointment", appointment.name, "invoiced")
|
invoiced = frappe.db.get_value("Patient Appointment", appointment.name, "invoiced")
|
||||||
self.assertEqual(invoiced, 0)
|
self.assertEqual(invoiced, 0)
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ class PatientAppointment(Document):
|
|||||||
|
|
||||||
def after_insert(self):
|
def after_insert(self):
|
||||||
self.update_prescription_details()
|
self.update_prescription_details()
|
||||||
self.update_fee_validity()
|
|
||||||
invoice_appointment(self)
|
invoice_appointment(self)
|
||||||
|
self.update_fee_validity()
|
||||||
send_confirmation_msg(self)
|
send_confirmation_msg(self)
|
||||||
|
|
||||||
def set_status(self):
|
def set_status(self):
|
||||||
@@ -107,7 +107,7 @@ def invoice_appointment(appointment_doc):
|
|||||||
enable_free_follow_ups = frappe.db.get_single_value('Healthcare Settings', 'enable_free_follow_ups')
|
enable_free_follow_ups = frappe.db.get_single_value('Healthcare Settings', 'enable_free_follow_ups')
|
||||||
if enable_free_follow_ups:
|
if enable_free_follow_ups:
|
||||||
fee_validity = check_fee_validity(appointment_doc)
|
fee_validity = check_fee_validity(appointment_doc)
|
||||||
if fee_validity.status == 'Completed':
|
if fee_validity and fee_validity.status == 'Completed':
|
||||||
fee_validity = None
|
fee_validity = None
|
||||||
elif not fee_validity:
|
elif not fee_validity:
|
||||||
if frappe.db.exists('Fee Validity Reference', {'appointment': appointment_doc.name}):
|
if frappe.db.exists('Fee Validity Reference', {'appointment': appointment_doc.name}):
|
||||||
|
|||||||
Reference in New Issue
Block a user