Exemplo n.º 1
0
def user_stockpicking(request):
    partnerid = request.user.jyinfo.jy_partner_id
    if request.GET:
        partno = request.GET.get('search_prt', '')
        del_city = request.GET.get('del_city', 'None')
        stock_states = request.GET.get('stock_states', None)
        del_states = request.GET.get('del_states', None)
        del_type = request.GET.get('del_type', None)
        data = get_stockpicking(partnerid, 'current', 'express', partno)
        if del_city:
            data = [one for one in data if one['location'] == del_city]
        if del_type:
            data = [one for one in data if one['deliverytype'] == del_type]
    else:
        del_states = ''
        data = get_stockpicking(partnerid, 'current', 'express')

    dataArr1 = []
    for var1 in data:
        if del_states == '' or del_states == var1['state']:
            dataArr1.append(var1)
        elif del_states == 'not_available' and var1['state'] == 'assigned':
            dataArr1.append(var1)
    data = []
    for picking in dataArr1:
        if picking['lines_count'] > 0:
            data.append(picking)
    totalrows = len(data)
    return render(request, "accounts/stockpicking.html", {'data': data,
                                                          'partnerid': partnerid, 'totalrows': totalrows})
Exemplo n.º 2
0
def user_stockpicking_self_finished(request):
    partnerid = request.user.jyinfo.jy_partner_id
    deliverytype = request.GET.get('deliverytype', '')
    deliverycity = request.GET.get('deliverycity', '')  # 交货地
    carrier_type = request.GET.get('carrier_type', '')
    partno = request.GET.get('partnoitem', '')  # 型号
    date = request.GET.get('date', '')  # 日期

    #data = get_stockpicking(partnerid, 'finished', '', partno)
    data = get_stockpicking(
        partnerid, 'finished', carrier_type, date, deliverytype, deliverycity, partno)
    newdata = []
    for one in data:
        one['lines_count'] = 0  # 总条目数
        lines = one['lines'].values()
        for line in lines[0]:
            line['iscontainsign'] = False
            line['sign_qty'] = 0  # 总发货数量
            routes = line['latest_state']
            if routes:
                for route in routes:
                    if route['state'] == 'sign':
                        one['lines_count'] += 1
                        line['sign_time'] = route['time']
                        line['sign_qty'] += route['qty']
                        line['iscontainsign'] = True
                        newdata.append(one)

    data = newdata
    for one in data:
        # for key,values in one['lines'].items():
        key = one['lines'].keys()[0]
        values = one['lines'].values()[0]
        arr = []
        for value in values:
            if value['iscontainsign']:
                money_type = value['price'][0:1]
                value['totalprice'] = float(
                    value['order_qty']) * float(value['price'][1:])
                value['totalprice'] = money_type + str(value['totalprice'])
                arr.append(value)
        one['lines'][key] = arr

    # 清除重复的出库单
    arr = []
    for one in data:
        flag = True
        if len(arr) != 0:
            for two in arr:
                if one['name'] == two['name']:
                    flag = False
            if flag:
                arr.append(one)
                flag = True
        else:
            arr.append(one)
    data = arr
    totalrows = len(data)
    return render(request, "accounts/stockpicking_self_al.html", {'data': data, 'partnoitem': partno, 'date': date,
                                                                  'totalrows': totalrows, 'deliverycity': deliverycity})
Exemplo n.º 3
0
def user_already_instorage(request):
    partnerid = request.user.jyinfo.jy_partner_id

    partno = request.GET.get('partnoitem', '')  # 型号
    deliverycity = request.GET.get('deliverycity', '')  # 交货地
    carrier_type = request.GET.get('carrier_type', '')  # 收货方式
    data = get_stockpicking(partnerid, 'current',
                            carrier_type, '', '', deliverycity, partno)

    newdata = []
    for one in data:
        stoct_out_number = one['name']
        if one['lines_count'] > 0:
            dataarr = []  # 用来从新组织数据
            key = one['lines'].keys()[0]
            values = one['lines'].values()[0]
            for value in values:
                in_qty = 0
                in_time = one['so_confirmed_time']
                for state in value['latest_state']:
                    addnum = 0
                    if state['state'] == 'st_in_done':  # and value['ins']:
                        result = check_stock_out_is_print(
                            stoct_out_number, partnerid)
                        finished = result['finished']
                        if finished == False:  # 已入库但没有打印的,视为如入库,打印了大视为正在备货
                            in_qty += int(state['qty'])
                            in_time = state['time']
                            dataarr.append(value)
                            addnum += 1
                value['in_qty'] = in_qty  # 入库数量
                value['in_time'] = in_time  # 入库时间
            one['lines'][key] = dataarr
            one['lines_count'] = len(dataarr)
            if dataarr:
                newdata.append(one)
    data = newdata
    for one in data:  # 计算还没入库数量
        arrivenum = 0  # 入库总量
        totalordernum = 0  # 采购总量
        values = one['lines'].values()[0]
        for value in values:
            totalordernum += int(value['order_qty'])
            for laststate in value['ins']:
                if laststate[1] == 'done':
                    arrivenum += int(laststate[0])
        one['notarrivenum'] = totalordernum - arrivenum
    # print data
    totalrows = len(data)
    return render(request, "accounts/already_instorage.html",
                  {'data': data, 'partnoitem': partno, 'deliverycity': deliverycity,
                   'carrier_type': carrier_type, 'totalrows': totalrows})
