Beispiel #1
0
def back_invoice():
    now_date = datetime.datetime.now()
    info = request.values.get('info', '').strip()
    location = int(request.values.get('location', 0))
    year = request.values.get('year', now_date.strftime('%Y'))
    month = request.values.get('month', now_date.strftime('%m'))

    if month != '00':
        search_date = datetime.datetime.strptime(
            str(year) + '-' + str(month), '%Y-%m')
        end_search_date = (
            search_date + datetime.timedelta(days=(search_date.max.day - search_date.day) + 1)).replace(day=1)
        orders = [k for k in BackInvoiceRebate.query.filter(BackInvoiceRebate.back_time >= search_date,
                                                            BackInvoiceRebate.back_time < end_search_date)
                  if k.douban_order.status == 1]
    else:
        orders = [k for k in BackInvoiceRebate.all() if k.back_time.year == int(
            year) and k.douban_order.status == 1]
    if location != 0:
        orders = [k for k in orders if location in k.douban_order.locations]
    if info:
        orders = [k for k in orders if info in k.douban_order.search_invoice_info]
    orders = sorted(list(orders), key=lambda x: x.back_time, reverse=False)
    if request.values.get('action', '') == 'download':
        response = write_order_excel(list(orders), 'douban_back_invoice')
        return response
    return tpl('/saler/douban_order/data_query/index.html',
               orders=orders, location=location,
               year=year, month=month, info=info,
               title=u"已收客户返点发票", t_type='douban_back_invoice')
Beispiel #2
0
def pay_medium_invoice():
    if not (g.user.is_media() or g.user.is_media_leader() or g.user.is_contract()):
        abort(404)
    now_date = datetime.datetime.now()
    info = request.values.get('info', '').strip()
    location = int(request.values.get('location', 0))
    year = request.values.get('year', now_date.strftime('%Y'))
    month = request.values.get('month', now_date.strftime('%m'))

    if month != '00':
        search_date = datetime.datetime.strptime(
            str(year) + '-' + str(month), '%Y-%m')
        end_search_date = (
            search_date + datetime.timedelta(days=(search_date.max.day - search_date.day) + 1)).replace(day=1)
        orders = [k for k in MediumInvoicePay.query.filter(MediumInvoicePay.pay_time >= search_date,
                                                           MediumInvoicePay.pay_time < end_search_date)
                  if k.client_order.status == 1 and k.pay_status == 0]
    else:
        orders = [k for k in MediumInvoicePay.all() if k.pay_time.year == int(
            year) and k.client_order.status == 1 and k.pay_status == 0]
    if location != 0:
        orders = [k for k in orders if location in k.client_order.locations]
    if info:
        orders = [k for k in orders if info in k.client_order.search_info]
    orders = sorted(list(orders), key=lambda x: x.pay_time, reverse=False)
    if request.values.get('action', '') == 'download':
        response = write_order_excel(list(orders), 'pay_medium_invoice')
        return response
    return tpl('/media/client_order/data_query/index.html',
               orders=orders, location=location,
               year=year, month=month, info=info,
               title=u"付款给媒体金额", t_type='pay_medium_invoice')
Beispiel #3
0
def back_money():
    now_date = datetime.datetime.now()
    info = request.values.get('info', '').strip()
    year = request.values.get('year', now_date.strftime('%Y'))
    month = request.values.get('month', now_date.strftime('%m'))

    if month != '00':
        search_date = datetime.datetime.strptime(
            str(year) + '-' + str(month), '%Y-%m')
        end_search_date = (
            search_date + datetime.timedelta(days=(search_date.max.day - search_date.day) + 1)).replace(day=1)
        orders = [k for k in searchAdBackMoney.query.filter(searchAdBackMoney.back_time >= search_date,
                                                    searchAdBackMoney.back_time < end_search_date)
                  if k.client_order.status == 1]
    else:
        orders = [k for k in searchAdBackMoney.all() if k.back_time.year == int(
            year) and k.client_order.status == 1]
    if info:
        orders = [k for k in orders if info in k.client_order.search_invoice_info]
    orders = sorted(list(orders), key=lambda x: x.back_time, reverse=False)
    if request.values.get('action', '') == 'download':
        response = write_order_excel(list(orders), 'back_money')
        return response
    return tpl('/finance/searchAd_order/data_query/index.html',
               orders=orders,
               year=year, month=month, info=info,
               title=u"客户回款金额", t_type='back_money')
