3
؀h                 @   sD  d dl mZmZmZmZmZmZmZ d dlmZm	Z	 d dl
Z
d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlm Z  dd Z!G dd dZ"G dd dZ#G dd dZ$G dd dZ%G dd dZ&G dd dZ'G dd dZ(G dd dZ)dS )    )Flaskjsonifyrender_templateurl_forrequestredirectjson)datetime	timedeltaN)db)BookingType)PaymentMethod)BookingStatus)	Mandatory)Vehicle)	GuestType)Gate)FacilityPricingc             C   s   | j j  d S )N)sessionclose)self r   -/booking_service/app/routes/seed_functions.pyr      s    r   c               @   s   e Zd Zdd ZdS )BookingTypeSeedc              C   s  g } t jjtjtjd kjtjdkj dkrXtdddddd}t jj| | j	d t jjtjtjd kjtjd	kj dkrtd	d
ddddd}t jj| | j	d t jjtjtjd kjtjdkj dkrtddddddd}t jj| | j	d t jjtjtjd kjtjdkj dkr^tddddddd}t jj| | j	d t jjtjtjd kjtjdkj dkrtdddddd}t jj| | j	d t jjtjtjd kjtjdkj dkr
tdddddd}t jj| | j	d t jjtjtjd kjtjdkj dkr`tdd d!ddd}t jj| | j	d" y,t jj
  tt  | j	d# td$| id%fS  tk
r } z8t| t jj  tt  g } | j	d& td$| id'fS d }~X nX d S )(NPB001A20r   zPartner BookingzA booking made by a partner.1Admin)booking_type_public_idbooking_type_namebooking_type_descriptionbooking_type_back
session_idz/Partner Booking has been added to the database.GB601X10zGuest BookingzA guest booking.)r   r   r   booking_type_publicr    r!   z-Guest Booking has been added to the database.ZVB938L19Z	VolunteerzVolunteer booking.z)Volunteer has been added to the database.FF9330A3zFront Office BookingzFront Office Booking booking.z4Front Office Booking has been added to the database.8D7E6504SchoolzSchool booking.)r   r   r   booking_type_groupr!   z&School has been added to the database.C3237489	CorporatezCorporate booking.z)Corporate has been added to the database.7769748CzMember BookingzMember booking.z&Member has been added to the database.z9The booking types table has been seeded. Please carry on.message   zgIt's us, not you. There was an error while seeding the booking types table. :-( Please try again later.i  )r   r   queryr   filterdeletion_markerr   countaddappendcommitr   r   	Exceptionprintrollback)outputpartner_bookingguest_bookingZ	volunteerschool	corporatememberer   r   r   "seed_default_booking_types_methods   s    










z2BookingTypeSeed.seed_default_booking_types_methodsN)__name__
__module____qualname__r>   r   r   r   r   r      s   r   c               @   s   e Zd Zdd ZdS )BookingStatusSeedc              C   sz  g } t jjtjtjd kjtjdkj dkrVtddddd}t jj| | j	d t jjtjtjd kjtjdkj dkrtdd	d
dd}t jj| | j	d t jjtjtjd kjtjdkj dkrtddddd}t jj| | j	d t jjtjtjd kjtjdkj dkrNtddddd}t jj| | j	d t jjtjtjd kjtjdkj dkrtddddd}t jj| | j	d t jjtjtjd kjtjdkj dkrtddddd}t jj| | j	d t jjtjtjd kjtjdkj dkrJtddddd}t jj| | j	d t jjtjtjd kjtjd kj dkrtd d!d"dd}t jj| | j	d# t jjtjtjd kjtjd$kj dkrtd$d%d&dd}	t jj|	 | j	d' y,t jj
  tt  | j	d( td)| id*fS  tk
rt }
 z8t|
 t jj  tt  g } | j	d+ td)| id,fS d }
~
X nX d S )-Nz$d0c9dc58-4bd7-4279-85e1-70b8b1632f02r   	ConfirmedzA confirmed order.r   )booking_status_public_idbooking_status_namebooking_status_descriptionr!   z)Confirmed has been added to the database.z$4161804a-846b-438d-b969-ae2af85fd4c8UnconfirmedzAn unconfirmed booking.z+Unconfirmed has been added to the database.z$17e163c2-cbcf-4323-9606-609f0015fb65	AbandonedzAn abandoned booking.z)Abandoned has been added to the database.z$626f13f2-aab0-4488-a774-44969b3062a3	CancelledzA cancelled booking.z)Cancelled has been added to the database.z$d57587b6-24da-40a6-a4d1-fe41972dc936zPending Paymentz%A booking that is yet to be paid for.z/Pending Payment has been added to the database.z$3216010b-7c03-48b4-b82e-6c8ea5e3096bzNo-ShowzGA booking that is yet to be checked in past the expected check-in date.z'No-Show has been added to the database.z$693afa26-7429-4a79-afbf-e44e513663dfUpdatedz A booking that has been updated.z'Updated has been added to the database.z$3b5376e0-a4dc-476e-aebc-6280b44b756az
To Invoicez A booking that is to be invoicedz*To Invoice has been added to the database.z$180e751e-a70f-4052-8119-0dffd938c2c9Depositz2A booking that has had an incomplete payment made.z'Deposit has been added to the database.z:The booking status table has been seeded. Please carry on.r+   r,   zhIt's us, not you. There was an error while seeding the booking status table. :-( Please try again later.i  )r   r   r-   r   r.   r/   rD   r0   r1   r2   r3   r   r   r4   r5   r6   )r7   Z	confirmedZunconfirmedZ	abandoned	cancelledpendingZno_showupdatedinvoiceZdepositr=   r   r   r   seed_default_booking_status   s    












z-BookingStatusSeed.seed_default_booking_statusN)r?   r@   rA   rP   r   r   r   r   rB      s   rB   c               @   s   e Zd Zdd ZdS )PaymentMethodSeedc              C   s  g } t jjtjtjd kjtjdkj dkrZtddddddd}t jj| | j	d t jjtjtjd kjtjd	kj dkrtd	d
ddddd}t jj| | j	d t jjtjtjd kjtjdkj dkrtdddddd}t jj| | j	d t jjtjtjd kjtjdkj dkr\tdddddd}t jj| | j	d t jjtjtjd kjtjdkj dkrtddddddd}t jj| | j	d t jjtjtjd kjtjdkj dkr
tdddddd}t jj| | j	d t jjtjtjd kjtjdkj dkr`tdddddd}t jj| | j	d  y,t jj
  tt  | j	d! td"| id#fS  tk
