Esempio n. 1
0
def obtain_worth(end_date):
    last_worth = 0
    aggregate = Major.listWithTotalPrice(FIRST_DATE, end_date)
    for major in aggregate:
        if major.income:
            last_worth += major.amount
        else:
            last_worth -= major.amount
    return last_worth
Esempio n. 2
0
def obtain_worth(end_date):
    last_worth = 0
    aggregate = Major.listWithTotalPrice(FIRST_DATE, end_date)
    for major in aggregate:
        if major.income:
            last_worth += major.amount
        else:
            last_worth -= major.amount
    return last_worth
Esempio n. 3
0
def init_table():
    majors = Major.listWithMinor().order_by(Major.income.desc(), Major.id, Minor.id)
    table = {}
    table["order"] = []
    table["majors"] = []
    prev = None
    for major in majors:
        table["order"].append(major.minor.id)
        if prev == None or prev != major.id:
            table["majors"].append((major.id, major.income, major.name))
            prev = major.id
        table[major.minor.id] = (major.id, major.name, major.income, major.minor.name, 0)
    return table
Esempio n. 4
0
def init_table():
    majors = Major.listWithMinor().order_by(Major.income.desc(), Major.id,
                                            Minor.id)
    table = {}
    table['order'] = []
    table['majors'] = []
    prev = None
    for major in majors:
        table['order'].append(major.minor.id)
        if prev == None or prev != major.id:
            table['majors'].append((major.id, major.income, major.name))
            prev = major.id
        table[major.minor.id] = (major.id, major.name, major.income,
                                 major.minor.name, 0)
    return table
Esempio n. 5
0
def major_add():
    if request.method == 'POST':
        if request.form.get('major_id'):
            major = get_object_or_404(Major, Major.id == request.form['major_id'])
            minors = Minor.listWithStats(request.form['major_id'])
            major.name = request.form['name']
            major.income = bool(request.form.get('income'))
            major.save()
            flash('Category #%d updated successfully.' % major.id, 'success')
        else: 
            major = Major.create(name=request.form['name'],
                                 income=bool(request.form.get('income')))
            minors = []
            for minor_name in string.split(request.form['minors'], ','):
                if len(minor_name) > 0:
                    minor = Minor.create(name=string.strip(minor_name), major=major)
                    minors.append(minor)
            flash('A category created successfully.', 'success')
        return render_template('major.html', major=major, minors=minors)
    return render_template('major.html')
Esempio n. 6
0
def major_add():
    if request.method == 'POST':
        if request.form.get('major_id'):
            major = get_object_or_404(Major,
                                      Major.id == request.form['major_id'])
            minors = Minor.listWithStats(request.form['major_id'])
            major.name = request.form['name']
            major.income = bool(request.form.get('income'))
            major.save()
            flash('Category #%d updated successfully.' % major.id, 'success')
        else:
            major = Major.create(name=request.form['name'],
                                 income=bool(request.form.get('income')))
            minors = []
            for minor_name in string.split(request.form['minors'], ','):
                if len(minor_name) > 0:
                    minor = Minor.create(name=string.strip(minor_name),
                                         major=major)
                    minors.append(minor)
            flash('A category created successfully.', 'success')
        return render_template('major.html', major=major, minors=minors)
    return render_template('major.html')
Esempio n. 7
0
def minor_detail(id):
    minor = get_object_or_404(Minor, Minor.id == id)
    majors = Major.select().order_by(Major.id)
    return render_template('minor.html', minor=minor, majors=majors)
Esempio n. 8
0
def minor_detail(id):
    minor = get_object_or_404(Minor, Minor.id == id)
    majors = Major.select().order_by(Major.id)
    return render_template('minor.html', minor=minor, majors=majors)