예제 #1
0
    def get(self):
        menu = []
        try:
            datos = Persona.getAll()
            if datos:
                for row in datos:
                    data = {
                        "id": row.id,
                        "nombre": row.nombre,
                        "apellido_paterno": row.apellido_paterno,
                        "apellido_materno": row.apellido_materno,
                        "genero": row.genero,
                        "tipo_persona": row.tipo_persona,
                        "identificacion": row.identificacion,
                        "fecha_nacimiento": str(row.fecha_nacimiento),
                        "estado": row.estado,
                        "created_at": str(row.created_at),
                        "updated_at": str(row.updated_at)
                    }

                    menu.append(data)

            return {"response": {"data": {"info": menu}}}, 200

        except Exception as e:
            print(" ## Error ## \n")
            print(e)
            print("\n")
            return {"message": "Ha ocurrido un error de conexión."}, 500
예제 #2
0
    def get(self):
        try:
            parser = reqparse.RequestParser()
            parser.add_argument(
                'id',
                type=str,
                required=False,
                help="Debe indicar id prestador",
            )
            parser.add_argument(
                'correo',
                type=str,
                required=False,
                help="Debe indicar id Sucursal",
            )
            parser.add_argument(
                'telefono',
                type=str,
                required=False,
                help="Debe indicar id Sucursal",
            )
            data = parser.parse_args()

            info = Persona.personaFullInfo(data["id"], data["correo"],
                                           data["telefono"])
            return info
        except Exception as e:
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            msj = 'Error: ' + str(
                exc_obj) + ' File: ' + fname + ' linea: ' + str(
                    exc_tb.tb_lineno)
            return {"message": msj}, 500
예제 #3
0
    def get(self):
        menu = []
        try:
            datos = Usuario.getAll()
            if datos:
                for row in datos:
                    data = {
                        "id": row.id,
                        "correo": row.correo,
                        "telefono": row.telefono,
                        "password": row.password,
                        "id_persona": row.id_persona,
                        "created_at": str(row.created_at),
                        "updated_at": str(row.updated_at),
                        "datos_persona": Persona.get_data(row.id_persona)
                    }

                    menu.append(data)

            return {"response": {"data": {"info": menu}}}, 200

        except Exception as e:
            print(" ## Error ## \n")
            print(e)
            print("\n")
            return {"message": "Ha ocurrido un error de conexión."}, 500
예제 #4
0
 def get_user_login(cls,user, password):
     sql = "select * from usuario where correo = '"+ str(user) +"' or telefono ='"+ str(user) +"' and password = md5("+ str(password) +")"
     query = db.session.execute(sql)
     if query:
         for x in query:
             return Persona.personaFullInfo(x.id_persona) 
     return  None
예제 #5
0
    def get(self):
        menu = []
        try:
            datos = Cliente.getAll()
            if datos:
                for row in datos:
                    data = {
                        "id": row.id,
                        "nombre": row.nombre,
                        "id_persona": row.id_persona,
                        "giro": row.giro,
                        "created_at": str(row.created_at),
                        "updated_at": str(row.updated_at),
                        "datos_persona" : Persona.get_data(row.id_persona)
                    }
                    
                    menu.append(data)
                        
            return {  "response":{"data": { "info": menu }}}, 200
            

        except Exception as e:
            print(" ## Error ## \n")
            print(e)
            print("\n")
            return {"message": "Ha ocurrido un error de conexión."}, 500
