コード例 #1
0
ファイル: payment.py プロジェクト: seddikdimassi/nadine
def usaepay_transactions(request, year, month, day):
    d = date(year=int(year), month=int(month), day=int(day))
    open_batch = False
    amex = []
    visamc = []
    ach = []
    settled_checks = []
    other_transactions = []
    totals = {'amex_total':0, 'visamc_total':0, 'ach_total':0, 'total':0}
    open_xero_invoices = XeroAPI().get_open_invoices_by_user()
    try:
        api = PaymentAPI()

        if 'close_batch' in request.GET:
            api.close_current_batch()
            messages.add_message(request, messages.INFO, "Current batch closed")

        transactions = api.get_transactions(year, month, day)
        totals['total_count'] = len(transactions)

        # Pull the settled checks seperately
        settled_checks = api.get_checks_settled_by_date(year, month, day)

        for t in transactions:
            # Pull the member and the amount they owe
            member = Member.objects.filter(user__username = t['username']).first()
            if member:
                t['member'] = member
                t['open_bill_amount'] = member.open_bill_amount()
                t['xero_invoices'] = open_xero_invoices.get(t['username'], [])
                for i in t['xero_invoices']:
                    if i['AmountDue'] != t['amount']:
                        t['xero_invoices'].remove(i)

            # Total up all the Settled transactions
            if t['transaction_type'] == "Sale" and t['status'] != "Declined" and t['status'] != "Error":
                totals['total'] = totals['total'] + t['amount']
                if t['card_type'] == "A":
                    amex.append(t)
                    totals['amex_total'] = totals['amex_total'] + t['amount']
                elif t['card_type'] == "V" or t['card_type'] == "M":
                    visamc.append(t)
                    totals['visamc_total'] = totals['visamc_total'] + t['amount']
                elif t['card_type'] == "ACH":
                    ach.append(t)
                    totals['ach_total'] = totals['ach_total'] + t['amount']

                # Presence of authorized transactions means this batch is still open
                if t['status'] == "Authorized":
                    open_batch = True
            else:
                other_transactions.append(t)


    except Exception as e:
        messages.add_message(request, messages.ERROR, e)

    return render_to_response('staff/charges.html', {'date': d, 'amex': amex, 'visamc': visamc, 'ach':ach, 'open_batch':open_batch,
                                                      'other_transactions': other_transactions, 'settled_checks':settled_checks, 'totals':totals,
                                                      'next_date': d + timedelta(days=1), 'previous_date': d - timedelta(days=1)}, context_instance=RequestContext(request))
コード例 #2
0
ファイル: payment.py プロジェクト: nadineproject/nadine
def usaepay_transactions(request, year, month, day):
    d = date(year=int(year), month=int(month), day=int(day))
    open_batch = False
    amex = []
    visamc = []
    ach = []
    settled_checks = []
    other_transactions = []
    totals = {'amex_total':0, 'visamc_total':0, 'ach_total':0, 'settled_checks':0, 'total':0}

    open_xero_invoices = {}
    try:
        open_xero_invoices = XeroAPI().get_open_invoices_by_user()
    except Exception:
        # Xero not integrated
        pass

    try:
        api = PaymentAPI()

        if 'close_batch' in request.GET:
            api.close_current_batch()
            messages.add_message(request, messages.INFO, "Current batch closed")

        # Pull the settled checks seperately
        settled_checks = api.get_checks_settled_by_date(year, month, day)
        add_bills_and_invoices(settled_checks, open_xero_invoices)
        for t in settled_checks:
            totals['settled_checks'] = totals['settled_checks'] + t['amount']

        # Pull the transactions and suplement the information
        transactions = api.get_transactions(year, month, day)
        add_bills_and_invoices(transactions, open_xero_invoices)

        # Total up all the Settled transactions
        totals['total_count'] = len(transactions) + len(settled_checks)
        for t in transactions:
            if t['transaction_type'] == "Sale" and t['status'] != "Declined" and t['status'] != "Error":
                totals['total'] = totals['total'] + t['amount']
                if t['card_type'] == "A":
                    amex.append(t)
                    totals['amex_total'] = totals['amex_total'] + t['amount']
                elif t['card_type'] == "V" or t['card_type'] == "M":
                    visamc.append(t)
                    totals['visamc_total'] = totals['visamc_total'] + t['amount']
                elif t['card_type'] == "ACH":
                    ach.append(t)
                    totals['ach_total'] = totals['ach_total'] + t['amount']

                # Presence of authorized transactions means this batch is still open
                if t['status'] == "Authorized":
                    open_batch = True
            else:
                other_transactions.append(t)
    except Exception as e:
        messages.add_message(request, messages.ERROR, e)

    context = {
        'date': d,
        'amex': amex,
        'visamc': visamc,
        'ach':ach,
        'open_batch':open_batch,
        'other_transactions': other_transactions,
        'settled_checks':settled_checks,
        'totals':totals,
        'previous_date': d - timedelta(days=1),
        'next_date': d + timedelta(days=1),
    }
    return render(request, 'staff/billing/charges.html', context)
