After implementing the ticketing system in Open Event, it was necessary to implement the control of fees for each type of currency. Thus an Admin page for controlling the percentage of fees and the maximum allowed fee for each type of currency was made:
Here initially on loading the system for the first time the service fees and maximum fees are 0. The Super Admin then sets the values. However if for some reason the maximum fee is still left blank then it becomes equal to the service fees.
The backend code for this is as follows:
if 'service_fee' in kwargs: ticket_service_fees = kwargs.get('service_fee') ticket_maximum_fees = kwargs.get('maximum_fee') from app.helpers.data_getter import DataGetter from app.helpers.data import save_to_db currencies = DataGetter.get_payment_currencies() ticket_fees = DataGetter.get_fee_settings() if not ticket_fees: for i, (currency, has_paypal, has_stripe) in enumerate(currencies): currency = currency.split(' ') if float(ticket_maximum_fees[i]) == 0.0: ticket_maximum_fees[i] = ticket_service_fees[i] ticket_fee = TicketFees(currency=currency, service_fee=ticket_service_fees[i], maximum_fee=ticket_maximum_fees[i]) save_to_db(ticket_fee, "Ticket Fees settings saved") else: i = 0 for fee in ticket_fees: if float(ticket_maximum_fees[i]) == 0.0: ticket_maximum_fees[i] = ticket_service_fees[i] fee.service_fee = ticket_service_fees[i] fee.maximum_fee = ticket_maximum_fees[i] save_to_db(fee, "Fee Options Updated") i += 1
So it checks if the ‘service fees’ is there in the request. If Yes then it stores all the service fees in one list and all the corresponding maximum fees in another list. Then it checks if the fee settings are already stored in the database using the
ticket_fees = DataGetter.get_fee_settings()
If the organizer is setting the fees for the first time then it will return None. In that case new settings are created. If fees are already created then the settings are just modified. And in both cases if the maximum fee is 0 then the maximum fee will be set to service fee.
Thus the fee system is implemented for the tickets.