예제 #1
0
def update_invoice(invoice_id):
    invoice = Invoice.get(invoice_id)
    if not invoice:
        abort(404)
    if request.method == 'POST':
        company = request.values.get('edit_company', '')
        tax_id = request.values.get('edit_tax_id', '')
        detail = request.values.get('edit_detail', '')
        money = request.values.get('edit_money', 0)
        invoice_num = request.values.get('edit_invoice_num', '')
        invoice_type = request.values.get('invoice_type', 0)
        create_time = request.values.get(
            'edit_create_time', datetime.datetime.now().strftime('%Y-%m-%d'))
        if not tax_id:
            flash(u"修改发票失败,公司名称不能为空", 'danger')
        elif not detail:
            flash(u"修改发票失败,发票内容不能为空", 'danger')
        elif not money:
            flash(u"修改发票失败,发票金额不能为空", 'danger')
        elif not invoice_num:
            flash(u"修改发票失败,发票号不能为空", 'danger')
        else:
            invoice.company = company
            invoice.tax_id = tax_id
            invoice.detail = detail
            invoice.invoice_num = invoice_num
            invoice.money = money
            invoice.invoice_type = invoice_type
            invoice.create_time = create_time
            invoice.save()
            flash(u'修改发票(%s)成功!' % company, 'success')
            invoice.client_order.add_comment(g.user, u"修改发票信息,%s" % (
                u'发票内容: %s; 发票号: %s; 发票金额: %s元' % (invoice.detail, invoice_num, str(invoice.money))), msg_channel=1)
    return redirect(url_for("finance_client_order_invoice.info", order_id=invoice.client_order.id))
예제 #2
0
파일: invoice.py 프로젝트: cash2one/braavos
def apply_invoice(invoice_id):
    invoice = Invoice.get(invoice_id)
    if not invoice:
        abort(404)
    invoices_ids = request.values.getlist('invoices')
    invoices = Invoice.gets(invoices_ids)
    if not invoices:
        abort(403)
    emails = request.values.getlist('email')
    msg = request.values.get('msg', '')
    action = int(request.values.get('action', 0))
    to_users = invoice.client_order.direct_sales + invoice.client_order.agent_sales + \
        [invoice.client_order.creator, g.user] + \
        invoice.client_order.leaders
    send_type = "saler"
    if action == 2:
        invoice_status = INVOICE_STATUS_APPLY
        action_msg = u'客户发票开具申请'
    elif action == 3:
        to_users = User.finances()
        invoice_status = INVOICE_STATUS_APPLYPASS
        action_msg = u'同意客户发票开具申请'
        send_type = "finance"
    elif action == 4:
        invoice_status = INVOICE_STATUS_FAIL
        action_msg = u'客户发票开具申请未通过'
    if action != 10:
        for invoice in invoices:
            invoice.invoice_status = invoice_status
            invoice.create_time = datetime.date.today()
            invoice.save()
            flash(
                u'[%s 发票开具申请,发票金额%s]  %s ' %
                (invoice.company, invoice.money, action_msg), 'success')
            invoice.client_order.add_comment(
                g.user,
                u"%s,%s" % (action_msg, u'发票内容: %s; 发票金额: %s元' %
                            (invoice.detail, str(invoice.money))),
                msg_channel=1)
    else:
        action_msg = u'消息提醒'

    context = {
        "to_users": to_users,
        "action_msg": action_msg,
        "info": msg,
        "order": invoice.client_order,
        "send_type": send_type,
        "action": action,
        "invoices": invoices,
        "to_other": emails
    }
    invoice_apply_signal.send(current_app._get_current_object(),
                              context=context)
    return redirect(
        url_for("saler_client_order_invoice.index",
                order_id=invoice.client_order.id))
예제 #3
0
def delete_invoice(invoice_id):
    if not g.user.is_finance():
        abort(404)
    invoice = Invoice.get(invoice_id)
    order_id = invoice.client_order.id
    invoice.client_order.add_comment(g.user, u"删除发票信息:%s" % (
        u'发票内容: %s; 发票金额: %s元' % (invoice.detail, str(invoice.money))), msg_channel=1)
    invoice.delete()
    flash(u"删除成功", 'danger')
    return redirect(url_for("finance_client_order_invoice.info", order_id=order_id))
