예제 #1
0
def invoice_pass(invoice_id):
    if not g.user.is_finance():
        abort(404)
    invoice = MediumInvoice.get(invoice_id)
    if not invoice:
        abort(404)
    invoices_ids = request.values.getlist('invoices')
    invoices_pay = MediumInvoicePay.gets(invoices_ids)
    if not invoices_pay:
        abort(403)
    emails = request.values.getlist('email')
    msg = request.values.get('msg', '')
    action = int(request.values.get('action', 0))

    to_users = [g.user] + \
        User.medias() + User.media_leaders() + User.super_leaders()
    to_emails = list(set(emails + [x.email for x in to_users]))

    if action != 10:
        invoice_status = MEDIUM_INVOICE_STATUS_PASS
        action_msg = u'媒体款项已打款'
        for invoice_pay in invoices_pay:
            invoice_pay.pay_status = invoice_status
            invoice_pay.save()
            flash(u'媒体订单款已打,名称:%s, 付款金额%s' % (
                invoice_pay.medium_invoice.client_order.name +
                '-' + invoice_pay.medium_invoice.medium.name,
                str(invoice_pay.money)), 'success')
            invoice_pay.medium_invoice.client_order.add_comment(
                g.user, u'媒体订单款已付款,名称%s, 付款金额%s ' % (
                    invoice_pay.medium_invoice.client_order.name +
                        '-' + invoice_pay.medium_invoice.medium.name,
                    str(invoice_pay.money)),
                msg_channel=3)
    else:
        action_msg = u'消息提醒'
    context = {"to_users": to_users,
               "action": 0,
               "action_msg": action_msg,
               "info": msg,
               "invoice": invoice,
               "order": invoice.client_order,
               "send_type": 'end',
               "invoice_pays": invoices_pay}
    medium_invoice_apply_signal.send(
        current_app._get_current_object(), context=context)
    flash(u'已发送邮件给 %s ' % (', '.join(to_emails)), 'info')
    return redirect(url_for("finance_client_order_medium_pay.pay_info", invoice_id=invoice_id))
예제 #2
0
def apply_pay(invoice_id):
    medium_invoice = MediumInvoice.get(invoice_id)
    if not medium_invoice:
        abort(404)
    invoice_pay_ids = request.values.getlist('invoices')
    invoice_pays = MediumInvoicePay.gets(invoice_pay_ids)
    if not invoice_pays:
        abort(403)
    emails = request.values.getlist('email')
    msg = request.values.get('msg', '')
    action = int(request.values.get('action', 0))
    to_users = [g.user] + User.medias() + User.media_leaders() + \
        User.super_leaders()
    if action == 2:
        action_msg = u'媒体打款申请'
        for invoice in invoice_pays:
            invoice.pay_status = MEDIUM_INVOICE_STATUS_APPLY
            invoice.save()
            flash(u'[%s媒体申请打款,打款金额: %s, 发票号: %s]  %s ' %
                  (invoice.medium_invoice.company, invoice.money,
                   invoice.medium_invoice.invoice_num, invoice.detail), 'success')

            invoice.medium_invoice.client_order.add_comment(g.user, u"%s,%s" % (
                action_msg, u' %s媒体申请打款,打款金额: %s, 发票号: %s  %s ' %
                (invoice.medium_invoice.company, invoice.money,
                    invoice.medium_invoice.invoice_num, invoice.detail)), msg_channel=3)
        send_type = "saler"
    elif action == 3:
        action_msg = u'媒体打款申请'
        for invoice in invoice_pays:
            invoice.pay_status = MEDIUM_INVOICE_STATUS_F_AGREE
            invoice.save()
            flash(u'[副总裁同意%s媒体打款,打款金额: %s, 发票号: %s]  %s ' %
                  (invoice.medium_invoice.company, invoice.money,
                   invoice.medium_invoice.invoice_num, invoice.detail), 'success')

            invoice.medium_invoice.client_order.add_comment(g.user, u"%s,%s" % (
                action_msg, u' 副总裁同意%s媒体打款,打款金额: %s, 发票号: %s  %s ' %
                (invoice.medium_invoice.company, invoice.money,
                    invoice.medium_invoice.invoice_num, invoice.detail)), msg_channel=3)
        send_type = "saler"
    elif action == 4:
        action_msg = u'黄亮已批准媒体打款'
        to_users += User.finances()
        for invoice in invoice_pays:
            invoice.pay_status = MEDIUM_INVOICE_STATUS_AGREE
            invoice.save()
            flash(u' 同意%s媒体订单打款申请,打款金额: %s, 发票号: %s  %s ' %
                  (invoice.medium_invoice.company, invoice.money,
                   invoice.medium_invoice.invoice_num, invoice.detail), 'success')

            invoice.medium_invoice.client_order.add_comment(g.user, u"%s,%s" % (
                action_msg, u' %s媒体同意打款,打款金额: %s, 发票号: %s  %s ' %
                (invoice.medium_invoice.company, invoice.money,
                    invoice.medium_invoice.invoice_num, invoice.detail)), msg_channel=3)
        send_type = "finance"
    else:
        action_msg = u'消息提醒'

    context = {"to_users": to_users,
               "action": action,
               "to_other": emails,
               "action_msg": action_msg,
               "info": msg,
               "invoice": medium_invoice,
               "order": medium_invoice.client_order,
               "send_type": send_type,
               "invoice_pays": invoice_pays}
    medium_invoice_apply_signal.send(
        current_app._get_current_object(), context=context)
    return redirect(url_for('saler_client_order_medium_invoice.invoice', invoice_id=invoice_id))
