fix: set patient while billing, tests fixed
This commit is contained in:
parent
7ea8623229
commit
79b01838c3
@ -119,6 +119,7 @@ def invoice_appointment(appointment_doc):
|
|||||||
|
|
||||||
if automate_invoicing and not appointment_invoiced and not fee_validity:
|
if automate_invoicing and not appointment_invoiced and not fee_validity:
|
||||||
sales_invoice = frappe.new_doc('Sales Invoice')
|
sales_invoice = frappe.new_doc('Sales Invoice')
|
||||||
|
sales_invoice.patient = appointment_doc.patient
|
||||||
sales_invoice.customer = frappe.get_value('Patient', appointment_doc.patient, 'customer')
|
sales_invoice.customer = frappe.get_value('Patient', appointment_doc.patient, 'customer')
|
||||||
sales_invoice.appointment = appointment_doc.name
|
sales_invoice.appointment = appointment_doc.name
|
||||||
sales_invoice.due_date = getdate()
|
sales_invoice.due_date = getdate()
|
||||||
@ -339,7 +340,6 @@ def make_encounter(source_name, target_doc=None):
|
|||||||
['practitioner', 'practitioner'],
|
['practitioner', 'practitioner'],
|
||||||
['medical_department', 'department'],
|
['medical_department', 'department'],
|
||||||
['patient_sex', 'patient_sex'],
|
['patient_sex', 'patient_sex'],
|
||||||
['encounter_date', 'appointment_date'],
|
|
||||||
['invoiced', 'invoiced'],
|
['invoiced', 'invoiced'],
|
||||||
['company', 'company']
|
['company', 'company']
|
||||||
]
|
]
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import unittest
|
import unittest
|
||||||
import frappe
|
import frappe
|
||||||
from erpnext.healthcare.doctype.patient_appointment.patient_appointment import update_status
|
from erpnext.healthcare.doctype.patient_appointment.patient_appointment import update_status, make_encounter
|
||||||
from frappe.utils import nowdate, add_days
|
from frappe.utils import nowdate, add_days
|
||||||
from frappe.utils.make_random import get_random
|
from frappe.utils.make_random import get_random
|
||||||
|
|
||||||
@ -23,6 +23,14 @@ class TestPatientAppointment(unittest.TestCase):
|
|||||||
create_encounter(appointment)
|
create_encounter(appointment)
|
||||||
self.assertEquals(frappe.db.get_value('Patient Appointment', appointment.name, 'status'), 'Closed')
|
self.assertEquals(frappe.db.get_value('Patient Appointment', appointment.name, 'status'), 'Closed')
|
||||||
|
|
||||||
|
def test_start_encounter(self):
|
||||||
|
patient, medical_department, practitioner = create_healthcare_docs()
|
||||||
|
appointment = create_appointment(patient, practitioner, add_days(nowdate(), 3))
|
||||||
|
encounter = create_encounter(appointment)
|
||||||
|
self.assertEquals(frappe.db.get_value('Patient Encounter', encounter.name, 'company'), appointment.company)
|
||||||
|
self.assertEquals(frappe.db.get_value('Patient Encounter', encounter.name, 'practitioner'), appointment.practitioner)
|
||||||
|
self.assertEquals(frappe.db.get_value('Patient Encounter', encounter.name, 'patient'), appointment.patient)
|
||||||
|
|
||||||
def test_invoicing(self):
|
def test_invoicing(self):
|
||||||
patient, medical_department, practitioner = create_healthcare_docs()
|
patient, medical_department, practitioner = create_healthcare_docs()
|
||||||
frappe.db.set_value('Healthcare Settings', None, 'enable_free_follow_ups', 0)
|
frappe.db.set_value('Healthcare Settings', None, 'enable_free_follow_ups', 0)
|
||||||
@ -33,7 +41,11 @@ class TestPatientAppointment(unittest.TestCase):
|
|||||||
frappe.db.set_value('Healthcare Settings', None, 'automate_appointment_invoicing', 1)
|
frappe.db.set_value('Healthcare Settings', None, 'automate_appointment_invoicing', 1)
|
||||||
appointment = create_appointment(patient, practitioner, add_days(nowdate(), 2), invoice=1)
|
appointment = create_appointment(patient, practitioner, add_days(nowdate(), 2), invoice=1)
|
||||||
self.assertEqual(frappe.db.get_value('Patient Appointment', appointment.name, 'invoiced'), 1)
|
self.assertEqual(frappe.db.get_value('Patient Appointment', appointment.name, 'invoiced'), 1)
|
||||||
self.assertTrue(frappe.db.get_value('Patient Appointment', appointment.name, 'ref_sales_invoice'))
|
sales_invoice_name = frappe.db.get_value('Sales Invoice Item', {'reference_dn': appointment.name}, 'parent')
|
||||||
|
self.assertTrue(sales_invoice_name)
|
||||||
|
self.assertEqual(frappe.db.get_value('Sales Invoice', sales_invoice_name, 'company'), appointment.company)
|
||||||
|
self.assertEqual(frappe.db.get_value('Sales Invoice', sales_invoice_name, 'patient'), appointment.patient)
|
||||||
|
self.assertEqual(frappe.db.get_value('Sales Invoice', sales_invoice_name, 'paid_amount'), appointment.paid_amount)
|
||||||
|
|
||||||
def test_appointment_cancel(self):
|
def test_appointment_cancel(self):
|
||||||
patient, medical_department, practitioner = create_healthcare_docs()
|
patient, medical_department, practitioner = create_healthcare_docs()
|
||||||
@ -53,8 +65,8 @@ class TestPatientAppointment(unittest.TestCase):
|
|||||||
appointment = create_appointment(patient, practitioner, nowdate(), invoice=1)
|
appointment = create_appointment(patient, practitioner, nowdate(), invoice=1)
|
||||||
update_status(appointment.name, 'Cancelled')
|
update_status(appointment.name, 'Cancelled')
|
||||||
# check invoice cancelled
|
# check invoice cancelled
|
||||||
sales_invoice = frappe.db.get_value('Patient Appointment', appointment.name, 'ref_sales_invoice')
|
sales_invoice_name = frappe.db.get_value('Sales Invoice Item', {'reference_dn': appointment.name}, 'parent')
|
||||||
self.assertEqual(frappe.db.get_value('Sales Invoice', sales_invoice, 'status'), 'Cancelled')
|
self.assertEqual(frappe.db.get_value('Sales Invoice', sales_invoice_name, 'status'), 'Cancelled')
|
||||||
|
|
||||||
|
|
||||||
def create_healthcare_docs():
|
def create_healthcare_docs():
|
||||||
@ -90,14 +102,9 @@ def create_patient():
|
|||||||
patient = patient.name
|
patient = patient.name
|
||||||
return patient
|
return patient
|
||||||
|
|
||||||
def create_encounter(appointment=None):
|
def create_encounter(appointment):
|
||||||
encounter = frappe.new_doc('Patient Encounter')
|
|
||||||
if appointment:
|
if appointment:
|
||||||
encounter.appointment = appointment.name
|
encounter = make_encounter(appointment.name)
|
||||||
encounter.patient = appointment.patient
|
|
||||||
encounter.practitioner = appointment.practitioner
|
|
||||||
encounter.encounter_date = appointment.appointment_date
|
|
||||||
encounter.encounter_time = appointment.appointment_time
|
|
||||||
encounter.save()
|
encounter.save()
|
||||||
encounter.submit()
|
encounter.submit()
|
||||||
return encounter
|
return encounter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user