예제 #4
0
def invoice_num(invoice_id):
    if not g.user.is_finance():
        abort(404)
    invoice = Invoice.get(invoice_id)
    if not invoice:
        abort(404)
    invoice_num = request.values.get('invoice_num', '')
    invoice.invoice_num = invoice_num
    invoice.save()
    flash(u'保存成功!', 'success')
    invoice.client_order.add_comment(
        g.user, u"%s" % (u'更新了发票号: %s;' % (invoice.invoice_num)), msg_channel=1)
    return redirect(url_for("finance_client_order_invoice.info", order_id=invoice.client_order.id))
예제 #5
0
def delete_invoice(invoice_id):
    if not g.user.is_finance():
        abort(404)
    invoice = Invoice.get(invoice_id)
    order_id = invoice.client_order.id
    invoice.client_order.add_comment(g.user,
                                     u"删除发票信息:%s" %
                                     (u'发票内容: %s; 发票金额: %s元' %
                                      (invoice.detail, str(invoice.money))),
                                     msg_channel=1)
    invoice.delete()
    flash(u"删除成功", 'danger')
    return redirect(
        url_for("finance_client_order_invoice.info", order_id=order_id))
예제 #6
0
def apply_invoice(invoice_id):
    invoice = Invoice.get(invoice_id)
    if not invoice:
        abort(404)
    invoices_ids = request.values.getlist('invoices')
    invoices = Invoice.gets(invoices_ids)
    if not invoices:
        abort(403)
    emails = request.values.getlist('email')
    msg = request.values.get('msg', '')
    action = int(request.values.get('action', 0))
    to_users = invoice.client_order.direct_sales + invoice.client_order.agent_sales + \
        [invoice.client_order.creator, g.user] + \
        invoice.client_order.leaders
    send_type = "saler"
    if action == 2:
        invoice_status = INVOICE_STATUS_APPLY
        action_msg = u'客户发票开具申请'
    elif action == 3:
        to_users = User.finances()
        invoice_status = INVOICE_STATUS_APPLYPASS
        action_msg = u'同意客户发票开具申请'
        send_type = "finance"
    elif action == 4:
        invoice_status = INVOICE_STATUS_FAIL
        action_msg = u'客户发票开具申请未通过'
    if action != 10:
        for invoice in invoices:
            invoice.invoice_status = invoice_status
            invoice.create_time = datetime.date.today()
            invoice.save()
            flash(u'[%s 发票开具申请,发票金额%s]  %s ' %
                  (invoice.company, invoice.money, action_msg), 'success')
            invoice.client_order.add_comment(g.user, u"%s,%s" % (
                action_msg, u'发票内容: %s; 发票金额: %s元' % (invoice.detail, str(invoice.money))), msg_channel=1)
    else:
        action_msg = u'消息提醒'

    context = {"to_users": to_users,
               "action_msg": action_msg,
               "info": msg,
               "order": invoice.client_order,
               "send_type": send_type,
               "action": action,
               "invoices": invoices,
               "to_other": emails
               }
    invoice_apply_signal.send(
        current_app._get_current_object(), context=context)
    return redirect(url_for("saler_client_order_invoice.index", order_id=invoice.client_order.id))
예제 #7
0
def invoice_num(invoice_id):
    if not g.user.is_finance():
        abort(404)
    invoice = Invoice.get(invoice_id)
    if not invoice:
        abort(404)
    invoice_num = request.values.get('invoice_num', '')
    invoice.invoice_num = invoice_num
    invoice.save()
    flash(u'保存成功!', 'success')
    invoice.client_order.add_comment(g.user,
                                     u"%s" % (u'更新了发票号: %s;' %
                                              (invoice.invoice_num)),
                                     msg_channel=1)
    return redirect(
        url_for("finance_client_order_invoice.info",
                order_id=invoice.client_order.id))
