Beispiel #1
0
def close_tab(user, request_data_dict):
    if 'place_id' and "tip" not in request_data_dict:
        return False
    deal_place_id = int(request_data_dict['place_id'])
    place = DealPlace.objects.get(id=deal_place_id)
    point_of_sale = place.point_of_sale
    tab = Tab.objects.get(user=user,
                          point_of_sale=point_of_sale,
                          closed=False,
                          cancelled=False)
    tip = Decimal(request_data_dict['tip'])
    tab = add_amount_paid_to_tab(tab, tip)
    if not authorize_payment_for_entire_tab(tab):
        return tab
    tab = close_tab_in_object(tab, tip)
    response = close_simplicity_tab(tab)
    if response != 1:
        print "close tab failed"
        send_marketing_email("*****@*****.**", "POS ERROR",
                             ['*****@*****.**'],
                             "POS ERROR close_tab failed",
                             "POS ERROR close_tab failed",
                             "POS ERROR close_tab failed", "test")
        return False
    return tab
Beispiel #2
0
def authorize_payment_for_entire_tab(tab):
    user = tab.user
    amount_to_authorize = tab.amount_paid + tab.convenience_fee
    result = braintree.Transaction.sale({
        "customer_id": str(user.id),
        "amount": str(amount_to_authorize)
    })
    print "Successful Authorization: " + str(result.is_success)
    if result.is_success:
        tab.payment_authorization = result.transaction.id
        tab.save()
        return True
    elif result.transaction:
        print("Error processing transaction:")
        print("  code: " + result.transaction.processor_response_code)
        print("  text: " + result.transaction.processor_response_text)
        send_marketing_email("*****@*****.**", "BRAINTREE ERROR",
                             ['*****@*****.**'],
                             "BRAINTREE ERROR processing transaction",
                             "BRAINTREE ERROR processing transaction",
                             "BRAINTREE ERROR processing transaction", "test")
        return False
    else:
        for error in result.errors.deep_errors:
            print("attribute: " + error.attribute)
            print("  code: " + error.code)
            print("  message: " + error.message)
        send_marketing_email("*****@*****.**", "BRAINTREE ERROR",
                             ['*****@*****.**'], "BRAINTREE DEEP ERROR",
                             "BRAINTREE DEEP ERROR", "BRAINTREE DEEP ERROR",
                             "test")
        return False
Beispiel #3
0
def send_daily_event_staffer_email_to_general_manager():
    upcoming_events = SponsoredEvent.objects.filter(
        start__gte=datetime.datetime.now())
    markets = Market.objects.all()
    html = "Markets to Hire Staffers<br>"
    for market in markets:
        if EventManager.objects.filter(
                market=market, status=STAFFER_STATUS.PRIMARY).count() < 2:
            html = html + market.name + "<br>"
    html = html + "<br>Events without Staffing<br>"
    for event in upcoming_events:
        if not EventStaffer.objects.filter(
                event=event, status=STAFFER_STATUS.PRIMARY).exists():
            market = get_market_for_event(event)
            html = html + str(
                event.place.name
            ) + " - " + market.name + "<br> No Primary Staffer<br><br>"
    html = html + "<br>Events with Staffing<br>"
    for event in upcoming_events:
        if EventStaffer.objects.filter(event=event,
                                       status=STAFFER_STATUS.PRIMARY).exists():
            primary = EventStaffer.objects.get(event=event,
                                               status=STAFFER_STATUS.PRIMARY)
            backup = EventStaffer.objects.filter(event=event,
                                                 status=STAFFER_STATUS.BACKUP)
            market = get_market_for_event(event)
            html = html + str(
                event.place.name
            ) + " - " + market.name + "<br>Primary: " + primary.manager.name + " " + str(
                primary.manager.phone_number) + "<br>" + "Backups: " + str(
                    len(backup)) + "<br>"
    send_marketing_email("*****@*****.**", "Hotspot",
                         ["*****@*****.**"], "Event Staffing", "", html,
                         "Event Staffing Daily Email")
Beispiel #4
0
def update_tab_and_tab_item_objects(tab):
    simplicity_tab_info = return_simplicity_tab_info(tab)
    if simplicity_tab_info == -1:
        print "update_tab_and_tab_item_objects failed"
        send_marketing_email("*****@*****.**", "POS ERROR",
                             ['*****@*****.**'], "POS ERROR get tab failed",
                             "POS ERROR get tab failed",
                             "POS ERROR get tab failed", "test")
        return False
    tab = update_tab_object(tab, simplicity_tab_info)
    tab_items = update_tab_item_objects(tab, simplicity_tab_info)
    return tab, tab_items
Beispiel #5
0
def add_hotspot_drink_and_return_drink_info(tab, deal):
    response = add_hotspot_drink_to_simplicity_tab(tab, deal)
    if response != 1:
        print "add drink failed"
        send_marketing_email("*****@*****.**", "POS ERROR",
                             ['*****@*****.**'],
                             "POS ERROR add_hotspot_drink failed",
                             "POS ERROR add_hotspot_drink failed",
                             "POS ERROR add_hotspot_drink failed", "test")
        return False
    simplicity_tab_info = return_simplicity_tab_info(tab)
    added_drink_menu_id = simplicity_tab_info['items'][0]['dtl_id']
    added_drink_overall_id = simplicity_tab_info['items'][0]['item_id']
    added_drink_name = simplicity_tab_info['items'][0]['name']
    added_drink_price = simplicity_tab_info['items'][0]['price']
    return added_drink_menu_id, added_drink_overall_id, added_drink_name, added_drink_price
