def customerController(self, userObj): """This method contains all functionality related to the customer along with the flow Args: - userObj -- User Raises: Returns: """ state = 2 while state >= 2: #display menu for customer while state == 2: pageName = 'Customer Home Screen' userName = userObj.getFirstName() optionDisplay = {'1': 'View Halls', '2': 'Search Hall', '3': 'Book Hall', '4': 'View Quotation Requests', '5': 'View Bookings'} pageNavDict = {'O': 'Logout', 'E': 'Exit'} headerDisplay = 'Input key to select corresponding option' displayDict = {'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'headerDisplay': headerDisplay} self.displayPage(displayDict) invalidSelectionFlag, selection = self.selectOption(optionDisplay, pageNavDict) # for navigation menu if not invalidSelectionFlag: if selection in pageNavDict: state = self.navOptions(selection, state) elif selection == '1': state = 3 elif selection == '2': state = 4 elif selection == '3': state = 7 elif selection == '4': state = 7 elif selection == '5': state = 9 else: print('Invalid selection, Please input again') #display list of halls and provide selection option while state == 3: pageName = 'View All Halls' userName = userObj.getFirstName() optionDisplay = Hall.viewAllHalls() pageNavDict = {'B': 'Go Back', 'O': 'Logout', 'E': 'Exit'} headerDisplay = 'Select ID to view detail and request quotation' displayDict = {'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'state': state, 'headerDisplay': headerDisplay} self.displayPage(displayDict) invalidSelectionFlag, selection = self.selectOption(optionDisplay, pageNavDict) if not invalidSelectionFlag: if selection in pageNavDict: if selection == 'B': state = 2 else: state = self.navOptions(selection, state) else: state = 5 index = selection else: print('Invalid selection, Please input again') #display hall details of the hall id entered while state == 4: print('Filter by Date') #accept date from user for booking start date dateCounter = 3 while dateCounter > 0: dateFlag, dateObj = self.acceptDate() if dateFlag: startDate = dateObj break else: dateCounter = dateCounter - 1 # input(str(dateCounter)) print(dateObj,', please try again') else: print('Maximum retry reached, navigating back') time.sleep(3) state = 2 #accept date from user for booking end date if dateFlag: dateCounter = 3 while dateCounter > 0: dateFlag, dateObj = self.acceptDate(startDate) if dateFlag: endDate = dateObj break else: dateCounter = dateCounter - 1 print(dateObj,', please try again') else: print('Maximum retry reached, navigating back') time.sleep(3) state = 2 if dateFlag: pageName = "Halls available on selected dates" userName = userObj.getFirstName() optionDisplay = self.getAvailableHalls(startDate, endDate) pageNavDict = {'B': 'Go Back', 'O': 'Logout', 'E': 'Exit'} headerDisplay = "Input ID to view hall details and request quotation" displayDict = {'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'headerDisplay': headerDisplay} self.displayPage(displayDict) invalidSelectionFlag, selection = self.selectOption(optionDisplay, pageNavDict) if not invalidSelectionFlag: if selection in pageNavDict: if selection == 'B': state = 2 else: state = self.navOptions(selection, state) else: state = 5 index = selection else: print('Invalid selection, Please input again') #intermediary state not to be jumped onto while state == 5: pageName = 'Hall Details' userName = userObj.getFirstName() optionDisplay = Hall.viewHallDetails(index) pageNavDict = {'R': 'Request Quote', 'B': 'Go Back', 'O': 'Logout', 'E': 'Exit'} hallDetails = Hall.viewHallDetails(index) pageNavDict = {'R': 'Request Quote', 'B': 'Go Back', 'O': 'Logout', 'E': 'Exit'} displayDict = {'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'state': state} self.displayPage(displayDict) placeHolder = dict() invalidSelectionFlag, selection = self.selectOption(placeHolder, pageNavDict) if not invalidSelectionFlag: if selection in pageNavDict: if selection == 'R': state = 6 if selection == 'B': state = 3 else: state = self.navOptions(selection, state) else: print('Invalid selection, Please input again') #create quotation request while state == 6: # pageName = pageName # userName = userName # optionDisplay = optionDisplay # pageNavDict = pageNavDict # message = message # state = state # headerDisplay = headerDisplay quotationInfo = dict() quotationInfo['reqDate'] = datetime.datetime.now() dateCounter = 3 #accept date from user for booking start date while dateCounter > 0: dateFlag, dateObj = self.acceptDate() if dateFlag: quotationInfo['bookingStartDate'] = dateObj break else: dateCounter = dateCounter - 1 input(str(dateCounter)) print(dateObj,', please try again') else: print('Maximum retry reached, navigating back') state = 5 #accept date from user for booking end date if dateFlag: dateCounter = 3 while dateCounter > 0: dateFlag, dateObj = self.acceptDate(quotationInfo['bookingStartDate']) if dateFlag: quotationInfo['bookingEndDate'] = dateObj break else: dateCounter = dateCounter - 1 print(dateObj,', please try again') else: print('Maximum retry reached, navigating back') state = 5 if dateFlag: quotationInfo['hallId'] = index quotationInfo['customerId'] = userObj.getRowId() quotationInfo['quotationAmount'] = self.calculateQuote(quotationInfo['bookingStartDate'], quotationInfo['bookingEndDate'], quotationInfo['hallId']) print('Charge for booking from {} to {} is {}.'.format(quotationInfo['bookingStartDate'].isoformat(),quotationInfo['bookingEndDate'].isoformat(),quotationInfo['quotationAmount'])) customerConfirmCounter = 3 while customerConfirmCounter > 0: confirmation = input('Confirm Quotation Request(Y/N): ') if confirmation.isalpha(): if confirmation.lower() == 'y': #create object of quotations quotationObj = Quotation(quotationInfo) state = 7 break elif confirmation.lower() == 'n': print('Taking back to previous menu') time.sleep(2) state = 5 break else: print('Invalid input!! Try again') customerConfirmCounter = customerConfirmCounter - 1 else: print('Invalid input!! Try again') customerConfirmCounter = customerConfirmCounter - 1 if customerConfirmCounter == 0: print('Maximum Taking back to previous menu') time.sleep(2) state = 5 #display all quotation requests made by the customer while state == 7: pageName = 'Quotation Requests' userName = userObj.getFirstName() optionDisplay = Quotation.listQuotationRequests(userObj.getRowId()) pageNavDict = {'B': 'Go Back', 'O': 'Logout', 'E': 'Exit'} headerDisplay = 'Select an ID to make a booking' footerDisplay = 'Booking can be made only for approved requests' displayDict = {'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'state': state, 'headerDisplay': headerDisplay, 'footerDisplay': footerDisplay} self.displayPage(displayDict) placeholder = dict() invalidSelectionFlag, selection = self.selectOption(optionDisplay, pageNavDict) if not invalidSelectionFlag: if selection in pageNavDict: if selection == 'B': state = 2 else: state = self.navOptions(selection, state) else: quotationObj = Quotation({'quotationId': selection}) if quotationObj.getStatus() == 'Approved': state = 8 elif quotationObj.getStatus() == 'Pending': print('Quotation ID {} is pending at Owner'.format(quotationObj.getQuotationId())) time.sleep(2) state = 7 elif quotationObj.getStatus() == 'Completed': print('Booking for the Quotation ID {} is already made by you, try another Quotation ID'.format(quotationObj.getQuotationId())) time.sleep(2) state = 7 else: print('Quotation ID {} is rejected by Owner'.format(quotationObj.getQuotationId())) time.sleep(2) state = 7 else: print('Invalid selection, Please input again') time.sleep(2) #display the hall details before booking while state == 8: bookingInfo = {'bookingStartDate': quotationObj.getBookingStartDate(),'bookingEndDate': quotationObj.getBookingEndDate(),'hallId': quotationObj.getHallId(), 'customerId': quotationObj.getCustomerId(),'bookingAmount': quotationObj.getQuotationAmount(),'quotationId': quotationObj.getQuotationId()} optionDisplay = bookingInfo pageName = 'Book Hall' userName = userObj.getFirstName() pageNavDict = {'P': 'Make Payment', 'B': 'Go Back', 'O': 'Logout', 'E': 'Exit'} footerDisplay = 'Make payment and complete the booking' # state = state # headerDisplay = headerDisplay displayDict = {'footerDisplay': footerDisplay, 'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'state': state} # tableHeader = self.displayPage(displayDict) placeHolder = dict() invalidSelectionFlag, selection = self.selectOption(placeHolder, pageNavDict) if not invalidSelectionFlag: if selection in pageNavDict: if selection == 'B': state = 7 elif selection == 'P': paytype = input('Select Payment Option: \n [1] Cash \n [2] Coupon \n Enter your choice: ') if paytype.isdigit(): if paytype == '1': #create object of quotations bookingObj = Booking(bookingInfo) Quotation.changeStatus(quotationObj.getQuotationId(), 'Completed') paymentInfo = dict() paymentInfo['paymentType'] = 'Cash' paymentInfo['paymentAmount'] = bookingInfo['bookingAmount'] paymentInfo['bookingId'] = bookingObj.getRowId() paymentInfo['customerId'] = userObj.getRowId() paymentObj = Payment(paymentInfo) bookingObj.addPaymentInfo(paymentObj.getRowId()) state = 9 break elif paytype == '2': couponCode = input('Please Enter the coupon code: ') bookingObj = Booking(bookingInfo) Quotation.changeStatus(quotationObj.getQuotationId(), 'Completed') paymentInfo = dict() paymentInfo['paymentType'] = 'Cash' paymentInfo['couponCode'] = couponCode paymentInfo['paymentAmount'] = bookingInfo['bookingAmount'] paymentInfo['bookingId'] = bookingObj.getRowId() paymentInfo['customerId'] = userObj.getRowId() paymentObj = Payment(paymentInfo) bookingObj.addPaymentInfo(paymentObj.getRowId()) state = 9 break else: print('Invalid input!! Try again') else: state = self.navOptions(selection, state) else: print('Invalid selection, Please input again') #creation of booking object while state == 9: optionDisplay = Booking.viewUserBookings(userObj) pageName = 'Completed Bookings' userName = userObj.getFirstName() pageNavDict = {'B': 'Go Back', 'O': 'Logout', 'E': 'Exit'} displayDict = {'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'state': state} # tableHeader = self.displayPage(displayDict) placeHolder = dict() invalidSelectionFlag, selection = self.selectOption(placeHolder, pageNavDict) if not invalidSelectionFlag: if selection in pageNavDict: if selection == 'B': state = 2 else: state = self.navOptions(selection, state) else: print('Invalid selection, Please input again') self.state = state
def ownerController(self, userObj): """ This method contains all functionality related to the owner along with the flow Args: - userObj -- User Raises: Returns: """ state = 2 while state >= 2: while state == 2: pageName = 'Owner Home Screen' userName = userObj.getFirstName() optionDisplay = { '1': 'Manage Halls', '2': 'View Quotation Request', '3': 'Manage Bookings', '4': 'Manage Payments' } pageNavDict = {'O': 'Logout', 'E': 'Exit'} headerDisplay = 'Input key to select corresponding option' displayDict = { 'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'headerDisplay': headerDisplay } self.displayPage(displayDict) invalidSelectionFlag, selection = self.selectOption( optionDisplay, pageNavDict) # for navigation menu if not invalidSelectionFlag: if selection in pageNavDict: state = self.navOptions(selection, state) elif selection == '1': # take to next state to display hall listing state = 3 elif selection == '2': state = 5 elif selection == '3': state = 7 elif selection == '4': state = 8 else: print('Invalid selection, Please input again') while state == 3: optionDisplay = Hall.viewUserHalls(userObj) pageName = 'Manage Hall Page' userName = userObj.getFirstName() pageNavDict = { 'O': 'Logout', 'E': 'Exit', 'B': 'Back', 'A': 'Add New Hall' } headerDisplay = 'Select ID to view corresponding Hall Information and modify' displayDict = { 'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'headerDisplay': headerDisplay } self.displayPage(displayDict) invalidSelectionFlag, selection = self.selectOption( optionDisplay, pageNavDict) # for navigation menu if not invalidSelectionFlag: if selection in pageNavDict: if selection == 'A': hallExistFlag, hallInfo = self.acceptHallDetails( userObj) # create a user object if hallExistFlag: state = 3 else: confirmation = input( 'Confirm Addition Request(Y/N): ') if confirmation.isalpha(): if confirmation.lower() == 'y': #create object of quotations hallObj = Hall(hallInfo) elif confirmation.lower() == 'n': print('Taking back to previous menu') time.sleep(1) state = 3 if selection == 'B': state = 2 state = self.navOptions(selection, state) else: # take to next state to display hall listing state = 4 else: print('Invalid selection, Please input again') while state == 4: index = int(selection) optionDisplay = Hall.viewHallDetails(index) pageName = 'Hall Detail Page' userName = userObj.getFirstName() pageNavDict = { 'M': 'Modify Hall', 'D': 'Delete Hall', 'B': 'Go Back', 'O': 'Logout', 'E': 'Exit' } displayDict = { 'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'state': state } self.displayPage(displayDict) #placeholder dictionary bookHallPage = dict() #displayPage('Hall Details', userObj.getFirstName(), hallDetails, navPageDict, state) invalidSelectionFlag, selection = self.selectOption( optionDisplay, pageNavDict) if not invalidSelectionFlag: if selection in pageNavDict: if selection == 'B': state = 3 if selection == 'M': hallExistFlag, hallModify = self.acceptModifyHallDetails( userObj, optionDisplay) # create a user object if not hallExistFlag: hallModify['hallId'] = optionDisplay[0] confirmation = input( 'Confirm Modification Request(Y/N): ') if confirmation.isalpha(): if confirmation.lower() == 'y': #create object of quotations hallObj = Hall(hallModify) hallObj.modifyhall( optionDisplay[0], hallModify) elif confirmation.lower() == 'n': print('Taking back to previous menu') time.sleep(1) state = 3 elif selection == 'D': hallDelete = dict() hallDelete['hallId'] = optionDisplay[0] confirmation = input( 'Confirm Delete Request(Y/N): ') if confirmation.isalpha(): if confirmation.lower() == 'y': #create object of quotations hallObj = Hall(hallDelete) hallObj.deletehall(optionDisplay[0]) elif confirmation.lower() == 'n': print('Taking back to previous menu') time.sleep(1) state = 3 else: state = self.navOptions(selection, state) else: print('Invalid selection, Please input again') while state == 5: optionDisplay = Quotation.listOwnerQuotationRequests( userObj.getRowId()) pageName = 'Requested Quotations Page' userName = userObj.getFirstName() pageNavDict = {'O': 'Logout', 'E': 'Exit', 'B': 'Back'} headerDisplay = 'Select ID to Modify Quotation Requests' displayDict = { 'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'headerDisplay': headerDisplay, 'state': state } self.displayPage(displayDict) #navPageDict = {'O': 'Logout', 'E': 'Exit', 'B': 'Back'} #displayPage('Requested Quotations Page', userObj.getFirstName(), quotationList, navPageDict, state) invalidSelectionFlag, selection = self.selectOption( optionDisplay, pageNavDict) if not invalidSelectionFlag: if selection == 'B': state = 2 elif selection in pageNavDict: state = self.navOptions(selection, state) else: # take to next state to display hall listing state = 6 else: print('Invalid selection, Please input again') while state == 6: index = int(selection) optionDisplay = Quotation.viewQuotationDetails(index) pageName = 'Quotation Details Page' userName = userObj.getFirstName() if (optionDisplay[5] == 'Pending'): pageNavDict = { 'A': 'Accept', 'M': 'Modify', 'R': 'Reject', 'B': 'Go Back', 'O': 'Logout', 'E': 'Exit' } else: pageNavDict = {'B': 'Go Back', 'O': 'Logout', 'E': 'Exit'} displayDict = { 'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'state': state } self.displayPage(displayDict) #displayPage('Quotation Details', userObj.getFirstName(), quotationDetails, navPageDict, state) #placeholder dictionary placeHolder = dict() invalidSelectionFlag, selection = self.selectOption( placeHolder, pageNavDict) if not invalidSelectionFlag: if selection in pageNavDict: if selection == 'B': state = 5 if selection == 'M': newAmount = input('Enter New Quotation Amount: ') if newAmount.isdigit(): confirmation = input( 'Confirm Modification Request(Y/N): ') if confirmation.isalpha(): if confirmation.lower() == 'y': #create object of quotations Quotation.changeAmount( optionDisplay[0], newAmount) elif confirmation.lower() == 'n': print('Taking back to previous menu') time.sleep(1) state = 5 else: print('Please enter a valid value[float only]') selection = index time.sleep(1) elif selection == 'A': confirmation = input( 'Confirm Accept Request(Y/N): ') if confirmation.isalpha(): if confirmation.lower() == 'y': #create object of quotations Quotation.changeStatus( optionDisplay[0], 'Approved') elif confirmation.lower() == 'n': print('Taking back to previous menu') time.sleep(1) state = 5 elif selection == 'R': confirmation = input( 'Confirm Reject Request(Y/N): ') if confirmation.isalpha(): if confirmation.lower() == 'y': #create object of quotations Quotation.changeStatus( optionDisplay[0], 'Rejected') elif confirmation.lower() == 'n': print('Taking back to previous menu') time.sleep(1) state = 5 else: state = self.navOptions(selection, state) else: print('Invalid selection, Please input again') state = 5 while state == 7: optionDisplay = Booking.listOwnerBookings(userObj.getRowId()) pageName = 'Completed Bookings' userName = userObj.getFirstName() pageNavDict = {'B': 'Go Back', 'O': 'Logout', 'E': 'Exit'} displayDict = { 'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'state': state } # tableHeader = self.displayPage(displayDict) placeHolder = dict() invalidSelectionFlag, selection = self.selectOption( placeHolder, pageNavDict) if not invalidSelectionFlag: if selection in pageNavDict: if selection == 'B': state = 2 else: state = self.navOptions(selection, state) else: print('Invalid selection, Please input again') while state == 8: optionDisplay = Payment.listOwnerPaymentRequests( userObj.getRowId()) pageName = 'Requested Payments Page' userName = userObj.getFirstName() pageNavDict = {'O': 'Logout', 'E': 'Exit', 'B': 'Back'} headerDisplay = 'Select ID to accept/reject Payment' displayDict = { 'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'headerDisplay': headerDisplay, 'state': state } self.displayPage(displayDict) #navPageDict = {'O': 'Logout', 'E': 'Exit', 'B': 'Back'} #displayPage('Requested Quotations Page', userObj.getFirstName(), quotationList, navPageDict, state) invalidSelectionFlag, selection = self.selectOption( optionDisplay, pageNavDict) if not invalidSelectionFlag: if selection == 'B': state = 2 elif selection in pageNavDict: state = self.navOptions(selection, state) else: # take to next state to display hall listing state = 9 else: print('Invalid selection, Please input again') while state == 9: index = int(selection) optionDisplay = Payment.viewPaymentDetails(index) pageName = 'Payments Details Page' userName = userObj.getFirstName() if (optionDisplay[4] == 'Pending'): pageNavDict = { 'A': 'Accept', 'R': 'Reject', 'B': 'Go Back', 'O': 'Logout', 'E': 'Exit' } else: pageNavDict = {'B': 'Go Back', 'O': 'Logout', 'E': 'Exit'} displayDict = { 'pageName': pageName, 'userName': userName, 'optionDisplay': optionDisplay, 'pageNavDict': pageNavDict, 'state': state } self.displayPage(displayDict) #displayPage('Quotation Details', userObj.getFirstName(), quotationDetails, navPageDict, state) #placeholder dictionary QuotationPage = dict() invalidSelectionFlag, selection = self.selectOption( optionDisplay, pageNavDict) if not invalidSelectionFlag: if selection in pageNavDict: if selection == 'B': state = 8 elif selection == 'A': confirmation = input( 'Confirm Accept Request(Y/N): ') if confirmation.isalpha(): if confirmation.lower() == 'y': #create object of quotations Payment.changeStatus( optionDisplay[0], 'Approved') Booking.changeStatus( optionDisplay[5], 'Confirmed') elif confirmation.lower() == 'n': print('Taking back to previous menu') time.sleep(1) state = 8 elif selection == 'R': confirmation = input( 'Confirm Reject Request(Y/N): ') if confirmation.isalpha(): if confirmation.lower() == 'y': #create object of quotations Payment.changeStatus( optionDisplay[0], 'Rejected') Booking.changeStatus( optionDisplay[5], 'Declined') elif confirmation.lower() == 'n': print('Taking back to previous menu') time.sleep(1) state = 8 else: state = self.navOptions(selection, state) else: print('Invalid selection, Please input again') self.state = state