Beispiel #1
0
def get_compras_table(request):
    objects = Compra.objects.all()
    list_display = ['fecha', 'tipo', 'identificador', 'proveedor.razon_social', 'neto', 'iva', 'total', 'estado']
    list_global_search = ['proveedor__razon_social', 'numero']
    data_struct = dict(enumerate(map(lambda x: x.replace(".", "__"), list_display)))

    recordsTotal = objects.count()

    objects = filtering(request.GET, objects, data_struct, list_global_search)

    objects = ordering(request.GET, objects, data_struct)

    recordsFiltered = objects.count()

    # finally, slice according to length sent by dataTables:
    start = int(request.GET['start'])
    length = int(request.GET['length'])
    objects = objects[start: (start + length)]


    # extract information
    data = make_data(objects, list_display)

    # define response
    response = {
        'data': data,
        'recordsTotal': recordsTotal,
        'recordsFiltered': recordsFiltered,
        'draw': request.GET['draw']
    }

    return JsonResponse(response)
Beispiel #2
0
def get_compras_table(request):
    objects = Compra.objects.all()
    list_display = [
        'fecha', 'tipo', 'identificador', 'proveedor.razon_social', 'neto',
        'iva', 'total', 'estado'
    ]
    list_global_search = ['proveedor__razon_social', 'numero']
    data_struct = dict(
        enumerate(map(lambda x: x.replace(".", "__"), list_display)))

    recordsTotal = objects.count()

    objects = filtering(request.GET, objects, data_struct, list_global_search)

    objects = ordering(request.GET, objects, data_struct)

    recordsFiltered = objects.count()

    # finally, slice according to length sent by dataTables:
    start = int(request.GET['start'])
    length = int(request.GET['length'])
    objects = objects[start:(start + length)]

    # extract information
    data = make_data(objects, list_display)

    # define response
    response = {
        'data': data,
        'recordsTotal': recordsTotal,
        'recordsFiltered': recordsFiltered,
        'draw': request.GET['draw']
    }

    return JsonResponse(response)
Beispiel #3
0
def get_articulos_table(request):
    objects = Articulo.objects.all()
    desde = request.GET['desde']
    es_b = True if 'es_b' in request.GET else False
    if desde == 'seleccionArticulo':
        list_display = [
            'pk', 'codigo', 'codigo_fabrica', 'denominacion', 'rubro.nombre',
            'precio_venta'
        ]
        # list_filter = ['codigo', 'codigo_fabrica','denominacion']
    elif desde == 'mainArticulos':
        list_display = [
            'codigo', 'codigo_fabrica', 'denominacion', 'linea.nombre',
            'subrubro.nombre', 'ultima_actualizacion_precio'
        ]
        list_global_search = ['denominacion', 'codigo', 'codigo_fabrica']
        data_struct = dict(enumerate(list_display))

    # Cuenta total de articulos:
    recordsTotal = objects.count()

    # Filtrado de los articulos
    objects = filtering(request.GET, objects, data_struct, list_global_search)

    # Ordenado
    objects = ordering(request.GET, objects, data_struct)

    # Conteo de articulos despues dle filtrado
    recordsFiltered = objects.count()

    # finally, slice according to length sent by dataTables:
    start = int(request.GET['start'])
    length = int(request.GET['length'])
    objects = objects[start:(start + length)]

    # extract information
    data = make_data(objects, list_display, "editarArticulo",
                     "suspenderArticulo", "habilitarArticulo")

    # define response
    response = {
        'data': data,
        'recordsTotal': recordsTotal,
        'recordsFiltered': recordsFiltered,
        'draw': request.GET['draw']
    }

    # serialize to json
    s = StringIO()
    json.dump(response, s)
    s.seek(0)
    return HttpResponse(s.read())
Beispiel #4
0
def cobros___get_cobros_table(request):
    objects = Recibo.objects.all()
    list_display = [
        'fecha_dd_mm_aaaa()', 'numero_full', 'cliente.razon_social',
        'total_str'
    ]
    list_global_search = ['numero', 'cliente__razon_social']
    data_struct = {
        0: 'fecha',
        1: 'numero_full',
        2: 'cliente__razon_social',
        4: 'total_str'
    }

    # Cuenta total de articulos:
    recordsTotal = objects.count()

    # Filtrado de los articulos
    objects = filtering(request.GET, objects, data_struct, list_global_search)

    # Ordenado
    objects = ordering(request.GET, objects, data_struct)

    # Conteo de articulos despues dle filtrado
    recordsFiltered = objects.count()

    # finally, slice according to length sent by dataTables:
    start = int(request.GET['start'])
    length = int(request.GET['length'])
    objects = objects[start:(start + length)]

    data = []
    for obj in objects:
        row = map(lambda field: _getattr_foreingkey(obj, field), list_display)
        detalle_pago = Detalle_cobro.objects.filter(recibo=obj)
        det = ""
        for detalle in detalle_pago:
            det = det + "%s<br>" % detalle.venta
        row.insert(3, det)
        ops = '<a class="imprimirRecibo" href="%s">IMPRIMIR</a>' % (
            reverse_lazy('imprimirRecibo', args=[obj.pk]))
        row.append(ops)
        data.append(row)
    # define response
    response = {
        'data': data,
        'recordsTotal': recordsTotal,
        'recordsFiltered': recordsFiltered,
        'draw': request.GET['draw']
    }
    return JsonResponse(response)