Beispiel #6
0
def check_for_open_tabs_to_close():
    try:
        six_hours_prior = datetime.now() - timedelta(hours=6)
        open_tabs = Tab.objects.filter(tab_claimed=True,
                                       closed=False,
                                       cancelled=False,
                                       date_created__lt=six_hours_prior)
        for tab in open_tabs:
            close_tab(tab)
        print "finished checking for open tabs to close"
    except:
        print "FAIL: check_for_open_tabs_to_close"
        send_marketing_email("*****@*****.**", "CHRON ERROR",
                             ['*****@*****.**'],
                             "CHRON ERROR in check_for_open_tabs_to_close",
                             "CHRON ERROR in check_for_open_tabs_to_close",
                             "CHRON ERROR in check_for_open_tabs_to_close",
                             "test")
Beispiel #7
0
def check_if_ids_exist(deal_place):
    # if not deal_place.twitter_id and not deal_place.facebook_id:
    #     html = "missing facebook and twitter: " + deal_place.name
    #     if deal_place.website:
    #         html = html + ", " + deal_place.website
    #     send_marketing_email('*****@*****.**', 'Will Xu', ['*****@*****.**', '*****@*****.**'], 'missing an id', '', html, 'missing_id')
    # elif not deal_place.twitter_id:
    #     html = "missing twitter: " + deal_place.name
    #     if deal_place.website:
    #         html = html + ", " + deal_place.website
    #     send_marketing_email('*****@*****.**', 'Will Xu', ['*****@*****.**', '*****@*****.**'], 'missing an id', '', html, 'missing_id')
    if not deal_place.facebook_id:
        html = "missing facebook: " + deal_place.name
        if deal_place.website:
            html = html + ", " + deal_place.website
        send_marketing_email('*****@*****.**', 'Will Xu',
                             ['*****@*****.**', '*****@*****.**'],
                             'missing an id', '', html, 'missing_id')
Beispiel #8
0
def check_for_unclaimed_tabs_to_cancel():
    try:
        two_hours_prior = datetime.now() - timedelta(hours=2)
        unclaimed_tabs = Tab.objects.filter(tab_claimed=False,
                                            closed=False,
                                            cancelled=False,
                                            date_created__lt=two_hours_prior)
        for unclaimed_tab in unclaimed_tabs:
            updated_tab, tab_items = update_tab_and_tab_item_objects(
                unclaimed_tab)
            if not updated_tab.tab_claimed and len(tab_items) < 1:
                cancel_tab(updated_tab)
        print "finished checking for unclaimed tabs to cancel"
    except:
        print "FAIL: check_for_unclaimed_tabs_to_cancel"
        send_marketing_email(
            "*****@*****.**", "CHRON ERROR", ['*****@*****.**'],
            "CHRON ERROR in check_for_unclaimed_tabs_to_cancel",
            "CHRON ERROR in check_for_unclaimed_tabs_to_cancel",
            "CHRON ERROR in check_for_unclaimed_tabs_to_cancel", "test")
Beispiel #9
0
def create_tab(user, request_data_dict):
    deal_place_id = int(request_data_dict['place_id'])
    place = DealPlace.objects.get(id=deal_place_id)
    point_of_sale = place.point_of_sale
    api_tab_id = create_simplicity_tab(user, point_of_sale)
    print type(api_tab_id)
    print api_tab_id
    try:
        print int(api_tab_id)
    except ValueError:
        print "create tab failed, pos not active"
        send_marketing_email("*****@*****.**", "POS ERROR",
                             ['*****@*****.**'],
                             "POS ERROR create_tab failed",
                             "POS ERROR create_tab failed, pos not active",
                             "POS ERROR create_tab failed, pos not active",
                             "test")
        return False
    if int(api_tab_id) < 0:
        print "create tab failed"
        send_marketing_email("*****@*****.**", "POS ERROR",
                             ['*****@*****.**'],
                             "POS ERROR create_tab failed",
                             "POS ERROR create_tab failed",
                             "POS ERROR create_tab failed", "test")
        return False
    tab = create_tab_object(user, api_tab_id, point_of_sale)
    tab_items = []
    #deal = get_active_deal_for_place(place)
    #if deal:
    #    added_drink_menu_id, added_drink_overall_id, added_drink_name, added_drink_price = add_hotspot_drink_and_return_drink_info(tab, deal)
    #    tab_item = create_tab_item_object(tab, added_drink_menu_id, added_drink_overall_id, added_drink_name, added_drink_price, deal)
    #    tab_item = add_extra_deal_properties(tab_item)
    #    tab_items = [tab_item]
    #else:
    #    tab_items = []
    simplicity_tab_info = return_simplicity_tab_info(tab)
    tab = update_tab_object(tab, simplicity_tab_info)
    return tab, tab_items