U
    âøiH‡ ã                   @   s`  d dl mZ d dl mZmZmZmZmZmZmZmZ d dl	m	Z	 d dl
Z
d dlZd dlZd dlZd dlmZ d dlZd dlZd dlmZ d dlmZ d dlmZ d d	lmZmZmZ d d
l	m	Z	mZ d dlmZ d dlmZ d dl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZu d dlvmwZw d dlxmyZymzZz dd„ Z{dS )é    )Úcurrent_app)ÚjsonifyÚrequestÚredirectÚurl_forÚsessionr   Úrender_templateÚflash)ÚdatetimeN)ÚDecimal)Úsend_activation_email)ÚMessage)ÚNamedTemporaryFile)ÚHostÚSCHEMEÚ
Productivo)r
   Údate)ÚFileStorage)Úsubir_archivo_ftp_desde_request)UÚget_fueltypeÚget_kw_by_fuelÚget_engine_brandsÚget_alternator_brandsÚget_voltagesÚget_certificationsÚget_breaker_catalogÚget_protection_typesÚget_control_brandsÚget_control_modelsÚget_preheater_voltagesÚget_battery_chargersÚget_enclosure_typesÚget_enclosure_materialsÚget_enclosure_lights_acÚget_enclosure_lights_dcÚget_enclosure_space_heatersÚget_enclosure_load_centersÚget_estop_catalogÚget_spring_catalogÚget_tank_capacity_catalogÚget_tank_type_catalogÚget_spill_containment_catalogÚget_warranty_catalogÚget_testing_catalogÚ
save_quoteÚget_quote_dataÚget_genset_dataÚupdate_genset_pricingÚget_breaker_dataÚget_protection_dataÚupdate_breaker_pricingÚupdate_protection_pricingÚget_breaker_option_dataÚupdate_breaker_option_pricingÚget_controller_dataÚupdate_controller_pricingÚget_preheater_dataÚupdate_preheater_pricingÚget_battery_charger_dataÚupdate_battery_charger_pricingÚget_controller_option_qty_dataÚupdate_dse2157_pricingÚupdate_dse2548_pricingÚupdate_comap_dse2157_pricingÚupdate_comap_dse2548_pricingÚget_controller_option_dataÚ update_controller_option_pricingÚget_enclosure_dataÚget_light_dataÚget_space_heater_dataÚget_load_center_dataÚupdate_enclosure_pricingÚ"update_enclosure_component_pricingÚget_enclosure_option_qty_dataÚget_enclosure_option_dataÚupdate_enclosure_option_pricingÚget_spring_isolator_dataÚget_estop_dataÚupdate_estop_pricingÚupdate_spring_isolator_pricingÚget_accessory_option_dataÚupdate_accessory_option_pricingÚget_tank_dataÚget_spill_containment_dataÚget_tank_option_dataÚupdate_tank_pricingÚupdate_tank_option_pricingÚget_warranty_dataÚget_testing_dataÚupdate_warranty_pricingÚupdate_testing_pricingÚget_Definitive_quote_dataÚget_genset_modelÚget_frecuencyÚget_seller_infoÚget_profile_infoÚupdate_RoutePDFÚget_RoutePDFÚget_countrysÚget_discount_country_valueÚ update_commercial_country_valuesÚgetAll_StopButtonEnclosureÚgetAll_louvers_inÚgetAll_louvers_out)ÚCZE_Quotes_Controller)ÚCZE_Quotes_ServiceÚ"StopButtonEnclosureOptions_Servicec           $         s  ˆj ddgddd„ ƒ}ˆj ddgddd„ ƒ}ˆj d	dgdd
d„ ƒ}ˆj ddgddd„ ƒ}ˆj ddgddd„ ƒ}ˆj ddgddd„ ƒ}ˆj ddgddd„ ƒ}ˆ  d¡dd„ ƒ}	ˆ  d¡dd„ ƒ}
ˆ  d¡dd „ ƒ}ˆ  d!¡d"d#„ ƒ}ˆ  d$¡d%d&„ ƒ}ˆ  d'¡d(d)„ ƒ}ˆ  d*¡d+d,„ ƒ}ˆ  d-¡d.d/„ ƒ}ˆ  d0¡d1d2„ ƒ}ˆ  d3¡d4d5„ ƒ}ˆj d6dgdd7d8„ ƒ}ˆj d9dgdd:d;„ ƒ}ˆj d<dgdd=d>„ ƒ}ˆj d?dgdd@dA„ ƒ}ˆj dBdgddCdD„ ƒ}ˆj dEdgddFdG„ ƒ}ˆ  dH¡dIdJ„ ƒ}ˆ  dK¡dLdM„ ƒ}ˆj dNdgddOdP„ ƒ}ˆj dQdgddRdS„ ƒ}ˆj dTdgddUdV„ ƒ}ˆ  dW¡dXdY„ ƒ}ˆj dZdgdd[d\„ ƒ}ˆj d]d^gd‡fd_d`„ƒ} dadb„ ‰ˆj dcdd^gd‡ ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡fddde„ƒ}!‡	fdfdg„‰‡	fdhdi„‰‡fdjdk„‰‡	fdldm„‰‡fdndo„‰‡	fdpdq„‰‡fdrds„‰‡	fdtdu„‰ ‡fdvdw„‰‡	fdxdy„‰‡fdzd{„‰‡	fd|d}„‰‡fd~d„‰‡	fd€d„‰d‚dƒ„ ‰‡fd„d…„‰d†d‡„ ‰dˆd‰„ ‰dŠd‹„ ‰	ˆj dŒd^gd‡ ‡‡‡‡‡‡‡‡‡
‡‡‡‡‡‡‡‡‡‡fddŽ„ƒ}"ˆj ddgddd‘„ ƒ}#d’d“„ ‰
d S )”Nz+/Ventas/Ventas_EUA/Cotizador_EUA/fuel-typesÚGET)Úmethodsc               
   S   sT   zt ƒ } t| ƒdfW S  tk
rN } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S ©NéÈ   Úerroréô  )r   r   Ú	ExceptionÚstr©Z
fuel_typesÚe© rw   údC:\Users\victor.barrera\Documents\proyectos\elepV3\Elep\src\App\Ventas_Module\VentasEUA\Cotizador.pyÚget_fuel_types;   s
    z(get_optionsimput.<locals>.get_fuel_typesz4/Ventas/Ventas_EUA/Cotizador_EUA/StopButtonEnclosurec               
   S   sT   zt ƒ } t| ƒdfW S  tk
rN } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S ro   )rg   r   rs   rt   ru   rw   rw   rx   Úend_getAll_StopButtonEnclosureD   s
    z8get_optionsimput.<locals>.end_getAll_StopButtonEnclosurez0/Ventas/Ventas_EUA/Cotizador_EUA/load_louvers_inc               
   S   sT   zt ƒ } t| ƒdfW S  tk
rN } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S ro   )rh   r   rs   rt   ru   rw   rw   rx   Úend_getAll_louvers_inM   s
    z/get_optionsimput.<locals>.end_getAll_louvers_inz1/Ventas/Ventas_EUA/Cotizador_EUA/load_louvers_outc               
   S   sT   zt ƒ } t| ƒdfW S  tk
rN } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S ro   )ri   r   rs   rt   ru   rw   rw   rx   Úend_getAll_louvers_outV   s
    z0get_optionsimput.<locals>.end_getAll_louvers_outz8/Ventas/Ventas_EUA/Cotizador_EUA/capacidades/<fuel_type>c              
   S   sV   zt | ƒ}t|ƒdfW S  tk
rP } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S ro   )r   r   rs   rt   )Ú	fuel_typeZcapacidadesrv   rw   rw   rx   Úget_capacidades_   s
    z)get_optionsimput.<locals>.get_capacidadeszF/Ventas/Ventas_EUA/Cotizador_EUA/engine-brands/<fuel_type>/<kw_output>c              
   S   sX   zt | |ƒ}t|ƒdfW S  tk
rR } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S ro   )r   r   rs   rt   )r}   Ú	kw_outputÚbrandsrv   rw   rw   rx   Úget_engine_brands_routeh   s
    
z1get_optionsimput.<locals>.get_engine_brands_routez\/Ventas/Ventas_EUA/Cotizador_EUA/alternator-brands/<fuel_type>/<kw_output>/<engine_brand_id>c              
   S   sZ   zt | ||ƒ}t|ƒdfW S  tk
rT } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S ro   )r   r   rs   rt   )r}   r   Úengine_brand_idr€   rv   rw   rw   rx   Úget_alternator_brands_routeq   s
    z5get_optionsimput.<locals>.get_alternator_brands_routezi/Ventas/Ventas_EUA/Cotizador_EUA/voltages/<fuel_type>/<kw_output>/<engine_brand_id>/<alternator_brand_id>c              
   S   s\   zt | |||ƒ}t|ƒdfW S  tk
rV } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S ro   )r   r   rs   rt   )r}   r   r‚   Úalternator_brand_idÚvoltagesrv   rw   rw   rx   Úget_voltages_routez   s
    z,get_optionsimput.<locals>.get_voltages_routez|/Ventas/Ventas_EUA/Cotizador_EUA/certifications/<fuel_type>/<kw_output>/<engine_brand_id>/<alternator_brand_id>/<voltage_id>c              
   S   sZ   zt | ||||ƒ}t|ƒW S  tk
rT } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S ©Nrq   rr   )r   r   rs   rt   )r}   r   r‚   r„   Ú
voltage_idZcertificationsrv   rw   rw   rx   Úget_certifications_routeƒ   s
    
z2get_optionsimput.<locals>.get_certifications_routez0/Ventas/Ventas_EUA/Cotizador_EUA/breaker-optionsc               
   S   sP   zt ƒ } t| ƒW S  tk
rJ } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S r‡   )r   r   rs   rt   )Úbreakersrv   rw   rw   rx   Úget_breaker_catalog_routeŒ   s
    
z3get_optionsimput.<locals>.get_breaker_catalog_routez@/Ventas/Ventas_EUA/Cotizador_EUA/protection-types/<breaker_type>c              
   S   sR   zt | ƒ}t|ƒW S  tk
rL } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S r‡   )r   r   rs   rt   )Zbreaker_typeZprotectionsrv   rw   rw   rx   Úget_protection_types_route•   s
    
z4get_optionsimput.<locals>.get_protection_types_routez/Ventas/Ventas_EUA/Cotizador_EUA/control-brands/<fuel_type>/<kw_output>/<engine_brand_id>/<alternator_brand_id>/<voltage_id>/<certification_id>c              
   S   sj   zt | |||||ƒ}t|ƒW S  tk
rd } z*td|› ƒ tdt|ƒiƒdf W Y ¢S d }~X Y nX d S )Nz$Error obteniendo marcas de control: rq   rr   )r   r   rs   Úprintrt   )r}   r   r‚   r„   rˆ   Úcertification_idr€   rv   rw   rw   rx   Úget_control_brands_routež   s    
z2get_optionsimput.<locals>.get_control_brands_routezB/Ventas/Ventas_EUA/Cotizador_EUA/control-models/<control_brand_id>c              
   S   sR   zt | ƒ}t|ƒW S  tk
rL } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S r‡   )r   r   rs   rt   )Zcontrol_brand_idÚmodelsrv   rw   rw   rx   Úget_control_models_route©   s
    
z2get_optionsimput.<locals>.get_control_models_routez3/Ventas/Ventas_EUA/Cotizador_EUA/preheater-voltagesc               
   S   s^   zt ƒ } t| ƒW S  tk
rX } z*td|› ƒ tdt|ƒiƒdf W Y ¢S d }~X Y nX d S )Nz,Error obteniendo voltajes de precalentador: rq   rr   )r   r   rs   r   rt   )r…   rv   rw   rw   rx   Úget_preheater_voltages_route±   s    
z6get_optionsimput.<locals>.get_preheater_voltages_routez1/Ventas/Ventas_EUA/Cotizador_EUA/battery-chargersc               
   S   s^   zt ƒ } t| ƒW S  tk
rX } z*td|› ƒ tdt|ƒiƒdf W Y ¢S d }~X Y nX d S )Nu)   Error obteniendo cargadores de baterÃ­a: rq   rr   )r    r   rs   r   rt   )Zchargersrv   rw   rw   rx   Úget_battery_chargers_routeº   s    
z4get_optionsimput.<locals>.get_battery_chargers_routez[/Ventas/Ventas_EUA/Cotizador_EUA/enclosure-types/<fuel_type>/<kw_output>/<certification_id>c              
   S   sV   zt | ||ƒ}t|ƒW S  tk
rP } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S r‡   )r!   r   rs   rt   )r}   r   rŽ   Útypesrv   rw   rw   rx   Úget_enclosure_types_routeÃ   s
    
z3get_optionsimput.<locals>.get_enclosure_types_routezp/Ventas/Ventas_EUA/Cotizador_EUA/enclosure-materials/<fuel_type>/<kw_output>/<certification_id>/<enclosure_type>c              
   S   sX   zt | |||ƒ}t|ƒW S  tk
rR } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S r‡   )r"   r   rs   rt   )r}   r   rŽ   Zenclosure_typeÚ	materialsrv   rw   rw   rx   Úget_enclosure_materials_routeË   s
    
z7get_optionsimput.<locals>.get_enclosure_materials_routez4/Ventas/Ventas_EUA/Cotizador_EUA/enclosure-lights-acc               
   S   s^   zt ƒ } t| ƒW S  tk