r } z8t| t jj  tt  g } | j	d$ td"| id%fS d }~X nX d S )&Nz$73414fc2-5bf7-42d1-9cdf-08fee8a0b08er   zCredit CardzMeans of payment by credit cardr   r   )payment_method_public_idpayment_method_namepayment_method_descriptionpayment_method_guestpayment_method_partnerr!   z+Credit Card has been added to the database.z$cbff45f3-4f12-41da-8b4a-bf308112f032ZMpesazMobile money payment method.z%Mpesa has been added to the database.z$746bb582-89ed-4c83-ac3c-f25d9d60b266zBank Transferz"Means of payment by bank transfer.)rR   rS   rT   rV   r!   z-Bank Transfer has been added to the database.z$a4e3aeb3-0937-49d5-b3dd-87b8c2f2654bZOtherzMiscellaneous payment method.z%Other has been added to the database.z$4c6a9513-ea69-437e-9c3a-32a7afc1706az%Split (Two Different Payment Methods)zA mix of two payment methods.zESplit (Two Different Payment Methods) has been added to the database.z$94a91336-3bac-4e2f-8881-2887d27e4d61Z	InclusivezN/A.z)Inclusive has been added to the database.z$1e62ecfc-6a3a-4112-835c-4dc3fe8e28c7ZPrepaidz'Prepaid has been added to the database.z;The payment methods table has been seeded. Please carry on.r+   r,   ziIt's us, not you. There was an error while seeding the payment methods table. :-( Please try again later.i  )r   r   r-   r   r.   r/   rR   r0   r1   r2   r3   r   r   r4   r5   r6   )r7   Zcard_methodZmpesa_methodZbank_transfer_methodr=   r   r   r   seed_default_payment_methods>  s    










z.PaymentMethodSeed.seed_default_payment_methodsN)r?   r@   rA   rW   r   r   r   r   rQ   =  s   rQ   c               @   s   e Zd Zdd ZdS )MandatoryPaymentsSeedc              C   sr  g } t jjtjtjd kjtjdkj dkrtddddddd	d
}t jj| | j	d tddddddd	d
}t jj| | j	d tddddddd	d
}t jj| | j	d tddddddd	d
}t jj| | j	d tddddddd	d
}t jj| | j	d td d!dd"ddd	d
}t jj| | j	d# td$d%ddddd	d
}t jj| | j	d& td'd(dd"ddd	d
}t jj| | j	d) td*d+dd,ddd	d
}	t jj|	 | j	d- tdd.dd/d0dd	d
}
t jj|
 | j	d1 y,t jj
  tt  | j	d2 td3| id4fS  tk
