コード例 #1
0
def ViewInvoice(code, tpy):
    Appr = InvoicesAPI.ApproversList()
    iframe = url_for('invoices.InvoiceView', code=code)
    invs = InvoicesAPI.GetInvoices(tpy)
    RS, CGS, Stat = InvoicesAPI.REVSnCOST(code)
    if request.method == 'POST':
        if request.form['submit'] == 'Submit' and session['username'] in Appr:
            if tpy == 'procurement' or tpy == 'return':
                try:
                    InvoicesAPI.UpdateInvoice(session['username'],
                                              session['password'], code, tpy,
                                              request.form['statuses'])
                    flash('Invoice updated successfully...',
                          category='success')
                    return redirect(
                        url_for('invoices.ViewInvoice', code=code, tpy=tpy))
                except Exception as e:
                    flash(str(e), category='fail')
                    return redirect(
                        url_for('invoices.ViewInvoice', code=code, tpy=tpy))
            elif tpy == 'sales' or tpy == 'refund':
                try:
                    InvoicesAPI.UpdateInvoice(
                        session['username'],
                        session['password'],
                        code,
                        tpy,
                        request.form['statuses'],
                        REV_Account=request.form['RVACT'],
                        CGS_Account=request.form['CGSACT'])
                    flash('Invoice updated successfully...',
                          category='success')
                    return redirect(
                        url_for('invoices.ViewInvoice', code=code, tpy=tpy))
                except Exception as e:
                    flash(str(e), category='fail')
                    return redirect(
                        url_for('invoices.ViewInvoice', code=code, tpy=tpy))
        else:
            flash(
                'User does not have permission to approve or cancel this invoice',
                category='fail')
            return redirect(url_for('invoices.ViewInvoice', code=code,
                                    tpy=tpy))
    return render_template('invoices/view_invoice.html',
                           username=session['username'],
                           role=session['role'],
                           invs=invs,
                           iframe=iframe,
                           type=tpy,
                           RS=RS,
                           CGS=CGS,
                           Stat=Stat)
コード例 #2
0
def EditRefundInvoice(invcode):
    customers = InvoicesAPI.GetAllCustomers()
    currencies = AccountingAPI.GetAllCurrencies()
    itms = EnterpriseAPI.ItemPicker()
    pkgs = EnterpriseAPI.PackagePicker()
    invs = InvoicesAPI.GetInvoices('refund')
    srvs = InvoicesAPI.GetServicesByType('Revenue')
    data1, data2 = InvoicesAPI.GetInvoice(session['username'],
                                          session['password'], invcode)
    if request.method == 'POST':
        if request.form['submit'] == 'Submit':
            try:
                InvoicesAPI.EditInvoice(
                    session['username'], session['password'], invcode,
                    'refund', request.form['Customer'],
                    request.form['SheetDate'], request.form['currency'],
                    request.form['terms'], request.form.getlist('description'),
                    request.form.getlist('unitprice'),
                    request.form.getlist('quantity'),
                    request.form.getlist('amount'),
                    request.form['totalamount'], request.form['discount'],
                    request.form['tax'], request.form['invamount'],
                    request.form['pay_method'],
                    request.form['billing_account'], request.form['comments'])

                flash('Invoices updated successfully', category='success')
                return redirect(url_for('invoices.RefundInvoice'))
            except Exception as e:
                flash(str(e), category='fail')
                return redirect(url_for('invoices.RefundInvoice'))
    return render_template('invoices/edit_refund_invoice.html',
                           username=session['username'],
                           role=session['role'],
                           itms=itms,
                           pkgs=pkgs,
                           customers=customers,
                           currencies=currencies,
                           invs=invs,
                           data1=data1,
                           data2=data2,
                           invcode=invcode,
                           srvs=srvs)
コード例 #3
0
def ProcurementInvoice():
    providers = EnterpriseAPI.GetProviders()
    currencies = AccountingAPI.GetAllCurrencies()
    itms = EnterpriseAPI.ItemPicker()
    pkgs = EnterpriseAPI.PackagePicker()
    invs = InvoicesAPI.GetInvoices('procurement')
    srvs = InvoicesAPI.GetServicesByType('Expense')
    if request.method == 'POST':
        if request.form['submit'] == 'Submit':
            try:
                invcode = InvoicesAPI.AddInvoice(
                    session['username'], session['password'], 'procurement',
                    request.form['Customer'], request.form['SheetDate'],
                    request.form['currency'], request.form['terms'],
                    request.form.getlist('description'),
                    request.form.getlist('unitprice'),
                    request.form.getlist('quantity'),
                    request.form.getlist('amount'),
                    request.form['totalamount'], request.form['discount'],
                    request.form['tax'], request.form['invamount'],
                    request.form['pay_method'],
                    request.form['billing_account'], request.form['comments'])

                flash('Invoices created successfully', category='success')
                return redirect(url_for('invoices.ProcurementInvoice'))
            except Exception as e:
                flash(str(e), category='fail')
                return redirect(url_for('invoices.ProcurementInvoice'))
    return render_template('invoices/procurement_invoice.html',
                           username=session['username'],
                           role=session['role'],
                           itms=itms,
                           pkgs=pkgs,
                           providers=providers,
                           currencies=currencies,
                           invs=invs,
                           srvs=srvs)