rX } z*td|› ƒ tdt|ƒiƒdf W Y ¢S d }~X Y nX d S )Nz%Error obteniendo luces AC de caseta: rq   rr   )r#   r   rs   r   rt   ©Zlightsrv   rw   rw   rx   Úget_enclosure_lights_ac_routeÓ   s    
z7get_optionsimput.<locals>.get_enclosure_lights_ac_routez4/Ventas/Ventas_EUA/Cotizador_EUA/enclosure-lights-dcc               
   S   s^   zt ƒ } t| ƒW S  tk
rX } z*td|› ƒ tdt|ƒiƒdf W Y ¢S d }~X Y nX d S )Nz%Error obteniendo luces DC de caseta: rq   rr   )r$   r   rs   r   rt   r˜   rw   rw   rx   Úget_enclosure_lights_dc_routeÜ   s    
z7get_optionsimput.<locals>.get_enclosure_lights_dc_routez8/Ventas/Ventas_EUA/Cotizador_EUA/enclosure-space-heatersc               
   S   s^   zt ƒ } t| ƒW S  tk
rX } z*td|› ƒ tdt|ƒiƒdf W Y ¢S d }~X Y nX d S )Nz*Error obteniendo calentadores de espacio: rq   rr   )r%   r   rs   r   rt   )Zheatersrv   rw   rw   rx   Ú!get_enclosure_space_heaters_routeå   s    
z;get_optionsimput.<locals>.get_enclosure_space_heaters_routez7/Ventas/Ventas_EUA/Cotizador_EUA/enclosure-load-centersc               
   S   s^   zt ƒ } t| ƒW S  tk
rX } z*td|› ƒ tdt|ƒiƒdf W Y ¢S d }~X Y nX d S )Nz#Error obteniendo centros de carga: rq   rr   )r&   r   rs   r   rt   )Zcentersrv   rw   rw   rx   Ú get_enclosure_load_centers_routeî   s    
z:get_optionsimput.<locals>.get_enclosure_load_centers_routez1/Ventas/Ventas_EUA/Cotizador_EUA/additional-estopc               
   S   sb   zt ƒ } t| ƒdfW S  tk
r\ } z*td|› ƒ tdt|ƒiƒdf W Y ¢S d }~X Y nX d S )Nrp   z%Error en ruta de paro de emergencia: rq   rr   )r'   r   rs   r   rt   ©Úoptionsrv   rw   rw   rx   Úget_estop_catalog_route÷   s    z1get_optionsimput.<locals>.get_estop_catalog_routez2/Ventas/Ventas_EUA/Cotizador_EUA/additional-springc               
   S   sb   zt ƒ } t| ƒdfW S  tk
r\ } z*td|› ƒ tdt|ƒiƒdf W Y ¢S d }~X Y nX d S )Nrp   z&Error en ruta de resorte de aislador: rq   rr   )r(   r   rs   r   rt   r   rw   rw   rx   Úget_spring_catalog_route   s    z2get_optionsimput.<locals>.get_spring_catalog_routez:/Ventas/Ventas_EUA/Cotizador_EUA/tank-capacity/<kw_output>c              
   S   sR   zt | ƒ}t|ƒW S  tk
rL } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S r‡   )r)   r   rs   rt   )r   Z
capacitiesrv   rw   rw   rx   Úget_tank_capacity_route	  s
    
z1get_optionsimput.<locals>.get_tank_capacity_routezF/Ventas/Ventas_EUA/Cotizador_EUA/tank-type/<kw_output>/<tank_autonomy>c              
   S   sT   zt | |ƒ}t|ƒW S  tk
rN } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S r‡   )r*   r   rs   rt   )r   Ztank_autonomyr”   rv   rw   rw   rx   Úget_tank_type_route  s
    

z-get_optionsimput.<locals>.get_tank_type_routez2/Ventas/Ventas_EUA/Cotizador_EUA/spill-containmentc               
   S   sT   zt ƒ } t| ƒdfW S  tk
rN } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S ro   )r+   r   rs   rt   r   rw   rw   rx   Úget_spill_containment_route  s
    z5get_optionsimput.<locals>.get_spill_containment_routez)/Ventas/Ventas_EUA/Cotizador_EUA/countrysc               
   S   sT   zt ƒ } t| ƒdfW S  tk
rN } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S ro   )rd   r   rs   rt   r   rw   rw   rx   Úget_countrys_route"  s
    z,get_optionsimput.<locals>.get_countrys_routez1/Ventas/Ventas_EUA/Cotizador_EUA/warranty-optionsc               
   S   sT   zt ƒ } t| ƒdfW S  tk
rN } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S ro   )r,   r   rs   rt   r   rw   rw   rx   Úget_warranty_options_route*  s
    z4get_optionsimput.<locals>.get_warranty_options_routez</Ventas/Ventas_EUA/Cotizador_EUA/testing-options/<kw_output>c              
   S   sR   zt | ƒ}t|ƒW S  tk
rL } ztdt|ƒiƒdf W Y ¢S d }~X Y nX d S r‡   )r-   r   rs   rt   )r   rž   rv   rw   rw   rx   Úget_testing_options_route2  s
    
z3get_optionsimput.<locals>.get_testing_options_routez1/Ventas/Ventas_EUA/Cotizador_EUA/get-profile-infoc               
   S   sÊ   z|t  d¡} | s"tddiƒdfW S t| ƒ}|s@tddiƒdfW S | d¡dkrp| d	¡rpt|d	 ƒ}|rp||d