rl } z8t| t jj  tt  g } | j	d5 td3| id6fS d }~X nX d S )7Nz$cf347d6b-11e8-4b85-95bf-543da14e0bb3r   z$cdf8982a-3252-40ec-a49b-d752420eaa9bzNon Resident AdultZUSDZ85Ai  r   )payment_public_idpayment_personpayment_person_currencypayment_person_amountmarkermaximum_numberr!   z2Non Resident Adult has been added to the database.z$6ba37724-04df-4a1d-b475-c2915ec52a81zNon Resident ChildZ42Ci  z2Non Resident Child has been added to the database.z$9ab7da60-6813-411a-9a00-f2d8a413c5bbzNon Resident Student21i  z4Non Resident Student has been added to the database.z$b0dc8ab1-91e2-4474-ad29-9dcda9c30fc5zEA Resident AdultKESZ2200z1EA Resident Adult has been added to the database.z$a0d24649-c085-4b5e-adec-d3f93f2e22d2zEA Resident ChildZ1100z1EA Resident Child has been added to the database.z$18b25633-12bb-44da-b9f8-47dc629bace4zEA Resident Student550z3EA Resident Student has been added to the database.z$a8fe2f62-1671-41ff-a059-d80a5d1d3ea7zCitizen Adultz-Citizen Adult has been added to the database.z$c1b66cb1-6c83-42c0-86f5-0db21d1b9f60zCitizen Childz-Citizen Child has been added to the database.z$c7bf17ef-5d92-4cf7-866a-881fba828de3zCitizen StudentZ275z/Citizen Student has been added to the database.Infant0Iz&Infant has been added to the database.z>The mandatory payments table has been seeded. Please carry on.r+   r,   zlIt's us, not you. There was an error while seeding the mandatory payments table. :-( Please try again later.i  )r   r   r-   r   r.   r/   rZ   r0   r1   r2   r3   r   r   r4   r5   r6   )r7   non_resident_adultnon_resident_childnon_resident_studentZea_resident_adultZea_resident_childea_resident_studentZcitizen_adultZcitizen_childcitizen_studentZinfantr=   r   r   r   seed_default_mandatory_payments  s    













z5MandatoryPaymentsSeed.seed_default_mandatory_paymentsN)r?   r@   rA   rl   r   r   r   r   rX     s   rX   c               @   s   e Zd Zdd ZdS )VehicleChargesSeedc              C   s  g } t jjtjtjd kjtjdkj dkrZtddddddd}t jj| | j	d	 t jjtjtjd kjtjd
kj dkrtd
dddddd}t jj| | j	d t jjtjtjd kjtjdkj dkrtddddddd}t jj| | j	d y,t jj
  tt  | j	d td| idfS  tk
r } z8t| t jj  tt  g } | j	d td| idfS d }~X nX d S )Nz$d1954103-53af-4411-9550-1634d255e343r   z1 to 6 Seatsi  z$162fface-f5f1-41de-913b-d2bb784dda3a   r   )vehicle_charge_public_idvehicle_charge_categoryvehicle_charge_category_costvehicle_charge_cost_currencyr_   r!   z/The vehicle class 1 to 6 seats has been seeded.z$e6473bfe-ccc1-4f96-850a-ae022eb4e87az7 to 14 Seatsi  z0The vehicle class 7 to 14 seats has been seeded.z$99330ddf-4bd6-4c5e-8844-66b6d7ba1134z15 Seats and Abovei'  z5The vehicle class 15 seats and above has been seeded.z;The vehicle charges table has been seeded. Please carry on.r+   r,   ziIt's us, not you. There was an error while seeding the vehicle charges table. :-( Please try again later.i  )r   r   r-   r   r.   r/   ro   r0   r1   r2   r3   r   r   r4   r5   r6   )r7   Z	vehicle_1Z	vehicle_2Z	vehicle_3r=   r   r   r   seed_default_vehicle_chargesb  sh    






z/VehicleChargesSeed.seed_default_vehicle_chargesN)r?   r@   rA   rs   r   r   r   r   rm   a  s   rm   c               @   s   e Zd Zdd ZdS )BookingGuestTypesSeedc        
      C   s6  g } t jjtjtjd kjtjdkj dkrTtdddd}t jj| | j	d t jjtjtjd kjtjdkj dkrtdddd}t jj| | j	d	 t jjtjtjd kjtjd