Exemplo n.º 4
0
def user_alreadyinstorage_preparegoods(request):
    partnerid = request.user.jyinfo.jy_partner_id
    deliverytype = request.GET.get('deliverytype', '')  # 发货方式
    deliverycity = request.GET.get('deliverycity', '')  # 库房
    carrier_type = request.GET.get('carrier_type', '')
    partno = request.GET.get('partnoitem', '')

    #data = get_stockpicking(partnerid, 'current', '','')
    data = get_stockpicking(
        partnerid, 'current', carrier_type, '', deliverytype, deliverycity, partno)
    newdata = []
    for one in data:
        stoct_out_number = one['name']
        if one['lines_count'] > 0:
            dataarr = []  # 用来从新组织数据
            key = one['lines'].keys()[0]
            values = one['lines'].values()[0]
            for value in values:
                for state in value['latest_state']:
                    addnum = 0
                    if state['state'] == 'st_in_done':  # and value['ins']:
                        result = check_stock_out_is_print(
                            stoct_out_number, partnerid)
                        finished = result['finished']
                        if finished:  # 已入库但没有打印的,视为如入库,打印了大视为正在备货
                            dataarr.append(value)
                            addnum += 1
            one['lines'][key] = dataarr
            if dataarr:
                newdata.append(one)
    data = newdata
    for one in data:  # 计算还没入库数量
        arrivenum = 0  # 入库总量
        totalordernum = 0  # 采购总量
        # for key,values in one['lines'].items():
        key = one['lines'].keys()[0]
        values = one['lines'].values()[0]
        for value in values:
            totalordernum += int(value['order_qty'])
            for laststate in value['ins']:
                if laststate[1] == 'done':
                    arrivenum += int(laststate[0])
        one['notarrivenum'] = totalordernum - arrivenum
    totalrows = len(data)

    return render(request, "accounts/preparegoods.html", {'data': data, 'partnoitem': partno, 'totalrows': totalrows,
                                                          'deliverycity': deliverycity, 'deliverytype': deliverytype})
Exemplo n.º 5
0
def user_stockpicking_al(request):
    partnerid = request.user.jyinfo.jy_partner_id
    deliverytype = request.GET.get('deliverytype', '')
    deliverycity = request.GET.get('deliverycity', '')  # 库房
    # carrier_type = request.GET.get('carrier_type', '')
    partno = request.GET.get('partnoitem', '')  # 型号
    date = request.GET.get('date', '')  # 日期
    currentpage = request.GET.get('currentpage', '1')  # 当前页

    #data = get_stockpicking(partnerid,'finished','express',partno)
    data = get_stockpicking(partnerid, 'finished', '',
                            date, deliverytype, deliverycity, partno)

    newdata = []
    for one in data:
        lines = one['lines'].values()
        addnum = 0
        one['lines_count'] = 0
        lines = iter(lines)
        while 1:
            try:
                for line in lines.next():

                    line['order_qty'] = int(line['order_qty'])
                    out_qty = 0  # 发货数量
                    for state in line['latest_state']:
                        if state['state'] in ['st_out_done', 'sign']:
                            out_qty += state['qty']
                        # print state['qty']
                    line['out_qty'] = out_qty
                    if line['out_qty'] != 0:
                        one['lines_count'] += 1
                    routes = line['latest_state']
                    if routes and addnum == 0 and one['lines_count'] != 0:
                        newdata.append(one)
                        addnum += 1
            except StopIteration:
                break

    data = newdata
    totalrows = len(data)

    return render(request, "accounts/stockpicking_al.html", {'data': data, 'partnoitem': partno, 'date': date,
                                                             'totalrows': totalrows, 'deliverycity': deliverycity})