Ejemplo n.º 1
0
def forgot():
    add_account_form = AddAccountForm()
    #If user is logged in, they certainly didn't forget their goddam password
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = ForgotPasswordForm()
    return render_template('forgot-password.html', form=form)
Ejemplo n.º 2
0
def alerts():
    current_account=""
    expense_form = SubmitExpenseForm()
    deposit_form = SubmitDepositForm()
    add_account_form = AddAccountForm()
    if True:
        current_account,current_account_name,accounts,len_act,current_balance,current_deposits,current_expenses,deposits,expenses,all_accounts,all_balances = set_standard_values()
    return render_template('alerts.html',accounts=accounts,current_balance=current_balance,all_accounts=all_accounts,all_balances=all_balances,
                            len_act=len_act,current_account=current_account,current_account_name=current_account_name,
                            deposits=deposits,expenses=expenses,expense_form=expense_form,deposit_form=deposit_form)
Ejemplo n.º 3
0
def charts():
    current_account = ""
    add_account_form = AddAccountForm()
    if True:
        current_account, current_account_name, accounts, len_act, balance, deposits, expenses = set_standard_values(
        )
    return render_template('charts.html',
                           accounts=accounts,
                           balance=balance,
                           len_act=len_act,
                           current_account=current_account,
                           current_account_name=current_account_name,
                           deposits=deposits,
                           expenses=expenses)
Ejemplo n.º 4
0
def reports():
    length = 10
    add_account_form = AddAccountForm()
    expense_form = SubmitExpenseForm()
    deposit_form = SubmitDepositForm()
    current_account = ""
    if True:
        current_account, current_account_name, accounts, len_act, balance, deposits, expenses = set_standard_values(
        )
    return render_template('reports.html',
                           length=length,
                           accounts=accounts,
                           balance=balance,
                           len_act=len_act,
                           current_account=current_account,
                           current_account_name=current_account_name,
                           deposits=deposits,
                           expenses=expenses,
                           expense_form=expense_form,
                           deposit_form=deposit_form)
Ejemplo n.º 5
0
def home():
    #Set Form Values
    expense_form = SubmitExpenseForm()
    deposit_form = SubmitDepositForm()
    add_account_form = AddAccountForm()
    #Get Default Values for All Forms
    if True:
        current_account, current_account_name, accounts, len_act, balance, deposits, expenses = set_standard_values(
        )
    ### Form Submit for Adding New Account Modal ###
    if add_account_form.validate_on_submit():
        account = Account(name=add_account_form.account_name.data,
                          safe_bal=add_account_form.safe_bal.data,
                          crit_bal=add_account_form.crit_bal.data,
                          owner_id=current_user.id)
        db.session.add(account)
        db.session.commit()
        # If This is the First Account, Set it as Default in View
        if len(current_user.accounts) == 1:
            all_accounts = Account.query.filter(Account.id).all()
            last_account = all_accounts[-1]
            last_account = last_account.id
            current_user.current_account = last_account
            db.session.commit()
        #flash('Account Has Been Added', 'success')
        return redirect(url_for('home'))
    ##################################################
    ### Form Submit for Adding an Expense ###
    if expense_form.validate_on_submit():
        #Convert Decimals to Full Integers to be divided later
        temp_amount = str(round(float(expense_form.amount.data), 2))
        if len(temp_amount.split('.')[1]) == 1:
            temp_amount = temp_amount + "0"
        expense_form.amount.data = int(temp_amount.replace('.', ''))
        #End of Convert
        expense = Expense(date=expense_form.date.data,
                          amount=expense_form.amount.data,
                          payee=expense_form.payee.data,
                          category=expense_form.category.data,
                          comment=expense_form.comment.data,
                          acct_id=current_user.current_account)
        db.session.add(expense)
        db.session.commit()
        #flash('Payment Entered Successfully', 'success')
        return redirect(url_for('home'))
    ###########################################
    ### Form Submit for Adding a Deposit ###
    if deposit_form.validate_on_submit():
        temp_amount = str(round(float(deposit_form.dep_amount.data), 2))
        if len(temp_amount.split('.')[1]) == 1:
            temp_amount = temp_amount + "0"
        deposit_form.dep_amount.data = int(temp_amount.replace('.', ''))
        deposit = Deposit(date=deposit_form.dep_date.data,
                          amount=deposit_form.dep_amount.data,
                          source=deposit_form.dep_source.data,
                          acct_id=current_user.current_account)
        db.session.add(deposit)
        db.session.commit()
        #flash('Deposit Has Been Added.', 'success')
        return redirect(url_for('home'))
    ############################################
    # Re-Format dates so they are 'Murican' ###
    for x in range(0, len(deposits)):
        temp_date = str(deposits[x].date)
        Y, m, d = (x for x in temp_date.split('-'))
        new_date = (m + '/' + d + '/' + Y)
        deposits[x].date = new_date
    for x in range(0, len(expenses)):
        temp_date = str(expenses[x].date)
        Y, m, d = (x for x in temp_date.split('-'))
        new_date = (m + '/' + d + '/' + Y)
        expenses[x].date = new_date
    #############################################
    ### Create The Required Chart Values ###
    colors = [
        "#cf1919", "#16b53b", "#1a3cc7", "#fa9f20", "#891af0", "#ffef3b",
        "#285926", "#7d3232", "#434175", "#d66dca", "#f7f283", "#64367a",
        "#000000", "#818485", "#ffffff", "#3ab6c2"
    ]
    # Create a Unique List of Expense Categories to Be used in Charts (by using set() function)
    expense_categories = []
    for x in range(0, len(expenses)):
        expense_categories.append(expenses[x].category)
    expense_categories = list(set(expense_categories))
    #Create a List Using the Expense Categories for the Amounts in the Chart
    expense_amounts = []
    expense_colors = []
    for z in range(0, len(expense_categories)):
        expense_colors.append(colors[z])
    for category_name in expense_categories:
        category_amount = 0
        for y in range(0, len(expenses)):
            if expenses[y].category == category_name:
                category_amount = category_amount + (expenses[y].amount / 100)
        expense_amounts.append(category_amount)
    ##############################################
    return render_template('home.html',
                           accounts=accounts,
                           balance=balance,
                           len_act=len_act,
                           current_account=current_account,
                           current_account_name=current_account_name,
                           add_account_form=add_account_form,
                           expense_form=expense_form,
                           deposit_form=deposit_form,
                           expenses=expenses,
                           deposits=deposits,
                           set=zip(expense_amounts, expense_categories,
                                   expense_colors))
