Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2017
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.79 KB | None | 0 0
  1. # Es el accountid de la cuenta
  2. if accountnumber:
  3. # Consulto la cuenta
  4. fetchXml = <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" >
  5. fetchXml += <entity name="account">
  6. fetchXml += <attribute name="accountid"/>
  7. fetchXml += <attribute name="name"/>
  8. fetchXml += <attribute name="accountnumber"/>
  9. fetchXml += <filter type="and">
  10. fetchXml += <condition attribute="accountnumber" value=" + \
  11. accountnumber + " operator="eq" />
  12. fetchXml += </filter>
  13. fetchXml += </entity>
  14. fetchXml += </fetch>
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22. url = 'https://secure.smartix.com.ar/SmartixApi/ISrvB2BCotizacionVehiculo.svc?wsdl'
  23. client = Client(url)
  24.  
  25. if not IdCotizacion:
  26. # Request cotizacion
  27. ns2 = client.factory.create('ns2:RequestB2BCotizacionEstandarDTO')
  28. print "Create RequestB2BCotizacionEstandarDTO"
  29. # print ns2
  30. ns2.IdCondicionB2B2C = 52
  31. ns2.SmartixPassword = 'RAN001'
  32. ns2.SmartixUserName = 'cotizadorralf@mc-lean.com'
  33. ns2.AnioModelo = year
  34. ns2.CeroKm = km0
  35. # TODO Check GNCVALUE for SMARTIX
  36. if gncvalue:
  37. ns2.ValorGnc = gncvalue
  38. else:
  39. ns2.ValorGnc = 0
  40. ns2.CodigoInfoAuto = codia
  41. ns2.CodigoProvincia = str(provincecode).zfill(2)
  42. ns2.CodigoTipoIva = taxtype
  43. ns2.CodigoTipoUso = use
  44. ns2.FechaNacimientoTitular = birthdate
  45. ns2.CodigoCiudad = str(citycode)
  46. ns2.InformacionLead = ""
  47. if str(citycode) == "0":
  48. ns2.CodigoCiudad = "102400104"
  49. # print ns2
  50. print ns2
  51. # IniciarCotizacion(ns2:RequestB2BCotizacionEstandarDTO request, )
  52. # Este método genera una nueva cotización para Autos y dispara las consultas con las compañías aseguradoras configuradas.
  53. # Devuelve el Número de Cotización generado para luego poder
  54. # obtener el resultado de la cotización.
  55.  
  56. try:
  57. ns2_IniCot = client.service.IniciarCotizacion(ns2)
  58. except WebFault, e:
  59. # print e
  60. return TextScreenElement(u"Error al Iniciar Cotización, intente más tarde.").setColor("orange").setBold()
  61. print "IniciarCotizacion"
  62. # print ns2_IniCot
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. # Request Configuracion
  71. ns2 = client.factory.create('ns2:RequestB2BConfiguracionDTO')
  72. print "Create RequestB2BConfiguracionDTO"
  73. # print ns2
  74. ns2.SmartixUserName = 'cotizadorralf@mc-lean.com'
  75. ns2.SmartixPassword = 'RAN001'
  76. ns2.IdCondicionB2B2C = 52
  77. # print ns2
  78. # GetConfiguracion(ns2:RequestB2BConfiguracionDTO request, )
  79. # Este método devuelve el listado de aseguradoras y coberturas configuradas para un usuario y condición específicos,
  80. # para la sección Autos.
  81. ns2_GetConf = client.service.GetConfiguracion(ns2)
  82. print "GetConfiguracion"
  83. # print ns2_GetConf
  84. elms.append(GridScreenElement([
  85. GridScreenElement.Row([
  86. GridScreenElement.Cell(
  87. TextScreenElement(" OFERTAS DE SEGURO").setBold()),
  88. ]),
  89. ]))
  90. import time
  91. while True:
  92. # Request Cotizacion resultados
  93. ns2 = client.factory.create(
  94. 'ns2:RequestB2BCotizacionResultadoDTO')
  95. ns2.SmartixUserName = 'cotizadorralf@mc-lean.com'
  96. ns2.SmartixPassword = 'RAN001'
  97. ns2.IdCondicionB2B2C = 52
  98. ns2.IdCotizacion = ns2_IniCot.IdCotizacion
  99. ns2.TipoCotizacionRespuesta = "Indistinto"
  100. # print ns2
  101. # GetResultadoNormalizado(ns2:RequestB2BCotizacionResultadoDTO request, )
  102. # Este método devuelve los resultados de una cotización a partir del Número de Cotización obtenido con el método IniciarCotizacion.
  103. # El resultado se devuelve agrupado por Aseguradoras y por Clases de Coberturas.
  104. # El mismo se debe llamar n veces hasta que el resultado
  105. # indique que no quedan cotizaciones pendientes.
  106. ns2_GetResNorm = client.service.GetResultadoNormalizado(ns2)
  107. print "GetResultadoNormalizado"
  108. print ns2_GetResNorm
  109. time.sleep(5)
  110.  
  111. # Recorrer Cotizaciones
  112. if ns2_GetResNorm.CotizacionesAseguradoras:
  113. for c in ns2_GetResNorm.CotizacionesAseguradoras:
  114. for aseguradora in c[1]:
  115. IdAseguradora = aseguradora.IdAseguradora
  116. if (IdAseguradora == 153) or (IdAseguradora == 56) or (IdAseguradora == 34):
  117. IdItem = aseguradora.IdItem
  118. suma = aseguradora.SumaVehiculo
  119. for cuotas in aseguradora.Cotizaciones[0]:
  120. if cuotas.ClaseCobertura == "C":
  121. CodigoProducto = cuotas.Productos.ItemProductoDTO[
  122. 0].CodigoProducto
  123. Descripcion = elimina_tildes(
  124. u"%s" % cuotas.Productos.ItemProductoDTO[0].Descripcion)
  125. if ((IdAseguradora == 56) or (IdAseguradora == 34) or (IdAseguradora == 153 and (CodigoProducto == "080100" or CodigoProducto == "070100"))):
  126. id = str(
  127. IdAseguradora) + "-" + CodigoProducto
  128. monto = cuotas.Productos.ItemProductoDTO[
  129. 0].PremioConIva
  130. ids[id] = [
  131. Descripcion, monto, IdItem]
  132.  
  133. if (ns2_GetResNorm.CotizacionesPendientes == 0):
  134. break
  135. SCC = False
  136. if (ids == {}):
  137. elms.append(GridScreenElement([
  138. GridScreenElement.Row([
  139. GridScreenElement.Cell(
  140. TextScreenElement(
  141. u"Cotización de Seguro no disponible.").setBold()),
  142. ]),
  143. GridScreenElement.Row([
  144. GridScreenElement.Cell(
  145. ButtonScreenElement(
  146. tr("Anterior")).setId("back"),),
  147. ]),
  148. ]))
  149. else:
  150. if len(ids) == 1 and ids.has_key("153-070100"):
  151. SCC = True
  152. for id in ids:
  153. if (id != "153-070100") or SCC:
  154. idAseguradora = id.split('-')[0]
  155. if idAseguradora == "153":
  156. name = u"San Cristóbal"
  157. elif idAseguradora == "56":
  158. name = "La Mercantil Andina"
  159. elif idAseguradora == "34":
  160. name = "Boston"
  161.  
  162.  
  163. if IdCotizacion:
  164. for id in ids:
  165. if data.find("reserv" + id).getData(False):
  166.  
  167. url = 'https://secure.smartix.com.ar/SmartixApi/ISrvB2BSolicitudPolizaVehiculo.svc?wsdl'
  168. client = Client(url)
  169. print "SMARTIX"
  170. print client
  171. urlsolicitudsmartix = ""
  172. erroresSmartix = []
  173. # Solicitud
  174. ns1 = client.factory.create(
  175. 'ns1:RequestB2BSolicitudPolizaDTO')
  176. print "Create RequestB2BSolicitudPolizaDTO"
  177. # print ns1
  178. ns1.SmartixUserName = 'cotizadorralf@mc-lean.com'
  179. ns1.SmartixPassword = 'RAN001'
  180. ns1.IdCondicionB2B2C = 52
  181. ns1.IdCotizacion = IdCotizacion
  182. ns1.IdItem = int(ids[id][2])
  183. ns1.CodigoProducto = id.split("-")[1]
  184. from datetime import datetime
  185. ns1.Fecha = datetime.today()
  186. ns1.Apellido = lastname
  187. ns1.Nombre = name
  188. ns1.Email = "documentacion@carfacil.com.ar"
  189. ns1.Telefono1 = cell
  190. ns1.Telefono2 = homephone
  191. ns1.Telefono3 = workphone
  192.  
  193. # GenerarSolicitud(ns1:RequestB2BSolicitudPolizaDTO
  194. # request, )
  195. ns1_solicitud = client.service.GenerarSolicitud(ns1)
  196. # print str(ns1_solicitud)
  197.  
  198. if ns1_solicitud.Errores:
  199. # print str(ns1_solicitud.Errores)
  200. for error in ns1_solicitud.Errores.string:
  201. from unicodedata import normalize
  202. erroresSmartix.append(
  203. elimina_tildes(u"%s" % error))
  204. else:
  205. print "URL Solicitud Smartix: "
  206. # print ns1_solicitud.UrlSolicitudDetalle
  207. urlsolicitudsmartix = ns1_solicitud.UrlSolicitudDetalle
  208.  
  209. temp = self.getStorage()
  210. cuota = ids[id][1]
  211. detalle = ids[id][0]
  212. temp.append({"seguro": cuota})
  213. temp.append({"erroresSmartix": erroresSmartix})
  214. self.setStorage(temp)
  215.  
  216. url = iss.WsdlUrl
  217. client = Client(url)
  218. response = client.service.Configure(
  219. "", iss.CrmUser, iss.CrmEmail, password, iss.CrmUrl)
  220.  
  221. # Creo el arreglo con los atributos
  222. arrayOpp = client.factory.create('ns2:ArrayOfstring')
  223.  
  224. arrayOpp.string.append(
  225. "new_companiadeseguro|" + self.getAseguradora(id.split('-')[0]))
  226. arrayOpp.string.append(
  227. "new_montoseguro|" + str(float(cuota)))
  228. arrayOpp.string.append(
  229. "new_detallecompaiadeseguro|" + detalle[:100])
  230. if urlsolicitudsmartix:
  231. arrayOpp.string.append(
  232. "new_urlsolicitudsmartix|" + urlsolicitudsmartix)
  233. if IdCotizacion:
  234. arrayOpp.string.append(
  235. "new_codigodecotizacionsmartix|" + str(IdCotizacion))
  236.  
  237. ind = 1
  238. SCC = False
  239. if len(ids) == 1 and ids.has_key("153-070100"):
  240. SCC = True
  241. alreadysave = []
  242. for id2 in ids:
  243. if ((id2 != "153-070100") or SCC)and not id2.split('-')[0] in alreadysave:
  244. alreadysave.append(id2.split('-')[0])
  245. desc = ids[id2][0]
  246. monto = ids[id2][1]
  247. arrayOpp.string.append(
  248. "new_coberturaseguro%s|%s" % (str(ind), desc[:100]))
  249. if ind == 1:
  250. arrayOpp.string.append("new_compaiadeseguro%s|%s" % (
  251. str(ind), self.getAseguradora(id2.split('-')[0])))
  252. arrayOpp.string.append(
  253. "new_montoseguro1%s|%s" % (str(ind), monto))
  254. else:
  255. arrayOpp.string.append("new_companiadeseguro%s|%s" % (
  256. str(ind), self.getAseguradora(id2.split('-')[0])))
  257. arrayOpp.string.append(
  258. "new_montoseguro%s|%s" % (str(ind), monto))
  259. ind = ind + 1
  260. if ind == 4:
  261. break
  262.  
  263. # print arrayOpp
  264.  
  265. # Update(xs:string EntityName, xs:string EntityId,
  266. # ns2:ArrayOfstring Atributos, )
  267. opportunity_update = client.service.Update(
  268. 'opportunity', oportunityID, arrayOpp)
  269. print "ACTUALIZO OPORTUNIDAD CON EL SEGURO"
  270. # print opportunity_update
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement