def driver_taxi_bookings(request): if 'AUTHORIZATION' in request.headers and 'USERTYPE' in request.headers: req_token = request.META['HTTP_AUTHORIZATION'] user_type = request.META['HTTP_USERTYPE'] operator_id = request.POST.get('driver_id', '') user = {} booking_type = request.POST.get('booking_type', '') page_no = request.POST.get('page_no', '') limit_from = 0 limit_to = 0 print(page_no) if page_no: limit_from = (int(page_no) - 1) * 10 limit_to = 10 else: limit_from = 0 limit_to = 2147483647 user_token = req_token.split() if user_token[0] == 'Token': try: user = getUserinfoFromAccessToken(user_token[1], user_type) except Exception as e: data = {'success': 0, 'error': "Missing Parameter Value Try Again..."} return JsonResponse(data) if user: try: cursor = connection.cursor() cursor.callproc('getAllDriverTaxiBookings', [operator_id,booking_type,limit_from,limit_to]) emp = dictfetchall(cursor) cursor.close() for e in emp: cursor1 = connection.cursor() booking_id = e['id'] cursor1.callproc('getAllTaxiBookingPassangers', [booking_id]) passanger = dictfetchall(cursor1) e['Passangers'] = passanger e['booking_type'] = booking_type cursor1.close() data = {'success': 1, 'Bookings': emp, 'booking_type':booking_type} return JsonResponse(data) except Exception as e: data = {'success': 0, 'error': getattr(e, 'message', str(e))} return JsonResponse(data) else: data = {'success': 0, 'error': "User Information Not Found"} return JsonResponse(data) else: data = {'success': 0, 'Corporates': "Token Not Found"} return JsonResponse(data) else: data = {'success': 0, 'error': "Missing Parameter Value Try Again..."} return JsonResponse(data)
def employee_reject_bus_bookings(request): if 'AUTHORIZATION' in request.headers and 'USERTYPE' in request.headers: req_token = request.META['HTTP_AUTHORIZATION'] user_type = request.META['HTTP_USERTYPE'] booking_id = request.POST.get('booking_id', '') user_id = request.POST.get('user_id', '') user_comment = request.POST.get('user_comment', '') user = {} user_token = req_token.split() if user_token[0] == 'Token': try: user = getUserinfoFromAccessToken(user_token[1], user_type) except Exception as e: data = {'success': 0, 'error': "Missing Parameter Value Try Again..."} return JsonResponse(data) if user: try: cursor = connection.cursor() cursor.callproc('rejectEmployeeBusBookings', [user_id,user_type,booking_id,user_comment]) emp = dictfetchall(cursor) print(emp) data = {'success': 1, 'message': "Booking Reject Successfully"} cursor.close() cursor2 = connection.cursor() cursor2.callproc('viewTaxiBooking', [booking_id]) emp = dictfetchall(cursor2) cursor2.close() cursor1 = connection.cursor() cursor1.callproc('getAllTaxiBookingPassangers', [booking_id]) passanger = dictfetchall(cursor1) emp[0]['Passangers'] = passanger cursor1.close() add_booking_email = RejectBooking_Email() thread = Thread(target=add_booking_email.send_email_sms_ntf, args=(emp, "Bus")) thread.start() return JsonResponse(data) except Exception as e: data = {'success': 0, 'error': getattr(e, 'message', str(e))} return JsonResponse(data) else: data = {'success': 0, 'error': "User Information Not Found"} return JsonResponse(data) else: data = {'success': 0, 'Corporates': "Token Not Found"} return JsonResponse(data) else: data = {'success': 0, 'error': "Missing Parameter Value Try Again..."} return JsonResponse(data)
def add_taxi(request): for x in range(1, 10): cursor = connection.cursor() cursor.callproc('addTaxiBooking', [ user_type, user_id, entity_id, corporate_id, spoc_id, group_id, subgroup_id, tour_type, pickup_city, pickup_location, drop_location, pickup_datetime, taxi_type, package_id, no_of_days, reason_booking, no_of_seats, assessment_code, assessment_city_id, employees, booking_datetime, booking_email, '@last_booking_id' ]) cursor.execute("SELECT @last_booking_id") last_booking_id = cursor.fetchone()[0] print(last_booking_id) cursor.close() cursor1 = connection.cursor() cursor1.callproc('acceptTaxiBooking', [last_booking_id, user_id, user_type]) data = dictfetchall(cursor1) cursor1.close() cursor2 = connection.cursor() cursor2.callproc('assignTaxiBooking', [ vendor_booking_id, operator_id, driver_id, taxi_id, last_booking_id, user_id, user_type ]) company = dictfetchall(cursor2) cursor3 = connection.cursor() cursor3.callproc('addTaxiInvoice', [ tax_on_management_fee, tax_on_management_fee_percentage, management_fee_igst, management_fee_cgst, management_fee_sgst, management_fee_igst_rate, management_fee_cgst_rate, management_fee_sgst_rate, igst_amount, cgst_amount, sgst_amount, hours_done, allowed_hours, extra_hours, charge_hour, days, start_km, end_km, kms_done, allowed_kms, extra_kms, extra_km_rate, base_rate, extra_hr_charges, extra_km_charges, driver_allowance, total_excluding_tax, other_charges, total, sub_total, radio_rate, bb_entity, cotrav_billing_entity, last_booking_id, user_id, user_type ]) company = dictfetchall(cursor3) data = {'success': 1, 'message': 'data insert Successfully..!'} return JsonResponse(data)
def get_test_data(request): try: cursor = connection.cursor() cursor.callproc('getAllServiceType', []) company = dictfetchall(cursor) cursor.close() data = {'success': 1, 'Types': company} return JsonResponse(data) except Exception as e: data = {'success': 0, 'error': getattr(e, 'message', str(e))} return JsonResponse(data)
def add_hotel(request): for x in range(1, 10): cursor = connection.cursor() cursor.callproc('addHotelBooking', [ pickup_city, pickup_city, preferred_area, boarding_datetime, boarding_datetime, bus_type, bus_type, bus_type, bus_type, booking_datetime, assessment_code, assessment_city_id, no_of_seats, group_id, subgroup_id, spoc_id, corporate_id, cotrav_billing_entity, reason_booking, user_id, user_type, employees, booking_email, '@last_booking_id' ]) booking_id = dictfetchall(cursor) cursor.execute("SELECT @last_booking_id") last_booking_id = cursor.fetchone()[0] print(last_booking_id) cursor.close() cursor1 = connection.cursor() cursor1.callproc('acceptHotelBooking', [last_booking_id, user_id, user_type]) data = dictfetchall(cursor1) cursor1.close() cursor2 = connection.cursor() cursor2.callproc('assignHotelBooking', [ pickup_city, assign_room_type, assign_room_type, assign_room_type, assign_room_type, agent_booking_id, comment, last_booking_id, user_id, user_type, base_rate, agent_booking_id, portal_used, oper_commission, base_rate, management_fee, tax_on_management_fee, tax_on_management_fee_percentage, sub_total, cotrav_billing_entity, igst, cgst, sgst, management_fee_igst, management_fee_cgst, management_fee_sgst, management_fee_igst_rate, management_fee_cgst_rate, management_fee_sgst_rate, tax_mng_amt, oper_ticket_price, oper_commission, oper_commission_type, oper_igst, oper_cgst, oper_sgst, client_ticket_path, vender_ticket_path, igst_amount, cgst_amount, sgst_amount ]) company = dictfetchall(cursor2) data = {'success': 1, 'message': 'data insert Successfully..!'} return JsonResponse(data)
def add_train(request): for x in range(1, 10): cursor = connection.cursor() cursor.callproc('addTrainBooking', [ user_type, user_id, corporate_id, spoc_id, group_id, subgroup_id, pickup_location_train, drop_location_train, bus_type, bus_type, bus_type, booking_datetime, pickup_datetime, entity_id, preferred_bus, reason_booking, no_of_seats, assessment_code, assessment_city_id, employees, booking_email, pickup_datetime, '@last_booking_id' ]) cursor.execute("SELECT @last_booking_id") last_booking_id = cursor.fetchone()[0] print(last_booking_id) cursor.close() cursor1 = connection.cursor() cursor1.callproc('acceptTrainBooking', [last_booking_id, user_id, user_type]) data = dictfetchall(cursor1) cursor1.close() cursor2 = connection.cursor() cursor2.callproc('assignTrainBooking', [ ticket_no, pnr_no, assign_bus_type_id, seat_no, portal_used, operator_name, operator_contact, boarding_point, boarding_datetime, last_booking_id, user_id, user_type, train_name, base_rate, management_fee, tax_on_management_fee, tax_on_management_fee_percentage, sub_total, cotrav_billing_entity, igst, cgst, sgst, management_fee_igst, management_fee_cgst, management_fee_sgst, management_fee_igst_rate, management_fee_cgst_rate, management_fee_sgst_rate, tax_mng_amt, client_ticket_path ]) company = dictfetchall(cursor2) data = {'success': 1, 'message': 'data insert Successfully..!'} return JsonResponse(data)
def started_from_pickup(request): if 'AUTHORIZATION' in request.headers and 'USERTYPE' in request.headers: req_token = request.META['HTTP_AUTHORIZATION'] user_type = request.META['HTTP_USERTYPE'] booking_id = request.POST.get('booking_id', '') pickup_lat = request.POST.get('pickup_lat', '') pickup_lng = request.POST.get('pickup_lng', '') pickup_km_reading = request.POST.get('pickup_km_reading', '') pickup_datetime = request.POST.get('pickup_datetime', '') if pickup_datetime: pickup_datetime = datetime.strptime(pickup_datetime, '%d-%m-%Y %H:%M:%S') user = {} booking_type = request.POST.get('booking_type', '') generate_otp = ''.join(random.choice(string.digits) for _ in range(6)) user_token = req_token.split() if user_token[0] == 'Token': try: user = getUserinfoFromAccessToken(user_token[1], user_type) except Exception as e: data = {'success': 0, 'error': "Missing Parameter Value Try Again..."} return JsonResponse(data) if user: try: cursor = connection.cursor() cursor.callproc('addStartedFromPickup', [booking_id,pickup_lat,pickup_lng,pickup_km_reading,pickup_datetime]) emp = dictfetchall(cursor) cursor.close() data = {'success': 1, 'data': 'Status Update Successfully', 'end_otp':generate_otp} return JsonResponse(data) except Exception as e: data = {'success': 0, 'error': getattr(e, 'message', str(e))} return JsonResponse(data) else: data = {'success': 0, 'error': "User Information Not Found"} return JsonResponse(data) else: data = {'success': 0, 'Corporates': "Token Not Found"} return JsonResponse(data) else: data = {'success': 0, 'error': "Missing Parameter Value Try Again..."} return JsonResponse(data)
def arrived_at_drop(request): if 'AUTHORIZATION' in request.headers and 'USERTYPE' in request.headers: req_token = request.META['HTTP_AUTHORIZATION'] user_type = request.META['HTTP_USERTYPE'] booking_id = request.POST.get('booking_id', '') user_id = request.POST.get('user_id', '') drop_lat = request.POST.get('drop_lat', '') drop_lng = request.POST.get('drop_lng', '') drop_km_reading = request.POST.get('drop_km_reading', '') drop_google = request.POST.get('cal_distance_start_garage_to_drop_google', '') drop_self = request.POST.get('cal_distance_start_garage_to_drop_self', '') pickup_to_drop_google = request.POST.get('cal_distance_pickup_to_drop_google', '') end_garage = request.POST.get('est_distance_drop_to_end_garage', '') drop_to_end_garage = request.POST.get('est_time_drop_to_end_garage', '') state_tax = request.POST.get('state_tax', '') parking = request.POST.get('parking', '') toll_tax = request.POST.get('toll_tax', '') extras = request.POST.get('extras', '') drop_datetime = request.POST.get('drop_datetime', '') if drop_datetime: drop_datetime = datetime.strptime(drop_datetime, '%d-%m-%Y %H:%M:%S') user = {} user_token = req_token.split() if user_token[0] == 'Token': try: user = getUserinfoFromAccessToken(user_token[1], user_type) except Exception as e: data = {'success': 0, 'error': "Missing Parameter Value Try Again..."} return JsonResponse(data) if user: try: cursor = connection.cursor() cursor.callproc('addArrivedAtDrop', [booking_id,drop_lat,drop_lng,drop_km_reading,drop_google,drop_self,pickup_to_drop_google,end_garage, drop_to_end_garage,state_tax,parking,toll_tax,extras,drop_datetime,'@start_garage_km_reading']) emp1 = dictfetchall(cursor) print(emp1) cursor.execute("SELECT @start_garage_km_reading") start_garage_km_reading = cursor.fetchone()[0] print(start_garage_km_reading) if not start_garage_km_reading: start_garage_km_reading = 0 cursor.close() cursor1 = connection.cursor() cursor1.callproc('viewTaxiBooking', [booking_id]) emp = dictfetchall(cursor1) cursor1.close() payin_slip = "" cotrav_billing_entity = 1 bb_entity = emp[0]['billing_entity_id'] radio_rate = emp[0]['base_rate'] tour_type_id = emp[0]['tour_type'] pickup_datetime = emp[0]['pickup_datetime'] if pickup_datetime: pickup_datetime = datetime.strptime(pickup_datetime, '%d-%m-%Y %H:%M') diff = drop_datetime - pickup_datetime days, seconds = diff.days, diff.seconds if tour_type_id == 1: hrs_done = days * 24 + seconds // 3600 print("i mheheheherhrh") print(hrs_done) else: hrs_done = days * 24 + seconds // 3600 print("i mheheheherhrh else") print(hrs_done) allowed_hrs = emp[0]['hours'] extra_hrs = hrs_done - allowed_hrs print(extra_hrs) if extra_hrs < 0: extra_hrs = 0 hr_rate = emp[0]['hour_rate'] print(hr_rate) extra_hrs_charge = hr_rate * extra_hrs print(extra_hrs_charge) print("end allowed_kms_per_day ") print(extra_hrs_charge) start_km = start_garage_km_reading end_km = drop_km_reading + drop_to_end_garage print(end_km) print("start_km") print(start_km) kms_done = float(end_km) - float(start_km) print("kms_done") print(kms_done) allowed_kms_per_day = emp[0]['kms'] if tour_type_id == 1 : allowed_kms = allowed_kms_per_day else: allowed_kms = allowed_kms_per_day * hrs_done extra_kms = kms_done - allowed_kms if extra_kms < 0: extra_kms = 0 km_rate = emp[0]['km_rate'] extra_kms_charge = km_rate * extra_kms driver_allowance_per_day = emp[0]['night_rate'] if tour_type_id == 1: driver_allowance = driver_allowance_per_day else: driver_allowance = driver_allowance_per_day * hrs_done print("i mheheheherhrh else") base_rate_per_day = emp[0]['base_rate'] if tour_type_id == 1: base_rate = base_rate_per_day else: base_rate = base_rate_per_day * hrs_done total_ex_tax = base_rate + extra_kms_charge + extra_hrs_charge + driver_allowance tax_rate = 12 igst = (total_ex_tax * 12) / 100 print("i mheheheherhrh else") total_after_tax = float(total_ex_tax) + float(igst) + float(state_tax) + float(parking) + float(toll_tax) + float(extras) print("Total after taxxxx") print(total_after_tax) cursor2 = connection.cursor() cursor2.callproc('addTaxiInvoice', [tax_rate, tax_rate, igst, 0,0, igst, 0, 0, igst, 0, 0, hrs_done, allowed_hrs, extra_hrs, hr_rate, days, start_km, end_km, kms_done, allowed_kms, extra_kms, km_rate, base_rate, extra_hrs_charge, extra_kms_charge, driver_allowance, total_ex_tax, extras, total_after_tax, total_after_tax, radio_rate, bb_entity, cotrav_billing_entity, booking_id, user_id, user_type, payin_slip]) company = dictfetchall(cursor2) cursor1 = connection.cursor() cursor1.callproc('viewTaxiBooking', [booking_id]) emp = dictfetchall(cursor1) cursor1.close() cursor.close() data = {'success': 1, 'data': 'Status Update Successfully', 'InvoiceDetails':emp} return JsonResponse(data) except Exception as e: print(e) data = {'success': 0, 'error': getattr(e, 'message', str(e))} return JsonResponse(data) else: data = {'success': 0, 'error': "User Information Not Found"} return JsonResponse(data) else: data = {'success': 0, 'Corporates': "Token Not Found"} return JsonResponse(data) else: data = {'success': 0, 'error': "Missing Parameter Value Try Again..."} return JsonResponse(data)
def add_flight(request): for x in range(1, 10): cursor3 = connection.cursor() cursor3.callproc('addFlightBooking', [ usage_type, journey_type, flight_class, pickup_location, drop_location, booking_datetime, boarding_datetime, boarding_point, assessment_code, no_of_seats, group_id, subgroup_id, spoc_id, corporate_id, cotrav_billing_entity, reason_booking, user_id, user_type, employees, booking_email, assessment_city_id, '@last_booking_id' ]) booking_id = dictfetchall(cursor3) cursor3.execute("SELECT @last_booking_id") last_booking_id = cursor3.fetchone()[0] print(last_booking_id) cursor3.close() cursor11 = connection.cursor() cursor11.callproc('acceptFlightBooking', [last_booking_id, user_id, user_type]) data = dictfetchall(cursor11) cursor11.close() cursor = connection.cursor() cursor.callproc('assignFlightBooking', [ usage_type, flight_class, journey_type, no_of_stops, last_booking_id, bus_type, bus_type, user_id, user_type, base_rate, management_fee, tax_on_management_fee, tax_on_management_fee_percentage, sub_total, cotrav_billing_entity, igst, cgst, sgst, management_fee_igst, management_fee_cgst, management_fee_sgst, management_fee_igst_rate, management_fee_cgst_rate, management_fee_sgst_rate, tax_mng_amt, oper_ticket_price, oper_commission, oper_commission_type, oper_cotrav_billing_entity, oper_igst, oper_cgst, oper_sgst, client_ticket_path, vender_ticket_path, igst_amount, cgst_amount, sgst_amount, operator_id, vendor_booking_id ]) result = dictfetchall(cursor) cursor.close() for x in range(len(flight_from)): cursor1 = connection.cursor() cursor1.callproc('addFlightBookingFlights', [ flight_name[x], flight_no[x], pnr_no[x], flight_from[x], flight_to[x], departure_time[x], arrival_time[x], last_booking_id, user_id, user_type, is_return_flight[x] ]) result = dictfetchall(cursor1) cursor1.close() for xx in range(finalpass): print("1i m here") print(employee_booking_id[xx]) print(booking_id) print("herer 2") cursor2 = connection.cursor() cursor2.callproc( 'updateFlightPassangerTickectNo', [ticket_number[xx], employee_booking_id[xx], last_booking_id]) result = dictfetchall(cursor2) cursor2.close() data = {'success': 1, 'message': 'data insert Successfully..!'} return JsonResponse(data)