Ejemplo n.º 6
0
def home():
    #Get Default Values for All Forms
    if True:
        current_account,current_account_name,accounts,len_act,current_balance,current_deposits,current_expenses,deposits,expenses,all_accounts,all_balances = set_standard_values()
    #Set Form Values
    expense_form = SubmitExpenseForm()
    deposit_form = SubmitDepositForm()
    add_account_form = AddAccountForm()
    if add_account_form.validate_on_submit():
        account = Account(name = add_account_form.account_name.data, safe_bal = add_account_form.safe_bal.data,
                          crit_bal = add_account_form.crit_bal.data,owner_id=current_user.id)
        db.session.add(account)
        db.session.commit()
        # If This is the First Account, Set it as Default in View
        if len(current_user.accounts) == 1:
            all_accounts = Account.query.filter(Account.id).all()
            last_account = all_accounts[-1]
            last_account = last_account.id
            current_user.current_account = last_account
            db.session.commit()
        #flash('Account Has Been Added', 'success')
        return redirect(url_for('home'))
    ##################################################
    ### Form Submit for Adding an Expense ###
    if expense_form.validate_on_submit():
        #Convert Decimals to Full Integers to be divided later
        temp_amount=str(round(float(expense_form.amount.data),2))
        if len(temp_amount.split('.')[1]) == 1:
            temp_amount = temp_amount + "0"
        expense_form.amount.data = int(temp_amount.replace('.',''))
        #End of Convert
        expense = Expense(date = expense_form.date.data,amount = expense_form.amount.data, payee = expense_form.payee.data,
                           category = expense_form.category.data, comment = expense_form.comment.data, acct_id=current_user.current_account)
        db.session.add(expense)
        db.session.commit()
        #flash('Payment Entered Successfully', 'success')
        return redirect(url_for('home'))
    ###########################################
    ### Form Submit for Adding a Deposit ###
    if deposit_form.validate_on_submit():
        temp_amount=str(round(float(deposit_form.dep_amount.data),2))
        if len(temp_amount.split('.')[1]) == 1:
            temp_amount = temp_amount + "0"
        deposit_form.dep_amount.data = int(temp_amount.replace('.',''))
        deposit= Deposit(date=deposit_form.dep_date.data,amount=deposit_form.dep_amount.data,source=deposit_form.dep_source.data,acct_id=current_user.current_account)
        db.session.add(deposit)
        db.session.commit()
        #flash('Deposit Has Been Added.', 'success')
        return redirect(url_for('home'))
    ############################################
    # Re-Format dates so they are 'Murican' ###
    for x in range(0,len(current_deposits)):
        temp_date=str(current_deposits[x].date)
        Y,m,d = (x for x in temp_date.split('-'))
        new_date = (m + '/' + d +'/' + Y)
        current_deposits[x].date = new_date
    for x in range(0,len(current_expenses)):
        temp_date=str(current_expenses[x].date)
        Y,m,d = (x for x in temp_date.split('-'))
        new_date = (m + '/' + d +'/' + Y)
        current_expenses[x].date = new_date
    ############################################

    ########################################
    ### Create The Required Chart Values ###
    # Create a Unique List of Expense Categories to Be used in Charts (by using set() function)
    expense_categories=[]
    for x in range (0,len(current_expenses)):
            expense_categories.append(current_expenses[x].category)
    expense_categories= list(set(expense_categories))
    #Create a List Using the Expense Categories for the Amounts in the Chart
    # Set Some Default Colors to Be used in Charts #
    colors=["#cf1919","#16b53b","#1a3cc7","#fa9f20","#891af0","#ffef3b",
                    "#285926","#7d3232","#434175","#d66dca","#f7f283","#64367a",
                    "#000000","#818485","#ffffff","#3ab6c2"]
    #   If More Colors Are Required, we will create them   #
    if len(colors) < len(expense_categories):
        diff_len = len(expense_categories) - len(colors)
        for missing_color in range(0,diff_len):
            new_color=""
            for pos in range(0,6):
                # Flip a Coin To See if you get Numbers or Letters #
                coin_toss=randint(0,1)
                #If 0, You have an Integer
                if coin_toss == 0:
                    new_char=randint(0,9)
                else:
                    #Otherwise You get a letter
                    alphas="ABCDEF"
                    new_char=random.choice(alphas)
                new_color=(new_color + str(new_char))
            new_color=("#" + new_color)
            colors.append(new_color)
    ######  OK - We Are Done Playing with Colors Now  ######
    expense_amounts=[]
    expense_colors=[]
    for z in range(0,len(expense_categories)):
        expense_colors.append(colors[z])
    for category_name in expense_categories:
        category_amount = 0
        for y in range(0, len(current_expenses)):
            if current_expenses[y].category == category_name:
                category_amount = category_amount + (current_expenses[y].amount)
        expense_amounts.append(category_amount)
    ##############################################
    tot_bal=0
    for i in range(0,len_act):
        if "(" in all_balances[i]: #In Case A Balance is Negative
            #Remove Parathesis so total Balance can Be calculated
            all_balances[i] = all_balances[i].replace("(","").replace(")","")
            tot_bal = tot_bal - float(all_balances[i].replace(",",""))
            #Put Parenthesis back for Viewing
            all_balances[i] = "(" + all_balances[i] + ")"
        else:
            tot_bal = float(all_balances[i].replace(",","")) + tot_bal
    tot_bal=str('{:,.2f}'.format(tot_bal))
    return render_template('home.html',tot_bal=tot_bal,accounts=accounts,current_balance=current_balance,all_accounts=all_accounts,all_balances=all_balances,
                            len_act=len_act,current_account=current_account,current_account_name=current_account_name,add_account_form=add_account_form,
                            expense_form=expense_form, deposit_form=deposit_form,expenses=expenses,current_expenses=current_expenses,current_deposits=current_deposits,deposits=deposits,
                            set=zip(expense_amounts,expense_categories,expense_colors))
Ejemplo n.º 7
0
def charts():
    current_account=""
    add_account_form = AddAccountForm()
    if True:
        current_account,current_account_name,accounts,len_act,current_balance,current_deposits,current_expenses,deposits,expenses,all_accounts,all_balances = set_standard_values()
    ########################################
    ### Create The Required Chart Values ###
    # Create a Unique List of Expense Categories to Be used in Charts (by using set() function)
    expense_categories=[]
    for x in range (0,len(current_expenses)):
            expense_categories.append(current_expenses[x].category)
    expense_categories= list(set(expense_categories))
    #Create a List Using the Expense Categories for the Amounts in the Chart
    # Set Some Default Colors to Be used in Charts #
    colors=["#cf1919","#16b53b","#1a3cc7","#fa9f20","#891af0","#ffef3b",
                    "#285926","#7d3232","#434175","#d66dca","#f7f283","#64367a",
                    "#000000","#818485","#ffffff","#3ab6c2"]
    #   If More Colors Are Required, we will create them   #
    if len(colors) < len(expense_categories):
        diff_len = len(expense_categories) - len(colors)
        for missing_color in range(0,diff_len):
            new_color=""
            for pos in range(0,6):
                # Flip a Coin To See if you get Numbers or Letters #
                coin_toss=randint(0,1)
                #If 0, You have an Integer
                if coin_toss == 0:
                    new_char=randint(0,9)
                else:
                    #Otherwise You get a letter
                    alphas="ABCDEF"
                    new_char=random.choice(alphas)
                new_color=(new_color + str(new_char))
            new_color=("#" + new_color)
            colors.append(new_color)
    ######  OK - We Are (Almost) Done Playing with Colors Now  ######
    # Set Empty Lists for Categories #
    expense_amounts=[]
    expense_colors=[]
    mtd_expense_amounts=[]
    mtd_expense_categories=[]
    mtd_colors=[]
    ytd_expense_amounts=[]
    ytd_expense_categories=[]
    ytd_colors=[]

    this_year=date.today().strftime("%Y")
    this_month=date.today().strftime("%m")

    for category_name in expense_categories:
        category_amount = 0
        mtd_category_amount = 0
        ytd_category_amount = 0
        for y in range(0, len(current_expenses)):
            if current_expenses[y].category == category_name:
                category_amount = category_amount + (current_expenses[y].amount)
                exp_year = str(current_expenses[y].date)[0:4]
                exp_month = str(current_expenses[y].date)[5:7]
                if exp_year == this_year:
                    ytd_category_amount = ytd_category_amount + (current_expenses[y].amount)
                    if exp_month == this_month:
                        mtd_category_amount = mtd_category_amount + (current_expenses[y].amount)
        expense_amounts.append(category_amount)
        if mtd_category_amount > 0:
            mtd_expense_categories.append(category_name)
            mtd_expense_amounts.append(mtd_category_amount)
        if ytd_category_amount > 0:
            ytd_expense_categories.append(category_name)
            ytd_expense_amounts.append(ytd_category_amount)
    for z in range(0,len(expense_categories)):
        expense_colors.append(colors[z])
    for z in range(0,len(mtd_expense_categories)):
        mtd_colors.append(colors[z])
    for z in range(0,len(ytd_expense_categories)):
        ytd_colors.append(colors[z])
    ##############################################
    return render_template('charts.html',accounts=accounts,current_balance=current_balance,len_act=len_act,
                            current_account=current_account,all_accounts=all_accounts,all_balances=all_balances,current_deposits=current_deposits,current_expenses=current_expenses,
                            current_account_name=current_account_name,set=zip(expense_amounts,expense_categories,expense_colors),
                            mtd=zip(mtd_expense_amounts,mtd_expense_categories,mtd_colors),ytd=zip(ytd_expense_amounts,ytd_expense_categories,ytd_colors))