A
This commit is contained in:
parent
2791054327
commit
a3d04cdbca
@ -3,8 +3,13 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
# import frappe
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class Appointment(Document):
|
||||
pass
|
||||
def validate(self):
|
||||
number_of_appointments_in_same_slot = frappe.db.count('Appointment',filters={'scheduled_time':self.scheduled_time})
|
||||
settings = frappe.get_doc('Appointment Booking Settings')
|
||||
if(number_of_appointments_in_same_slot>=settings.number_of_agents):
|
||||
frappe.throw('Time slot is not available')
|
||||
|
||||
|
@ -48,7 +48,7 @@
|
||||
}
|
||||
],
|
||||
"issingle": 1,
|
||||
"modified": "2019-09-01 10:20:06.935115",
|
||||
"modified": "2019-09-03 12:27:09.763730",
|
||||
"modified_by": "Administrator",
|
||||
"module": "CRM",
|
||||
"name": "Appointment Booking Settings",
|
||||
|
@ -3,8 +3,28 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
# import frappe
|
||||
import frappe
|
||||
from frappe import _
|
||||
import datetime
|
||||
from frappe.model.document import Document
|
||||
|
||||
class AppointmentBookingSettings(Document):
|
||||
pass
|
||||
def validate(self):
|
||||
# Day of week should not be repeated
|
||||
list_of_days = []
|
||||
date = '01/01/1970 '
|
||||
format_string = "%d/%m/%Y %H:%M:%S"
|
||||
for record in self.availability_of_slots:
|
||||
list_of_days.append(record.day_of_week)
|
||||
# Difference between from_time and to_time is multiple of appointment_duration
|
||||
from_time = datetime.datetime.strptime(date+record.from_time,format_string)
|
||||
to_time = datetime.datetime.strptime(date+record.to_time,format_string)
|
||||
timedelta = to_time-from_time
|
||||
if(from_time>to_time):
|
||||
frappe.throw('From Time cannot be later than To Time for '+record.day_of_week)
|
||||
if timedelta.total_seconds() % (self.appointment_duration*60):
|
||||
frappe.throw('The difference between from time and To Time must be a multiple of Appointment ')
|
||||
set_of_days = set(list_of_days)
|
||||
if len(list_of_days) > len(set_of_days):
|
||||
frappe.throw(_('Days of week must be unique'))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user