Beispiel #5
0
def get_clientes_table(request):
    objects = Cliente.objects.all()
    list_display = [
        'cuit', 'razon_social', 'localidad', 'get_provincia_display()',
        'telefono'
    ]
    list_global_search = list_display[1:2]
    data_struct = dict(enumerate(list_display))

    # Cuenta total de articulos:
    recordsTotal = objects.count()

    # Filtrado general de los articulos
    objects = filtering(request.GET, objects, data_struct, list_global_search)

    # Ordenado
    objects = ordering(request.GET, objects, data_struct)

    # Conteo de articulos despues dle filtrado
    recordsFiltered = objects.count()

    # finally, slice according to length sent by dataTables:
    start = int(request.GET['start'])
    length = int(request.GET['length'])
    objects = objects[start:(start + length)]

    # extract information
    detalle = u'''<u>SALDO</u>: <strong>%(saldo)s</strong><br>
                   <u>Información fiscal</u>:  Condición IVA: %(get_cond_iva_display())s - IIBB: %(codigo_ingresos_brutos)s<br>
                   <u>Dirección</u>: %(direccion)s, %(localidad)s (%(get_provincia_display())s) -- CP: %(codigo_postal)s<br>
                   <u>Contacto</u>:  TE: %(telefono)s  FAX: %(fax)s<br>
                   </u>Información extra</u>:<br>
                   %(notas)s'''
    data = make_data(objects, list_display, 'editarCliente',
                     'suspenderCliente', 'habilitarCliente', detalle)

    # define response
    response = {
        'data': data,
        'recordsTotal': recordsTotal,
        'recordsFiltered': recordsFiltered,
        'draw': request.GET['draw']
    }

    # serialize to json
    s = StringIO()
    json.dump(response, s)
    s.seek(0)
    return HttpResponse(s.read())
Beispiel #6
0
def get_proveedores_table(request):
    # SETEOS INICIALES
    objects = Proveedor.objects.all()
    list_display = ['razon_social', 'localidad', 'telefono', 'email']
    list_global_search = ['razon_social']
    data_struct = dict(enumerate(list_display))

    # Cuenta total de articulos:
    recordsTotal = objects.count()

    # Filtrado de los bancos
    objects = filtering(request.GET, objects, data_struct, list_global_search)

    # Ordenado
    objects = ordering(request.GET, objects, data_struct)

    # Conteo de articulos despues dle filtrado
    recordsFiltered = objects.count()

    # finally, slice according to length sent by dataTables:
    start = int(request.GET['start'])
    length = int(request.GET['length'])
    objects = objects[start:(start + length)]

    # extract information
    data = make_data(objects, list_display, "editarProveedor",
                     "suspenderProveedor", "habilitarProveedor")
    print data
    # define response
    response = {
        'data': data,
        'recordsTotal': recordsTotal,
        'recordsFiltered': recordsFiltered,
        'draw': request.GET['draw']
    }

    # serialize to json
    s = StringIO()
    json.dump(response, s)
    s.seek(0)
    return HttpResponse(s.read())
Beispiel #7
0
def get_proveedores_table(request):
    # SETEOS INICIALES
    objects = Proveedor.objects.all()
    list_display = ['razon_social', 'localidad', 'telefono', 'email']
    list_global_search = ['razon_social']
    data_struct = dict(enumerate(list_display))

    # Cuenta total de articulos:
    recordsTotal = objects.count()

    # Filtrado de los bancos
    objects = filtering(request.GET, objects, data_struct, list_global_search)

    # Ordenado
    objects = ordering(request.GET, objects, data_struct)

    # Conteo de articulos despues dle filtrado
    recordsFiltered = objects.count()

    # finally, slice according to length sent by dataTables:
    start = int(request.GET['start'])
    length = int(request.GET['length'])
    objects = objects[start: (start + length)]

    # extract information
    data = make_data(objects, list_display, "editarProveedor", "suspenderProveedor", "habilitarProveedor")
    print data
    # define response
    response = {
        'data': data,
        'recordsTotal': recordsTotal,
        'recordsFiltered': recordsFiltered,
        'draw': request.GET['draw']
    }

    # serialize to json
    s = StringIO()
    json.dump(response, s)
    s.seek(0)
    return HttpResponse(s.read())
