コード例 #1
0
def accounting_approve_reimbursement(transaction_id):
    banks = DB.Bank.query.order_by(DB.Bank.id).all()
    transaction = DB.Transaction.query.get(transaction_id)
    form = forms.ApproveReimbursement(obj=transaction)
    form.bank_id.choices = [(bank.id, bank.name) for bank in banks]
    form.category_id.choices = accounting_categories(IN=False)
    del form.is_revenue
    if form.validate_on_submit():
        transaction.date = string_to_date(request.form["date"])
        transaction.facturation_date = string_to_date(request.form["date"])
        transaction.amount = request.form["amount"]
        transaction.to_from = request.form["to_from"]
        transaction.description = request.form["description"]
        transaction.category_id = request.form["category_id"]
        transaction.bank_id = request.form["bank_id"]
        transaction.bank_statement_number = request.form[
            "bank_statement_number"]
        transaction.date_filed = date.today()
        transaction.filed_by_id = current_user.id
        DB.db.session.commit()

        upload_attachments(request, attachments, transaction, DB)

        flash("the transaction was filed", "confirmation")
        return redirect(url_for('accounting_approve_reimbursements'))
    return render_template('accounting/approve_reimbursement.html',
                           form=form,
                           transaction=transaction)
コード例 #2
0
ファイル: views_accounting.py プロジェクト: retmarut/MALMan
def accounting_approve_reimbursement(transaction_id):
    banks = DB.Bank.query.order_by(DB.Bank.id).all()
    transaction = DB.Transaction.query.get(transaction_id)
    form = forms.ApproveReimbursement(obj=transaction)
    form.bank_id.choices = [(bank.id, bank.name) for bank in banks]
    form.category_id.choices = accounting_categories(IN=False)
    del form.is_revenue
    if form.validate_on_submit():
        transaction.date = string_to_date(request.form["date"])
        transaction.facturation_date = string_to_date(request.form["date"])
        transaction.amount = request.form["amount"]
        transaction.to_from = request.form["to_from"]
        transaction.description = request.form["description"]
        transaction.category_id = request.form["category_id"]
        transaction.bank_id = request.form["bank_id"]
        transaction.bank_statement_number = request.form["bank_statement_number"]
        transaction.date_filed = date.today()
        transaction.filed_by_id = current_user.id
        DB.db.session.commit()

        upload_attachments(request, attachments, transaction, DB)

        flash("the transaction was filed", "confirmation")
        return redirect(url_for('accounting_approve_reimbursements'))
    return render_template('accounting/approve_reimbursement.html', form=form, transaction=transaction)
コード例 #3
0
ファイル: views_accounting.py プロジェクト: retmarut/MALMan
def accounting_edit_transaction(transaction_id):
    banks = DB.Bank.query.all()
    transaction = DB.Transaction.query.get(transaction_id)
    form = forms.EditTransaction(obj=transaction)
    form.bank_id.choices = [(bank.id, bank.name) for bank in banks]
    form.category_id.choices = accounting_categories()
    if form.validate_on_submit():
        confirmation = app.config['CHANGE_MSG']
        atributes = ['date', 'facturation_date', 'is_revenue', 'amount', 'to_from', 'description',
                     'category_id', 'bank_id', 'bank_statement_number']
        for atribute in atributes:
            old_value = getattr(transaction, str(atribute))
            new_value = request.form.get(atribute)
            if atribute == 'is_revenue':
                if new_value == '1':
                    new_value = True
                elif new_value == '0':
                    new_value = False
            elif atribute in ['date', 'facturation_date']:
                new_value = string_to_date(request.form.get(atribute))
            if str(new_value) != str(old_value):
                if atribute == 'facturation_date' and new_value == '':
                    new_value = request.form.get('date')
                setattr(transaction, atribute, new_value)
                confirmation = add_confirmation(confirmation, str(atribute) + " = " + str(new_value) +
                                                " (was " + str(old_value) + ")")
            transaction.date_filed
        DB.db.session.commit()

        uploadconfirmation = upload_attachments(request, attachments, transaction, DB)

        confirmation = add_confirmation(confirmation, uploadconfirmation)
        return_flash(confirmation)
        return redirect(request.url)
    return render_template('accounting/edit_transaction.html', form=form, transaction=transaction)
