Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Es el accountid de la cuenta
- if accountnumber:
- # Consulto la cuenta
- fetchXml = <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" >
- fetchXml += <entity name="account">
- fetchXml += <attribute name="accountid"/>
- fetchXml += <attribute name="name"/>
- fetchXml += <attribute name="accountnumber"/>
- fetchXml += <filter type="and">
- fetchXml += <condition attribute="accountnumber" value=" + \
- accountnumber + " operator="eq" />
- fetchXml += </filter>
- fetchXml += </entity>
- fetchXml += </fetch>
- url = 'https://secure.smartix.com.ar/SmartixApi/ISrvB2BCotizacionVehiculo.svc?wsdl'
- client = Client(url)
- if not IdCotizacion:
- # Request cotizacion
- ns2 = client.factory.create('ns2:RequestB2BCotizacionEstandarDTO')
- print "Create RequestB2BCotizacionEstandarDTO"
- # print ns2
- ns2.IdCondicionB2B2C = 52
- ns2.SmartixPassword = 'RAN001'
- ns2.SmartixUserName = 'cotizadorralf@mc-lean.com'
- ns2.AnioModelo = year
- ns2.CeroKm = km0
- # TODO Check GNCVALUE for SMARTIX
- if gncvalue:
- ns2.ValorGnc = gncvalue
- else:
- ns2.ValorGnc = 0
- ns2.CodigoInfoAuto = codia
- ns2.CodigoProvincia = str(provincecode).zfill(2)
- ns2.CodigoTipoIva = taxtype
- ns2.CodigoTipoUso = use
- ns2.FechaNacimientoTitular = birthdate
- ns2.CodigoCiudad = str(citycode)
- ns2.InformacionLead = ""
- if str(citycode) == "0":
- ns2.CodigoCiudad = "102400104"
- # print ns2
- print ns2
- # IniciarCotizacion(ns2:RequestB2BCotizacionEstandarDTO request, )
- # Este método genera una nueva cotización para Autos y dispara las consultas con las compañías aseguradoras configuradas.
- # Devuelve el Número de Cotización generado para luego poder
- # obtener el resultado de la cotización.
- try:
- ns2_IniCot = client.service.IniciarCotizacion(ns2)
- except WebFault, e:
- # print e
- return TextScreenElement(u"Error al Iniciar Cotización, intente más tarde.").setColor("orange").setBold()
- print "IniciarCotizacion"
- # print ns2_IniCot
- # Request Configuracion
- ns2 = client.factory.create('ns2:RequestB2BConfiguracionDTO')
- print "Create RequestB2BConfiguracionDTO"
- # print ns2
- ns2.SmartixUserName = 'cotizadorralf@mc-lean.com'
- ns2.SmartixPassword = 'RAN001'
- ns2.IdCondicionB2B2C = 52
- # print ns2
- # GetConfiguracion(ns2:RequestB2BConfiguracionDTO request, )
- # Este método devuelve el listado de aseguradoras y coberturas configuradas para un usuario y condición específicos,
- # para la sección Autos.
- ns2_GetConf = client.service.GetConfiguracion(ns2)
- print "GetConfiguracion"
- # print ns2_GetConf
- elms.append(GridScreenElement([
- GridScreenElement.Row([
- GridScreenElement.Cell(
- TextScreenElement(" OFERTAS DE SEGURO").setBold()),
- ]),
- ]))
- import time
- while True:
- # Request Cotizacion resultados
- ns2 = client.factory.create(
- 'ns2:RequestB2BCotizacionResultadoDTO')
- ns2.SmartixUserName = 'cotizadorralf@mc-lean.com'
- ns2.SmartixPassword = 'RAN001'
- ns2.IdCondicionB2B2C = 52
- ns2.IdCotizacion = ns2_IniCot.IdCotizacion
- ns2.TipoCotizacionRespuesta = "Indistinto"
- # print ns2
- # GetResultadoNormalizado(ns2:RequestB2BCotizacionResultadoDTO request, )
- # Este método devuelve los resultados de una cotización a partir del Número de Cotización obtenido con el método IniciarCotizacion.
- # El resultado se devuelve agrupado por Aseguradoras y por Clases de Coberturas.
- # El mismo se debe llamar n veces hasta que el resultado
- # indique que no quedan cotizaciones pendientes.
- ns2_GetResNorm = client.service.GetResultadoNormalizado(ns2)
- print "GetResultadoNormalizado"
- print ns2_GetResNorm
- time.sleep(5)
- # Recorrer Cotizaciones
- if ns2_GetResNorm.CotizacionesAseguradoras:
- for c in ns2_GetResNorm.CotizacionesAseguradoras:
- for aseguradora in c[1]:
- IdAseguradora = aseguradora.IdAseguradora
- if (IdAseguradora == 153) or (IdAseguradora == 56) or (IdAseguradora == 34):
- IdItem = aseguradora.IdItem
- suma = aseguradora.SumaVehiculo
- for cuotas in aseguradora.Cotizaciones[0]:
- if cuotas.ClaseCobertura == "C":
- CodigoProducto = cuotas.Productos.ItemProductoDTO[
- 0].CodigoProducto
- Descripcion = elimina_tildes(
- u"%s" % cuotas.Productos.ItemProductoDTO[0].Descripcion)
- if ((IdAseguradora == 56) or (IdAseguradora == 34) or (IdAseguradora == 153 and (CodigoProducto == "080100" or CodigoProducto == "070100"))):
- id = str(
- IdAseguradora) + "-" + CodigoProducto
- monto = cuotas.Productos.ItemProductoDTO[
- 0].PremioConIva
- ids[id] = [
- Descripcion, monto, IdItem]
- if (ns2_GetResNorm.CotizacionesPendientes == 0):
- break
- SCC = False
- if (ids == {}):
- elms.append(GridScreenElement([
- GridScreenElement.Row([
- GridScreenElement.Cell(
- TextScreenElement(
- u"Cotización de Seguro no disponible.").setBold()),
- ]),
- GridScreenElement.Row([
- GridScreenElement.Cell(
- ButtonScreenElement(
- tr("Anterior")).setId("back"),),
- ]),
- ]))
- else:
- if len(ids) == 1 and ids.has_key("153-070100"):
- SCC = True
- for id in ids:
- if (id != "153-070100") or SCC:
- idAseguradora = id.split('-')[0]
- if idAseguradora == "153":
- name = u"San Cristóbal"
- elif idAseguradora == "56":
- name = "La Mercantil Andina"
- elif idAseguradora == "34":
- name = "Boston"
- if IdCotizacion:
- for id in ids:
- if data.find("reserv" + id).getData(False):
- url = 'https://secure.smartix.com.ar/SmartixApi/ISrvB2BSolicitudPolizaVehiculo.svc?wsdl'
- client = Client(url)
- print "SMARTIX"
- print client
- urlsolicitudsmartix = ""
- erroresSmartix = []
- # Solicitud
- ns1 = client.factory.create(
- 'ns1:RequestB2BSolicitudPolizaDTO')
- print "Create RequestB2BSolicitudPolizaDTO"
- # print ns1
- ns1.SmartixUserName = 'cotizadorralf@mc-lean.com'
- ns1.SmartixPassword = 'RAN001'
- ns1.IdCondicionB2B2C = 52
- ns1.IdCotizacion = IdCotizacion
- ns1.IdItem = int(ids[id][2])
- ns1.CodigoProducto = id.split("-")[1]
- from datetime import datetime
- ns1.Fecha = datetime.today()
- ns1.Apellido = lastname
- ns1.Nombre = name
- ns1.Email = "documentacion@carfacil.com.ar"
- ns1.Telefono1 = cell
- ns1.Telefono2 = homephone
- ns1.Telefono3 = workphone
- # GenerarSolicitud(ns1:RequestB2BSolicitudPolizaDTO
- # request, )
- ns1_solicitud = client.service.GenerarSolicitud(ns1)
- # print str(ns1_solicitud)
- if ns1_solicitud.Errores:
- # print str(ns1_solicitud.Errores)
- for error in ns1_solicitud.Errores.string:
- from unicodedata import normalize
- erroresSmartix.append(
- elimina_tildes(u"%s" % error))
- else:
- print "URL Solicitud Smartix: "
- # print ns1_solicitud.UrlSolicitudDetalle
- urlsolicitudsmartix = ns1_solicitud.UrlSolicitudDetalle
- temp = self.getStorage()
- cuota = ids[id][1]
- detalle = ids[id][0]
- temp.append({"seguro": cuota})
- temp.append({"erroresSmartix": erroresSmartix})
- self.setStorage(temp)
- url = iss.WsdlUrl
- client = Client(url)
- response = client.service.Configure(
- "", iss.CrmUser, iss.CrmEmail, password, iss.CrmUrl)
- # Creo el arreglo con los atributos
- arrayOpp = client.factory.create('ns2:ArrayOfstring')
- arrayOpp.string.append(
- "new_companiadeseguro|" + self.getAseguradora(id.split('-')[0]))
- arrayOpp.string.append(
- "new_montoseguro|" + str(float(cuota)))
- arrayOpp.string.append(
- "new_detallecompaiadeseguro|" + detalle[:100])
- if urlsolicitudsmartix:
- arrayOpp.string.append(
- "new_urlsolicitudsmartix|" + urlsolicitudsmartix)
- if IdCotizacion:
- arrayOpp.string.append(
- "new_codigodecotizacionsmartix|" + str(IdCotizacion))
- ind = 1
- SCC = False
- if len(ids) == 1 and ids.has_key("153-070100"):
- SCC = True
- alreadysave = []
- for id2 in ids:
- if ((id2 != "153-070100") or SCC)and not id2.split('-')[0] in alreadysave:
- alreadysave.append(id2.split('-')[0])
- desc = ids[id2][0]
- monto = ids[id2][1]
- arrayOpp.string.append(
- "new_coberturaseguro%s|%s" % (str(ind), desc[:100]))
- if ind == 1:
- arrayOpp.string.append("new_compaiadeseguro%s|%s" % (
- str(ind), self.getAseguradora(id2.split('-')[0])))
- arrayOpp.string.append(
- "new_montoseguro1%s|%s" % (str(ind), monto))
- else:
- arrayOpp.string.append("new_companiadeseguro%s|%s" % (
- str(ind), self.getAseguradora(id2.split('-')[0])))
- arrayOpp.string.append(
- "new_montoseguro%s|%s" % (str(ind), monto))
- ind = ind + 1
- if ind == 4:
- break
- # print arrayOpp
- # Update(xs:string EntityName, xs:string EntityId,
- # ns2:ArrayOfstring Atributos, )
- opportunity_update = client.service.Update(
- 'opportunity', oportunityID, arrayOpp)
- print "ACTUALIZO OPORTUNIDAD CON EL SEGURO"
- # print opportunity_update
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement