fix: set fee validity start date and set status as Completed or Pending
This commit is contained in:
parent
2f2c09bd98
commit
f2574dde37
@ -75,7 +75,7 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Status",
|
"label": "Status",
|
||||||
"options": "Ongoing\nCompleted\nExpired",
|
"options": "Completed\nPending",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -98,7 +98,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-03-14 21:42:40.766973",
|
"modified": "2020-03-17 18:29:01.163961",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Healthcare",
|
"module": "Healthcare",
|
||||||
"name": "Fee Validity",
|
"name": "Fee Validity",
|
||||||
|
@ -11,17 +11,23 @@ import datetime
|
|||||||
class FeeValidity(Document):
|
class FeeValidity(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.update_status()
|
self.update_status()
|
||||||
|
self.set_start_date()
|
||||||
|
|
||||||
def update_status(self):
|
def update_status(self):
|
||||||
valid_till = getdate(self.valid_till)
|
valid_till = getdate(self.valid_till)
|
||||||
today = getdate()
|
start_date = getdate(self.start_date)
|
||||||
if self.visited >= self.max_visits:
|
if self.visited >= self.max_visits:
|
||||||
self.status = 'Completed'
|
self.status = 'Completed'
|
||||||
elif self.visited < self.max_visits:
|
else:
|
||||||
if valid_till >= today:
|
self.status = 'Pending'
|
||||||
self.status = 'Ongoing'
|
|
||||||
elif valid_till < today:
|
def set_start_date(self):
|
||||||
self.status = 'Expired'
|
self.start_date = getdate()
|
||||||
|
for appointment in self.ref_appointments:
|
||||||
|
appointment_date = frappe.db.get_value('Patient Appointment', appointment.appointment, 'appointment_date')
|
||||||
|
if getdate(appointment_date) < self.start_date:
|
||||||
|
self.start_date = getdate(appointment_date)
|
||||||
|
|
||||||
|
|
||||||
def create_fee_validity(appointment):
|
def create_fee_validity(appointment):
|
||||||
fee_validity = frappe.new_doc('Fee Validity')
|
fee_validity = frappe.new_doc('Fee Validity')
|
||||||
@ -36,8 +42,3 @@ def create_fee_validity(appointment):
|
|||||||
})
|
})
|
||||||
fee_validity.save(ignore_permissions=True)
|
fee_validity.save(ignore_permissions=True)
|
||||||
return fee_validity
|
return fee_validity
|
||||||
|
|
||||||
def update_validity_status():
|
|
||||||
docs = frappe.get_all('Fee Validity', filters={'status': ['not in', ['Completed', 'Expired']]})
|
|
||||||
for doc in docs:
|
|
||||||
frappe.get_doc("Task", doc.name).update_status()
|
|
||||||
|
@ -95,7 +95,7 @@ def check_payment_fields_reqd(patient):
|
|||||||
free_follow_ups = frappe.db.get_single_value('Healthcare Settings', 'enable_free_follow_ups')
|
free_follow_ups = frappe.db.get_single_value('Healthcare Settings', 'enable_free_follow_ups')
|
||||||
if automate_invoicing:
|
if automate_invoicing:
|
||||||
if free_follow_ups:
|
if free_follow_ups:
|
||||||
fee_validity = frappe.db.exists('Fee Validity', {'patient': patient, 'status': 'Ongoing'})
|
fee_validity = frappe.db.exists('Fee Validity', {'patient': patient, 'status': 'Pending'})
|
||||||
if fee_validity:
|
if fee_validity:
|
||||||
return {'fee_validity': fee_validity}
|
return {'fee_validity': fee_validity}
|
||||||
return True
|
return True
|
||||||
|
@ -42,6 +42,9 @@ def validate_customer_created(patient):
|
|||||||
frappe.throw(msg, title=_('Customer Not Found'))
|
frappe.throw(msg, title=_('Customer Not Found'))
|
||||||
|
|
||||||
def get_fee_validity(patient_appointments):
|
def get_fee_validity(patient_appointments):
|
||||||
|
if not frappe.db.get_single_value('Healthcare Settings', 'enable_free_follow_ups'):
|
||||||
|
return
|
||||||
|
|
||||||
fee_validity_details = []
|
fee_validity_details = []
|
||||||
items_to_invoice = []
|
items_to_invoice = []
|
||||||
valid_days = frappe.db.get_single_value('Healthcare Settings', 'valid_days')
|
valid_days = frappe.db.get_single_value('Healthcare Settings', 'valid_days')
|
||||||
@ -346,18 +349,21 @@ def manage_prescriptions(invoiced, ref_dt, ref_dn, dt, created_check_field):
|
|||||||
|
|
||||||
|
|
||||||
def check_fee_validity(appointment):
|
def check_fee_validity(appointment):
|
||||||
|
if not frappe.db.get_single_value('Healthcare Settings', 'enable_free_follow_ups'):
|
||||||
|
return
|
||||||
|
|
||||||
validity = frappe.db.exists('Fee Validity', {
|
validity = frappe.db.exists('Fee Validity', {
|
||||||
'practitioner': appointment.practitioner,
|
'practitioner': appointment.practitioner,
|
||||||
'patient': appointment.patient,
|
'patient': appointment.patient,
|
||||||
'status': 'Ongoing'
|
'status': 'Pending',
|
||||||
|
'valid_till': ('>=', appointment.appointment_date)
|
||||||
})
|
})
|
||||||
if not validity:
|
if not validity:
|
||||||
return
|
return
|
||||||
|
|
||||||
fee_validity = frappe.get_doc('Fee Validity', validity)
|
validity = frappe.get_doc('Fee Validity', validity)
|
||||||
appointment_date = getdate(appointment.appointment_date)
|
return validity
|
||||||
if fee_validity.valid_till >= appointment_date and fee_validity.visited < fee_validity.max_visits:
|
|
||||||
return fee_validity
|
|
||||||
|
|
||||||
def manage_fee_validity(appointment):
|
def manage_fee_validity(appointment):
|
||||||
fee_validity = check_fee_validity(appointment)
|
fee_validity = check_fee_validity(appointment)
|
||||||
|
@ -310,8 +310,7 @@ scheduler_events = {
|
|||||||
"erpnext.crm.doctype.email_campaign.email_campaign.send_email_to_leads_or_contacts",
|
"erpnext.crm.doctype.email_campaign.email_campaign.send_email_to_leads_or_contacts",
|
||||||
"erpnext.crm.doctype.email_campaign.email_campaign.set_email_campaign_status",
|
"erpnext.crm.doctype.email_campaign.email_campaign.set_email_campaign_status",
|
||||||
"erpnext.selling.doctype.quotation.quotation.set_expired_status",
|
"erpnext.selling.doctype.quotation.quotation.set_expired_status",
|
||||||
"erpnext.healthcare.doctype.patient_appointment.patient_appointment.update_appointment_status",
|
"erpnext.healthcare.doctype.patient_appointment.patient_appointment.update_appointment_status"
|
||||||
"erpnext.healthcare.doctype.fee_validity.fee_validity.update_validity_status"
|
|
||||||
],
|
],
|
||||||
"daily_long": [
|
"daily_long": [
|
||||||
"erpnext.setup.doctype.email_digest.email_digest.send",
|
"erpnext.setup.doctype.email_digest.email_digest.send",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user