< t|ƒdfW S  tk
rÄ } z*td|› ƒ tdt|ƒiƒdf W Y ¢S d }~X Y nX d S )NÚuser_idrq   zUsuario no autenticadoi‘  zPerfil no encontradoé”  ÚRequestTypeID)ÚDISEUAÚDISCANZSellerUserIDZ
SellerInforp   u*   Error obteniendo informaciÃ³n del perfil: rr   )r   Úgetr   ra   r`   rs   r   rt   )r§   Zprofile_infoZseller_inforv   rw   rw   rx   Úget_profile_info_route:  s    
z0get_optionsimput.<locals>.get_profile_info_routez+/Ventas/Ventas_EUA/Cotizador_EUA/save-quoteÚPOSTc               
      sŽ   z:t  ¡ } tdƒ t| ƒ t| ƒ}ˆ |ƒ td|ddœƒW S  tk
rˆ } z0tdt|ƒ› ƒ tdt|ƒdœƒdf W Y ¢S d }~X Y nX d S )	Nu)   Datos recibidos para guardar cotizaciÃ³n:Tu!   CotizaciÃ³n guardada exitosamente)ÚsuccessÚquote_idÚmessageu   Error al guardar cotizaciÃ³n: F)r¯   rq   rr   )r   Úget_jsonr   r.   r   rs   rt   )Údatar°   rv   )Úpricing_Gensetrw   rx   Úsave_quote_routeQ  s&    ý
þýz*get_optionsimput.<locals>.save_quote_routec           .      S   sL  zt | ƒ}|stdƒ‚t|d |d |d |d |d |d |d |d	 |d
 ƒ	}|röt| |d |d |d |d |d |d |d |d |d |d |d |d |d |d |d |d |d |d |d |d |d |d  |d! |d" |d# ƒ |d	 }|d }d$|d
  d$ }d%}d&}tdƒD ]~}|||  d'krft|||  ||ƒ}	|	rft| |d |	ƒ |||  d(kr&t|||  ||ƒ}
|
r&t| |d |
ƒ q&d)d*d+gd,d-d.gd/d0d1gd2d3d4gd5d6d7gd8d9d:gd;œ}tdƒD ]d}| 	¡ D ]T\}}|| \}}|| }|| }|d<krðt
|||ƒ}|rðt| |d ||ƒ qðqä|d= d>krxt|d= ||ƒ}|rxt| |ƒ |d? d'kr¦t|d? ||ƒ}|r¦t| |ƒ |d@ d'krÔt|d@ ||ƒ}|rÔt| |ƒ |dA }|dB }|dC d<krt|dA |||ƒ}|rt| |ƒ |dD d<krHt|dE ||dF |ƒ}|rHt| |ƒ |dG d<kr|t|dH ||dI |ƒ}|r|t| |ƒ |dJ d<kr°t|dK ||dL |ƒ}|r°t| |ƒ dMdNdOdPdQdRdSdTg}|D ]<\}}}|| d<krÈt|| ||ƒ}|rÈt| ||ƒ qÈt|d |d |d |dU |dV ||ƒ}|r>t| |ƒ |dW d'krxt|dW ||dX |dYdZ}|rxt| d[|ƒ |d\ d'kr²t|d\ ||d] |d^dZ}|r²t| d_|ƒ |d` d'krèt|d` ||da |ƒ}|rèt| db|ƒ |dc d'krt|dc ||ƒ}|rt| dd|ƒ dedfg}|dg } | dhkrDt ¡ }!|!  | ¡ |di }"|"dhkrht ¡ }#|# !| ¡ |dj }$|$dhkrŒt ¡ }#|# "| ¡ |D ]D\}}}}%|| d<krt#|| |||% |ƒ}|rt$| ||ƒ qdkdldmdng}&|&D ]<\}}}|| d<kræt%|| ||ƒ}|ræt$| ||ƒ qæ|do d'krXt&|do ||dp |ƒ}'|'rXt'| |'ƒ |dq d'kr†t(|dq ||ƒ}(|(r†t)| |(ƒ drdsdtdudvdwdxdydzd{d|d}d~dd€dg}|D ]<\}}}|| d<kr®t*|| ||ƒ}|r®t+| ||ƒ q®t,||d‚ |dƒ ||ƒ})|)rt-| |)ƒ |d„ d'krDt.|d„ ||ƒ}*|*rDt/| d…|*ƒ d†d‡dˆd‰dŠd‹dŒddŽddd‘g}|D ]<\}}}|| d<krdt0|| ||ƒ}|rdt/| ||ƒ qd|d’ d'krÒt1|d’ |||ƒ}+|+rÒt2| |+ƒ t | ƒ}|d“ d'krt3|d“ ||d” |ƒ},|,rt4| |,ƒ W dYS  tk
rF }- zt5d•|-› ƒ ‚ W 5 dh}-~-X Y nX dhS )–uB   Procesa todos los precios y fichas tÃ©cnicas para una cotizaciÃ³n.u   CotizaciÃ³n no encontradar   é   é   é   é   é   é   é   é±   Zcost_idÚ
unit_priceÚ
tech_sheetÚGenset_PriceTotÚEngineModelZEngineTSheetZE_TierZE_RpmZE_PowerZE_NumberOfCylinderZE_AspirationZE_Governor_typeZE_Control_voltageZE_Battery_typeZE_Hotstart_modelZE_RadiatorTempÚAlternatorModelZAlternatorTSheetZA_PowerfactorZA_Insulation_SystemZA_Control_SystemZA_ProtectionZ
A_AvrModelZA_Voltage_RegulationZA_Class_temp_riseéd   é   é   õ   Seleccione una opciÃ³nú"Seleccione un modelo de interrptor)é   é   )é   é   )é&   é'   )é   é   )é   é   )é(   é)   )é   é   )é   é   )é*   é+   )é   é   )é    é!   )é,   é-   )é   é   )é"   é#   )é.   é/   )é   é   )é$   é%   )é0   é1   )Zsunt_tZsunt_wZgfiZaux_cZ	breaker_lZ	motorizedÚNoé2   úSelecciona la marca de controlé4   é6   é8   é:   é9   é<   é;   é=   é?   é>   é@   éB   éA   éC   )Zcomap_dse890éD   éE   )Zpanel_heateréF   éG   )Zremote_displayéH   éI   )ZantenaéJ   éK   )Zdse890éL   éM   )Zpanel_heaterCMPé²   é³   )Zremote_displayCMPé´   éµ   )Z	antenaCMPé¶   é·   éN   éO   éP   éR   T)Zis_acZlight_acéS   éU   FZlight_dcéV   éX   Zspace_heateréY   Zload_center)Zgfcié[   é\   é]   )Z
receptableé^   é_   é`   éº   Né¾   éÀ   )Zprewireéa   éb   )Úautolouverséc   rÃ   )Zreceptautolouversée   éf   )ZopeningEnclousureé¸   é¹   ég   éi   éj   )Zband_heaterél   ém   )Z
pmg_updateén   éo   )Zdigital_regulatorép   éq   )Zvoltage_rheostatér   és   )Zthermal_wrapét   éu   )Zbase_heaterév   éw   )Zbattery_switchéx   éy   )Zbattery_holderéz   é{   )Z
oil_heateré|   é}   )Zoil_level_switché~   é   )Zcommon_alarm_relayé€   é   )Zfunction_relayé‚   éƒ   )Zcoolanté„   é…   )Zoilé†   é‡   )Zdisconnect_switchéˆ   é‰   )Zremote_estopéŠ   é‹   éŒ   éŽ   é”   Z
spill_cont)Z
break_trayé   é‘   )Z
fuel_levelé’   é“   )Zoverfillé–   é—   )Z	dual_fuelé˜   é™   )Z	high_fueléš   é›   )Zremote_alarméœ   é   )Z	vent_pipeéž   éŸ   )Z	flammableé    é¡   )Znfpaé¢   é£   )Z
no_smokingé¤   é¥   )Ztank_numberé¦   é§   )Z
fluid_conté¨   é©   é®   éª   é°   zError procesando precios: )6r/   rs   r0   r1   Úranger2   r4   r3   r5   Úitemsr6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rI   rF   rJ   rG   rH   rk   ZupdateQuote_stopButtonEnclosureZupdate_quote_louvers_inZupdate_quote_louvers_outrK   rM   rL   rO   rP   rN   rQ   rR   rS   rT   rW   rU   rX   rV   rZ   r\   rY   r[   r   ).r°   Ú
quote_dataZgenset_dataZ
qty_gensetr   ZDiscountZbreaker_start_indexZprotection_start_indexÚiZbreaker_dataZprotection_dataZbreaker_optionsZbreaker_idxZoption_typeZindices_listZitem_idxZdesc_idxÚ
item_valueZ
desc_valueZoption_dataZcontroller_dataZpreheater_dataZcharger_dataZa56Za58rž   Zenclosure_dataZlight_ac_dataZlight_dc_dataZheater_dataZcenter_dataZqty_optionsZstop_idZ
czeServiceÚ
louvers_inZlouversServiceÚlouvers_outZqty_idxZsimple_optionsZ
estop_dataZspring_dataZ	tank_dataZ
spill_dataZtesting_dataZwarranty_datarv   rw   rw   rx   r´   j  s¦   ÷æú	
ü	


ü
ü
ü
ü
÷ýù	
ûûüýþ





üüýü
ý
ðýû
ýôýü
ü
z(get_optionsimput.<locals>.pricing_Gensetz"/Ventas/VentasEUA/VEUcotizadorbasec                     sÎ  t jdkrDt j d¡} | s0tddƒ ttdƒƒS | td< ttdƒƒS t j d¡}|r\|td< t d¡} | s€tddƒ ttdƒƒS ˆ| ƒ}ˆ| ƒ}ˆ|ƒ}ˆ|ƒ}ˆ| ƒ}ˆ|ƒ}ˆ|ƒ}ˆ| ƒ}	ˆ	|	ƒ}
ˆ|
ƒ}ˆ| ƒ}ˆ
|ƒ}ˆ|ƒ}ˆ | ƒ}ˆ|ƒ}ˆ|ƒ}ˆ| ƒ}ˆ|ƒ}ˆ|ƒ}|| | | | | }ˆ| |ƒ}ˆ|ƒ}ˆ|ƒ}|| }ˆ| |ƒ}t	t
|ƒƒ|d  }t| |d |ƒ d	d
h}||||
||||||||||||||t ¡  d¡|d| dœ}td|ŽS )Nr®   r°   u/   No se proporcionÃ³ un ID de cotizaciÃ³n vÃ¡lidorq   ÚindexÚcotizador_baseu/   No se encontrÃ³ el ID de cotizaciÃ³n en sesiÃ³nÚtotalzalexis.moreno@igsa.com.mxzcarlos.velazquezm@igsa.com.mxú%d/%m/%YT)r³   Útable_CotizacionGensetÚtable_CotizacionBreakersÚtable_CotizacionControlÚtable_CotizacionEnclosureÚtable_CotizacionAccesoriesÚtable_CotizacionTankÚtable_WarrantyAndTestÚprice_CotizacionGensetÚprice_CotizacionBreakersÚprice_CotizacionControlÚprice_CotizacionEnclosureÚprice_CotizacionAccesoriesÚprice_CotizacionTankÚprice_WarrantyAndTestÚ	GranTotalÚcountryDataÚofertaComercialÚ
today_dateÚemails_Quotes_NrtAmeZshow_send_buttonr°   ú&Ventas/VentasEUA/VEUcotizadorbase.html)r†  )r   ÚmethodÚformr¬   r	   r   r   r   Úargsr   rt   rf   r
   ÚnowÚstrftimer   )r°   Zurl_quote_idÚGeneral_InformationÚCotizacionGenset_datars  rz  ÚCotizacionBreakers_datart  r{  ÚCotizacionControl_dataru  r|  ÚCotizacionEnclosure_datarv  r}  ÚCotizacionAccesories_datarw  r~  ÚCotizacionTank_datarx  r  ÚGenset_priceÚCotizacionWarrantyAndTest_datary  r€  r  ÚcountryDiscountDatarƒ  r…  Úcontext)ÚGet_CotizacionAccesories_dataÚGet_CotizacionBreakers_dataÚGet_CotizacionControl_dataÚGet_CotizacionEnclosure_dataÚGet_CotizacionGenset_dataÚGet_CotizacionTank_dataÚGet_General_InformationÚ Get_warranty_and_testing_pricingÚgenerate_quote_table_AccesoriesÚgenerate_quote_table_ControlÚgenerate_quote_table_EnclosureÚgenerate_quote_table_GensetÚgenerate_quote_table_TankÚgenerate_quote_table_WTÚgenerate_quote_table_breakersÚget_country_discontÚsum_total_pricesrw   rx   rp     s„    





êz(get_optionsimput.<locals>.cotizador_basec                    sÈ  t | ƒ}|sdS ‡ fdd„| ¡ D ƒ}t ¡  d¡}|d }t|ƒ}|d }t|ƒ}| |d |d d	œd
|i||d |d › d|d › d|d › d|d |d dœ|d |d |d |d |d |d |d |d |d |d dœ|d d œ|d! |d" |d# |d$ |d% |d& |d' |d( |d) d*œ|d+ d,œd-|d- id.|d. id/|d/ id0œ|d1 d2|d2 id3œ|d4 |d5 d6œd7|d7 i|d8 |d9 |d: |d; |d< d=œ|d> |d? |d@ dAœdBœ}|S )CN©u2   Error: No se encontraron datos para la cotizaciÃ³nr¨   c                    s   i | ]\}}|ˆ |ƒ“qS rw   rw   ©Ú.0ÚkÚv©Úconvert_decimalrw   rx   Ú
<dictcomp>  s      zEget_optionsimput.<locals>.Get_General_Information.<locals>.<dictcomp>ú%Y-%m-%dÚGenset_CostIDÚ	VoltageIDÚProjectÚReqCustomer©ZprojectZcustomer_requirementsÚDATEÚFuelTypeFrontÚKWOutputz KWÚ	Frecuencyz Hzz VÚPhasesÚCertification)ÚGenset_modelr·  r¸  r¹  r²  rº  r»  ÚEngineBrandrÁ   ÚEngine_TierÚ
Engine_RpmÚEngine_PowerÚEngine_NumberOfCylinderÚEngine_AspirationÚEngine_Governor_typeÚEngine_Control_voltageÚEngine_RadiatorTemp)r¾  r¿  rÀ  rÁ  rÂ  rÃ  rÄ  rÅ  ÚEngine_TSheet)r½  rÁ   ÚspecificationsrÆ  ÚAlternatorBrandrÂ   ÚAltern_PowerfactorÚAltern_Insulation_SysÚAltern_Control_SystemÚAltern_ProtectionÚAltern_AvrModelÚAltern_VoltageRegulatÚAltern_Class_temp_rise)rÉ  rÊ  rË  rÌ  rÍ  rÎ  rÏ  ÚAltern_TSheet)rÈ  rÂ   rÇ  rÐ  ÚBreaker1ÚBreaker2ÚBreaker3©rÑ  rÒ  rÓ  ÚControlModelÚBateryCharger)rÕ  ZAdicionalyConfigControllerÚBaseTankÚTankAutonomy)r×  rØ  ZAcousticEnclosureÚCustomerCompanyÚCustomerAddressÚCustomerContactÚCustomerEmailÚCustomerTel©rÙ  rÚ  rÛ  rÜ  rÝ  Ú
SellerNameÚSellerEmailÚSellerPhone©rß  rà  rá  )r°   Úproject_infor   Zgeneral_infoZengineZ
alternatorÚBreakersÚ
controllerÚTankÚ	EnclosureÚCustomerÚSeller)r]   ri  r
   rŠ  r‹  r^   r_   )r°   rj  r¶  r±  r¼  r²  ÚDatos_voltajesrŒ  r­  rw   rx   r  ‰  s¤    þ ÿøø
óù	ô ÿ ÿ ÿù ÿþþ ÿûý±Vz1get_optionsimput.<locals>.Get_General_Informationc           
         sð   t | ƒ}|sdS ‡ fdd„| ¡ D ƒ}t ¡  d¡}|d }t|ƒ}|d }t|ƒ}| dd¡› d	|› d
| dd¡› d| dd¡› d| dd¡› d| dd¡› d| dd¡› d| dd¡› d}|d }| ||||d |d |d dœdœ}	|	S )Nr¨  c                    s   i | ]\}}|ˆ |ƒ“qS rw   rw   r©  r­  rw   rx   r¯  û  s      zGget_optionsimput.<locals>.Get_CotizacionGenset_data.<locals>.<dictcomp>r°  r±  r²  r·  Ú z GENERATOR SET MODEL z, STANDBY POWER r¸  z, ZVoltage_Frontz. r½  z ENGINE rÁ   rÈ  z ALTERNATOR rÂ   z, STANDARD ACCESSORIESÚ	QtyGensetÚGenset_Unit_PriceÚGenset_TSheetrÀ   )r¼  Ú
GensetDESCÚGensetQTYTOTrí  rî  rÀ   )r°   ÚGenset)r]   ri  r
   rŠ  r‹  r^   r_   r¬   )
r°   rj  r¶  r±  r¼  r²  rê  rï  rð  r  r­  rw   rx   r›  ô  s,    jÿúþz3get_optionsimput.<locals>.Get_CotizacionGenset_datac              
      sr   d}d‡ fdd„	}|   di ¡}|rf|  d¡rf|||  d¡|  d¡|  d¡|  d	¡|  d
¡|  d¡ƒ7 }|d7 }|S )u  
        Genera el HTML para la tabla del generador (Genset) con enlaces a fichas tÃ©cnicas
    
        Args:
            CotizacionGenset_data (dict): Datos del generador
        
        Returns:
            str: HTML para la tabla del generador
        ú
        <tbody>
        Nc           	         s|   |d ks|dkrdS ˆ |ƒ}ˆ |ƒ}|rH|  ¡ rHd|› d| p>d› d}n| pNd}d|› d|p^d› d|phd› d|› d|› dS ©Nrë  ú	<a href="ú*" target="_blank" class="tech-sheet-link">ú</a>ú&
            <tr>
                <td>ú</td>
                <td>ú$</td>
            </tr>
            ©Ústrip©	ÚitemÚdescriptionZqtyr¾   Ztotal_pricer¿   Zformatted_unit_priceZformatted_total_priceZ	item_cell©Úformat_pricerw   rx   Ú
render_row+  s$    þýüûúzIget_optionsimput.<locals>.generate_quote_table_Genset.<locals>.render_rowrñ  rï  r¼  rð  rí  rÀ   rî  ú
        </tbody>
        )N©r¬   )r  Úhtmlr  Zgensetrÿ  rw   rx   r¢    s    
ú	z5get_optionsimput.<locals>.generate_quote_table_Gensetc           -   :      sz  t | ƒ}|sdS ‡ fdd„| ¡ D ƒ}|d }d}|d }d}|d }d}|d }|d }	d}
|d }d	}|d }d
}|d }|d }d}|d }d}|d }d}|d }|d }d}|d }d	}|d }d
}|d }|d }d}|d } d}!|d }"d}#|d }$|d }%d}&|d }'d	}(|d })d
}*|d }+| |d |d ||d |d |d |d |d |||d |d |d |d |d |||d |d |d |d |d |||d |d |d |d |d  |	|d! |d" |d# |d$ |d% |
||d& |d' |d( |d	 |d) |||d* |d+ |d, |d- |d. |||d/ |d0 |d1 d2œ0d3œ|d4 |d5 ||d6 |d7 |d8 |d9 |d: |||d; |d< |d= |d> |d? |||d@ |dA |dB |dC |dD |||dE |dF |dG |dH |dI ||dJ |dK |dL |dM |dN |||dO |dP |dQ |dR |dS |||dT |dU |dV |dW |dX |||dY |dZ |d[ d\œ0d]œ|d^ |d_ ||d` |da |db |dc |dd || |de |df |dg |dh |di |!|"|dj |dk |dl |dm |dn |#|$|do |dp |dq |dr |ds |%|dt |du |dv |dw |dx |&|'|dy |dz |d{ |d| |d} |(|)|d~ |d |d€ |d |d‚ |*|+|dƒ |d„ |d… d†œ0d‡œdˆœd‰œ},|,S )ŠNr¨  c                    s   i | ]\}}|ˆ |ƒ“qS rw   rw   r©  r­  rw   rx   r¯  ^  s      zIget_optionsimput.<locals>.Get_CotizacionBreakers_data.<locals>.<dictcomp>rì  z
Shunt tripzShunt trip wiringzGFI (Ground fault indication)zAuxiliary contactsÚItem_Breaker_L1zMotorized BreakerÚItem_breaker1rÑ  ÚBreaker1_PriceÚBreaker1_TSheetÚBreaker1_PriceTotÚItem_Sunt_t1ÚShunt_trip1ÚSunt_t1_PriceÚSunt_t1_TSheetÚSunt_t1_PriceTotÚItem_Sunt_w1ÚShunt_trip_wiring1ÚSunt_w1_PriceÚSunt_w1_TSheetÚSunt_w1_PriceTotÚ	Item_GFI1ÚGFI1Ú
GFI1_PriceÚGFI1_TSheetÚGFI1_PriceTotÚItem_Proyection_t1ÚProtection_type1ÚProyection_t1_PriceÚProyection_t1_TSheetÚProyection_t1_PriceTotÚItem_Auxiliary_c1ÚAuxiliary_contacts1ÚAuxiliary_c1_PriceÚAuxiliary_c1_TSheetÚAuxiliary_c1_PriceTotÚBreaker_Lock1ÚBreaker_L1_PriceÚBreaker_L1_TSheetÚBreaker_L1_PriceTotÚItem_Motorized_B1ÚMotorized_Breaker1ÚMotorized_B1_PriceÚMotorized_B1_TSheetÚMotorized_B1_PriceTot)0r
  r  ÚShunt_trip1DESCÚShunt_trip1_QTYTOTr  r  r  r  r  ÚShunt_trip_wiring1DESCÚShunt_trip_wiring1_QTYTOTr  r  r  r  r  ÚItem_GFI1DESCÚItem_GFI1_QTYTOTr  r  r  r  r  ÚProtection_type1_QTYTOTr  r  r  r  r  ÚAuxiliary_contactsDESCÚAuxiliary_contacts_QTYTOTr   r!  r"  r  r#  ÚBreaker_LockDESCÚBreaker_Lock_QTYTOTr$  r%  r&  r'  r(  ÚMotorized_BreakerDESCÚMotorized_Breaker_QTYTOTr)  r*  r+  )r  rÑ  ÚBreaker1QTYTOTr  r  r	  ÚConfigAndAccesories_Breaker1ÚItem_breaker2rÒ  ÚBreaker2_PriceÚBreaker2_TSheetÚBreaker2_PriceTotÚItem_Sunt_t2ÚShunt_trip2ÚSunt_t2_PriceÚSunt_t2_TSheetÚSunt_t2_PriceTotÚItem_Sunt_w2ÚShunt_trip_wiring2ÚSunt_w2_PriceÚSunt_w2_TSheetÚSunt_w2_PriceTotÚ	Item_GFI2ÚGFI2Ú