コード例 #4
0
ファイル: views_my_account.py プロジェクト: warddr/MALMan
def account_edit_own_account():
    userdata = DB.User.query.get(current_user.id)
    form = forms.MembersEditOwnAccount(obj=userdata)
    if form.validate_on_submit():
        confirmation = app.config['CHANGE_MSG']
        atributes = ['name', 'date_of_birth', 'email', 'telephone', 'city',
                     'postalcode', 'bus', 'number', 'street', 'show_telephone',
                     'show_email']
        for atribute in atributes:
            old_value = getattr(userdata, atribute)
            if atribute in ['show_telephone', 'show_email']:
                new_value = atribute in request.form
            elif atribute in ['date_of_birth']:
                new_value = string_to_date(request.form.get(atribute))
            else:
                new_value = request.form.get(atribute)
            if str(new_value) != str(old_value):
                user = DB.User.query.get(current_user.id)
                setattr(user, atribute, new_value)
                DB.db.session.commit()
                confirmation = add_confirmation(confirmation, atribute +
                                                " = " + str(new_value) +
                                                " (was " + str(old_value) + ")")
        return_flash(confirmation)
        return redirect(request.url)
    return render_template('my_account/edit_own_account.html', userdata=userdata,
                           form=form)
コード例 #5
0
def file_membershipfee(transaction_id):
    users = DB.User.query
    form = forms.FileMembershipFee()
    form.user_id.choices = [(user.id, user.name)
                            for user in users.order_by('name').all()]
    transaction = DB.Transaction.query.get(transaction_id)

    if form.validate_on_submit():
        payeduntil = string_to_date(request.form["until"])
        payeduntil = payeduntil.replace(month=payeduntil.month + 1,
                                        day=1) - timedelta(days=1)
        item = DB.MembershipFee(user_id=request.form["user_id"],
                                transaction_id=transaction_id,
                                until=payeduntil)
        DB.db.session.add(item)
        DB.db.session.commit()
        user = users.get(request.form["user_id"])
        flash(
            user.name + "'s membership dues are paid until then end of " +
            payeduntil.strftime('%Y-%m'), "confirmation")
        return redirect(url_for('accounting_log'))

    return render_template('accounting/file_membershipfee.html',
                           form=form,
                           transaction=transaction)
コード例 #6
0
def accounting_add_transaction():
    banks = DB.Bank.query.order_by(DB.Bank.id).all()
    form = forms.AddTransaction()
    form.bank_id.choices = [(bank.id, bank.name) for bank in banks]
    form.category_id.choices = accounting_categories()
    if form.validate_on_submit():
        if request.form["facturation_date"] != '':
            facturation_date = string_to_date(request.form["facturation_date"])
        else:
            facturation_date = string_to_date(request.form["date"])
        # convert empty string to None if necessary to prevent a crash
        if request.form["bank_statement_number"] == '':
            bank_statement_number = None
        else:
            bank_statement_number = request.form["bank_statement_number"]
        transaction = DB.Transaction(
            date=string_to_date(request.form["date"]),
            facturation_date=facturation_date,
            is_revenue=request.form["is_revenue"],
            amount=request.form["amount"],
            to_from=request.form["to_from"],
            description=request.form["description"],
            category_id=request.form["category_id"],
            bank_id=request.form["bank_id"],
            bank_statement_number=bank_statement_number,
            date_filed=date.today(),
            filed_by_id=current_user.id)
        DB.db.session.add(transaction)
        DB.db.session.commit()

        upload_attachments(request, attachments, transaction, DB)

        if request.form["category_id"] == '6':
            id = DB.Transaction.query.order_by(
                DB.Transaction.id.desc()).first()
            return redirect(url_for('topup_bar_account', transaction_id=id.id))
        elif request.form["category_id"] == '8':
            id = DB.Transaction.query.order_by(
                DB.Transaction.id.desc()).first()
            return redirect(url_for('file_membershipfee',
                                    transaction_id=id.id))
        return redirect(url_for('accounting_log'))

        flash("the transaction was filed", "confirmation")
    return render_template('accounting/add_transaction.html', form=form)