예제 #6
0
    def get(self):
        menu = []
        try:
            datos = Orden.getAll()
            if datos:
                for row in datos:
                    sucursal = Sucursal.get_data(row.id_sucursal)
                    data = {
                        "id": row.id,
                        "id_persona": row.id_persona,
                        "id_sucursal": row.id_sucursal,
                        "id_creador": row.id_creador,
                        "id_direccion": row.id_direccion,
                        "id_tipo_entrega": row.id_tipo_entrega,
                        "hora_recepcion": str(row.hora_recepcion),
                        "hora_salida": str(row.hora_salida),
                        "created_at": str(row.created_at),
                        "updated_at": str(row.updated_at),
                        "datos_sucursal" : sucursal,
                        "empresa_full_data" : Persona.get_data(sucursal[0]["id_cliente"]),
                        "datos_creador" : Persona.get_data(row.id_creador),
                        "datos_tipo_entrega" : TipoEntrega.get_data(row.id_tipo_entrega),
                        "datos_cliente": Persona.get_data(row.id_persona),
                        "direccion_cliente" : PersonaDireccion.DireccionByPersona(row.id_persona),
                        "telefono_cliente" : Telefono.get_data_by_persona(row.id_persona),
                        "correo_cliente" : Correo.get_data_by_persona(row.id_persona),
                        "datos_repartidor" : OrdenRepartidor.RepartidorByOrden(row.id),
                        "detalle_orden" : OrdenDetalle.DetalleByOrden(row.id)
                    }
                    
                    menu.append(data)
                        
            return {  "response":{"data": { "info": menu }}}, 200
            

        except Exception as e:
            print(" ## Error ## \n")
            print(e)
            print("\n")
            return {"message": "Ha ocurrido un error de conexión."}, 500
예제 #7
0
    def get(self):
        try:
            parser = reqparse.RequestParser()
            parser.add_argument(
                'id',
                type=str,
                required=True,
                help="Debe indicar id producto",
            )
            data = parser.parse_args()

            Prod = Producto.get_data(data['id'])
            if Prod:
                iva = Iva.get_data(Prod[0]["id_iva"])
                imagen = ProductoImagen.get_data_id(Prod[0]['id'])
                cliente = Cliente.get_data(Prod[0]['id_cliente'])

                Prod[0]["fix_iva"] = Prod[0]["precio"] - round(
                    Prod[0]["precio"] / iva[0]["valor"], 0)
                Prod[0]["cantidad"] = 1
                Prod[0]["fix_iva"] = int(Prod[0]["fix_iva"])
                Prod[0]["fix_precio_bruto"] = int(Prod[0]["precio"] -
                                                  Prod[0]["fix_iva"])
                Prod[0]['iva'] = int(iva[0]['valor'])
                Prod[0]["cantidad"] = 1
                Prod[0]["datos_cliente"] = cliente,
                Prod[0]["cliente_full_data"] = Persona.get_data(
                    cliente[0]["id_persona"]),
                Prod[0]["datos_tipo_producto"] = TipoProducto.get_data(
                    Prod[0]['id_tipo_producto']),
                Prod[0][
                    "ingredientes"] = ProductoIngrediente.IngredienteByProducto(
                        Prod[0]['id']),
                Prod[0]['imagen'] = imagen[0]['id']
                return Prod

            return None
        except Exception as e:
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            msj = 'Error: ' + str(
                exc_obj) + ' File: ' + fname + ' linea: ' + str(
                    exc_tb.tb_lineno)
            return {"message": msj}, 500
예제 #8
0
 def get(self):
     try:
         parser = reqparse.RequestParser()
         parser.add_argument('identificacion',
                             type=str,
                             required=True,
                             help="Debe indicar identificacion",
                             
                             )  
         data = parser.parse_args()
         info = Persona.personaFullInfo(None, None, None, data["identificacion"])
         if info:
             return {"estado": 1,"data":info}
         return {"estado": 0, "msj": "No se encontro la información solicitada"}
     except Exception as e:
         print(" ## Error ## \n")
         print(e)
         print("\n")
         return {"message": "Ha ocurrido un error de conexión."}, 500
예제 #9
0
    def RepartidorByOrden(cls, id_orden):
        sql = "SELECT \
                    or1.*, r.* \
                FROM orden o \
                JOIN orden_repartidor or1 ON or1.id_orden = o.id \
                JOIN repartidor r ON r.id = or1.id_tipo_pago \
                WHERE o.id = " + str(id_orden) + " "

        query = db.session.execute(sql)
        result = []
        if query:
            for x in query:
                temp = {
                    "id": x.id,
                    "id_tipo_pago": x.id_tipo_pago,
                    "id_orden": x.id_orden,
                    "data_repartidor": Persona.get_data(x.id_persona)
                }
                result.append(temp)

        return result