Beispiel #4
0
def outsource():
    now_date = datetime.datetime.now()
    info = request.values.get('info', '').strip()
    location = int(request.values.get('location', 0))
    year = request.values.get('year', now_date.strftime('%Y'))
    month = request.values.get('month', now_date.strftime('%m'))
    if month != '00':
        search_date = datetime.datetime.strptime(
            str(year) + '-' + str(month), '%Y-%m')
        end_search_date = (
            search_date + datetime.timedelta(days=(search_date.max.day - search_date.day) + 1)).replace(day=1)

        orders = [k for k in MergerOutSource.query.filter(MergerOutSource.create_time >= search_date,
                                                          MergerOutSource.create_time < end_search_date,
                                                          MergerOutSource.status == 0)]
        orders += [k for k in MergerDoubanOutSource.query.filter(MergerDoubanOutSource.create_time >= search_date,
                                                                 MergerDoubanOutSource.create_time < end_search_date,
                                                                 MergerDoubanOutSource.status == 0)]
    else:
        orders = [k for k in MergerOutSource.all(
        ) if k.create_time.year == int(year) and k.status == 0]
        orders += [k for k in MergerDoubanOutSource.all()
                   if k.create_time.year == int(year) and k.status == 0]
    if location != 0:
        orders = [k for k in orders if location in k.locations]
    if info:
        orders = [k for k in orders if info in k.search_invoice_info]
    orders = sorted(list(orders), key=lambda x: x.create_time, reverse=False)
    if request.values.get('action', '') == 'download':
        response = write_order_excel(list(orders), 'outsource')
        return response
    return tpl('/saler/client_order/data_query/index.html',
               orders=orders, location=location,
               year=year, month=month, info=info,
               title=u"对公外包打款", t_type='outsource')
Beispiel #5
0
def agent_invoice():
    if not g.user.is_searchad_leader():
        abort(404)
    now_date = datetime.datetime.now()
    info = request.values.get('info', '').strip()
    year = request.values.get('year', now_date.strftime('%Y'))
    month = request.values.get('month', now_date.strftime('%m'))
    if month != '00':
        search_date = datetime.datetime.strptime(
            str(year) + '-' + str(month), '%Y-%m')
        end_search_date = (
            search_date + datetime.timedelta(days=(search_date.max.day - search_date.day) + 1)).replace(day=1)
        orders = [k for k in searchAdInvoice.query.filter(searchAdInvoice.create_time >= search_date,
                                                  searchAdInvoice.create_time < end_search_date,
                                                  searchAdInvoice.invoice_status == 0) if k.rebate_order.status == 1]
    else:
        orders = [k for k in searchAdInvoice.all() if k.create_time.year == int(
            year) and k.invoice_status == 0 and k.rebate_order.status == 1]
    if info:
        orders = [k for k in orders if info in k.rebate_order.search_invoice_info]
    orders = sorted(list(orders), key=lambda x: x.create_time, reverse=False)
    if request.values.get('action', '') == 'download':
        response = write_order_excel(list(orders), 'agent_invoice')
        return response
    return tpl('/saler/searchAd_rebate_order/data_query/index.html',
               orders=orders,
               year=year, month=month, info=info,
               title=u"已开客户发票", t_type='agent_invoice')
Beispiel #6
0
def back_invoice():
    now_date = datetime.datetime.now()
    info = request.values.get('info', '').strip()
    location = int(request.values.get('location', 0))
    year = request.values.get('year', now_date.strftime('%Y'))
    month = request.values.get('month', now_date.strftime('%m'))

    if month != '00':
        search_date = datetime.datetime.strptime(
            str(year) + '-' + str(month), '%Y-%m')
        end_search_date = (
            search_date + datetime.timedelta(days=(search_date.max.day - search_date.day) + 1)).replace(day=1)
        orders = [k for k in BackInvoiceRebate.query.filter(BackInvoiceRebate.back_time >= search_date,
                                                            BackInvoiceRebate.back_time < end_search_date)
                  if k.douban_order.status == 1]
    else:
        orders = [k for k in BackInvoiceRebate.all() if k.back_time.year == int(
            year) and k.douban_order.status == 1]
    if location != 0:
        orders = [k for k in orders if location in k.douban_order.locations]
    if info:
        orders = [k for k in orders if info in k.douban_order.search_invoice_info]
    orders = sorted(list(orders), key=lambda x: x.back_time, reverse=False)
    if request.values.get('action', '') == 'download':
        response = write_order_excel(list(orders), 'douban_back_invoice')
        return response
    return tpl('/finance/douban_order/data_query/index.html',
               orders=orders, location=location,
               year=year, month=month, info=info,
               title=u"已收客户返点发票", t_type='douban_back_invoice')
Beispiel #7
0
def rebate_agent_invoice():
    if not (g.user.is_finance() or g.user.is_aduit()):
        abort(404)
    now_date = datetime.datetime.now()
    info = request.values.get('info', '').strip()
    location = int(request.values.get('location', 0))
    year = request.values.get('year', now_date.strftime('%Y'))
    month = request.values.get('month', now_date.strftime('%m'))

    if month != '00':
        search_date = datetime.datetime.strptime(
            str(year) + '-' + str(month), '%Y-%m')
        end_search_date = (
            search_date + datetime.timedelta(days=(search_date.max.day - search_date.day) + 1)).replace(day=1)
        orders = [k for k in AgentInvoice.query.filter(AgentInvoice.add_time >= search_date,
                                                       AgentInvoice.add_time < end_search_date)
                  if k.client_order.status == 1]
    else:
        orders = [k for k in AgentInvoice.all() if k.add_time.year == int(
            year) and k.client_order.status == 1]
    if location != 0:
        orders = [k for k in orders if location in k.client_order.locations]
    if info:
        orders = [k for k in orders if info in k.client_order.search_invoice_info]
    orders = sorted(list(orders), key=lambda x: x.add_time, reverse=False)
    if request.values.get('action', '') == 'download':
        response = write_order_excel(list(orders), 'rebate_agent_invoice')
        return response
    return tpl('/finance/client_order/data_query/index.html',
               orders=orders, location=location,
               year=year, month=month, info=info,
               title=u"客户付款返点发票", t_type='rebate_agent_invoice')
Beispiel #8
0
def personal_outsource():
    now_date = datetime.datetime.now()
    info = request.values.get('info', '').strip()
    location = int(request.values.get('location', 0))
    year = request.values.get('year', now_date.strftime('%Y'))
    month = request.values.get('month', now_date.strftime('%m'))

    if month != '00':
        search_date = datetime.datetime.strptime(
            str(year) + '-' + str(month), '%Y-%m')
        end_search_date = (search_date + datetime.timedelta(
            days=(search_date.max.day - search_date.day) + 1)).replace(day=1)

        orders = [
            k for k in MergerPersonalOutSource.query.filter(
                MergerPersonalOutSource.create_time >= search_date,
                MergerPersonalOutSource.create_time < end_search_date,
                MergerPersonalOutSource.status == 0)
        ]
        orders += [
            k for k in MergerDoubanPersonalOutSource.query.filter(
                MergerDoubanPersonalOutSource.create_time >= search_date,
                MergerDoubanPersonalOutSource.create_time < end_search_date,
                MergerDoubanPersonalOutSource.status == 0)
        ]
    else:
        orders = [
            k for k in MergerPersonalOutSource.all()
            if k.create_time.year == int(year) and k.status == 0
        ]
        orders += [
            k for k in MergerDoubanPersonalOutSource.all()
            if k.create_time.year == int(year) and k.status == 0
        ]
    if location != 0:
        orders = [k for k in orders if location in k.locations]
    if info:
        orders = [k for k in orders if info in k.search_invoice_info]
    orders = sorted(list(orders), key=lambda x: x.create_time, reverse=False)
    if request.values.get('action', '') == 'download':
        response = write_order_excel(list(orders), 'personal_outsource')
        return response
    return tpl('/saler/client_order/data_query/index.html',
               orders=orders,
               location=location,
               year=year,
               month=month,
               info=info,
               title=u"个人外包打款",
               t_type='personal_outsource')