예제 #3
0
def apply_pay(invoice_id):
    medium_invoice = MediumInvoice.get(invoice_id)
    if not medium_invoice:
        abort(404)
    invoice_pay_ids = request.values.getlist('invoices')
    invoice_pays = MediumInvoicePay.gets(invoice_pay_ids)
    if not invoice_pays:
        abort(403)
    emails = request.values.getlist('email')
    msg = request.values.get('msg', '')
    action = int(request.values.get('action', 0))
    to_users = [g.user] + User.medias() + User.media_leaders() + \
        User.super_leaders()
    if action == 2:
        action_msg = u'媒体打款申请'
        for invoice in invoice_pays:
            invoice.pay_status = MEDIUM_INVOICE_STATUS_APPLY
            invoice.save()
            flash(
                u'[%s媒体申请打款,打款金额: %s, 发票号: %s]  %s ' %
                (invoice.medium_invoice.company, invoice.money,
                 invoice.medium_invoice.invoice_num, invoice.detail),
                'success')

            invoice.medium_invoice.client_order.add_comment(
                g.user,
                u"%s,%s" %
                (action_msg, u' %s媒体申请打款,打款金额: %s, 发票号: %s  %s ' %
                 (invoice.medium_invoice.company, invoice.money,
                  invoice.medium_invoice.invoice_num, invoice.detail)),
                msg_channel=3)
        send_type = "saler"
    elif action == 3:
        action_msg = u'媒体打款申请'
        for invoice in invoice_pays:
            invoice.pay_status = MEDIUM_INVOICE_STATUS_F_AGREE
            invoice.save()
            flash(
                u'[副总裁同意%s媒体打款,打款金额: %s, 发票号: %s]  %s ' %
                (invoice.medium_invoice.company, invoice.money,
                 invoice.medium_invoice.invoice_num, invoice.detail),
                'success')

            invoice.medium_invoice.client_order.add_comment(
                g.user,
                u"%s,%s" %
                (action_msg, u' 副总裁同意%s媒体打款,打款金额: %s, 发票号: %s  %s ' %
                 (invoice.medium_invoice.company, invoice.money,
                  invoice.medium_invoice.invoice_num, invoice.detail)),
                msg_channel=3)
        send_type = "saler"
    elif action == 4:
        action_msg = u'黄亮已批准媒体打款'
        to_users += User.finances()
        for invoice in invoice_pays:
            invoice.pay_status = MEDIUM_INVOICE_STATUS_AGREE
            invoice.save()
            flash(
                u' 同意%s媒体订单打款申请,打款金额: %s, 发票号: %s  %s ' %
                (invoice.medium_invoice.company, invoice.money,
                 invoice.medium_invoice.invoice_num, invoice.detail),
                'success')

            invoice.medium_invoice.client_order.add_comment(
                g.user,
                u"%s,%s" %
                (action_msg, u' %s媒体同意打款,打款金额: %s, 发票号: %s  %s ' %
                 (invoice.medium_invoice.company, invoice.money,
                  invoice.medium_invoice.invoice_num, invoice.detail)),
                msg_channel=3)
        send_type = "finance"
    else:
        action_msg = u'消息提醒'

    context = {
        "to_users": to_users,
        "action": action,
        "to_other": emails,
        "action_msg": action_msg,
        "info": msg,
        "invoice": medium_invoice,
        "order": medium_invoice.client_order,
        "send_type": send_type,
        "invoice_pays": invoice_pays
    }
    medium_invoice_apply_signal.send(current_app._get_current_object(),
                                     context=context)
    return redirect(
        url_for('saler_client_order_medium_invoice.invoice',
                invoice_id=invoice_id))