예제 #10
0
    def post(self):
        try:
            apellido = None
            tipo_persona = 1
            depto = None
            departamento = None
            numerod = None
            dataJson = request.get_json()

            if 'apellido' in dataJson and dataJson["apellido"]:
                apellido = dataJson["apellido"]
            if 'tipo_persona' in dataJson and dataJson["tipo_persona"]:
                apellido = dataJson["tipo_persona"]
            if 'numerod' in dataJson and dataJson["numerod"]:
                numerod = dataJson["numerod"]
            if 'departamento' in dataJson and dataJson["departamento"]:
                depto = dataJson["departamento"]

            identificacion = None
            if "identificacion" in dataJson:
                identificacion = dataJson["identificacion"]

            jsoPersona = {
                "identificacion": identificacion,
                "nombre": dataJson["nombre"],
                "apellido_paterno": apellido,
                "apellido_materno": None,
                "genero": None,
                "tipo_persona": tipo_persona,
                "fecha_nacimiento": None,
                "estado": 1
            }

            insert = Persona.insert(jsoPersona)

            if insert:
                jsonTelefono = {
                    "id_persona": insert,
                    "numero": dataJson["numero"]
                }
                telInsert = Telefono.insert(jsonTelefono)

                jsonEmail = {
                    "id_persona": insert,
                    "direccion": dataJson["email"]
                }
                corInsert = Correo.insert(jsonEmail)
                comuna = None
                insertDir = None
                pdInser = None
                if "id_place" in dataJson and dataJson["id_place"] != "":
                    if "id_comuna" in dataJson:
                        comuna = dataJson["id_comuna"]
                    jsonDireccion = {
                        "id_comuna": comuna,
                        "id_tipo_direccion": dataJson["id_tipo_direccion"],
                        "direccion_escrita": dataJson["direccion"],
                        "numero": numerod,
                        "departamento": depto,
                        "id_place": dataJson["id_place"]
                    }
                    insertDir = Direccion.insert(jsonDireccion)

                if insertDir is not None:
                    jsonDireccionPersona = {
                        "id_persona": insert,
                        "id_direccion": insertDir
                    }
                    pdInser = PersonaDireccion.insert(jsonDireccionPersona)
            else:
                return {
                    "estado_response": 0,
                    "msj": "Ha ocurrido un error en el registro"
                }

            if dataJson["registro"] == 1:
                if telInsert is not None and corInsert is not None:
                    jsonReg = {
                        "id_persona": insert,
                        "correo": dataJson["email"],
                        "telefono": dataJson["numero"],
                        "password": dataJson["password"]
                    }
                    jsonUser = Usuario.insert(jsonReg)
                    user = Persona.personaFullInfo(insert)
                    response = {"estado": 1, "msj": "Bienvenido", "data": user}
            if dataJson["registro"] == 2:
                if telInsert is not None and corInsert is not None:
                    jsonReg = {
                        "id_persona": insert,
                        "nombre": dataJson["nombre"],
                        "giro": dataJson["giro"],
                    }
                    jsonUser = Cliente.insert(jsonReg)
                    user = Persona.personaFullInfo(insert)
                    response = {"estado": 1, "msj": "Bienvenido", "data": user}
                else:

                    return {
                        "estado_response": 0,
                        "msj": "Ha ocurrido un error en el registro"
                    }
            else:
                if telInsert is not None and corInsert is not None:
                    user = Persona.personaFullInfo(insert)
                    response = {"estado": 1, "msj": "Bienvenido", "data": user}
                else:
                    return {
                        "estado": 0,
                        "msj": "Ha ocurrido un error en el registro"
                    }
            return response

        except Exception as e:
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            msj = 'Error: ' + str(
                exc_obj) + ' File: ' + fname + ' linea: ' + str(
                    exc_tb.tb_lineno)
            return {'mensaje': str(msj)}, 500