Beispiel #9
0
def medium_rebate_invoice():
    if not (g.user.is_searchad_leader() or g.user.is_finance()):
        abort(404)
    now_date = datetime.datetime.now()
    info = request.values.get('info', '').strip()
    year = request.values.get('year', now_date.strftime('%Y'))
    month = request.values.get('month', now_date.strftime('%m'))

    if month != '00':
        search_date = datetime.datetime.strptime(
            str(year) + '-' + str(month), '%Y-%m')
        end_search_date = (search_date + datetime.timedelta(
            days=(search_date.max.day - search_date.day) + 1)).replace(day=1)
        orders = [
            k for k in searchAdMediumRebateInvoice.query.filter(
                searchAdMediumRebateInvoice.create_time >= search_date,
                searchAdMediumRebateInvoice.create_time < end_search_date,
                searchAdMediumRebateInvoice.invoice_status == 0)
            if k.client_order.status == 1
        ]
    else:
        orders = [
            k for k in searchAdMediumRebateInvoice.all()
            if k.create_time.year == int(year) and k.invoice_status == 0
            and k.client_order.status == 1
        ]
    if info:
        orders = [
            k for k in orders if info in k.client_order.search_invoice_info
        ]
    orders = sorted(list(orders), key=lambda x: x.create_time, reverse=False)
    if request.values.get('action', '') == 'download':
        response = write_order_excel(list(orders), 'medium_rebate_invoice')
        return response
    return tpl('/saler/searchAd_order/data_query/index.html',
               orders=orders,
               year=year,
               month=month,
               info=info,
               title=u"已开媒体返点发票",
               t_type='medium_rebate_invoice')
Beispiel #10
0
def pay_rebate_agent_invoice():
    now_date = datetime.datetime.now()
    info = request.values.get('info', '').strip()
    year = request.values.get('year', now_date.strftime('%Y'))
    month = request.values.get('month', now_date.strftime('%m'))

    if month != '00':
        search_date = datetime.datetime.strptime(
            str(year) + '-' + str(month), '%Y-%m')
        end_search_date = (search_date + datetime.timedelta(
            days=(search_date.max.day - search_date.day) + 1)).replace(day=1)
        orders = [
            k for k in searchAdAgentInvoicePay.query.filter(
                searchAdAgentInvoicePay.pay_time >= search_date,
                searchAdAgentInvoicePay.pay_time < end_search_date)
            if k.client_order.status == 1
        ]
    else:
        orders = [
            k for k in searchAdAgentInvoicePay.all()
            if k.pay_time.year == int(year) and k.client_order.status == 1
        ]
    if info:
        orders = [
            k for k in orders if info in k.client_order.search_invoice_info
        ]

    orders = sorted(list(orders), key=lambda x: x.pay_time, reverse=False)
    if request.values.get('action', '') == 'download':
        response = write_order_excel(list(orders), 'pay_rebate_agent_invoice')
        return response
    return tpl('/finance/searchAd_order/data_query/index.html',
               orders=orders,
               year=year,
               month=month,
               info=info,
               title=u"已收客户返点发票",
               t_type='pay_rebate_agent_invoice')