コード例 #7
0
ファイル: views_accounting.py プロジェクト: retmarut/MALMan
def accounting_add_transaction():
    banks = DB.Bank.query.order_by(DB.Bank.id).all()
    form = forms.AddTransaction()
    form.bank_id.choices = [(bank.id, bank.name) for bank in banks]
    form.category_id.choices = accounting_categories()
    if form.validate_on_submit():
        if request.form["facturation_date"] != '':
            facturation_date = string_to_date(request.form["facturation_date"])
        else:
            facturation_date = string_to_date(request.form["date"])
        # convert empty string to None if necessary to prevent a crash
        if request.form["bank_statement_number"] == '':
            bank_statement_number = None
        else:
            bank_statement_number = request.form["bank_statement_number"]
        transaction = DB.Transaction(date=string_to_date(request.form["date"]),
                                     facturation_date=facturation_date,
                                     is_revenue=request.form["is_revenue"],
                                     amount=request.form["amount"],
                                     to_from=request.form["to_from"],
                                     description=request.form["description"],
                                     category_id=request.form["category_id"],
                                     bank_id=request.form["bank_id"],
                                     bank_statement_number=bank_statement_number,
                                     date_filed=date.today(),
                                     filed_by_id=current_user.id)
        DB.db.session.add(transaction)
        DB.db.session.commit()

        upload_attachments(request, attachments, transaction, DB)

        if request.form["category_id"] == '6':
            id = DB.Transaction.query.order_by(DB.Transaction.id.desc()).first()
            return redirect(url_for('topup_bar_account', transaction_id=id.id))
        elif request.form["category_id"] == '8':
            id = DB.Transaction.query.order_by(DB.Transaction.id.desc()).first()
            return redirect(url_for('file_membershipfee', transaction_id=id.id))
        return redirect(url_for('accounting_log'))

        flash("the transaction was filed", "confirmation")
    return render_template('accounting/add_transaction.html', form=form)
コード例 #8
0
def members_edit_member(user_id):
    userdata = DB.User.query.get(user_id)
    roles = DB.Role.query.all()
    # add roles to form
    for role in roles:
        # check the checkbox if the user has the role
        if role in userdata.roles:
            setattr(forms.MembersEditAccount, 'perm_' + str(role.name),
                    BooleanField(role.name, default='y'))
        else:
            setattr(forms.MembersEditAccount, 'perm_' + str(role.name),
                    BooleanField(role.name))
    form = forms.MembersEditAccount(obj=userdata)
    del form.email
    if form.validate_on_submit():
        confirmation = app.config['CHANGE_MSG']
        atributes = [
            'name', 'date_of_birth', 'telephone', 'city', 'postalcode', 'bus',
            'number', 'street', 'show_telephone', 'show_email',
            'membership_dues'
        ]
        atributes.extend([role for role in roles])
        for atribute in atributes:
            if atribute in roles:
                old_value = atribute in userdata.roles
                new_value = 'perm_' + atribute.name in request.form
            elif atribute in ['show_telephone', 'show_email']:
                old_value = getattr(userdata, atribute)
                new_value = atribute in request.form
            elif atribute in ['date_of_birth']:
                old_value = getattr(userdata, atribute)
                new_value = string_to_date(request.form.get(atribute))
            else:
                old_value = getattr(userdata, atribute)
                new_value = request.form.get(atribute)
            if str(new_value) != str(old_value):
                if atribute in roles:
                    if new_value:
                        DB.user_datastore.add_role_to_user(userdata, atribute)
                    else:
                        DB.user_datastore.remove_role_from_user(
                            userdata, atribute)
                else:
                    user = DB.User.query.get(user_id)
                    setattr(user, atribute, new_value)
                confirmation = add_confirmation(
                    confirmation,
                    str(atribute) + " = " + str(new_value) + " (was " +
                    str(old_value) + ")")
                DB.db.session.commit()
        return_flash(confirmation)
        return redirect(request.url)
    return render_template('members/edit_account.html', form=form)