コード例 #3
0
ファイル: payment.py プロジェクト: obfusgator/nadine
def usaepay_transactions(request, year, month, day):
    d = date(year=int(year), month=int(month), day=int(day))
    open_batch = False
    ach = []
    credit_cards = []
    settled_checks = []
    other_transactions = []
    totals = {'cc_total':0, 'ach_total':0, 'settled_checks':0, 'total':0}

    open_xero_invoices = {}
    try:
        open_xero_invoices = XeroAPI().get_open_invoices_by_user()
    except Exception:
        # Xero not integrated
        pass

    try:
        api = PaymentAPI()

        if 'close_batch' in request.GET:
            api.close_current_batch()
            messages.add_message(request, messages.INFO, "Current batch closed")

        # Pull the settled checks seperately
        settled_checks = api.get_checks_settled_by_date(year, month, day)
        add_bills_and_invoices(settled_checks, open_xero_invoices)
        for t in settled_checks:
            totals['settled_checks'] = totals['settled_checks'] + t['amount']

        # Pull the transactions and suplement the information
        transactions = api.get_transactions(year, month, day)
        add_bills_and_invoices(transactions, open_xero_invoices)

        # Total up all the Settled transactions
        totals['total_count'] = len(transactions) + len(settled_checks)
        for t in transactions:
            if t['transaction_type'] == "Sale" and t['status'] != "Declined" and t['status'] != "Error":
                totals['total'] = totals['total'] + t['amount']
                if t['card_type'] == "ACH":
                    ach.append(t)
                    totals['ach_total'] = totals['ach_total'] + t['amount']
                else:
                    credit_cards.append(t)
                    totals['cc_total'] = totals['cc_total'] + t['amount']

                # Presence of authorized transactions means this batch is still open
                if t['status'] == "Authorized":
                    open_batch = True
            else:
                other_transactions.append(t)
    except Exception as e:
        messages.add_message(request, messages.ERROR, e)

    context = {
        'date': d,
        'ach':ach,
        'credit_cards': credit_cards,
        'open_batch':open_batch,
        'other_transactions': other_transactions,
        'settled_checks':settled_checks,
        'totals':totals,
        'previous_date': d - timedelta(days=1),
        'next_date': d + timedelta(days=1),
    }
    return render(request, 'staff/billing/charges.html', context)
コード例 #4
0
ファイル: payment.py プロジェクト: FarsetLabs/farset-nadine
def usaepay_transactions(request, year, month, day):
    d = date(year=int(year), month=int(month), day=int(day))
    open_batch = False
    amex = []
    visamc = []
    ach = []
    settled_checks = []
    other_transactions = []
    totals = {"amex_total": 0, "visamc_total": 0, "ach_total": 0, "total": 0}
    open_xero_invoices = XeroAPI().get_open_invoices_by_user()
    try:
        api = PaymentAPI()

        if "close_batch" in request.GET:
            api.close_current_batch()
            messages.add_message(request, messages.INFO, "Current batch closed")

        transactions = api.get_transactions(year, month, day)
        totals["total_count"] = len(transactions)

        # Pull the settled checks seperately
        settled_checks = api.get_checks_settled_by_date(year, month, day)

        for t in transactions:
            # Pull the member and the amount they owe
            u = User.objects.filter(username=t["username"]).first()
            if u:
                # TODO - change to User
                t["member"] = u.profile
                t["open_bill_amount"] = u.profile.open_bill_amount()
                t["xero_invoices"] = open_xero_invoices.get(t["username"], [])
                for i in t["xero_invoices"]:
                    if i["AmountDue"] != t["amount"]:
                        t["xero_invoices"].remove(i)

            # Total up all the Settled transactions
            if t["transaction_type"] == "Sale" and t["status"] != "Declined" and t["status"] != "Error":
                totals["total"] = totals["total"] + t["amount"]
                if t["card_type"] == "A":
                    amex.append(t)
                    totals["amex_total"] = totals["amex_total"] + t["amount"]
                elif t["card_type"] == "V" or t["card_type"] == "M":
                    visamc.append(t)
                    totals["visamc_total"] = totals["visamc_total"] + t["amount"]
                elif t["card_type"] == "ACH":
                    ach.append(t)
                    totals["ach_total"] = totals["ach_total"] + t["amount"]

                # Presence of authorized transactions means this batch is still open
                if t["status"] == "Authorized":
                    open_batch = True
            else:
                other_transactions.append(t)

    except Exception as e:
        messages.add_message(request, messages.ERROR, e)

    return render_to_response(
        "staff/charges.html",
        {
            "date": d,
            "amex": amex,
            "visamc": visamc,
            "ach": ach,
            "open_batch": open_batch,
            "other_transactions": other_transactions,
            "settled_checks": settled_checks,
            "totals": totals,
            "next_date": d + timedelta(days=1),
            "previous_date": d - timedelta(days=1),
        },
        context_instance=RequestContext(request),
    )