Beispiel #1
0
def ReceptionBill():
    bills = InvoicesAPI.GetBills('reception')
    paymethod = {}
    if request.method == 'POST':
        if request.form['submit'] == 'Submit':
            try:
                paymethod['acttype'] = 'Assets'
                paymethod['actcat'] = request.form['PaymentMethod']
                paymethod['actname'] = request.form['PaymentAccount']
                paymethod['currency'] = request.form['PaymentCurrency']
                paymethod['debit'] = request.form['debit']
                paymethod['credit'] = 0

                InvoicesAPI.CreateBill(
                    session['username'], session['password'],
                    request.form['PaymentDate'], 'reception',
                    request.form.getlist('account-type'),
                    request.form.getlist('account-category'),
                    request.form.getlist('account-name'),
                    request.form.getlist('currency'), paymethod['credit'],
                    request.form.getlist('credit'),
                    request.form.getlist('description'), paymethod,
                    request.form['comments'])
                flash('Bill successfully created...', category='success')
                return redirect(url_for('invoices.ReceptionBill'))
            except Exception as e:
                flash(str(e), category='fail')
                return redirect(url_for('invoices.ReceptionBill'))
    return render_template('invoices/reception_bill.html',
                           username=session['username'],
                           role=session['role'],
                           bills=bills)
Beispiel #2
0
def ViewPaymentBill(billcode):
    Appr = InvoicesAPI.BillApproversList()
    bills = InvoicesAPI.GetBills('payment')
    paymethod = {}
    data1, data2 = InvoicesAPI.GetOneBill(billcode, 'payment')
    if request.method == 'POST':
        if request.form['submit'] == 'Submit' and session['username'] in Appr:
            try:
                InvoicesAPI.RegisterBill(session['username'],
                                         session['password'], billcode,
                                         request.form['status'])
                flash('Bill registered successfully...', category='success')
                return redirect(url_for('invoices.PaymentBill'))
            except Exception as e:
                flash(str(e), category='fail')
                return redirect(url_for('invoices.PaymentBill'))
        else:
            flash(
                'This user does not have permission to register this bill...',
                category='fail')
            return redirect(
                url_for('invoices.ViewPaymentBill', billcode=billcode))
    return render_template('invoices/view_payment_bill.html',
                           username=session['username'],
                           role=session['role'],
                           bills=bills,
                           data1=data1,
                           data2=data2)