kj dkrtd
ddd}t jj| | j	d t jjtjtjd kjtjdkj dkrFtdddd}t jj| | j	d t jjtjtjd kjtjdkj dkrtdddd}t jj| | j	d t jjtjtjd kjtjdkj dkrtdddd}t jj| | j	d t jjtjtjd kjtjdkj dkr<tdddd}t jj| | j	d t jjtjtjd kjtjdkj dkrtdddd}t jj| | j	d t jjtjtjd kjtjdkj dkrtdddd}t jj| | j	d t jjtjtjd kjtjdkj dkr2tdd dd}	t jj|	 | j	d! d S )"NZbd952f21r   zCitizen Adultr   )booking_guest_type_public_idbooking_guest_type_namer!   z-Citizen Adult has been added to the database.Z534613c1zEA Resident Adultz1EA Adult Resident has been added to the database.Zc78b0b7azNon Resident Adultz2Non Resident Adult has been added to the database.Z5d895853zCitizen Childz-Citizen Child has been added to the database.Zb2c2dbf0zEA Resident Childz1EA Child Resident has been added to the database.Z71f4f313zNon Resident Childz2Non Resident Child has been added to the database.2df20a96rd   z&Infant has been added to the database.Z172775c1zCitizen Studentz/Citizen Student has been added to the database.Z429bb1f4zEA Resident Studentz3EA Resident Student has been added to the database.Z9a6e34d2zNon Resident Studentz4Non Resident Student has been added to the database.)
r   r   r-   r   r.   r/   ru   r0   r1   r2   )
r7   Zea_adult_citizenZea_adult_residentrg   Zea_child_citizenZea_child_residentrh   rk   rj   ri   r   r   r   (seed_default_booking_guest_types_methods  s    








z>BookingGuestTypesSeed.seed_default_booking_guest_types_methodsN)r?   r@   rA   rx   r   r   r   r   rt     s   rt   c               @   s   e Zd Zdd ZdS )	GatesSeedc              C   s,  g } t jjtjtjd kjtjdkj dkrTtdddd}t jj| | j	d t jjtjtjd kjtjdkj dkrtdddd}t jj| | j	d	 y,t jj
  tt  | j	d
 td| idfS  tk
r& } z8t| t jj  tt  g } | j	d td| idfS d }~X nX d S )NZ05e7ee16r   zGolf 2r   )gate_public_id	gate_namer!   z&Golf 2 has been added to the database.Z9ac19eb6zGolf 3z&Golf 3 has been added to the database.z1The gates table has been seeded. Please carry on.r+   r,   z_It's us, not you. There was an error while seeding the gates table. :-( Please try again later.i  )r   r   r-   r   r.   r/   rz   r0   r1   r2   r3   r   r   r4   r5   r6   )r7   Zgate1Zgate2r=   r   r   r   seed_default_gates3  sB    





zGatesSeed.seed_default_gatesN)r?   r@   rA   r|   r   r   r   r   ry   2  s   ry   c               @   s   e Zd Zdd ZdS )FacilityPricingTypeSeedc              C   s  g } t jjtjtjd kjtjdkj dkrVtddd dd}t jj| | j	d t jjtjtjd kjtjdkj dkrtddd dd}t jj| | j	d	 t jjtjtjd kjtjd
kj dkrtd
dd dd}t jj| | j	d y,t jj
  tt  | j	d td| idfS  tk
r| } z8t| t jj  tt  g } | j	d td| idfS d }~X nX d S )N266677c3r   zFully Cateredr   )facility_pricing_type_public_idfacility_pricing_namefacility_pricing_specialr!   z-Fully Catered has been added to the database.9a9a77ebzSelf-cateredz,Self-catered has been added to the database.377788d4zSelf-catered plus Chefz6Self-catered plus Chef has been added to the database.zBThe facility pricing types table has been seeded. Please carry on.r+   r,   zpIt's us, not you. There was an error while seeding the facility pricing types table. :-( Please try again later.i  )r   r   r-   r   r.   r/   r   r0   r1   r2   r3   r   r   r4   r5   r6   )r7   Zfully_cateredZself_cateredZchefr=   r   r   r   #seed_default_facility_pricing_typesd  s\    






z;FacilityPricingTypeSeed.seed_default_facility_pricing_typesN)r?   r@   rA   r   r   r   r   r   r}   c  s   r}   )*flaskr   r   r   r   r   r   r   r	   r
   pymysqlosmathrequestsuuidroutesr   database.booking_typesr   database.payment_methodsr   database.booking_statusr   database.mandatory_paymentsr   database.vehicler   database.booking_guest_typesr   database.gater   database.facility_pricing_typer   r   r   rB   rQ   rX   rm   rt   ry   r}   r   r   r   r   <module>   s2   $( 
   G 1