コード例 #9
0
ファイル: views_members.py プロジェクト: Brixel/MALMan
def members_edit_member(user_id):
    userdata = DB.User.query.get(user_id)
    roles = DB.Role.query.all()
    # add roles to form
    for role in roles:
        # check the checkbox if the user has the role
        if role in userdata.roles:
            setattr(forms.MembersEditAccount, 'perm_' + str(role.name),
                    BooleanField(role.name, default='y'))
        else:
            setattr(forms.MembersEditAccount, 'perm_' + str(role.name),
                    BooleanField(role.name))
    form = forms.MembersEditAccount(obj=userdata)
    del form.email
    if form.validate_on_submit():
        confirmation = app.config['CHANGE_MSG']
        atributes = ['name', 'date_of_birth', 'telephone', 'city', 'postalcode',
                     'bus', 'number', 'street', 'show_telephone', 'show_email',
                     'membership_dues']
        atributes.extend([role for role in roles])
        for atribute in atributes:
            if atribute in roles:
                old_value = atribute in userdata.roles
                new_value = 'perm_' + atribute.name in request.form
            elif atribute in ['show_telephone', 'show_email']:
                old_value = getattr(userdata, atribute)
                new_value = atribute in request.form
            elif atribute in ['date_of_birth']:
                old_value = getattr(userdata, atribute)
                new_value = string_to_date(request.form.get(atribute))
            else:
                old_value = getattr(userdata, atribute)
                new_value = request.form.get(atribute)
            if str(new_value) != str(old_value):
                if atribute in roles:
                    if new_value:
                        DB.user_datastore.add_role_to_user(userdata, atribute)
                    else:
                        DB.user_datastore.remove_role_from_user(userdata, atribute)
                else:
                    user = DB.User.query.get(user_id)
                    setattr(user, atribute, new_value)
                confirmation = add_confirmation(confirmation, str(atribute) + " = " +
                                                str(new_value) + " (was " + str(old_value) + ")")
                DB.db.session.commit()
        return_flash(confirmation)
        return redirect(request.url)
    return render_template('members/edit_account.html', form=form)
コード例 #10
0
def accounting_edit_transaction(transaction_id):
    banks = DB.Bank.query.all()
    transaction = DB.Transaction.query.get(transaction_id)
    form = forms.EditTransaction(obj=transaction)
    form.bank_id.choices = [(bank.id, bank.name) for bank in banks]
    form.category_id.choices = accounting_categories()
    if form.validate_on_submit():
        confirmation = app.config["CHANGE_MSG"]
        atributes = [
            "date",
            "facturation_date",
            "is_revenue",
            "amount",
            "to_from",
            "description",
            "category_id",
            "bank_id",
            "bank_statement_number",
        ]
        for atribute in atributes:
            old_value = getattr(transaction, str(atribute))
            new_value = request.form.get(atribute)
            if atribute == "is_revenue":
                if new_value == "1":
                    new_value = True
                elif new_value == "0":
                    new_value = False
            elif atribute in ["date", "facturation_date"]:
                new_value = string_to_date(request.form.get(atribute))
            if str(new_value) != str(old_value):
                if atribute == "facturation_date" and new_value == "":
                    new_value = request.form.get("date")
                setattr(transaction, atribute, new_value)
                confirmation = add_confirmation(
                    confirmation, str(atribute) + " = " + str(new_value) + " (was " + str(old_value) + ")"
                )
            transaction.date_filed
        DB.db.session.commit()

        uploadconfirmation = upload_attachments(request, attachments, transaction, DB)

        confirmation = add_confirmation(confirmation, uploadconfirmation)
        return_flash(confirmation)
        return redirect(request.url)
    return render_template("accounting/edit_transaction.html", form=form, transaction=transaction)