Beispiel #8
0
def get_condiciones_venta_table(request):
    objects = Condicion_venta.objects.all()
    list_display = ['descripcion']
    list_global_search = list_display
    data_struct = dict(enumerate(list_display))

    # Cuenta total de articulos:
    recordsTotal = objects.count()

    # Filtrado de los articulos
    objects = filtering(request.GET, objects, data_struct, list_global_search)

    # Ordenado
    objects = ordering(request.GET, objects, data_struct)

    # Conteo de articulos despues dle filtrado
    recordsFiltered = objects.count()

    # finally, slice according to length sent by dataTables:
    start = int(request.GET['start'])
    length = int(request.GET['length'])
    objects = objects[start:(start + length)]

    data = make_data(objects, list_display, 'editarCondicionVenta')
    # define response
    response = {
        'data': data,
        'recordsTotal': recordsTotal,
        'recordsFiltered': recordsFiltered,
        'draw': request.GET['draw']
    }

    # serialize to json
    s = StringIO()
    json.dump(response, s)
    s.seek(0)
    return HttpResponse(s.read())
Beispiel #9
0
def get_subrubros_table(request):
    objects = SubRubro.objects.all()
    list_display = ['rubro.nombre', 'nombre', 'get_iva_display()']
    list_global_search = ['rubro__nombre', 'nombre']
    data_struct = {0: 'rubro__nombre', 1: 'nombre', 2: 'iva'}

    # Cuenta total de articulos:
    recordsTotal = objects.count()

    # Filtrado de los articulos
    objects = filtering(request.GET, objects, data_struct, list_global_search)

    # Ordenado
    objects = ordering(request.GET, objects, data_struct)

    # Conteo de articulos despues dle filtrado
    recordsFiltered = objects.count()

    # finally, slice according to length sent by dataTables:
    start = int(request.GET['start'])
    length = int(request.GET['length'])
    objects = objects[start:(start + length)]

    data = make_data(objects, list_display, 'editarSubrubro')
    # define response
    response = {
        'data': data,
        'recordsTotal': recordsTotal,
        'recordsFiltered': recordsFiltered,
        'draw': request.GET['draw']
    }

    # serialize to json
    s = StringIO()
    json.dump(response, s)
    s.seek(0)
    return HttpResponse(s.read())
Beispiel #10
0
def get_ventas_table(request):
    objects = Venta.objects.all()
    print objects
    list_display = [
        'fecha', 'info_completa', 'cliente.razon_social', 'estado()'
    ]
    list_global_search = ['numero', 'cliente__razon_social']
    data_struct = dict(enumerate(['fecha']))

    # Cuenta total de articulos:
    recordsTotal = objects.count()

    # Filtrado general de los articulos
    objects = filtering(request.GET, objects, data_struct, list_global_search)
    print objects

    # Ordenado
    objects = ordering(request.GET, objects, data_struct)
    print objects

    # Conteo de articulos despues dle filtrado
    recordsFiltered = objects.count()

    # finally, slice according to length sent by dataTables:
    start = int(request.GET['start'])
    length = int(request.GET['length'])
    objects = objects[start:(start + length)]

    #actions = []
    # actions.append(ApiTableActions(name='BorrarVenta',url='borrarVenta',icon='delete', cond='aprobado'))
    url_delete = "borrarVenta"
    url_aprobar = "aprobarVenta"
    url_obtener = "obtenerComprobante"

    # extract information
    data = []
    print objects
    for obj in objects:
        row = map(lambda field: _getattr_foreingkey(obj, field), list_display)
        if not obj.aprobado:
            row.append(
                '<a class="aprobar" href="%s"><i class="material-icons">done_all</i></a>'
                % reverse(url_aprobar, args=[obj.pk]))
            row.append(
                '<a href="%s"><i class="material-icons">delete</i></a>' %
                reverse(url_delete, args=[obj.pk]))
            row.append(
                '<a class="obtener" href="%s" style="pointer-events: none;"><i class="material-icons">print</i></a>'
                % reverse(url_obtener, args=[obj.pk]))
        else:
            row.append(
                '<a href="%s" style="pointer-events: none;"><i class="material-icons">done_all</i></a>'
                % reverse(url_aprobar, args=[obj.pk]))
            row.append(
                '<a href="%s" style="pointer-events: none;"><i class="material-icons">delete</i></a>'
                % reverse(url_delete, args=[obj.pk]))
            row.append(
                '<a class="obtener" href="%s"><i class="material-icons">print</i></a>'
                % reverse(url_obtener, args=[obj.pk]))
        data.append(row)

    # define response
    response = {
        'data': data,
        'recordsTotal': recordsTotal,
        'recordsFiltered': recordsFiltered,
        'draw': request.GET['draw']
    }

    # serialize to json
    s = StringIO()
    json.dump(response, s)
    s.seek(0)
    return HttpResponse(s.read())