def updatetoken(request): try: d = request.json app_id = json.loads( dbget( "select count(*) as appointment_id from new.appointment where app_id ='" + str(d['appointment_id']) + "'")) if app_id[0]['appointment_id'] == 1: dbput("update new.appointment set token_status='" + str(d['token_status']) + "',reason='" + str(d['reason']) + "' where app_id='" + str(d['appointment_id']) + "'") return (json.dumps( { "Message": "Record Updated Successfully", "Message_Code": "RUS", "Service_Status": "Success" }, indent=4)) else: return (json.dumps( { 'Message': 'Invalid Data', 'Message_Code': 'ID', 'Status': 'Failure' }, indent=4)) except: return (json.dumps( { "Message": "Appointments Updated Unsuccessful", "Message_Code": "AUUS", "Service_Status": "Failure" }, indent=4))
def updategupshupreservation(request): try: if request.method == 'GET': customer_mobile = request.args['customer_mobile'] id_proof = request.args['id_proof'] if request.method == 'POST': customer_mobile = request.json['customer_mobile'] id_proof = request.json['id_proof'] dbput("update ivr_room_customer_booked set id_proof='" + str(id_proof) + "' where customer_mobile='" + (customer_mobile) + "'") print("mohan") return (json.dumps( { "Message": "Record Updated Successfully", "Message_Code": "RUS", "Service_Status": "Success", "id_proof": id_proof }, indent=4)) except: return (json.dumps( { "Message": "Recored Updated UnSuccessfully", "Message_Code": "RUUS", "Service": "Failure" }, indent=4))
def update_doctorprofile(request): try: doctors = request.json speclaization = doctors['Specialization'] service = doctors['services'] doc_record = {k : v for k,v in doctors.items() if k not in ('Specialization','services')} doctor = {k : v for k,v in doctors.items() if k in ('doctor_id')} doctorid = json.loads(dbget("select count(*) as doctor_id from new.doctor_profile where doctor_profile_id ='"+d['doctor_id']+"'")) businessid = json.loads(dbget("select count(*) as business_id from new.business_profile where business_id ='"+str(d['business_id'])+"'")) if doctorid[0]['doctor_id'] == 1 and businessid[0]['business_id'] == 1 and len(speclaization) != 0 and len(service) != 0: doc = doctor.get('doctor_id') doc_record['doctor_profile_id'] = doctors['doctor_name'][:4]+str(doctor.get('doctor_id')) gensql('update','new.doctor_profile',doc_record,doctor) doc_profile_id = doc_record['doctor_profile_id'] d = {'doctor_id':doc_profile_id} dbput("delete from new.doctor_specialization where doctor_id='"+str(d)+"'") for sep in speclaization: i = {} i['specialization_id'] = sep i['doctor_id'] = doc_profile_id gensql('insert','new.doctor_specialization',i) dbput("delete from new.doctor_services where doctor_id='"+str(d)+"'") for ser in service: i = {} i['doctor_id'] = doc_profile_id i['service_id'] = ser gensql('insert','new.doctor_services',i) return(json.dumps({"Message":"Recored Updated Successfully","Message_Code":"RUS","Service_Status":"Success"},indent=4)) else: return(json.dumps({'Message': 'Invalid Data', 'Message_Code': 'ID', 'Status': 'Failure'},indent=4)) except: return(json.dumps({"Message":"Record Updated Unsuccessful","Message_Code":"RUUS","Service_Status":"Success"},indent=4))
def HOTEL_AR_POST_INSERT_CompressInvoice(request): d = request.json s ,z,f= {},[],{} print("hello world") select = json.loads(dbget("select * from account_receivable.invoice_no")) print(select,type(select),len(select)) invoice_id = (select[0]['invoice_num']+1) print(invoice_id) update = dbput("update account_receivable.invoice_no set invoice_num = '"+str(select[0]['invoice_num']+1)+"'") s['invoice_no'] = invoice_id s['account_name'] = d['account_name'] s['account_number'] = d['account_number'] s['invoice_supplement'] = d['invoice_supplement'] s['reference'] = d['reference'] s['market_id'] = d['market_id'] s['source_id'] = d['source_id'] s['room_class_id'] = d['room_class_id'] s['invoice_amount'] = d['invoice_amount'] s['open_amount'] = d['open_amount'] s['acc_invoice_satus'] = "New Compress" gensql('insert','account_receivable.accout_inivoice',s) z= d['invoice_no'] for i in z: print(invoice_id,i) f['new_invoice_id'] = invoice_id f['compress_invoice'] = i gensql('insert','account_receivable.account_compress',f) sql = dbput("update account_receivable.accout_inivoice set acc_invoice_satus = 'Compress'\ where account_number = '"+d['account_number']+"' and invoice_no = '"+str(i)+"'") return(json.dumps({"Return": "Record Inserted Successfully","ReturnCode": "RIS", "Status": "Success","StatusCode": "200","invoice_num":invoice_id},indent=4))
def Insert_Doctor_Login(request): try: d=request.json print(d) datetime1=datetime.datetime.now() print(datetime1) d['date_time'] = datetime1 doctorid = json.loads(dbget("select count(*) as doctor_id from new.doctorinbusiness where doctor_id ='"+d['doctor_id']+"'")) print( doctorid) businessid = json.loads(dbget("select count(*) as business_id from new.doctorinbusiness where business_id ='"+str(d['business_id'])+"'")) print(businessid) if doctorid[0]['doctor_id']==1 and businessid[0]['business_id']!=1: print("hai") dbput("update new.doctorinbusiness set login_status='" + str(d['login_status']) + "' \ where doctor_id='" +d['doctor_id']+"' and business_id='"+str(d['business_id'])+"'") gensql('insert','new.doctor_login',d) return(json.dumps({"Message":"Record Updated Successfully","Message_Code":"RUS","Service_Status":"Success"},indent=4)) else: return(json.dumps({"Message":"Invalid_Data","Message_Code":"ID","Service_Status":"UnSuccess"},indent=4)) #gensql('insert','new.doctor_login',d) except: return(json.dumps({"Message":"Record Inserted UnSuccessfull","Message_Code":"RIUS","Service_Status":"Failure"},indent=4))
def deleteservices(request): try: d=request.json['service_id'] dbput("delete from new.services where service_id='"+d+"'") return(json.dumps({"Message":"Record Deleted Successfully","Message_Code":"RDS","Service_Status":"Success"},indent=4)) except: return(json.dumps({"Message":"Record Deleted UnSuccessful","Message_Code":"RDUS","Service_Status":"Failure"},indent=4))
def HOTEL_CASH_RESERVATION_STATUS(request): d = request.json ac_log = {} app_datetime = application_date() RES_Log_Time = app_datetime[0] Posting_date = app_datetime[1] res_id = request.json['res_id'] res_room = request.json['res_room'] sql_value = json.loads(dbget("select reservation.res_reservation.res_guest_status from reservation.res_reservation where res_id="+res_id+" and res_room="+res_room+" ")) balance = sql_value[0]['res_guest_status'] if balance =="due out": status = "Check out" psql_value = dbput("update room_management.rm_room_list set rm_fo_status = 'vacant', \ rm_reservation_status = 'not reserved',rm_fo_person= '0',rm_room_status = 'Dirty' where rm_room = '"+str(res_room)+"' ") sql_value = dbput("update reservation.res_reservation set res_guest_status = '"+status+"' where res_id="+res_id+" and res_room="+res_room+" ") ac_log['Emp_Id'] = '121' ac_log['Emp_Firstname'] = "Admin" ac_log['RES_Log_Date'] = Posting_date ac_log['RES_Log_Time'] = app_datetime[2] ac_log['RES_Action_Type'] = "Checkout Reservation" ac_log['RES_Description'] = "Reservation should be checkout.The room number is"+" "+str(res_room) ac_log['Res_id'] = str(res_id) sql_value = gensql('insert','reservation.res_activity_log',ac_log) return(json.dumps({'Status': 'Success', 'StatusCode': '200','Return': 'Record Updated Successfully',"ReturnCode":"RUS"}, sort_keys=True, indent=4)) else: return(json.dumps({'Status':'Failure','Return':'Unable to update'}, sort_keys=True, indent=4))
def HOTEL_CAH_POST_UPDATE_TransfertoAnotherRoom(request): d = request.json a = { k: v for k, v in d.items() if v != '' if k not in ('Res_id', 'Res_room') } print("a", a) e = {k: v for k, v in d.items() if k != '' if k in ('Res_id', 'Res_room')} print("e", e) #option = a['transfer_option'] #print(option) if a['transfer_option'] == "GP": pass elif a['transfer_option'] == "EF": print( dbput("update cashiering.billing_post set res_room=" + a['to_room'] + " \ where Res_id=" + e['Res_id'] + " and Res_room=" + e['Res_room'] + " ")) #return(json.dumps({'Status': 'Success', 'StatusCode': '200', \ # 'Return': 'Record Updated Successfully','ReturnCode':'RUS'}, sort_keys=True, indent=4)) else: print( dbput("update cashiering.billing_post set res_room=" + a['to_room'] + " \ where Res_id=" + e['Res_id'] + " and Res_room=" + e['Res_room'] + " and checkno='" + str(a['checkno']) + "' ")) #return(json.dumps({'Status': 'Success', 'StatusCode': '200', \ # 'Return': 'Record Updated Successfully','ReturnCode':'RUS'}, sort_keys=True, indent=4)) #sql_value = gensql('update','cashiering.billing_post',a,e) #print(sql_value) app_datetime = application_date() res_id = e.get("Res_id") window = str(a.get("res_room")) Posting_date = app_datetime[1] Revenue_date = app_datetime[1] s = {} s['Posting_date'] = Posting_date s['Revenue_date'] = Revenue_date s['User_role'] = "Admin" s['User_name'] = "Admin" s['Res_id'] = res_id s['Posting_action'] = "Window Transfer to Window " + "" + window s['Posting_reason'] = "window Transfer to window " + " " + window + " reservation id " + res_id s['Posting_description'] = "Transfer charges from one window to another window successfully" gensql('insert', 'cashiering.posting_history_log', s) gensql('insert', 'cashiering.posting_changes_history_log', s) return (json.dumps( { 'Status': 'Success', 'StatusCode': '200', 'Return': 'Record Updated Successfully', 'ReturnCode': 'RUS' }, sort_keys=True, indent=4))
def HOTEL_RES_POST_INSERT_CancelReservation(request): d = request.json z = { k: v for k, v in d.items() if k not in ('Res_Arrival', 'Res_Depature', 'Res_Room_Type') } sql_value = gensql('insert', 'reservation.cancel_reservation', z) Res_id = d.get("Res_id") Res_unique_id = d.get("Res_unique_id") e, a = {}, {} e['Res_id'] = Res_id e['Res_unique_id'] = Res_unique_id a['Res_guest_status'] = "cancel" sql_value = gensql('update', 'reservation.res_reservation', a, e) print(sql_value) initial = datetime.datetime.strptime(d['Res_Depature'], '%Y-%m-%d').date() depature_minus = initial - datetime.timedelta(days=1) bookedcount = dbput( "update room_management.room_available set available_count=available_count + '1',\ booked_count = booked_count - '1' where rm_room = \ '" + str(d['Res_Room_Type']) + "' and \ rm_date between '" + str(d['Res_Arrival']) + "' and '" + str(depature_minus) + "' ") res_id = e.get("Res_id") Emp_Id = '121' Emp_Firstname = "Admin" select = json.loads(dbget("select * from reservation.cancel_id")) print(select, type(select), len(select)) print(select[0]['id']) cancel_id = str(select[0]['id'] + 1) print(cancel_id) update = dbput("update reservation.cancel_id set id = '" + str(select[0]['id'] + 1) + "'") s = {} s['Emp_Id'] = Emp_Id s['Emp_Firstname'] = Emp_Firstname app_datetime = application_date() s['RES_Log_Date'] = app_datetime[1] s['RES_Log_Time'] = app_datetime[2] s['RES_Action_Type'] = "Cancel Reservation" s['RES_Description'] = "cancellation Number is" + " " + cancel_id s['Res_id'] = res_id sql_value = gensql('insert', 'reservation.res_activity_log', s) return (json.dumps( { 'Status': 'Success', 'StatusCode': '200', 'Return': 'Record Inserted Successfully', 'cancellationNumber': cancel_id, 'ReturnCode': 'RIS' }, sort_keys=True, indent=4))
def deleteuser_profile(request): try: d=request.json['user_id'] dbput("delete from new.User_Profile where user_id='"+str(d)+"'") return(json.dumps({"Message":"Record Deleted Successfully","Message_Code":"RDS","Service_Status":"Success"},indent=4)) except: return(json.dumps({"Message":"Record Deleted UnSuccessfully","Message_Code":"RDUS","Service_Status":"UnSuccess"},indent=4))
def HOTEL_BBL_POST_INSERT_GroupCancel(request): sql_value = json.loads( dbget("select block_cancel_no from business_block.block_cancel")) print(sql_value, type(sql_value)) sql_value1 = sql_value[0]['block_cancel_no'] print(sql_value1, type(sql_value1)) count = sql_value1 + 1 psql = dbput("update business_block.block_cancel set block_cancel_no = '" + str(sql_value[0]['block_cancel_no'] + 1) + "'") d = request.json d['cancellation_number'] = count print(d) sql = gensql('insert', 'business_block.group_cancel', d) print(sql) block_id = d.get("block_id") psql = dbput( "update business_block.business_block_definite set block_status_id = '5' where block_id = '" + block_id + "'") cancelgrid = json.loads( dbget("select count(*) from business_block.grid where block_id= '" + block_id + "' \ union \ select count(*) from business_block.current_grid where block_id= '" + block_id + "' ")) print(cancelgrid) if cancelgrid[0]['count'] > 0: deltequery = dbput( "delete from business_block.grid where block_id = '" + block_id + "' ; \ delete from business_block.current_grid where block_id = '" + block_id + "'") app_datetime = application_date() #RES_Log_Time = datetime.datetime.utcnow()+datetime.timedelta(hours=5, minutes=30) RES_Log_Time = app_datetime[0] RES_Log_Date = app_datetime[1] print(RES_Log_Date) s = {} s['user_role'] = "Admin" s['date'] = RES_Log_Date s['time'] = RES_Log_Time s['block_id'] = d.get("block_id") s['action_type_id'] = "Group Cancelled" s['description'] = d.get("cancel_description") gensql('insert', 'business_block.business_block_activity_log', s) return (json.dumps( { "Return": "Record Inserted Successfully", "ReturnCode": "RIS", "Status": "Success", "StatusCode": "200", 'CancellationNumber': count }, indent=4))
def HOTEL_AR_POST_INSERT_UNApplyPayment(request): d = request.json app_datetime = application_date() Posting_date = app_datetime[1] s = {} account_invoie = json.loads( dbget("select open_amount from account_receivable.accout_inivoice \ where account_number = '" + str(d['account_no']) + "' and invoice_no = '" + str(d['invoice_no']) + "'")) acc_inv = account_invoie[0]['open_amount'] + d['posting_amount'] print(acc_inv) acc_set = json.loads( dbget("select account_balance from account_receivable.account_setup \ where account_number = '" + str(d['account_no']) + "'")) setupamount = acc_set[0]['account_balance'] + d['posting_amount'] a = { k: v for k, v in d.items() if v != '' if k not in ('account_no', 'invoice_no', 'posting_payment_id') } print(a) e = { k: v for k, v in d.items() if k != '' if k in ('account_no', 'invoice_no', 'posting_payment_id') } print(e) a['posting_date'] = Posting_date a['posting_status'] = "UnApply" a['posting_amount'] = '-' + str(d['posting_amount']) gensql('update', 'account_receivable.invoice_payment', a, e) sql = dbput( "update account_receivable.account_setup set account_balance = '" + str(setupamount) + "' \ where account_number = '" + d['account_no'] + "'") print(sql) psql = dbput( "update account_receivable.accout_inivoice set open_amount = '" + str(acc_inv) + "' \ where account_number = '" + d['account_no'] + "' and invoice_no = '" + str(d['invoice_no']) + "' ") return (json.dumps( { "Return": "Record Updated Successfully", "ReturnCode": "RUS", "Status": "Success", "StatusCode": "200" }, indent=4))
def delete_rate_plan(request): plan_id = request.json['rate_plan_id'] b_id = request.json['business_id'] dbput("delete from rate_plan where rate_plan_id=" + str(plan_id) + " and business_id = '" + b_id + "' ") return (json.dumps( { "ServiceStatus": "Success", "ServiceMessage": "Success" }, indent=2))
def Delete_Confgure_Alexa_With_Department(request): d = request.json dbput("delete from configure_alexa where config_alexa_id = '" + str(d['config_alexa_id']) + "'") return (json.dumps( { "Return": "Record Deleted Successfully", "ReturnCode": "RDS", "Status": "Success", "StatusCode": "200" }, indent=4))
def tokengeneration(request): try: d = request.json mob = json.loads(dbget("select count(*) as mobile from new.appointment where mobile ='"+d['mobile']+"' and business_date = '" + str(d['business_date']) + "' ")) if mob[0]['mobile'] == 1: return(json.dumps({'Message': 'Token Already Generated', 'Message_Code': 'TAG', 'Status': 'Failure',},indent=4)) doctorid = json.loads(dbget("select count(*) as doctor_id from new.doctor_profile where doctor_profile_id ='"+d['doctor_id']+"'")) mobile = json.loads(dbget("select count(*) as mobile from new.user_profile where mobile ='"+d['mobile']+"'")) businessid = json.loads(dbget("select count(*) as business_id from new.business_profile where business_id ='"+str(d['business_id'])+"'")) if mobile[0]['mobile'] == 1 and doctorid[0]['doctor_id'] == 1 and businessid[0]['business_id'] == 1: dt = datetime.datetime.strptime(d['business_date'], '%Y-%m-%d').date() # to convert string to date format currenttime = datetime.datetime.now() # to get current datetime todaydate = currenttime.date() todaytime = currenttime.strftime('%H:%M') # to get current time doc_id = {k: v for k, v in d.items() if k in ('doctor_id', 'business_id')} docidval = doc_id.get("doctor_id") bus_id = doc_id.get("business_id") x = currenttime.strftime("%a")[:3].lower() b = json.loads(dbget("select end_timing from new.timing where doctor_id = '" + str(docidval)+"' and business_id = '"+str(bus_id)+"'\ and day = '"+str(x)+"' and session='evening'")) etime = b[0]['end_timing'] # to get value from list if dt == todaydate and etime > todaytime: a = {k: v for k, v in d.items() if k in ('doctor_id', 'business_id', 'business_date')} res = json.loads(gensql('select', 'new.token_no', 'count(*)', a)) if res[0]['count'] == 0: a['token_no'] = 0 gensql('insert', 'new.token_no', a) token = json.loads(gensql('select', 'new.token_no', 'token_no', a)) if token[0]['token_no'] ==0: no = 1 else: no = token[0]['token_no'] + 1 d['token_no'] = no d['token_time'] = currenttime gensql('insert', 'new.appointment', d) wt = json.loads(dbget("select average_waiting_time from new.doctorinbusiness where doctor_id = '"+str(docidval)+"' and business_id = '"+str(bus_id)+"'")) waittime = wt[0]['average_waiting_time'] if no == 1: avg_wait = 0 else: avg_wait = (no - 1) * waittime dbput("update new.token_no set token_no ='"+str(no)+"' where doctor_id='"+str(a['doctor_id'])+"' and business_id = '"+str(bus_id)+"'") return (json.dumps( {'Message': 'Token Generated', 'Message_Code': 'TGS', 'Status': 'success', 'Token_No': no, 'waiting_time': avg_wait}, indent=4)) else: return (json.dumps({"Message": "Token should be Generated only for Today Date", "Message_Code": "TGTD", "Service Status": "Failure"}, indent=4)) else: return(json.dumps({'Message': 'Invalid Data', 'Message_Code': 'ID', 'Status': 'Failure'},indent=4)) except: return (json.dumps({"Message": "Token Generation UnSuccessful", "Message_Code": "TGUS", "Service_Status": "Failure"},indent=4))
def HOTEL_AR_POST_INSERT_AccountSetup(request): d = request.json print(d) count_pf_id = json.loads( dbget( "select count(*) from account_receivable.account_setup where profile_id='" + d['profile_id'] + "' ")) #print(count_pf_id[0]['count'],type(count_pf_id[0]['count'])) if count_pf_id[0]['count'] != 0: return (json.dumps( { "Return": "Record Already Inserted", "ReturnCode": "RAI", "Status": "Success", "StatusCode": "200" }, indent=4)) ac_name = json.loads( dbget( "select pf_account from profile.pf_company_profile where pf_id='" + d['profile_id'] + "' ")) ac_name = ac_name[0]['pf_account'] ac = ac_name.split(" ") name = '' for i in ac: name += i[0] #print(name) ac_no = json.loads( dbget("select ac_no from account_receivable.account_number")) ac_no1 = str(ac_no[0]['ac_no'] + 1) account_number = name + ac_no1 #print(account_number) dbput("update account_receivable.account_number set ac_no='" + str(ac_no[0]['ac_no'] + 1) + "' ") app_datetime = application_date() d['account_number'] = account_number d['created_on'] = app_datetime[1] d['account_balance'] = "0.00" gensql('insert', 'account_receivable.account_setup', d) return (json.dumps( { "Return": "Record Inserted Successfully", "ReturnCode": "RIS", "Status": "Success", "StatusCode": "200", "Account_number": account_number }, indent=4))
def HOTEL_PAC_POST_DELETE_Package(request): d = request.json dbput("delete from packages.package_code where package_code_id = " + str(d['package_code_id']) + " ") return (json.dumps( { 'Status': 'Success', 'StatusCode': '200', 'Return': 'Record Deleted Successfully', 'ReturnCode': 'RDS' }, sort_keys=True, indent=4))
def DeleteProfileRecord(request): pf_id = request.json['pf_id'] print(pf_id) if pf_id[0:3] == 'ind': sql = ("delete from profile.pf_individual_profile where pf_id = '"+pf_id+"' ") print(sql) dbput(sql) return(json.dumps({'Status': 'Success', 'StatusCode': '200','Return': 'Record Deleted Successfully','ReturnCode':'RDS'}, sort_keys=True, indent=4)) else : sql = ("delete from profile.pf_company_profile where pf_id = '"+pf_id+"' ") print(sql) dbput(sql) return(json.dumps({'Status': 'Success', 'StatusCode': '200','Return': 'Record Deleted Successfully','ReturnCode':'RDS'}, sort_keys=True, indent=4))
def Delete_Rate_details(request): d = request.json dbput( "delete FROM revenue_management.rate_details where rate_details_id=" + str(d['rate_details_id']) + " ") return (json.dumps( { 'Status': 'Success', 'StatusCode': '200', 'Return': 'Record Deleted Successfully', 'ReturnCode': 'RDS' }, sort_keys=True, indent=4))
def DeleteProfileRecord(): #con = psycopg2.connect(user='******',password='******',host='ec2-54-235-146-184.compute-1.amazonaws.com',port='5432',database='dfbvc8j8egd076') #cur = con.cursor() PF_Firstname = request.args['PF_Firstname'] PF_Mobileno = request.args['PF_Mobileno'] PF_Type = request.args['PF_Type'] if PF_Type == 'individual': if request.args.get('PF_Firstname') and request.args.get( 'PF_Mobileno') and request.args.get('PF_Type'): sql = ( "delete from profile.pf_individual_profile where PF_Firstname = '" + PF_Firstname + "' and PF_Mobileno = " + PF_Mobileno + " and PF_Type = '" + PF_Type + "'") print(sql) #cur.execute(sql) dbput(sql) #con.commit() return (json.dumps( { 'Status': 'Success', 'StatusCode': '200', 'Return': 'Record Deleted Successfully', 'ReturnCode': 'RDS' }, sort_keys=True, indent=4)) else: sql = ( "delete from profile.pf_company_profile where PF_Firstname = '" + PF_Firstname + "' and PF_Mobileno = " + PF_Mobileno + " and PF_Type = '" + PF_Type + "' ") print(sql) dbput(sql) return (json.dumps( { 'Status': 'Success', 'StatusCode': '200', 'Return': 'Record Deleted Successfully', 'ReturnCode': 'RDS' }, sort_keys=True, indent=4))
def HOTEL_PAC_POST_INSERT_Packages(request): d = request.json print(d) e = { k: v for k, v in d.items() if k not in ('alternates', 'item_inventory_selected_id') } print("0000", e) alternate_id = json.loads( dbget( "select max(alternate_id) as number1 from packages.alternate_selected" )) print("alternate_id", alternate_id[0]['number1']) for i in d['alternates']: #pass dbput( "insert into packages.alternate_selected (alternate_id,package_code_id) \ values ('" + str(alternate_id[0]['number1'] + 1) + "','" + str(i) + "') ") e['alternates_selected_id'] = int(alternate_id[0]['number1'] + 1) print("1111", e) item_inventory_id = json.loads( dbget( "select max(item_id) as number2 from packages.item_inventory_selected" )) print("item_inventory_id", item_inventory_id[0]['number2']) for i in d['item_inventory_selected_id']: #pass dbput( "insert into packages.item_inventory_selected (item_id,item_inventory_id) \ values ('" + str(item_inventory_id[0]['number2'] + 1) + "','" + str(i) + "') ") e['item_inventory_selected_id'] = int(item_inventory_id[0]['number2'] + 1) print("2222", e) gensql('insert', 'packages.package_code', e) return (json.dumps( { 'Status': 'Success', 'StatusCode': '200', 'Return': 'Record Inserted Successfully', 'ReturnCode': 'RIS' }, sort_keys=True, indent=4))
def HOTEL_AR_POST_DELETE_AccountTraces(request): account_traces_id = request.json['traces_id'] print(account_traces_id) dbput(( "delete from account_receivable.account_traces where account_traces_id = '" + account_traces_id + "' ")) return (json.dumps( { 'Status': 'Success', 'StatusCode': '200', 'Return': 'Record Deleted Successfully', 'ReturnCode': 'RDS' }, sort_keys=True, indent=4))
def HOTEL_AR_POST_DELETE_ArNotes(request): account_number = request.json['account_number'] ar_notes_id = request.json['ar_notes_id'] print(account_number) dbput(("delete from account_receivable.ar_notes where account_number = '" + account_number + "' and ar_notes_id = '" + str(ar_notes_id) + "' ")) return (json.dumps( { 'Status': 'Success', 'StatusCode': '200', 'Return': 'Record Deleted Successfully', 'ReturnCode': 'RDS' }, sort_keys=True, indent=4))
def HOTEL_AR_POST_DELETE_AccountSetup(request): pf_id = request.json['profile_id'] print(pf_id) dbput( ("delete from account_receivable.account_setup where profile_id = '" + pf_id + "' ")) return (json.dumps( { 'Status': 'Success', 'StatusCode': '200', 'Return': 'Record Deleted Successfully', 'ReturnCode': 'RDS' }, sort_keys=True, indent=4))
def HOTEL_AR_POST_SELECT_ApplyPaymentSelectiviely(request): d = request.json app_datetime = application_date() Posting_date = app_datetime[1] s = {} account_invoie = json.loads( dbget("select open_amount from account_receivable.accout_inivoice \ where account_number = '" + str(d['account_no']) + "' and invoice_no = '" + str(d['invoice_no']) + "'")) acc_inv = account_invoie[0]['open_amount'] - d['posting_amount'] print(acc_inv) acc_set = json.loads( dbget("select account_balance from account_receivable.account_setup \ where account_number = '" + str(d['account_no']) + "'")) setupamount = acc_set[0]['account_balance'] - d['posting_amount'] d['posting_date'] = Posting_date d['posting_status'] = "Apply" gensql('insert', 'account_receivable.invoice_payment', d) sql = dbput( "update account_receivable.account_setup set account_balance = '" + str(setupamount) + "' \ where account_number = '" + d['account_no'] + "'") psql = dbput( "update account_receivable.accout_inivoice set open_amount = '" + str(acc_inv) + "' \ where account_number = '" + d['account_no'] + "' and invoice_no = '" + str(d['invoice_no']) + "' ") s['invoice_id'] = str(d['invoice_no']) s['account_no'] = d['account_no'] s['payment_type_id'] = d['payment_code_id'] s['post_date'] = Posting_date s['payment_amount'] = d['posting_amount'] gensql('insert', 'account_receivable.account_pay_history', s) return (json.dumps( { "Return": "Record Inserted Successfully", "ReturnCode": "RIS", "Status": "Success", "StatusCode": "200" }, indent=4))
def yesterday_job(): yesterday = datetime.datetime.now() - datetime.timedelta(days=1) yesterday = str(yesterday) print(yesterday) sql_value = dbget( "select res_unique_id from reservation.res_reservation where res_arrival='" + yesterday + "' and res_guest_status in ('arrival')") sqlvalue = json.loads(sql_value) print("sqlval3", sqlvalue) if (len(sqlvalue) != 0): res_id = '' for i in sqlvalue: if len(res_unique_id) == 0: res_unique_id += "'" + str(i['res_unique_id']) + "'" else: res_unique_id += "," + "'" + str(i['res_unique_id']) + "'" print(res_unique_id) status = "no show" sql_value = dbput( "update reservation.res_reservation set res_guest_status = '" + status + "' where res_id in (" + str(res_unique_id) + ")") print(sql_value) else: pass
def insertpromotionalmessage(request): #e = request.json try: bus_id = request.json['business_id'] message = request.json['message'] st = request.json['message_date_start'] ed = request.json['message_date_end'] b_id = json.loads(dbget("select id from ivr_hotel_list where business_id='"+bus_id+"' ")) print(b_id[0]['id']) count = json.loads(dbget("select count(*) from ivr_promotional_message where \ id='"+str(b_id[0]['id'])+"' ")) print(count) e = {} e['message'] = message print(type(message)) e['id'] = b_id[0]['id'] e['message_date_start']= st e['message_date_end'] = ed if count[0]['count'] != 1: print(gensql('insert','ivr_promotional_message',e)) else: print(dbput("update ivr_promotional_message set message = '"+str(message)+"' , message_date_start = '"+st+"', message_date_end='"+ed+"' where id='"+str(b_id[0]['id'])+"' ")) a = {"ServiceStatus":"Success","ServiceMessage":"Success"} return(json.dumps(a)) except: a = {"ServiceStatus":"Success","ServiceMessage":"Failure"} return(json.dumps(a))
def HOTEL_AR_POST_DELETE_UnCompressInvoice(request): d = request.json z= d['invoice_no'] for i in d['invoice_no']: sql = dbput("update account_receivable.accout_inivoice set acc_invoice_satus = 'UnCompress' \ where account_number = '"+d['account_number']+"' and invoice_no = '"+str(i)+"'") print(sql) query = json.loads(dbget("select new_invoice_id from account_receivable.account_compress \ where compress_invoice = '"+str(i)+"'")) print(query) delinvoice = dbput("delete from account_receivable.accout_inivoice where invoice_no = '"+str(query[0]['new_invoice_id'])+"'") psql = dbput("delete from account_receivable.account_compress where compress_invoice = '"+str(i)+"' ") return(json.dumps({"Return": "Record Deleted Successfully","ReturnCode": "RDS","Status": "Success","StatusCode": "200"},indent=4))
def UpdateCompanyProfile(request): d = request.json select = json.loads(dbget("select * from profile.profile_id")) print(select,type(select),len(select)) print(select[0]['profile_id']) id1 = "cpy"+str(select[0]['profile_id']+1) print(id1) update = dbput("update profile.profile_id set profile_id = '"+str(select[0]['profile_id']+1)+"'") d['pf_id'] = id1 sql_value = gensql('insert','profile.pf_company_profile',d) data1 = d.get("PF_Firstname") pf_type = d['PF_Type'] #PF_Log_Time = datetime.datetime.utcnow()+datetime.timedelta(hours=5, minutes=30) #PF_Log_Time = PF_Log_Time.time().strftime("%H:%M:%S") #print(PF_Log_Time) #PF_Log_Date = datetime.datetime.utcnow().date() #print(PF_Log_Date) PF_Log_Description = "Create "+str(pf_type)+" Profile" + " "+str(data1) s = {} s['Emp_Id'] = '121' s['Emp_Firstname'] = "Admin" s['Emp_Lastname'] = "User" app_datetime = application_date() s['PF_Log_Date'] = app_datetime[1] s['PF_Log_Time'] = app_datetime[2] s['PF_Action_Type'] = "New Profile" s['PF_Log_Description'] = PF_Log_Description s['pf_id'] = id1 sql_value = gensql('insert','profile.pf_profile_activitylog',s) # finally return the value from DB_Wrapper return(json.dumps({'Status': 'Success', 'StatusCode': '200','Return': 'Record Inserted Successfully','profileid':id1,'profiletype':pf_type,'ReturnCode':'RIS'}, sort_keys=True, indent=4))
def Hotel_RES_Post_Insert_UpdateGuestPrivileges(request): s, mylist = {}, [] d = request.json for data in d['privileges_key_id']: s['res_id'] = d['res_id'] s['privileges_key_id'] = data sql_value = gensql('insert', 'reservation.res_guest_privileges', s) print(type(d['privileges_key_id'])) mylist = d['privileges_key_id'] if 5 in mylist: sql = dbput( "update reservation.res_guest_privileges set schedule_time = '" + str(d['schedule_time']) + "' \ where privileges_key_id = 5 and res_id = '" + str(d['res_id']) + "'") else: pass return (json.dumps( { 'Status': 'Success', 'StatusCode': '200', 'Return': 'Record Inserted Successfully', 'ReturnCode': 'RIS' }, sort_keys=True, indent=4))