コード例 #11
0
ファイル: views_accounting.py プロジェクト: retmarut/MALMan
def accounting_request_reimbursement():
    form = forms.RequestReimbursement()

    if form.validate_on_submit():
        transaction = DB.Transaction(advance_date=string_to_date(request.form["advance_date"]),
                                     is_revenue=False,
                                     amount=request.form["amount"],
                                     description=request.form["description"],
                                     reimbursement_comments=request.form["comments"],
                                     to_from=current_user.name)
        DB.db.session.add(transaction)
        DB.db.session.commit()

        upload_attachments(request, attachments, transaction, DB)

        flash("the request for reimbursement was filed", "confirmation")
        return redirect(request.url)
    return render_template('accounting/request_reimbursement.html', form=form)
コード例 #12
0
ファイル: views_accounting.py プロジェクト: retmarut/MALMan
def file_membershipfee(transaction_id):
    users = DB.User.query
    form = forms.FileMembershipFee()
    form.user_id.choices = [(user.id, user.name) for user in users.order_by('name').all()]
    transaction = DB.Transaction.query.get(transaction_id)

    if form.validate_on_submit():
        payeduntil = string_to_date(request.form["until"])
        payeduntil = payeduntil.replace(month=payeduntil.month+1, day=1) - timedelta(days=1)
        item = DB.MembershipFee(user_id=request.form["user_id"],
                                transaction_id=transaction_id,
                                until=payeduntil)
        DB.db.session.add(item)
        DB.db.session.commit()
        user = users.get(request.form["user_id"])
        flash(user.name + "'s membership dues are paid until then end of " + payeduntil.strftime('%Y-%m'), "confirmation")
        return redirect(url_for('accounting_log'))

    return render_template('accounting/file_membershipfee.html', form=form, transaction=transaction)
コード例 #13
0
def accounting_request_reimbursement():
    form = forms.RequestReimbursement()

    if form.validate_on_submit():
        transaction = DB.Transaction(
            advance_date=string_to_date(request.form["advance_date"]),
            is_revenue=False,
            amount=request.form["amount"],
            description=request.form["description"],
            reimbursement_comments=request.form["comments"],
            to_from=current_user.name)
        DB.db.session.add(transaction)
        DB.db.session.commit()

        upload_attachments(request, attachments, transaction, DB)

        flash("the request for reimbursement was filed", "confirmation")
        return redirect(request.url)
    return render_template('accounting/request_reimbursement.html', form=form)
コード例 #14
0
def accounting_edit_transaction(transaction_id):
    banks = DB.Bank.query.all()
    transaction = DB.Transaction.query.get(transaction_id)
    form = forms.EditTransaction(obj=transaction)
    form.bank_id.choices = [(bank.id, bank.name) for bank in banks]
    form.category_id.choices = accounting_categories()
    if form.validate_on_submit():
        confirmation = app.config['CHANGE_MSG']
        atributes = [
            'date', 'facturation_date', 'is_revenue', 'amount', 'to_from',
            'description', 'category_id', 'bank_id', 'bank_statement_number'
        ]
        for atribute in atributes:
            old_value = getattr(transaction, str(atribute))
            new_value = request.form.get(atribute)
            if atribute == 'is_revenue':
                if new_value == '1':
                    new_value = True
                elif new_value == '0':
                    new_value = False
            elif atribute in ['date', 'facturation_date']:
                new_value = string_to_date(request.form.get(atribute))
            if str(new_value) != str(old_value):
                if atribute == 'facturation_date' and new_value == '':
                    new_value = request.form.get('date')
                setattr(transaction, atribute, new_value)
                confirmation = add_confirmation(
                    confirmation,
                    str(atribute) + " = " + str(new_value) + " (was " +
                    str(old_value) + ")")
            transaction.date_filed
        DB.db.session.commit()

        uploadconfirmation = upload_attachments(request, attachments,
                                                transaction, DB)

        confirmation = add_confirmation(confirmation, uploadconfirmation)
        return_flash(confirmation)
        return redirect(request.url)
    return render_template('accounting/edit_transaction.html',
                           form=form,
                           transaction=transaction)