mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 11:49:10 +00:00
chore: Remove unintended changes
This commit is contained in:
@@ -17,7 +17,7 @@ from erpnext.accounts.doctype.invoice_discounting.invoice_discounting import (
|
|||||||
from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import (
|
from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import (
|
||||||
get_party_tax_withholding_details,
|
get_party_tax_withholding_details,
|
||||||
)
|
)
|
||||||
from erpnext.accounts.party import get_party_account, get_party_gle_currency
|
from erpnext.accounts.party import get_party_account
|
||||||
from erpnext.accounts.utils import (
|
from erpnext.accounts.utils import (
|
||||||
get_account_currency,
|
get_account_currency,
|
||||||
get_balance_on,
|
get_balance_on,
|
||||||
@@ -333,20 +333,6 @@ class JournalEntry(AccountsController):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def validate_party_account_currency(self):
|
|
||||||
for d in self.get("accounts"):
|
|
||||||
if d.party_type in ("Customer", "Supplier"):
|
|
||||||
party_gle_currency = get_party_gle_currency(d.party_type, d.party, self.company)
|
|
||||||
party_account_currency = get_account_currency(d.account)
|
|
||||||
party_currency = frappe.db.get_value(d.party_type, d.party, "default_currency")
|
|
||||||
|
|
||||||
if not party_gle_currency and (party_account_currency != party_currency):
|
|
||||||
frappe.throw(
|
|
||||||
_("Party Account {0} currency and default party currency should be same").format(
|
|
||||||
frappe.bold(d.account)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def check_credit_limit(self):
|
def check_credit_limit(self):
|
||||||
customers = list(
|
customers = list(
|
||||||
set(
|
set(
|
||||||
|
|||||||
@@ -163,14 +163,8 @@ def create_sales_invoice():
|
|||||||
sales_invoice.patient = patient
|
sales_invoice.patient = patient
|
||||||
sales_invoice.customer = frappe.db.get_value("Patient", patient, "customer")
|
sales_invoice.customer = frappe.db.get_value("Patient", patient, "customer")
|
||||||
sales_invoice.due_date = getdate()
|
sales_invoice.due_date = getdate()
|
||||||
<<<<<<< HEAD
|
|
||||||
sales_invoice.company = "_Test Company"
|
sales_invoice.company = "_Test Company"
|
||||||
sales_invoice.debit_to = get_receivable_account("_Test Company")
|
sales_invoice.debit_to = get_receivable_account("_Test Company")
|
||||||
=======
|
|
||||||
sales_invoice.company = '_Test Company'
|
|
||||||
sales_invoice.currency = 'INR'
|
|
||||||
sales_invoice.debit_to = get_receivable_account('_Test Company')
|
|
||||||
>>>>>>> bcaf475295 (fix: Healthcare module accounting test cases)
|
|
||||||
|
|
||||||
tests = [insulin_resistance_template, blood_test_template]
|
tests = [insulin_resistance_template, blood_test_template]
|
||||||
for entry in tests:
|
for entry in tests:
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ from frappe.model.document import Document
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from frappe.utils import flt, get_link_to_form, get_time, getdate
|
from frappe.utils import flt, get_link_to_form, get_time, getdate
|
||||||
|
|
||||||
from erpnext import get_company_currency
|
|
||||||
from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import (
|
from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import (
|
||||||
get_income_account,
|
get_income_account,
|
||||||
get_receivable_account,
|
get_receivable_account,
|
||||||
@@ -252,12 +251,7 @@ def invoice_appointment(appointment_doc):
|
|||||||
def create_sales_invoice(appointment_doc):
|
def create_sales_invoice(appointment_doc):
|
||||||
sales_invoice = frappe.new_doc("Sales Invoice")
|
sales_invoice = frappe.new_doc("Sales Invoice")
|
||||||
sales_invoice.patient = appointment_doc.patient
|
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.currency = frappe.get_value(
|
|
||||||
"Customer", sales_invoice.customer, "default_currency"
|
|
||||||
) or get_company_currency(appointment_doc.currency)
|
|
||||||
|
|
||||||
sales_invoice.appointment = appointment_doc.name
|
sales_invoice.appointment = appointment_doc.name
|
||||||
sales_invoice.due_date = getdate()
|
sales_invoice.due_date = getdate()
|
||||||
sales_invoice.company = appointment_doc.company
|
sales_invoice.company = appointment_doc.company
|
||||||
|
|||||||
@@ -235,43 +235,185 @@ class TestPatientAppointment(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
ip_record1 = frappe.get_doc("Inpatient Record", ip_record.name)
|
ip_record1 = frappe.get_doc("Inpatient Record", ip_record.name)
|
||||||
mark_invoiced_inpatient_occupancy(ip_record1)
|
mark_invoiced_inpatient_occupancy(ip_record1)
|
||||||
discharge_patient(ip_record1)
|
discharge_patient(ip_record1, now_datetime())
|
||||||
|
|
||||||
|
def test_payment_should_be_mandatory_for_new_patient_appointment(self):
|
||||||
|
frappe.db.set_value("Healthcare Settings", None, "enable_free_follow_ups", 1)
|
||||||
|
frappe.db.set_value("Healthcare Settings", None, "automate_appointment_invoicing", 1)
|
||||||
|
frappe.db.set_value("Healthcare Settings", None, "max_visits", 3)
|
||||||
|
frappe.db.set_value("Healthcare Settings", None, "valid_days", 30)
|
||||||
|
|
||||||
|
patient = create_patient()
|
||||||
|
assert check_is_new_patient(patient)
|
||||||
|
payment_required = check_payment_fields_reqd(patient)
|
||||||
|
assert payment_required is True
|
||||||
|
|
||||||
|
def test_sales_invoice_should_be_generated_for_new_patient_appointment(self):
|
||||||
|
patient, practitioner = create_healthcare_docs()
|
||||||
|
frappe.db.set_value("Healthcare Settings", None, "automate_appointment_invoicing", 1)
|
||||||
|
invoice_count = frappe.db.count("Sales Invoice")
|
||||||
|
|
||||||
|
assert check_is_new_patient(patient)
|
||||||
|
create_appointment(patient, practitioner, nowdate())
|
||||||
|
new_invoice_count = frappe.db.count("Sales Invoice")
|
||||||
|
|
||||||
|
assert new_invoice_count == invoice_count + 1
|
||||||
|
|
||||||
|
def test_overlap_appointment(self):
|
||||||
|
from erpnext.healthcare.doctype.patient_appointment.patient_appointment import OverlapError
|
||||||
|
|
||||||
|
patient, practitioner = create_healthcare_docs(id=1)
|
||||||
|
patient_1, practitioner_1 = create_healthcare_docs(id=2)
|
||||||
|
service_unit = create_service_unit(id=0)
|
||||||
|
service_unit_1 = create_service_unit(id=1)
|
||||||
|
appointment = create_appointment(
|
||||||
|
patient, practitioner, nowdate(), service_unit=service_unit
|
||||||
|
) # valid
|
||||||
|
|
||||||
|
# patient and practitioner cannot have overlapping appointments
|
||||||
|
appointment = create_appointment(
|
||||||
|
patient, practitioner, nowdate(), service_unit=service_unit, save=0
|
||||||
|
)
|
||||||
|
self.assertRaises(OverlapError, appointment.save)
|
||||||
|
appointment = create_appointment(
|
||||||
|
patient, practitioner, nowdate(), service_unit=service_unit_1, save=0
|
||||||
|
) # diff service unit
|
||||||
|
self.assertRaises(OverlapError, appointment.save)
|
||||||
|
appointment = create_appointment(
|
||||||
|
patient, practitioner, nowdate(), save=0
|
||||||
|
) # with no service unit link
|
||||||
|
self.assertRaises(OverlapError, appointment.save)
|
||||||
|
|
||||||
|
# patient cannot have overlapping appointments with other practitioners
|
||||||
|
appointment = create_appointment(
|
||||||
|
patient, practitioner_1, nowdate(), service_unit=service_unit, save=0
|
||||||
|
)
|
||||||
|
self.assertRaises(OverlapError, appointment.save)
|
||||||
|
appointment = create_appointment(
|
||||||
|
patient, practitioner_1, nowdate(), service_unit=service_unit_1, save=0
|
||||||
|
)
|
||||||
|
self.assertRaises(OverlapError, appointment.save)
|
||||||
|
appointment = create_appointment(patient, practitioner_1, nowdate(), save=0)
|
||||||
|
self.assertRaises(OverlapError, appointment.save)
|
||||||
|
|
||||||
|
# practitioner cannot have overlapping appointments with other patients
|
||||||
|
appointment = create_appointment(
|
||||||
|
patient_1, practitioner, nowdate(), service_unit=service_unit, save=0
|
||||||
|
)
|
||||||
|
self.assertRaises(OverlapError, appointment.save)
|
||||||
|
appointment = create_appointment(
|
||||||
|
patient_1, practitioner, nowdate(), service_unit=service_unit_1, save=0
|
||||||
|
)
|
||||||
|
self.assertRaises(OverlapError, appointment.save)
|
||||||
|
appointment = create_appointment(patient_1, practitioner, nowdate(), save=0)
|
||||||
|
self.assertRaises(OverlapError, appointment.save)
|
||||||
|
|
||||||
|
def test_service_unit_capacity(self):
|
||||||
|
from erpnext.healthcare.doctype.patient_appointment.patient_appointment import (
|
||||||
|
MaximumCapacityError,
|
||||||
|
OverlapError,
|
||||||
|
)
|
||||||
|
|
||||||
|
practitioner = create_practitioner()
|
||||||
|
capacity = 3
|
||||||
|
overlap_service_unit_type = create_service_unit_type(
|
||||||
|
id=10, allow_appointments=1, overlap_appointments=1
|
||||||
|
)
|
||||||
|
overlap_service_unit = create_service_unit(
|
||||||
|
id=100, service_unit_type=overlap_service_unit_type, service_unit_capacity=capacity
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in range(0, capacity):
|
||||||
|
patient = create_patient(id=i)
|
||||||
|
create_appointment(patient, practitioner, nowdate(), service_unit=overlap_service_unit) # valid
|
||||||
|
appointment = create_appointment(
|
||||||
|
patient, practitioner, nowdate(), service_unit=overlap_service_unit, save=0
|
||||||
|
) # overlap
|
||||||
|
self.assertRaises(OverlapError, appointment.save)
|
||||||
|
|
||||||
|
patient = create_patient(id=capacity)
|
||||||
|
appointment = create_appointment(
|
||||||
|
patient, practitioner, nowdate(), service_unit=overlap_service_unit, save=0
|
||||||
|
)
|
||||||
|
self.assertRaises(MaximumCapacityError, appointment.save)
|
||||||
|
|
||||||
|
def test_patient_appointment_should_consider_permissions_while_fetching_appointments(self):
|
||||||
|
patient, practitioner = create_healthcare_docs()
|
||||||
|
create_appointment(patient, practitioner, nowdate())
|
||||||
|
|
||||||
|
patient, new_practitioner = create_healthcare_docs(id=2)
|
||||||
|
create_appointment(patient, new_practitioner, nowdate())
|
||||||
|
|
||||||
|
roles = [{"doctype": "Has Role", "role": "Physician"}]
|
||||||
|
user = create_user(roles=roles)
|
||||||
|
new_practitioner = frappe.get_doc("Healthcare Practitioner", new_practitioner)
|
||||||
|
new_practitioner.user_id = user.email
|
||||||
|
new_practitioner.save()
|
||||||
|
|
||||||
|
frappe.set_user(user.name)
|
||||||
|
appointments = frappe.get_list("Patient Appointment")
|
||||||
|
assert len(appointments) == 1
|
||||||
|
|
||||||
|
frappe.set_user("Administrator")
|
||||||
|
appointments = frappe.get_list("Patient Appointment")
|
||||||
|
assert len(appointments) == 2
|
||||||
|
|
||||||
|
|
||||||
def create_healthcare_docs():
|
def create_healthcare_docs(id=0):
|
||||||
patient = create_patient()
|
patient = create_patient(id)
|
||||||
practitioner = frappe.db.exists("Healthcare Practitioner", "_Test Healthcare Practitioner")
|
practitioner = create_practitioner(id)
|
||||||
medical_department = frappe.db.exists("Medical Department", "_Test Medical Department")
|
|
||||||
|
|
||||||
if not medical_department:
|
return patient, practitioner
|
||||||
medical_department = frappe.new_doc("Medical Department")
|
|
||||||
medical_department.department = "_Test Medical Department"
|
|
||||||
medical_department.save(ignore_permissions=True)
|
|
||||||
medical_department = medical_department.name
|
|
||||||
|
|
||||||
if not practitioner:
|
|
||||||
practitioner = frappe.new_doc("Healthcare Practitioner")
|
|
||||||
practitioner.first_name = "_Test Healthcare Practitioner"
|
|
||||||
practitioner.gender = "Female"
|
|
||||||
practitioner.department = medical_department
|
|
||||||
practitioner.op_consulting_charge = 500
|
|
||||||
practitioner.inpatient_visit_charge = 500
|
|
||||||
practitioner.save(ignore_permissions=True)
|
|
||||||
practitioner = practitioner.name
|
|
||||||
|
|
||||||
return patient, medical_department, practitioner
|
|
||||||
|
|
||||||
|
|
||||||
def create_patient():
|
def create_patient(
|
||||||
patient = frappe.db.exists("Patient", "_Test Patient")
|
id=0, patient_name=None, email=None, mobile=None, customer=None, create_user=False
|
||||||
if not patient:
|
):
|
||||||
patient = frappe.new_doc("Patient")
|
if frappe.db.exists("Patient", {"firstname": f"_Test Patient {str(id)}"}):
|
||||||
patient.first_name = "_Test Patient"
|
patient = frappe.db.get_value("Patient", {"first_name": f"_Test Patient {str(id)}"}, ["name"])
|
||||||
patient.sex = "Female"
|
return patient
|
||||||
patient.default_currency = "INR"
|
|
||||||
patient.save(ignore_permissions=True)
|
patient = frappe.new_doc("Patient")
|
||||||
patient = patient.name
|
patient.first_name = patient_name if patient_name else f"_Test Patient {str(id)}"
|
||||||
return patient
|
patient.sex = "Female"
|
||||||
|
patient.mobile = mobile
|
||||||
|
patient.email = email
|
||||||
|
patient.customer = customer
|
||||||
|
patient.invite_user = create_user
|
||||||
|
patient.save(ignore_permissions=True)
|
||||||
|
|
||||||
|
return patient.name
|
||||||
|
|
||||||
|
|
||||||
|
def create_medical_department(id=0):
|
||||||
|
if frappe.db.exists("Medical Department", f"_Test Medical Department {str(id)}"):
|
||||||
|
return f"_Test Medical Department {str(id)}"
|
||||||
|
|
||||||
|
medical_department = frappe.new_doc("Medical Department")
|
||||||
|
medical_department.department = f"_Test Medical Department {str(id)}"
|
||||||
|
medical_department.save(ignore_permissions=True)
|
||||||
|
|
||||||
|
return medical_department.name
|
||||||
|
|
||||||
|
|
||||||
|
def create_practitioner(id=0, medical_department=None):
|
||||||
|
if frappe.db.exists(
|
||||||
|
"Healthcare Practitioner", {"firstname": f"_Test Healthcare Practitioner {str(id)}"}
|
||||||
|
):
|
||||||
|
practitioner = frappe.db.get_value(
|
||||||
|
"Healthcare Practitioner", {"firstname": f"_Test Healthcare Practitioner {str(id)}"}, ["name"]
|
||||||
|
)
|
||||||
|
return practitioner
|
||||||
|
|
||||||
|
practitioner = frappe.new_doc("Healthcare Practitioner")
|
||||||
|
practitioner.first_name = f"_Test Healthcare Practitioner {str(id)}"
|
||||||
|
practitioner.gender = "Female"
|
||||||
|
practitioner.department = medical_department or create_medical_department(id)
|
||||||
|
practitioner.op_consulting_charge = 500
|
||||||
|
practitioner.inpatient_visit_charge = 500
|
||||||
|
practitioner.save(ignore_permissions=True)
|
||||||
|
|
||||||
|
return practitioner.name
|
||||||
|
|
||||||
|
|
||||||
def create_encounter(appointment):
|
def create_encounter(appointment):
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import frappe
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
|
|
||||||
from erpnext import get_company_currency
|
|
||||||
|
|
||||||
|
|
||||||
class TherapyPlan(Document):
|
class TherapyPlan(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@@ -74,9 +72,6 @@ def make_sales_invoice(reference_name, patient, company, therapy_plan_template):
|
|||||||
si.company = company
|
si.company = company
|
||||||
si.patient = patient
|
si.patient = patient
|
||||||
si.customer = frappe.db.get_value("Patient", patient, "customer")
|
si.customer = frappe.db.get_value("Patient", patient, "customer")
|
||||||
si.currency = frappe.get_value(
|
|
||||||
"Customer", si.customer, "default_currency"
|
|
||||||
) or get_company_currency(si.company)
|
|
||||||
|
|
||||||
item = frappe.db.get_value("Therapy Plan Template", therapy_plan_template, "linked_item")
|
item = frappe.db.get_value("Therapy Plan Template", therapy_plan_template, "linked_item")
|
||||||
price_list, price_list_currency = frappe.db.get_values(
|
price_list, price_list_currency = frappe.db.get_values(
|
||||||
|
|||||||
Reference in New Issue
Block a user