예제 #8
0
파일: invoice.py 프로젝트: cash2one/braavos
def update_invoice(invoice_id):
    invoice = Invoice.get(invoice_id)
    if not invoice:
        abort(404)
    form = InvoiceForm(request.form)
    form.client_order.choices = [(invoice.client_order.id,
                                  invoice.client_order.client.name)]
    if request.method == 'POST' and form.validate():
        back_time = request.values.get('back_time', datetime.date.today())
        if not form.tax_id.data:
            flash(u"修改发票失败,公司名称不能为空", 'danger')
        elif not form.detail.data:
            flash(u"修改发票失败,发票内容不能为空", 'danger')
        elif not form.money.data:
            flash(u"修改发票失败,发票金额不能为空", 'danger')
        else:
            invoice.company = form.company.data,
            invoice.tax_id = form.tax_id.data,
            invoice.address = form.address.data,
            invoice.phone = form.phone.data,
            invoice.bank_id = form.bank_id.data,
            invoice.bank = form.bank.data,
            invoice.detail = form.detail.data,
            invoice.money = form.money.data,
            invoice.invoice_type = form.invoice_type.data,
            invoice.creator = g.user
            invoice.create_time = datetime.date.today()
            invoice.back_time = back_time
            invoice.save()
            flash(u'修改发票(%s)成功!' % form.company.data, 'success')
            invoice.client_order.add_comment(
                g.user,
                u"修改发票信息,%s" % (u'发票内容: %s; 发票金额: %s元' %
                                (invoice.detail, str(invoice.money))),
                msg_channel=1)
    else:
        for k in form.errors:
            flash(u"修改发票失败,%s" % (form.errors[k][0]), 'danger')
    return redirect(
        url_for("saler_client_order_invoice.index",
                order_id=invoice.client_order.id))
예제 #9
0
def update_invoice(invoice_id):
    invoice = Invoice.get(invoice_id)
    if not invoice:
        abort(404)
    if request.method == 'POST':
        company = request.values.get('edit_company', '')
        tax_id = request.values.get('edit_tax_id', '')
        detail = request.values.get('edit_detail', '')
        money = request.values.get('edit_money', 0)
        invoice_num = request.values.get('edit_invoice_num', '')
        invoice_type = request.values.get('invoice_type', 0)
        create_time = request.values.get(
            'edit_create_time',
            datetime.datetime.now().strftime('%Y-%m-%d'))
        if not tax_id:
            flash(u"修改发票失败,公司名称不能为空", 'danger')
        elif not detail:
            flash(u"修改发票失败,发票内容不能为空", 'danger')
        elif not money:
            flash(u"修改发票失败,发票金额不能为空", 'danger')
        elif not invoice_num:
            flash(u"修改发票失败,发票号不能为空", 'danger')
        else:
            invoice.company = company
            invoice.tax_id = tax_id
            invoice.detail = detail
            invoice.invoice_num = invoice_num
            invoice.money = money
            invoice.invoice_type = invoice_type
            invoice.create_time = create_time
            invoice.save()
            flash(u'修改发票(%s)成功!' % company, 'success')
            invoice.client_order.add_comment(
                g.user,
                u"修改发票信息,%s" %
                (u'发票内容: %s; 发票号: %s; 发票金额: %s元' %
                 (invoice.detail, invoice_num, str(invoice.money))),
                msg_channel=1)
    return redirect(
        url_for("finance_client_order_invoice.info",
                order_id=invoice.client_order.id))
예제 #10
0
def update_invoice(invoice_id):
    invoice = Invoice.get(invoice_id)
    if not invoice:
        abort(404)
    form = InvoiceForm(request.form)
    form.client_order.choices = [
        (invoice.client_order.id, invoice.client_order.client.name)]
    if request.method == 'POST' and form.validate():
        back_time = request.values.get('back_time', datetime.date.today())
        if not form.tax_id.data:
            flash(u"修改发票失败,公司名称不能为空", 'danger')
        elif not form.detail.data:
            flash(u"修改发票失败,发票内容不能为空", 'danger')
        elif not form.money.data:
            flash(u"修改发票失败,发票金额不能为空", 'danger')
        else:
            invoice.company = form.company.data,
            invoice.tax_id = form.tax_id.data,
            invoice.address = form.address.data,
            invoice.phone = form.phone.data,
            invoice.bank_id = form.bank_id.data,
            invoice.bank = form.bank.data,
            invoice.detail = form.detail.data,
            invoice.money = form.money.data,
            invoice.invoice_type = form.invoice_type.data,
            invoice.creator = g.user
            invoice.create_time = datetime.date.today()
            invoice.back_time = back_time
            invoice.save()
            flash(u'修改发票(%s)成功!' % form.company.data, 'success')
            invoice.client_order.add_comment(g.user, u"修改发票信息,%s" % (
                u'发票内容: %s; 发票金额: %s元' % (invoice.detail, str(invoice.money))), msg_channel=1)
    else:
        for k in form.errors:
            flash(u"修改发票失败,%s" % (form.errors[k][0]), 'danger')
    return redirect(url_for("saler_client_order_invoice.index", order_id=invoice.client_order.id))