GFI2_PriceÚGFI2_TSheetÚGFI2_PriceTotÚItem_Proyection_t2ÚProtection_type2ÚProyection_t2_PriceÚProyection_t2_TSheetÚProyection_t2_PriceTotÚItem_Auxiliary_c2ÚAuxiliary_contacts2ÚAuxiliary_c2_PriceÚAuxiliary_c2_TSheetÚAuxiliary_c2_PriceTotÚItem_Breaker_L2ÚBreaker_Lock2ÚBreaker_L2_PriceÚBreaker_L2_TSheetÚBreaker_L2_PriceTotÚItem_Motorized_B2ÚMotorized_Breaker2ÚMotorized_B2_PriceÚMotorized_B2_TSheetÚMotorized_B2_PriceTot)0r?  r@  ÚShunt_trip2DESCÚShunt_trip2_QTYTOTrA  rB  rC  rD  rE  ÚShunt_trip_wiring2DESCÚShunt_trip_wiring2_QTYTOTrF  rG  rH  rI  rJ  ÚItem_GFI2DESCÚItem_GFI2_QTYTOTrK  rL  rM  rN  rO  ÚProtection_type2_QTYTOTrP  rQ  rR  rS  rT  ÚAuxiliary_contacts2DESCÚAuxiliary_contacts2_QTYTOTrU  rV  rW  rX  rY  ÚBreaker_Lock2DESCÚBreaker_Lock2_QTYTOTrZ  r[  r\  r]  r^  ÚMotorized_Breaker2DESCÚMotorized_Breaker2_QTYTOTr_  r`  ra  )r;  rÒ  ÚBreaker2QTYTOTr<  r=  r>  ÚConfigAndAccesories_Breaker2ÚItem_breaker3rÓ  ÚBreaker3_PriceÚBreaker3_TSheetÚBreaker3_PriceTotÚItem_Sunt_t3ÚShunt_trip3ÚSunt_t3_PriceÚSunt_t3_TSheetÚSunt_t3_PriceTotÚItem_Sunt_w3ÚShunt_trip_wiring3ÚSunt_w3_PriceÚSunt_w3_TSheetÚSunt_w3_PriceTotÚ	Item_GFI3ÚGFI3Ú
GFI3_PriceÚGFI3_TSheetÚGFI3_PriceTotÚItem_Proyection_t3ÚProtection_type3ÚProyection_t3_PriceÚProyection_t3_TSheetÚProyection_t3_PriceTotÚItem_Auxiliary_c3ÚAuxiliary_contacts3ÚAuxiliary_c3_PriceÚAuxiliary_c3_TSheetÚAuxiliary_c3_PriceTotÚItem_Breaker_L3ÚBreaker_Lock3ÚBreaker_L3_PriceÚBreaker_L3_TSheetÚBreaker_L3_PriceTotÚItem_Motorized_B3ÚMotorized_Breaker3ÚMotorized_B3_PriceÚMotorized_B3_TSheetÚMotorized_B3_PriceTot)0ru  rv  ÚShunt_trip3DESCÚShunt_trip3_QTYTOTrw  rx  ry  rz  r{  ÚShunt_trip_wiring3DESCÚShunt_trip_wiring3_QTYTOTr|  r}  r~  r  r€  ÚItem_GFI3DESCÚItem_GFI3_QTYTOTr  r‚  rƒ  r„  r…  ÚProtection_type3_QTYTOTr†  r‡  rˆ  r‰  rŠ  ÚAuxiliary_contacts3DESCÚAuxiliary_contacts3_QTYTOTr‹  rŒ  r  rŽ  r  ÚBreaker_Lock3DESCÚBreaker_Lock3_QTYTOTr  r‘  r’  r“  r”  ÚMotorized_Breaker3DESCÚMotorized_Breaker3_QTYTOTr•  r–  r—  )rq  rÓ  ÚBreaker3QTYTOTrr  rs  rt  ÚConfigAndAccesories_Breaker3rÔ  )r°   rä  ©r]   ri  )-r°   rj  r9  r,  r-  r.  r/  r0  r1  r2  r3  r4  r5  r6  r7  r8  ro  rb  rc  rd  re  rf  rg  rh  ri  rj  rk  rl  rm  rn  r¥  r˜  r™  rš  r›  rœ  r  rž  rŸ  r   r¡  r¢  r£  r¤  rŽ  r­  rw   rx   r˜  W  s¸   ÂøKÂøKÂø€ íþ bz5get_optionsimput.<locals>.Get_CotizacionBreakers_datac              
      s„  d}d®‡ fdd„	}|   di ¡}|  di ¡}|r|  d¡dkr|||  d¡|  d¡|  d	¡|  d
¡|  d¡|  d¡ƒ7 }d|kr|d }|  d¡dkrÔ|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dkr|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dkrh|||  d¡|  d¡|  d ¡|  d!¡|  d"¡|  d#¡ƒ7 }|  d$¡dkr²|||  d%¡|  d$¡|  d&¡|  d'¡|  d(¡|  d)¡ƒ7 }|  d*¡dkrü|||  d+¡|  d,¡|  d-¡|  d.¡|  d/¡|  d0¡ƒ7 }|  d1¡dkrF|||  d2¡|  d3¡|  d4¡|  d5¡|  d6¡|  d7¡ƒ7 }|  d8¡dkr|||  d9¡|  d:¡|  d;¡|  d<¡|  d=¡|  d>¡ƒ7 }|  d?i ¡}|r|  d?¡dkr|||  d@¡|  d?¡|  dA¡|  dB¡|  dC¡|  dD¡ƒ7 }dE|kr|dE }|  dF¡dkrH|||  dG¡|  dH¡|  dI¡|  dJ¡|  dK¡|  dL¡ƒ7 }|  dM¡dkr’|||  dN¡|  dO¡|  dP¡|  dQ¡|  dR¡|  dS¡ƒ7 }|  dT¡dkrÜ|||  dU¡|  dV¡|  dW¡|  dX¡|  dY¡|  dZ¡ƒ7 }|  d[¡dkr&|||  d\¡|  d[¡|  d]¡|  d^¡|  d_¡|  d`¡ƒ7 }|  da¡dkrp|||  db¡|  dc¡|  dd¡|  de¡|  df¡|  dg¡ƒ7 }|  dh¡dkrº|||  di¡|  dj¡|  dk¡|  dl¡|  dm¡|  dn¡ƒ7 }|  do¡dkr|||  dp¡|  dq¡|  dr¡|  ds¡|  dt¡|  du¡ƒ7 }|  dvi ¡}|rx|  dv¡dkrx|||  dw¡|  dv¡|  dx¡|  dy¡|  dz¡|  d{¡ƒ7 }d||krx|d| }|  d}¡dkr¼|||  d~¡|  d¡|  d€¡|  d¡|  d‚¡|  dƒ¡ƒ7 }|  d„¡dkr|||  d…¡|  d†¡|  d‡¡|  dˆ¡|  d‰¡|  dŠ¡ƒ7 }|  d‹¡dkrP|||  dŒ¡|  d¡|  dŽ¡|  d¡|  d¡|  d‘¡ƒ7 }|  d’¡dkrš|||  d“¡|  d’¡|  d”¡|  d•¡|  d–¡|  d—¡ƒ7 }|  d˜¡dkrä|||  d™¡|  dš¡|  d›¡|  dœ¡|  d¡|  dž¡ƒ7 }|  dŸ¡dkr.|||  d ¡|  d¡¡|  d¢¡|  d£¡|  d¤¡|  d¥¡ƒ7 }|  d¦¡dkrx|||  d§¡|  d¨¡|  d©¡|  dª¡|  d«¡|  d¬¡ƒ7 }|d­7 }|S )¯uø   
        Genera el HTML para la tabla de breakers con enlaces a fichas tÃ©cnicas
    
        Args:
            CotizacionBreakers_data (dict): Datos de los breakers
        
        Returns:
            str: HTML para la tabla de breakers
        rò  Nc           	         s   |d ks|dks|dkrdS |dkr(dS ˆ |ƒ}ˆ |ƒ}|r\|  ¡ r\d|› d| pRd› d}n| pbd}d|› d|prd› d|p|d› d|› d|› d	S )
Nrë  rì   )rÆ   úSelect an optionrÇ   úSelect a breaker modelrô  rõ  rö  r÷  rø  rù  rú  rü  rÿ  rw   rx   r  –  s(    þýüûúzKget_optionsimput.<locals>.generate_quote_table_breakers.<locals>.render_rowrä  rÑ  )Nrë  rÆ   r¨  rÇ   r©  r  r9  r  r	  r  r:  r  ©Nrë  rì   r
  r,  r-  r  r  r  r  r  r.  r/  r  r  r  r  r  r0  r1  r  r  r  r  r  r2  r  r  r  r  r  r3  r4  r   r"  r!  r#  r  r5  r6  r$  r&  r%  r(  r'  r7  r8  r)  r+  r*  rÒ  r;  ro  r<  r>  r=  rp  r@  r?  rb  rc  rA  rC  rB  rE  rD  rd  re  rF  rH  rG  rJ  rI  rf  rg  rK  rM  rL  rO  rN  rh  rP  rR  rQ  rT  rS  ri  rj  rU  rW  rV  rY  rX  rk  rl  rZ  r\  r[  r^  r]  rm  rn  r_  ra  r`  rÓ  rq  r¥  rr  rt  rs  r¦  rv  ru  r˜  r™  rw  ry  rx  r{  rz  rš  r›  r|  r~  r}  r€  r  rœ  r  r  rƒ  r‚  r…  r„  rž  r†  rˆ  r‡  rŠ  r‰  rŸ  r   r‹  r  rŒ  r  rŽ  r¡  r¢  r  r’  r‘  r”  r“  r£  r¤  r•  r—  r–  r  )Nr  )rŽ  r  r  rŠ   Zbreaker1ÚaccessoriesZbreaker2Zbreaker3rÿ  rw   rx   r¥  ‡  sÌ   
ú

ú
ú
ú
ú
ú
ú
ú
ú

ú
ú
ú
ú
ú
ú
ú
ú

ú
ú
ú
ú
ú
ú
ú	z7get_optionsimput.<locals>.generate_quote_table_breakersc               a      s  t | ƒ}|sdS ‡ fdd„| ¡ D ƒ}|d }d}|d }d}|d }d}|d |d  }d}	|d	 |d  }
d
}d}|d |d  }d}|d |d  }d}|d }d}|d }d}|d }d}|d }d}|d }d}|d }d}|d }|d }| |d |d ||d |d |d |d |d |||d |d |d |d |||d |d  |d! |d" |||d# |d$ |d% |d& |d' |||d( |d) |d* |d+ |d, |	|
|d- |d. |d/ |d0 |d1 |||d2 |d3 |d4 |d5 |d6 |||d7 |d8 |d9 |d6 |||d7 |d8 |d9 |d: |d; |||d< |d= |d> |d? |d@ |||dA |dB |dC |dD |||dE |dF |dG |dH |dI |d |||dJ |dK |dL |dM |dN |d |||dO |dP |dQ dRœ|dS |dT |||dU |dV |dW |dX |dY ||dZ |d[ |d\ d]œJd^œd_œ}|S )`Nr¨  c                    s   i | ]\}}|ˆ |ƒ“qS rw   rw   r©  r­  rw   rx   r¯  Ø  s      zHget_optionsimput.<locals>.Get_CotizacionControl_data.<locals>.<dictcomp>rì  zControl Panel Heaterz'DSE2157 Output Module  (8 dry contacts)Ú
QtyDSE2157z$I-RB8 Output module (8 dry contacts)ZQtyComapDSE2157zDSE-2548zDSE2548 Remote AnnunciatorÚ
QtyDSE2548zIGL-RA15 Remote AnnunciatorZQtyComapDSE2548z!DSE890 Ethernet/4G gateway devicezCM3-ETHERNETz1GSM/GPS ANTENNA 3M RG-174, GSM-SMA(M), GPS-SMA(F)zRemote Display Module DSEzRemote Display Module COMAPÚItem_controllerrÕ  Úcontroller_PriceÚcontroller_TSheetÚControlModel_PriceTotÚItem_CtrlPanelHeaterÚCtrlPanelHeaterÚCtrlPanelHeater_PriceÚCtrlPanelHeater_TSheetÚCtrlPanelHeat_PriceTotÚItem_CtrlPanelHeaterCMPÚCtrlPanelHeaterCMP_PriceÚCtrlPanelHeaterCMP_TSheetÚCtrlPanelHeatCMP_PriceTotÚItem_RempteDisplModCMPÚRempteDisplModCMP_PriceÚRempteDisplModCMP_TSheetÚRempteDisplModCMP_PriceTotÚItem_AntenaCMPÚ	AntenaCMPÚAntenaCMP_PriceÚAntenaCMP_TSheetÚAntenaCMP_PriceTotÚItem_ComapDSE2157ÚComapDSE2157ÚComapDSE2157_PriceÚComapDSE2157_TSheetÚComapDSE2157_PriceTotÚItem_ComapDSE2548ÚComapDSE2548ÚComapDSE2548_PriceÚComapDSE2548_TSheetÚComapDSE2548_PriceTotÚItem_RempteDisplModÚRemoteDisplayModuleÚRempteDisplMod_PriceÚRempteDisplMod_TSheetÚRempteDisplMod_PriceTotÚItem_AntenaÚAntenaÚAntena_PriceÚAntena_TSheetÚAntena_PriceTotÚItem_DSE890ÚDSE890ÚDSE890_PriceÚDSE890_TSheetÚDSE890_PriceTotÚItem_ComapDSE890ÚComapDSE890_PriceÚComapDSE890_TSheetÚComapDSE890_PriceTotÚItem_DSE2157ÚDSE2157ÚDSE2157_PriceÚDSE2157_TSheetÚDSE2157_PriceTotÚItem_DSE2548ÚDSE2548ÚDSE2548_PriceÚDSE2548_TSheetÚDSE2548_PriceTot)rØ  rÙ  Ú
DSE890DESCÚDSE890QTYTOTrÚ  rÛ  rÜ  rÝ  ÚCMP_890_DESCRIPTIONÚCMP_890_QTYTOTALrÞ  rß  rà  rá  râ  r¬  ÚDSE2157DESCÚDSE2157QTYTOTrã  rä  rå  ræ  rç  r­  ÚDSE2548DESCÚDSE2548QTYTOTrè  ré  rê  ÚItem_CtrlVotlOperÚCtrlVotlOperÚCtrlVotlOper_PriceÚCtrlVotlOper_TSheetÚCtrlVotlOper_PriceTotÚItem_BateryChargerrÖ  ÚBateryCharger_PriceÚBateryCharger_TSheetÚBateryCharger_PriceTot)Jr³  r³  ÚCPHDESCÚ	CPHQTYTOTr´  rµ  r¶  r·  ÚCMP_CPH_DESCRIPTIONÚCMP_CPH_QTYTOTALr¸  r¹  rº  r»  ÚCMP_RDMDSE_DESCRIPTIONÚCMP_RDMDSE_QTYTOTALr¼  r½  r¾  r¿  rÀ  ÚCMP_GSM_GSP_DESCRIPTIONÚCMP_GSM_GSP_QTYTOTALrÁ  rÂ  rÃ  rÄ  rÅ  ÚCMP_2157_DESCRIPTIONÚCMP_2157_QTYTOTALrÆ  rÇ  rÈ  rÉ  rÊ  ÚCMP_2548_DESCRIPTIONÚCMP_2548_QTYTOTOTALrË  rÌ  rÍ  rÎ  rÏ  Ú
RDMDSEDESCÚRDMDSEQTYTOTrÐ  rÑ  rÒ  rÏ  r  r	  rÐ  rÑ  rÒ  rÓ  rÔ  ÚGSM_GSPDESCÚGSM_GSPQTYTOTrÕ  rÖ  r×  ÚConfigAndAccesories_DeepSearó  rô  ÚCtrlVotlOperDESCÚCtrlVotlOperQTYTOTrõ  rö  r÷  rø  rÖ  ÚBateryChargerQTYTOTrù  rú  rû  )r®  rÕ  ÚControlModelQTYr¯  r°  r±  ÚConfigAndAccesories_Controller)r°   rå  r§  ) r°   rj  r  rü  rý  rþ  rÿ  rï  rð  r  r  ZItem_controller_options_DSE2548rñ  rò  r  r  rë  rì  rí  rî  r
  r  r  r  r  r	  r  r  r   r  r  r  r­  rw   rx   r™  Ò  s*   Ú*€ øøþ z4get_optionsimput.<locals>.Get_CotizacionControl_datac              
      s¨  d}dp‡ fdd„	}|   di ¡}|rœ|  d¡dkrœ|||  d¡|  d¡|  d	¡|  d
¡|  d¡|  d¡ƒ7 }d|krœ|d }|  d¡dkrÈ|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dkr|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dkr\|||  d¡|  d¡|  d¡|  d ¡|  d!¡|  d"¡ƒ7 }|  d#¡dkr¦|||  d#¡|  d$¡|  d%¡|  d&¡|  d'¡|  d(¡ƒ7 }|  d)¡dkrð|||  d*¡|  d+¡|  d,¡|  d-¡|  d.¡|  d/¡ƒ7 }|  d0¡dkr:|||  d1¡|  d2¡|  d3¡|  d4¡|  d5¡|  d6¡ƒ7 }d7|kr|d7 }|  d8¡dkr–|||  d9¡|  d:¡|  d;¡|  d<¡|  d=¡|  d>¡ƒ7 }|  d?¡dkrà|||  d?¡|  d@¡|  dA¡|  dB¡|  dC¡|  dD¡ƒ7 }|  dE¡dkr*|||  dF¡|  dG¡|  dH¡|  dI¡|  dJ¡|  dK¡ƒ7 }|  dL¡dkrt|||  dM¡|  dN¡|  dO¡|  dP¡|  dQ¡|  dR¡ƒ7 }|  dS¡dkr¾|||  dT¡|  dU¡|  dV¡|  dW¡|  dX¡|  dY¡ƒ7 }|  dZ¡dkr|||  d[¡|  d\¡|  d]¡|  d^¡|  d_¡|  d`¡ƒ7 }|  da¡dbkrR|||  dc¡|  dd¡|  de¡|  df¡|  dg¡|  dh¡ƒ7 }|  di¡dkrœ|||  dj¡|  di¡|  dk¡|  dl¡|  dm¡|  dn¡ƒ7 }|do7 }|S )qu  
        Genera el HTML para la tabla de controladores con enlaces a fichas tÃ©cnicas
    
        Args:
            CotizacionControl_data (dict): Datos de los controladores
        
        Returns:
            str: HTML para la tabla de controladores
        rò  Nc           	         s   |d ks|dks|dkrdS |dkr(dS ˆ |ƒ}ˆ |ƒ}|r\|  ¡ r\d|› d| pRd› d}n| pbd}d|› d|prd› d|p|d› d|› d|› d	S )
Nrë  rì   )rÆ   r¨  rî   úSelect the cotroller brandrô  rõ  rö  r÷  rø  rù  rú  rü  rÿ  rw   rx   r  ³  s(    þýüûúzJget_optionsimput.<locals>.generate_quote_table_Control.<locals>.render_rowrå  rÕ  )Nrë  rÆ   r¨  rî   r  r®  r  r¯  r±  r°  r  r³  rª  r²  rü  rý  r´  r¶  rµ  r·  rþ  rÿ  r¸  rº  r¹  rÏ  rÎ  r  r	  rÐ  rÒ  rÑ  r»  r   r  r¼  r¾  r½  rÔ  rÓ  r
  r  rÕ  r×  rÖ  rÀ  r¿  r  r  rÁ  rÃ  rÂ  r  rÙ  rØ  rë  rì  rÚ  rÜ  rÛ  rÝ  rí  rî  rÞ  rà  rß  râ  rá  rï  rð  rã  rå  rä  rÅ  rÄ  r  r  rÆ  rÈ  rÇ  rç  ræ  rñ  rò  rè  rê  ré  rÊ  rÉ  r  r  rË  rÍ  rÌ  rô  ©Nrë  rÆ   r¨  ró  r  r  rõ  r÷  rö  rÖ  rø  r  rù  rû  rú  r  )Nr  )r  r  r  rå  r«  Zdeep_searÿ  rw   rx   r   ¤  s    
ú

ú
úú
úú
ú
ú
ú
ú
ú
úú
ú
ú	z6get_optionsimput.<locals>.generate_quote_table_Controlc           %         sl  t | ƒ}|sdS ‡ fdd„| ¡ D ƒ}d}|d }d}|d }d}|d }d}|d }	d	}
|d }d
}|d }d}|d }d}|d }d}|d }d}|d }d}|d }d}|d }d}|d }d}|d }d}|d }|d } d}!|d }"|d }#| |d |d |||d |d |d |d |d |||d |d |d |d |d  |||d! |d" |d# |d$ |d% |	||d& |d' |d( |d) |d* ||
|d+ |d, |d- |d. |d/ |||d0 |d1 |d2 |d3 |d4 |||d5 |d6 |d7 |d8 |d9 |||d: |d; |d< |d= |d> |||d? |d@ |dA |dB |dC |||dD |dE |dF |dG |dH |||dI |dJ |dK |dL |dM |||dN |dO |dP |dQ |dR |||dS |dT |dU |dV |dW |||dX |dY |dZ |d[ |d\ |||d] |d^ |d_ |d` |da |db | |dc |dd |de |df |dg |"|!|dh |di |dj |dk |dl |#|dm |dn |do dpœ}dqœ}$|$S )rNr¨  c                    s   i | ]\}}|ˆ |ƒ“qS rw   rw   r©  r­  rw   rx   r¯  ’  s      zKget_optionsimput.<locals>.Get_CotizacionAccesories_data.<locals>.<dictcomp>zAlternator strip heaterrì  zMX321 - PMG UpgradezDM110 Digital voltage regulatorzVoltage adjust rheostatzBattery thermal wrapzBattery pad heaterzBattery disconnect switchzBattery restraintzOil pan heaterzOil level switch-murphy 129zRelay - 10A Common alarmzRelay - 10A Run relayzCoolant in Gen-setzOil in Gen-SetzHeater Disconnect Switchesz-Remote E-Stop - Visual / Plastic hinged coverÚItem_BandHeaterÚ
BandHeaterÚBandHeater_PriceÚBandHeater_TSheetÚBandHeater_PriceTotÚItem_PMGUpdateÚ	PMGUpdateÚPMGUpdate_PriceÚPMGUpdate_TSheetÚPMGUpdate_PriceTotÚItem_DigitalRegulatorÚDigitalRegulatorÚDigitalRegulator_PriceÚDigitalRegulator_TSheetÚDigitalRegulat_PriceTotÚItem_VoltageRheostatÚVoltageRheostatÚVoltageRheostat_PriceÚVoltageRheostat_TSheetÚVoltageRheosta_PriceTotÚItem_ThermalWrapÚThermalWrapÚThermalWrap_PriceÚThermalWrap_TSheetÚThermalWrap_PriceTotÚItem_BaseHeaterÚ
BaseHeaterÚBaseHeater_PriceÚBaseHeater_TSheetÚBaseHeater_PriceTotÚItem_BatterySwitchÚBatterySwitchÚBatterySwitch_PriceÚBatterySwitch_TSheetÚBatterySwitch_PriceTotÚItem_BatteryHolderÚBatteryHolderÚBatteryHolder_PriceÚBatteryHolder_TSheetÚBatteryHolder_PriceTotÚItem_OilHeaterÚ	OilHeaterÚOilHeater_PriceÚOilHeater_TSheetÚOilHeater_PriceTotÚItem_OilLevelSwitchÚOilLevelSwitchÚOilLevelSwitch_PriceÚOilLevelSwitch_TSheetÚOilLevelSwitch_PriceTotÚItem_CommonAlarmRelayÚCommonAlarmRelayÚCommonAlarmRelay_PriceÚCommonAlarmRelay_TSheetÚCommonAlarmRel_PriceTotÚItem_FunctionRelayÚFunctionRelayÚFunctionRelay_PriceÚFunctionRelay_TSheetÚFunctionRelay_PriceTotÚItem_CoolantÚCoolantÚCoolant_PriceÚCoolant_TSheetÚCoolant_PriceTotÚItem_OilÚOilÚ	Oil_PriceÚ
Oil_TSheetÚOil_PriceTotÚItem_DisconnectSwitchesÚDisconnectSwitchesÚDisconnectSwitch_PriceÚDisconnectSwitch_TSheetÚDisconnectSwit_PriceTotÚItem_AddAccesory_EstopÚEStopÚQtyEStopÚEStop_priceÚEStop_TSheetÚEStop_PriceTotÚItem_RemoteEStopÚRemoteEStopÚRemoteEStop_PriceÚRemoteEStop_TSheetÚRemoteEStop_PriceTotÚItem_AddAccesory_SpringÚSpringIsolatorÚSpringIsolator_priceÚSpringIsolator_TSheetÚSpringIsolator_PriceTot)}r  r  ÚBandHeaterQTYTOTÚBandHeaterDESCr  r  r  r  r  ÚPMGUpdateQTYTOTÚPMGUpdateDESCr  r  r  r  r  ÚDigitalRegulatorQTYTOTÚDigitalRegulatorDESCr   r!  r"  r#  r$  ÚVoltageRheostatQTYTOTÚVoltageRheostatDESCr%  r&  r'  r(  r)  ÚThermalWrapQTYTOTÚThermalWrapDESCr*  r+  r,  r-  r.  ÚBaseHeaterQTYTOTÚBaseHeaterDESCr/  r0  r1  r2  r3  ÚBatterySwitchQTYTOTÚBatterySwitchDESCr4  r5  r6  r7  r8  ÚBatteryHolderQTYTOTÚBatteryHolderDESCr9  r:  r;  r<  r=  ÚOilHeaterQTYTOTÚOilHeaterDESCr>  r?  r@  rA  rB  ÚOilLevelSwitchQTYTOTÚOilLevelSwitchDESCrC  rD  rE  rF  rG  ÚCommonAlarmRelayQTYTOTÚCommonAlarmRelayDESCrH  rI  rJ  rK  rL  ÚFunctionRelayQTYTOTÚFunctionRelayDESCrM  rN  rO  rP  rQ  ÚCoolantQTYTOTÚCoolantDESCrR  rS  rT  rU  rV  Ú	OilQTYTOTÚOilDESCrW  rX  rY  rZ  r[  ÚDisconnectSwitchesQTYTOTÚDisconnectSwitchesDESCr\  r]  r^  r_  r`  ra  ÚEStopQTYTOTrb  rc  rd  re  rf  ÚRemoteEStopQTYTOTÚRemoteEStopDESCrg  rh  ri  rj  rk  ÚSpringIsolatorQTYTOTrl  rm  rn  )r°   ÚAdditionalAccesories_Gensetr§  )%r°   rj  rp  ro  rr  rq  rt  rs  rv  ru  rx  rw  rz  ry  r|  r{  r~  r}  r€  r  r‚  r  r„  rƒ  r†  r…  rˆ  r‡  rŠ  r‰  rŒ  r‹  r  r  rŽ  r  r‘  r­  rw   rx   r—  Œ  sR   € àþ 'z7get_optionsimput.<locals>.Get_CotizacionAccesories_datac              
      sX  d}d…‡ fdd„	}|   di ¡}|  d¡dkrf|||  d¡|  d	¡|  d
¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dkr®|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dkrö|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dkr@|||  d¡|  d¡|  d¡|  d ¡|  d!¡|  d"¡ƒ7 }|  d#¡dkrŠ|||  d$¡|  d%¡|  d&¡|  d'¡|  d(¡|  d)¡ƒ7 }|  d*¡dkrÔ|||  d+¡|  d,¡|  d-¡|  d.¡|  d/¡|  d0¡ƒ7 }|  d1¡dkr|||  d2¡|  d3¡|  d4¡|  d5¡|  d6¡|  d7¡ƒ7 }|  d8¡dkrh|||  d9¡|  d:¡|  d;¡|  d<¡|  d=¡|  d>¡ƒ7 }|  d?¡dkr²|||  d@¡|  dA¡|  dB¡|  dC¡|  dD¡|  dE¡ƒ7 }|  dF¡dkrü|||  dG¡|  dH¡|  dI¡|  dJ¡|  dK¡|  dL¡ƒ7 }|  dM¡dkrF|||  dN¡|  dO¡|  dP¡|  dQ¡|  dR¡|  dS¡ƒ7 }|  dT¡dkr|||  dU¡|  dV¡|  dW¡|  dX¡|  dY¡|  dZ¡ƒ7 }|  d[¡dkrÚ|||  d\¡|  d]¡|  d^¡|  d_¡|  d`¡|  da¡ƒ7 }|  db¡dkr$|||  dc¡|  dd¡|  de¡|  df¡|  dg¡|  dh¡ƒ7 }|  di¡dkrn|||  dj¡|  dk¡|  dl¡|  dm¡|  dn¡|  do¡ƒ7 }|  dp¡dqkr¸|||  dr¡|  dp¡|  ds¡|  dt¡|  du¡|  dv¡ƒ7 }|  dw¡dkr|||  dx¡|  dy¡|  dz¡|  d{¡|  d|¡|  d}¡ƒ7 }|  d~¡dqkrL|||  d¡|  d~¡|  d€¡|  d¡|  d‚¡|  dƒ¡ƒ7 }|d„7 }|S )†u$  
        Genera el HTML para la tabla de accesorios adicionales con enlaces a fichas tÃ©cnicas
    
        Args:
            CotizacionAccesories_data (dict): Datos de los accesorios adicionales
        
        Returns:
            str: HTML para la tabla de accesorios adicionales
        rò  Nc           	         s   |d ks|dks|dkrdS |dkr(dS ˆ |ƒ}ˆ |ƒ}|r\|  ¡ r\d|› d| pRd› d}n| pbd}d|› d|prd› d|p|d› d|› d|› d	S )
Nrë  rì   )rÆ   r¨  rô  rõ  rö  r÷  rø  rù  rú  rü  rÿ  rw   rx   r  €	  s(    þýüûúzMget_optionsimput.<locals>.generate_quote_table_Accesories.<locals>.render_rowr‘  r  rª  r  rp  ro  r  r  r  r  r  rr  rq  r  r  r  r  r  rt  rs  r   r"  r!  r$  r#  rv  ru  r%  r'  r&  r)  r(  rx  rw  r*  r,  r+  r.  r-  rz  ry  r/  r1  r0  r3  r2  r|  r{  r4  r6  r5  r8  r7  r~  r}  r9  r;  r:  r=  r<  r€  r  r>  r@  r?  rB  rA  r‚  r  rC  rE  rD  rG  rF  r„  rƒ  rH  rJ  rI  rL  rK  r†  r…  rM  rO  rN  rQ  rP  rˆ  r‡  rR  rT  rS  rV  rU  rŠ  r‰  rW  rY  rX  r[  rZ  rŒ  r‹  r\  r^  r]  r`  r  r_  r  rb  rd  rc  rf  re  r  rŽ  rg  ri  rh  rk  rj  r  rl  rn  rm  r  )Nr  )r‘  r  r  r«  rÿ  rw   rx   rŸ  q	  sN   
ú
ú
ú
ú
ú
ú
ú
ú
ú
ú
ú
ú
ú
ú
ú
ú
ú
ú	z9get_optionsimput.<locals>.generate_quote_table_Accesoriesc              `      sì  t  ¡ }t| ƒ}|sdS ‡ fdd„| ¡ D ƒ}| dd¡› d| dd¡›  ¡ }|d }d	}|d
 |d  }d}|d |d  }d}	|d }
d}|d }d}|d }d}|d }|d |d  }|d |d  }|d |d  }|d }d}| |d |d |||d |d |d |d |d |d
 |||d |d |d |d |d |d |||d  |d! |d" |d# |d$ |d ||d% |d& |d' |d( |d) |d ||d* |d+ |d, |d- |d. |d ||d/ |d0 |d1 |d2 |d3 ||d4 |d5 |d6 |d7 |d8 |	|
|d9 |d: |d; |d< |d= |||d> |d? |d@ |dA |dB |||dC |dD |dE |dF |d |||dG |dH |dI |dJ |dK |dL |dM |dN |dO |dP |dQ |dR |dS |dT |dU |dV |dW |dX |dY dZœWd[œd\œ}|S )]Nr¨  c                    s   i | ]\}}|ˆ |ƒ“qS rw   rw   r©  r­  rw   rx   r¯  v
  s      zJget_optionsimput.<locals>.Get_CotizacionEnclosure_data.<locals>.<dictcomp>ÚEnclosureTyperë  ú - ZEnclosure_ConfigIDrì  z120V GFCI ReceptacleÚQtyGFCI120Vz240V ReceptacleÚQtyReceptable120Vz)Prewire gen-set accesories to load centerzAutomatic LouverszOpening enclosurez*Louver fail contact wired to control panelÚ
QtylightACÚ
QtylightDCÚQtySpaceHeaterÚOpeningEnclousureÚItem_Enclosuree_typeÚEnclosure_priceÚEnclosure_TSheetÚEnclosure_PriceTotÚItem_GFCI120VÚGFCI120VÚGFCI120V_PriceÚGFCI120V_TSheetÚGFCI120V_PriceTotÚItem_Receptable120VÚReceptable120VÚReceptable120V_PriceÚReceptable120V_TSheetÚReceptable120V_PriceTotÚItem_Enclosure_ligthACÚlightACÚlightAC_priceÚlightAC_TSheetÚlightAC_PriceTotÚItem_Enclosure_ligthDCÚlightDCÚlightDC_priceÚlightDC_TSheetÚlightDC_PriceTotÚItem_Enclosure_SHeaterÚSpaceHeaterÚSpaceHeater_priceÚSpaceHeater_TSheetÚSpaceHeater_PriceTotÚItem_Enclosure_LCenterÚ
LoadCenterÚLoadCenter_priceÚLoadCenter_TSheetÚLoadCenter_PriceTotÚItem_PrewireAccsEnclÚPrewireAccsEnclousureÚPrewireAccsEnclo_PriceÚPrewireAccsEnclo_TSheetÚPrewireAccsEnc_PriceTotÚItem_autolouversr!  Úautolouvers_PriceÚautolouvers_TSheetÚautolouvers_PriceTotÚItem_ReceptautolouversÚReceptautolouversÚReceptautolouver_PriceÚReceptautolouver_TSheetÚReceptautolouv_PriceTotÚItem_OpeningEnclousureÚOpeningEnclousure_PriceÚOpeningEnclousure_TSheetÚOpeningEnclousure_PriceTotÚItem_StopButtonEnclosureÚStopButtonEnclosureÚStopButtonEnclosure_QtyÚStopButtonEnclosure_PriceÚStopButtonEnclosure_TSheetÚStopButtonEnclosure_PriceTotÚItem_louvers_inrm  Úlouvers_in_priceÚlouvers_in_tsheetÚlouvers_in_pricetotÚItem_louvers_outrn  Úlouvers_out_priceÚlouvers_out_tsheetÚlouvers_out_pricetot)Wrž  rŸ  r”  ÚGFCI120VDESCÚGFCI120VQTYTOTr   r¡  r¢  r£  r¤  r•  ÚReceptable120VDESCÚReceptable120VQTYTOTr¥  r¦  r§  r¨  r©  r–  ÚEnclosure_ligthACQTYTOTrª  r«  r¬  r­  r®  r—  ÚEnclosure_ligthDCQTYTOTr¯  r°  r±  r²  r³  r˜  ÚEnclosure_SHeaterQTYTOTr´  rµ  r¶  r·  r¸  ÚEnclosure_LCenterQTYTOTr¹  rº  r»  r¼  r½  ÚPWCDESCÚ	PWCQTYTOTr¾  r¿  rÀ  rÁ  r!  ÚAUTLOVEDESCÚAUTLOVEQTYTOTrÂ  rÃ  rÄ  rÅ  rÆ  ÚItem_ReceptautolouversDESCÚItem_ReceptautolouversQTYTOTrÇ  rÈ  rÉ  rÊ  r™  ÚOpeningEnclosure_DescriptionÚOpeningEnclosure_QtytotalrË  rÌ  rÍ  rÎ  rÏ  rÐ  rÑ  rÒ  rÓ  rÔ  rm  zlouvers_in_price:rÖ  r×  rØ  rn  rÙ  rÚ  rÛ  )rš  r’  ÚEnclosureDESCÚEnclosureQTYTOTr›  rœ  r  ÚConfigAndAccesories_Enclosure)r°   rç  )rl   Z!StopButtonEnclosureOptionsServicer]   ri  r¬   rû  )r°   Zstop_servicerj  rì  rí  rÜ  rÝ  rÞ  rß  rä  rå  ræ  rç  rê  rë  rè  ré  rà  rá  râ  rã  r  r­  rw   rx   rš  j
  sö    "“÷þ}z6get_optionsimput.<locals>.Get_CotizacionEnclosure_datac              
      s@  d}de‡ fdd„	}|   di ¡}|r4|  d¡dkr4|||  d¡|  d	¡|  d
¡|  d¡|  d¡|  d¡ƒ7 }d|kr4|d }|  d¡dkrÈ|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dkr|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dkr\|||  d ¡|  d¡|  d!¡|  d"¡|  d#¡|  d$¡ƒ7 }|  d%¡dkr¦|||  d&¡|  d%¡|  d'¡|  d(¡|  d)¡|  d*¡ƒ7 }|  d+¡dkrð|||  d,¡|  d+¡|  d-¡|  d.¡|  d/¡|  d0¡ƒ7 }|  d1¡dkr:|||  d2¡|  d1¡|  d3¡|  d4¡|  d5¡|  d6¡ƒ7 }|  d7¡dkr„|||  d8¡|  d9¡|  d:¡|  d;¡|  d<¡|  d=¡ƒ7 }|  d>¡dkrÎ|||  d?¡|  d@¡|  dA¡|  dB¡|  dC¡|  dD¡ƒ7 }|  dE¡dkr|||  dF¡|  dE¡|  dG¡|  dH¡|  dI¡|  dJ¡ƒ7 }|  dK¡dkrb|||  dL¡|  dM¡|  dN¡|  dO¡|  dP¡|  dQ¡ƒ7 }|  dR¡dkr¬|||  dS¡|  dT¡|  dU¡|  dV¡|  dW¡|  dX¡ƒ7 }|  dY¡dkrð|||  dZ¡|  dY¡d[|  d\¡|  d]¡|  d^¡ƒ7 }|  d_¡dkr4|||  d`¡|  d_¡d[|  da¡|  db¡|  dc¡ƒ7 }|dd7 }|S )fu  
        Genera el HTML para la tabla de la caseta (enclosure) con enlaces a fichas tÃ©cnicas
    
        Args:
            CotizacionEnclosure_data (dict): Datos de la caseta y sus accesorios
        
        Returns:
            str: HTML para la tabla de la caseta
        rò  Nc           	         s   |d ks|dks|dkrdS |dkr(dS ˆ |ƒ}ˆ |ƒ}|r\|  ¡ r\d|› d| pRd› d}n| pbd}d|› d|prd› d|p|d› d|› d|› d	S )
Nrë  rì   )rÆ   r¨  úSelect the enclosureúSeleccione el tipo de casetarô  rõ  rö  r÷  rø  rù  rú  rü  rÿ  rw   rx   r  &  s(    þýüûúzLget_optionsimput.<locals>.generate_quote_table_Enclosure.<locals>.render_rowrç  r’  )Nrë  rÆ   r¨  rï  rð  rš  rì  rí  r›  r  rœ  rî  rŸ  rª  rž  rÜ  rÝ  r   r¢  r¡  r¤  r£  rÞ  rß  r¥  r§  r¦  r©  r  r¨  rà  rª  r¬  r«  r®  r­  rá  r¯  r±  r°  r³  r²  râ  r´  r¶  rµ  r¸  r·  rã  r¹  r»  rº  r½  r¼  rä  rå  r¾  rÀ  r¿  r™  rÊ  rê  rë  rË  rÍ  rÌ  rÏ  rÎ  rÐ  rÑ  rÓ  rÒ  r!  rÁ  ræ  rç  rÂ  rÄ  rÃ  rÆ  rÅ  rè  ré  rÇ  rÉ  rÈ  rm  rÔ  Ú1rÕ  r×  rÖ  rn  rØ  rÙ  rÛ  rÚ  r  )Nr  )r  r  r  Z	enclosurer«  rÿ  rw   rx   r¡    s
   
ú

ú
ú
ú
ú
ú
ú
ú
úúú
ú	ú	ú	z8get_optionsimput.<locals>.generate_quote_table_Enclosurec              c      sæ  t | ƒ}|sdS ‡ fdd„| ¡ D ƒ}| dd¡› d| dd¡› d| dd¡› d	 ¡ }|d
 }d}|d
 }d}|d
 }d}|d
 }	d}
|d
 }d}|d
 }d}|d
 }d}|d
 }d}|d
 }d}|d
 }d}|d
 }d}|d
 }d}|d
 }|d
 }| |d |d |||d |d |d |d |d |||d |d |d |d  |d! |||d" |d# |d$ |d% |d& ||d' |d( |d) |d* |d+ ||	|d, |d- |d. |d/ |d0 |
||d1 |d2 |d3 |d4 |d5 |||d6 |d7 |d8 |d9 |d: |||d; |d< |d= |d> |d? |||d@ |dA |dB |dC |dD |||dE |dF |dG |dH |dI |||dJ |dK |dL |dM |dN |||dO |dP |dQ |dR |dS |||dT |dU |dV |dW |dX |||dY |dZ |d[ d\œZd]œd^œ}|S )_Nr¨  c                    s   i | ]\}}|ˆ |ƒ“qS rw   rw   r©  r­  rw   rx   r¯  ð  s      zEget_optionsimput.<locals>.Get_CotizacionTank_data.<locals>.<dictcomp>ZTankCapacityrë  r“  ÚTankTypeZTank_CapacityGALz galrì  zRupture basin switchzFuel level sensorzOverfill protection valvezDual fuel switcheszHigh fuel level switch (FDEP)zRemote Alarm Panelz(12 Ft above grade (extended vent piping)z+Combustible liquids- Keep fire away (qty.2)z NFPA 7044 identification (qty 2)zNo Smoking (qty 2)z)TTank number and safe fill height (qty.2)z100% Engine containmentÚTank_ConfigIDÚ
Tank_priceÚTank_TSheetÚTank_PriceTotÚItem_BreakTraySwitchÚBreakTraySwitchÚBreakTraySwitch_PriceÚBreakTraySwitch_TSheetÚBreakTraySwitc_PriceTotÚItem_FuelLevelSensorÚFuelLevelSensorÚFuelLevelSensor_PriceÚFuelLevelSensor_TSheetÚFuelLevelSenso_PriceTotÚItem_Tank_SpillContÚSpillContainmentÚSpillContainment_PriceÚSpillContainment_TSheetÚSpillContainme_PriceTotÚItem_OverfillValveÚOverfillValveÚOverfillValve_PriceÚOverfillValve_TSheetÚOverfillValve_PriceTotÚItem_DualFuelSwitchÚDualFuelSwitchesÚDualFuelSwitches_PriceÚDualFuelSwitches_TSheetÚDualFuelSwitch_PriceTotÚItem_HighFuelSwitchÚHighFuelSwitchÚHighFuelSwitch_PriceÚHighFuelSwitch_TSheetÚHighFuelSwitch_PriceTotÚItem_RemoteAlarmPÚRemoteAlarmPanelÚRemoteAlarmPanel_PriceÚRemoteAlarmPanel_TSheetÚRemoteAlarmPan_PriceTotÚItem_VentPipeÚVentPipeÚVentPipe_PriceÚVentPipe_TSheetÚVentPipe_PriceTotÚItem_FlammableLÚFlammableLiquidsÚFlammableLiquids_PriceÚFlammableLiquids_TSheetÚFlammableLiqui_PriceTotÚItem_NFPAIdentificatÚNFPAIdentificationÚNFPAIdentificat_PriceÚNFPAIdentificat_TSheetÚNFPAIdentifica_PriceTotÚItem_NoSmokingÚ	NoSmokingÚNoSmoking_PriceÚNoSmoking_TSheetÚNoSmoking_PriceTotÚItem_TankNumberÚ
TankNumberÚTankNumber_PriceÚTankNumber_TSheetÚTankNumber_PriceTotÚItem_FluidContainmentÚFluidContainmentÚFluidContainment_PriceÚFluidContainment_TSheetÚFluidContainme_PriceTot)Zr÷  rø  ÚBreakTraySwitchDESCÚBreakTraySwitchQTYTOTrù  rú  rû  rü  rý  ÚFuelLevelSensorDESCÚFuelLevelSensorQTYTOTrþ  rÿ  r   r  r  ÚTank_SpillContQTYTOTr  r  r  r  r  ÚOverfillValveDESCÚOverfillValveQTYTOTr  r	  r
  r  r  ÚDualFuelSwitchDESCÚDualFuelSwitchQTYTOTr  r  r  r  r  ÚHighFuelSwitchDESCÚHighFuelSwitchQTYTOTr  r  r  r  r  ÚRemoteAlarmPDESCÚRemoteAlarmPQTYTOTr  r  r  r  r  ÚVentPipeDESCÚVentPipeQTYTOTr  r  r  r  r   ÚFlammableLDESCÚFlammableLQTYTOTr!  r"  r#  r$  r%  ÚNFPAIdentificatDESCÚNFPAIdentificatQTYTOTr&  r'  r(  r)  r*  ÚNoSmokingDESCÚNoSmokingQTYTOTr+  r,  r-  r.  r/  ÚTankNumberDESCÚTankNumberQTYTOTr0  r1  r2  r3  r4  ÚFluidContainmentDESCÚFluidContainmentQTYTOTr5  r6  r7  )rò  ró  ÚTankDESCÚ
TankQTYTOTrô  rõ  rö  ÚConfigAndAccesories_Tank)r°   ræ  )r]   ri  r¬   rû  )r°   rj  rQ  rR  r8  r9  r:  r;  r=  r>  r?  r@  rA  rB  rC  rD  rE  rF  rG  rH  rI  rJ  rK  rL  rM  rN  rO  rP  r<  r’  r­  rw   rx   rœ  ê  s   2÷þ z1get_optionsimput.<locals>.Get_CotizacionTank_datac              
      sL  d}dl‡ fdd„	}|   di ¡}|r@|  d¡dkr@|||  d¡|  d	¡|  d
¡|  d¡|  d¡|  d¡ƒ7 }d|kr@|d }|  d¡dkrÈ|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dkr|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dkr\|||  d ¡|  d¡|  d!¡|  d"¡|  d#¡|  d$¡ƒ7 }|  d%¡dkr¦|||  d&¡|  d'¡|  d(¡|  d)¡|  d*¡|  d+¡ƒ7 }|  d,¡dkrð|||  d-¡|  d.¡|  d/¡|  d0¡|  d1¡|  d2¡ƒ7 }|  d3¡dkr:|||  d4¡|  d5¡|  d6¡|  d7¡|  d8¡|  d9¡ƒ7 }|  d:¡dkr„|||  d;¡|  d<¡|  d=¡|  d>¡|  d?¡|  d@¡ƒ7 }|  dA¡dkrÎ|||  dB¡|  dC¡|  dD¡|  dE¡|  dF¡|  dG¡ƒ7 }|  dH¡dkr|||  dI¡|  dJ¡|  dK¡|  dL¡|  dM¡|  dN¡ƒ7 }|  dO¡dkrb|||  dP¡|  dQ¡|  dR¡|  dS¡|  dT¡|  dU¡ƒ7 }|  dV¡dkr¬|||  dW¡|  dX¡|  dY¡|  dZ¡|  d[¡|  d\¡ƒ7 }|  d]¡dkrö|||  d^¡|  d_¡|  d`¡|  da¡|  db¡|  dc¡ƒ7 }|  dd¡dkr@|||  de¡|  df¡|  dg¡|  dh¡|  di¡|  dj¡ƒ7 }|dk7 }|S )mu  
        Genera el HTML para la tabla del tanque de combustible con enlaces a fichas tÃ©cnicas
    
        Args:
            CotizacionTank_data (dict): Datos del tanque y sus accesorios
        
        Returns:
            str: HTML para la tabla del tanque
        rò  Nc           	         s   |d ks|dks|dkrdS |dkr(dS ˆ |ƒ}ˆ |ƒ}|r\|  ¡ r\d|› d| pRd› d}n| pbd}d|› d|prd› d|p|d› d|› d|› d	S )
Nrë  rì   )rÆ   r¨  z!Seleccionela capacidad del tanqueúSelect the base tankrô  rõ  rö  r÷  rø  rù  rú  rü  rÿ  rw   rx   r  °  s(    þýüûúzGget_optionsimput.<locals>.generate_quote_table_Tank.<locals>.render_rowræ  rò  )Nrë  rÆ   r¨  z"Seleccione la capacidad del tanquerT  ró  rQ  rR  rô  rö  rõ  rS  rø  rª  r÷  r8  r9  rù  rû  rú  rý  rü  r:  r;  rþ  r   rÿ  r  r  r  r<  r  r  r  r  r  r=  r>  r  r
  r	  r  r  r?  r@  r  r  r  r  r  rA  rB  r  r  r  r  r  rC  rD  r  r  r  r  r  rE  rF  r  r  r  r   r  rG  rH  r!  r#  r"  r%  r$  rI  rJ  r&  r(  r'  r*  r)  rK  rL  r+  r-  r,  r/  r.  rM  rN  r0  r2  r1  r4  r3  rO  rP  r5  r7  r6  r  )Nr  )r’  r  r  Ztankr«  rÿ  rw   rx   r£  ¡  s
   
ú

ú
ú
ú
ú
ú
ú
ú
ú
ú
ú
ú
ú
ú	z3get_optionsimput.<locals>.generate_quote_table_Tankc           
   
      sÜ   t | ƒ}|sdS ‡ fdd„| ¡ D ƒ}t|d tƒr@t|d ƒn|d }|d }|| }|| }|| | }|d }| |d |d ||d |d ||d	 |d
œ|d |d |d ||d |d |d dœ||d  dœ}	|	S )uO   
        Agrega informaciÃ³n de garantÃ­as y pruebas a la cotizaciÃ³n.
        r¨  c                    s   i | ]\}}|ˆ |ƒ“qS rw   rw   r©  r­  rw   rx   r¯  ~  s      zNget_optionsimput.<locals>.Get_warranty_and_testing_pricing.<locals>.<dictcomp>ÚGaranty_Percentagerì  ÚItem_PrjWar_WarrantyÚGarantyÚGaranty_priceÚGaranty_PriceTot)rV  rW  ÚGarantyQTYTOTrU  ZGaranty_priceTABrX  ZGaranty_PriceTotTABrY  ÚItem_PrjWar_TestingÚTeastingÚTeasting_ConfigIDÚTeasting_priceÚTeasting_DocumentÚTeasting_PriceTot)r[  r\  r]  ÚTestingQTYTOTr^  r_  r`  )r°   ÚWarrantyÚTestingZPriceWarrantyAndTest)r]   ri  Ú
isinstancert   Úfloat)
r°   r“  rj  rU  rZ  Zunitaryprice_gensetrX  rY  ra  r”  r­  rw   rx   rž  t  s>    "øù	
ëz:get_optionsimput.<locals>.Get_warranty_and_testing_pricingc           	      S   s¢   t | ƒ}|sdS t| ƒ}|d |d |d |d dœ}d}|d td	ƒkr–tt|ƒƒ}|d | }|d
 dkrx|| }n|| }||d |d
 dœ}nd|i}|S )z0
        Retorna el valor del descuento
        )u2   Error: No se encontraron datos para al cotizaciÃ³nr¨   r¶   r·   r¸   r¹   )ZisoCodeÚstateÚ
isDiscountÚ	descuentor   rh  Ú0rg  T)rq  Zdiscountrg  rq  )r]   re   r   rt   )	r°   r  rj  Zcountry_discount_dataZrCountryDatarq  ZgranTotalDecimalrh  Úpayloadrw   rw   rx   r¦  ¥  s0    ü
ý ÿz-get_optionsimput.<locals>.get_country_discontc              
      sÀ   d}d‡ fdd„	}|   di ¡}|r`|  d¡r`|||  d¡|  d¡|  d¡|  d	¡|  d
¡dƒ7 }|   di ¡}|r´|  d¡r´|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|d7 }|S )u  
        Genera el HTML para la tabla de garantÃ­a y pruebas con enlaces a fichas tÃ©cnicas
    
        Args:
            CotizacionWarrantyAndTest_data (dict): Datos de garantÃ­a y pruebas
        
        Returns:
            str: HTML para la tabla de garantÃ­a y pruebas
        rò  Nc           	         s|   |d ks|dkrdS ˆ |ƒ}ˆ |ƒ}|rH|  ¡ rHd|› d| p>d› d}n| pNd}d|› d|p^d› d|phd› d|› d|› dS ró  rú  rü  rÿ  rw   rx   r  æ  s$    þýüûúzEget_optionsimput.<locals>.generate_quote_table_WT.<locals>.render_rowrb  rW  rV  rZ  rX  rY  rc  r\  r[  ra  r^  r`  r_  r  )Nr  )r”  r  r  ZwarrantyÚtestingrÿ  rw   rx   r¤  ×  s0    
ú
ú	z1get_optionsimput.<locals>.generate_quote_table_WTc              	   S   st   ddl }d}d}| || |j¡}|D ]J}d dd„ |D ƒ¡}z|rRt|ƒ}||7 }W q$ tk
rl   Y q$Y q$X q$|S )zè
        Suma todos los importes totales de una tabla HTML.
        
        Args:
            html_table (str): HTML de la tabla generada
            
        Returns:
            float: La suma total de todos los importes
        r   Ng        zY<tr>.*?<td>.*?</td>.*?<td>.*?</td>.*?<td>.*?</td>.*?<td>.*?</td>.*?<td>(.*?)</td>.*?</tr>rë  c                 s   s"   | ]}|  ¡ s|d kr|V  qdS )Ú.N)Úisdigit)rª  Úcrw   rw   rx   Ú	<genexpr>8  s       z=get_optionsimput.<locals>.sum_total_prices.<locals>.<genexpr>)ÚreÚfindallÚDOTALLÚjoinre  Ú
ValueError)Z
html_tablerp  Z	total_sumÚpatternÚmatchesZformatted_priceZclean_priceZprice_valuerw   rw   rx   r§     s    
z*get_optionsimput.<locals>.sum_total_pricesc              	   S   s<   | dkrdS zd  t| ƒ¡W S  ttfk
r6   Y dS X dS )zÄ
        Formatea un precio a formato de moneda (USD)
        
        Args:
            price (float): Precio a formatear
            
        Returns:
            str: Precio formateado
        Nz$0.00z${:,.2f})Úformatre  Ú	TypeErrorrt  )Zpricerw   rw   rx   r   E  s    
z&get_optionsimput.<locals>.format_pricec                 S   s   t | tƒrt| ƒS | S )u:   Convierte objetos Decimal a float para serializaciÃ³n JSON)rd  r   re  )Úobjrw   rw   rx   r®  W  s    
z)get_optionsimput.<locals>.convert_decimalz(/Ventas/VentasEUA/generar_pdf/<quote_id>c           ?         sÞ  zt| st dddœƒdfW S | td< tt ¡ ƒ}tj d¡}|› d| › }tj	}t
j |dd	d
d¡}t
j|dd t
j |d|› d¡}t
j |dd
dd¡}tjd||||gdd}| ¡ }	ˆ| ƒ}
|
d d }|
d d }|}t|dƒt}t|d|› ddd}d}d}d|› d| › }t||||ƒ}|d r:|d }t|| ƒ |}ˆ	|ƒ}|}||g}tj d d!¡ }td!kr\zVd"}t| ƒ}ˆ| ƒ}ˆ|ƒ}ˆ|ƒ}ˆ| ƒ}ˆ|ƒ}ˆ|ƒ} ˆ| ƒ}!ˆ|!ƒ}"ˆ|"ƒ}#ˆ| ƒ}$ˆ|$ƒ}%ˆ|%ƒ}&ˆ | ƒ}'ˆ
|'ƒ}(ˆ|(ƒ})ˆ| ƒ}*ˆ|*ƒ}+ˆ|+ƒ},||  |# |& |) |, }-ˆ| |-ƒ}.ˆ|.ƒ}/ˆ|/ƒ}0|-|0 }1ˆ| |1ƒ}2t ¡  d#¡}3| d$|3i|d% |d& d'œ|d( |d) |d* |d |d+ d,œ|d- |d |d. d/œ|| |#|&|)|,|0|1|2|d0 t ¡  d1¡| d2œd3œ}4| d4¡rrz@t |¡}
|
 ¡  td!dd5}5|5  |
j!¡ |5j"}6W 5 Q R X W n8 t#k
rn }7 zt$d6t|7ƒ› ƒ ‚ W 5 d }7~7X Y nX n2t
j %|¡s t$d7|› d8ƒ t&d9|› d8ƒ‚|}6t'd:|4d;}8t(|ˆjd< |d=}9|8|9_)t
j *|¡pÚd>}:z2t|6dƒ};|; +¡ }<|9j,|:d?|<d@ W 5 Q R X W n8 t#k
rF }7 zt$dAt|7ƒ› ƒ ‚ W 5 d }7~7X Y nX zˆ -|9¡ W nR t#k
r¨ }7 z2t$dBt|7ƒ› ƒ dCd l.}=t$dD|= /¡ › ƒ ‚ W 5 d }7~7X Y nX | d4¡rÎt
j %|6¡rÎt
 0|6¡ W nf t#k
r6 }7 zFdEt1ƒ krt
j %|6¡r| d4¡rt
 0|6¡ t$dFt|7ƒ› ƒ W 5 d }7~7X Y nX n"t d|dG iƒdfW  5 Q R £ W S W 5 Q R X t dH|dIdJœƒW S  t#k
rØ }7 zBdCd l.}=|= /¡ }>t$dK|>› ƒ t ddLt|7ƒ› dœƒdMf W Y ¢S d }7~7X Y nX d S )NNrq   u   ID de cotizaciÃ³n no vÃ¡lido)Ústatusr±   i  r°   ú/z,/Ventas/VentasEUA/VEUcotizadorbase?quote_id=ÚstaticZpdfÚVentasZ	VentasEUAT)Úexist_okZcotizacion_z.pdfÚpuppeteer_pdfzVEUcotizador.jsÚnode)Ústart_new_sessionrè  rÜ  ré  rà  ÚrbZTechnicalSheet)ÚstreamÚfilenameÚnamezB/domains/sycelephant.com/public_html/file/Ventas/EUA/Cotizaciones/z/Ventas/EUA/Cotizaciones/Ú_ÚexitoZurl_webÚDEBUGFu   CotizaciÃ³n del proyector°  r¶  r³  r´  rµ  rÙ  rÚ  rÛ  rÝ  rÞ  rß  rá  râ  ZCountry_Discountrr  )rz  r{  r|  r}  r~  r  r€  r  r‚  ZcountryDiscountr„  r°   )r°   r   rã  rè  ré  r–  )zhttp://zhttps://)ÚdeleteÚsuffixzERROR: Fallo al descargar PDF: zERROR: El archivo z
 no existezEl archivo z,/Ventas/VentasEUA/Mail/VEUcotizadormail.html)r³   ÚMAIL_USERNAME)ÚsenderÚ
recipientszdocumento.pdfzapplication/pdf)r„  Úcontent_typer³   z"ERROR: Error al adjuntar archivo: u$   ERROR: ExcepciÃ³n al enviar correo: r   zERROR: Detalles del error: Ú	temp_pathzC-------------Error al enviar el correo:----------------------------ZmensajeÚ
processingu#   La generaciÃ³n del PDF ha iniciado.)rz  Útokenr±   zError detallado: zError: rr   )2r   r   rt   ÚuuidÚuuid4r   Úhost_urlÚrstripr   Ú	root_pathÚosÚpathrs  ÚmakedirsÚ
subprocessÚPopenÚwaitÚopenr   r   rb   Úconfigr¬   r   r]   r
   rŠ  r‹  Ú
startswithÚrequestsÚraise_for_statusr   ÚwriteÚcontentr…  rs   r   ÚexistsÚFileNotFoundErrorr   r   r  ÚbasenameÚreadÚattachÚsendÚ	tracebackÚ
format_excÚunlinkÚlocals)?r°   r‘  Úbase_urlZ	quote_urlÚbase_dirZ
output_dirZoutput_pathÚscript_pathÚprocessZreturn_codeZ	respuestaZcorreo_customerZcorreo_SellerZruta_archivo_localÚfZtechnicalSheetZruta_pdfZcarpetarý  Ú	resultador„  Ú
directorioZurl_pdfZcorreos_destinoÚis_productionZasunto_correorj  r  rs  rz  rŽ  rt  r{  r  ru  r|  r  rv  r}  r‘  rw  r~  r’  rx  r  r“  r”  ry  r€  r  r•  r¶  r³   Ú	temp_filer  rv   Úcuerpo_htmlÚmsgZnombre_archivoÚfileZ	file_datarª  Ztraceback_str)r—  r˜  r™  rš  r›  rœ  r  rž  ÚappÚeliminar_pdfs_en_directoriorŸ  r   r¡  r¢  r£  r¤  r¥  r¦  Úmailr§  rw   rx   Úgenerar_pdf_cotizador]  sb   þý    ÿûú
ý




 ÿþûýôë%
ýý&
&,ý
þýz/get_optionsimput.<locals>.generar_pdf_cotizadorz,/Ventas/VentasEUA/check_pdf_status/<quoteId>c                 S   sX   t | ƒ}t|ƒ}tj dd¡ }tdkr2|d }ntj d¡}|› d}t	d||dœƒS )	Nrˆ  FTZRoutePDFr{  z /Ventas/Ventas_EUA/Cotizador_EUAZ	completed)rz  Úpdf_pathÚruta)
rc   rt   r   rž  r¬   r   r   r”  r•  r   )ZquoteIdZRutapdfZRuta_pdfrµ  r¿  r®  rw   rw   rx   Úcheck_pdf_statusG  s    

ýz*get_optionsimput.<locals>.check_pdf_statusc                 S   s   t j | d¡}t |¡}d}d}|D ]`}zt  |¡ |d7 }W q$ tk
rZ   |d7 }Y q$ tk
r‚ } z|d7 }W 5 d }~X Y q$X q$||dœS )Nz*.pdfr   r¶   )Ú
eliminadosÚfallidos)r—  r˜  rs  ÚglobÚremoveÚPermissionErrorrs   )r´  Zpatron_busquedaZarchivos_pdfrÁ  rÂ  Zarchivorv   rw   rw   rx   r»  Z  s    

z5get_optionsimput.<locals>.eliminar_pdfs_en_directorio)Úroute)$rº  r¼  ry   rz   r{   r|   r~   r   rƒ   r†   r‰   r‹   rŒ   r   r‘   r’   r“   r•   r—   r™   rš   r›   rœ   rŸ   r    r¡   r¢   r£   r¤   r¥   r¦   r­   rµ   rp  r½  rÀ  rw   )r—  r˜  r™  rš  r›  rœ  r  rž  rº  r®  r»  r   rŸ  r   r¡  r¢  r£  r¤  r¥  r¦  r¼  r´   r§  rx   Úget_optionsimput9   sÒ    






























   9.hk(;  2  M S i f z . T 8 T12I%4 j
rÇ  )|Úflaskr   r   r   r   r   r   r   r	   r
   r—  rÃ  r’  rš  Údecimalr   r   Ú App.Security_Module.UserPasswordr   Ú
flask_mailr   Útempfiler   rž  r   r   r   r   Zwerkzeug.datastructuresr   ZApp.Subir_Archivor   Z+Consultas_SQL.Ventas.VentasEUA.CotizadorSQLr   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   ZApp.api.controllerrj   ZApp.api.servicesrk   rl   rÇ  rw   rw   rw   rx   Ú<module>   s*   (ÿ ]