Beispiel #1
0
def chart():
    Dates.Now().start()
    income_list = Income.query.all()
    expense_list = Expense.query.all()
    deleteIncome = deleteIncomeForm()
    deleteExpense = deleteExpenseForm()
    expense_form = ExpenseForm()
    income_form = IncomeForm()
    span_form = SpanForm()
    form_submit(expense_form, income_form)
    span = span_form.span.data
    span_label = str(Dates.Dates().span_length(span))
    legend = "Daily Balance"
    labels, values = Occurence.Occurence().range_calc(span)
    Occurence.delete()
    Dates.Now().end()
    print(Dates.Now().result())
    return render_template(
        "chart.html",
        span=span_form,
        deleteExpense=deleteExpense,
        expenses=expense_list,
        incomes=income_list,
        deleteIncome=deleteIncome,
        income_form=income_form,
        expense_form=expense_form,
        values=values,
        labels=labels,
        legend=legend,
        span_label=span_label,
    )
Beispiel #2
0
    def enum_balance(self, *args):
        self.weeklyExpense = ExpenseList.weekly[1]
        self.biweeklyExpense = ExpenseList.biweekly[1]
        self.dailyExpenses = ExpenseList.daily[1]
        self.date = args[3]
        self.paydates = Comp.paydates(args[0])
        self.week = args[1]
        self.prices = args[2]
        self.dailyDays = [
            day for day in range(Dates.Dates().ordinal,
                                 Dates.Dates().ordinal + len(self.date))
        ]
        self.day = Date()

        try:
            self.total = 0
            # For each expense total, subtract from balance for each day
            self.enum_expenses()
            self.day.append_data()
        finally:
            del self.total
            del self.prices
            del self.date
            return self.day.return_data()
Beispiel #3
0
class ExpenseForm(FlaskForm):
    expense = StringField("expense", validators=[DataRequired()])
    price = StringField("price", validators=[DataRequired()])
    occurence = SelectField(
        "occurence",
        choices=[("1", "Daily"), ("2", "Weekly"), ("3", "Every other day"),
                 ("4", "Biweekly"), ("5", "Monthly")],
        validators=[DataRequired()],
    )
    expenseDate = SelectField(
        "expenseDate",
        choices=[(str(Dates.Dates().ordinal + x), date_list[x])
                 for x in range(365)],
        validators=[DataRequired()],
    )
    submit = SubmitField("Add Expense")
Beispiel #4
0
 def paydates(self, weekday, span):
     paydays = []
     if len(IncomeList.existing) < 1:
         IncomeList.existing.append(('None', [0], '0', '0', '1'))
     if len(IncomeList.recurring) < 1:
         IncomeList.recurring.append(('None', [0], '0', '0', '7'))
     for paydates in IncomeList.recurring:
         '''
         Begin with today's Dates
         '''
         print(paydates[3])
         print(paydates[4])
         paydates = [
             i
             for i in range(int(paydates[3]),
                            Dates.Dates().ordinal +
                            days.span_length(span), int(paydates[4]))
         ]
         paydays.append(paydates)
     return paydays
Beispiel #5
0
class IncomeForm(FlaskForm):
    income = StringField("income", validators=[DataRequired()])
    price = StringField("price", validators=[DataRequired()])
    occurence = SelectField(
        "occurence",
        choices=[
            ("1", "Daily"),
            ("2", "Weekly"),
            ("3", "Every other day"),
            ("4", "Biweekly"),
            ("5", "Existing balance"),
        ],
        validators=[DataRequired()],
    )
    payday = SelectField(
        "payday",
        choices=[(str(Dates.Dates().ordinal + x), date_list[x])
                 for x in range(365)],
        validators=[DataRequired()],
    )
    submit = SubmitField("Add Income")
Beispiel #6
0
    def other_add(self, deduct, label_span):
        daily = label_span[1]
        other = label_span[0]
        return [deduct[0] + deduct[1] for d in daily for o in other if d == o]

    def no_other(self, deduct, daily):
        return [deduct[0] for day in daily]

    def daily_add(self, deduct, otherInsert):
        return [deduct[0] for day in range(len(otherInsert))]

    def deduct_list(self, occurence):
        return [i for i in occurence]

    def stacked_list(self, occurence):
        return [i for elem in occurence for i in elem]

    def paydates(self, paydates):
        return [args for args in paydates for args in args]

    def prices(self):
        return [(float(existing[2]), float(recurring[2]))
                for existing in IncomeList.existing
                for recurring in IncomeList.recurring]


dates = Dates.Labels()
Comp = Comprehensions()
days = Dates.Dates()
Beispiel #7
0
)
from wtforms.validators import DataRequired
from flask import render_template, redirect, url_for
import os
from app.models import Expense, Income
from app import db
import app.Occurence_class as Occurence
import app.Dates as Dates

expenses = []
prices = []
occurences = []
incomes = []
income_prices = []
income_occurences = []
date_list = Dates.Comprehensions().d
dates = Dates.Dates()


class SpanForm(FlaskForm):
    span = SelectField(
        "Span",
        default="1",
        choices=[
            ("1", "1 Week"),
            ("2", "2 Weeks"),
            ("3", "1 Month"),
            ("4", "3 Months"),
            ("5", "6 Months"),
        ],
        validators=[DataRequired()],