a
    §0iH‡ ã                   @   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   sR   zt ƒ } t| ƒdfW S  tyL } z tdt|ƒiƒdfW  Y d }~S d }~0 0 d S ©NéÈ   Úerroréô  )r   r   Ú	ExceptionÚstr©Z
fuel_typesÚe© rw   ú:/var/www/html/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   sR   zt ƒ } t| ƒdfW S  tyL } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sR   zt ƒ } t| ƒdfW S  tyL } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sR   zt ƒ } t| ƒdfW S  tyL } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sT   zt | ƒ}t|ƒdfW S  tyN } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sV   zt | |ƒ}t|ƒdfW S  tyP } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sX   zt | ||ƒ}t|ƒdfW S  tyR } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sZ   zt | |||ƒ}t|ƒdfW S  tyT } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sX   zt | ||||ƒ}t|ƒW S  tyR } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sN   zt ƒ } t| ƒW S  tyH } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sP   zt | ƒ}t|ƒW S  tyJ } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sh   zt | |||||ƒ}t|ƒW S  tyb } z.td|› ƒ tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sP   zt | ƒ}t|ƒW S  tyJ } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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yV } z.td|› ƒ tdt|ƒiƒdfW  Y d }~S d }~0 0 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yV } z.td|› ƒ tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sT   zt | ||ƒ}t|ƒW S  tyN } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sV   zt | |||ƒ}t|ƒW S  tyP } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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yV } z.td|› ƒ tdt|ƒiƒdfW  Y d }~S d }~0 0 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yV } z.td|› ƒ tdt|ƒiƒdfW  Y d }~S d }~0 0 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yV } z.td|› ƒ tdt|ƒiƒdfW  Y d }~S d }~0 0 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yV } z.td|› ƒ tdt|ƒiƒdfW  Y d }~S d }~0 0 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   s`   zt ƒ } t| ƒdfW S  tyZ } z.td|› ƒ tdt|ƒiƒdfW  Y d }~S d }~0 0 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   s`   zt ƒ } t| ƒdfW S  tyZ } z.td|› ƒ tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sP   zt | ƒ}t|ƒW S  tyJ } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sR   zt | |ƒ}t|ƒW S  tyL } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sR   zt ƒ } t| ƒdfW S  tyL } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sR   zt ƒ } t| ƒdfW S  tyL } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sR   zt ƒ } t| ƒdfW S  tyL } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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   sP   zt | ƒ}t|ƒW S  tyJ } z tdt|ƒiƒdfW  Y d }~S d }~0 0 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v rp| d	¡rpt|d	 ƒ}|rp||d
< t|ƒdfW S  tyÂ } z.td|› ƒ tdt|ƒiƒdfW  Y d }~S d }~0 0 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y† } z4tdt|ƒ› ƒ tdt|ƒdœƒdfW  Y d }~S d }~0 0 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   s  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&g d)¢g d*¢g d+¢g d,¢g d-¢g d.¢d/œ}tdƒD ]d}| 	¡ D ]T\}}|| \}}|| }|| }|d0krät
|||ƒ}|rät| |d ||ƒ qäqØ|d1 d2krlt|d1 ||ƒ}|rlt| |ƒ |d3 d'kršt|d3 ||ƒ}|ršt| |ƒ |d4 d'krÈt|d4 ||ƒ}|rÈt| |ƒ |d5 }|d6 }|d7 d0krt|d5 |||ƒ}|rt| |ƒ |d8 d0kr<t|d9 ||d: |ƒ}|r<t| |ƒ |d; d0krpt|d< ||d= |ƒ}|rpt| |ƒ |d> d0kr¤t|d? ||d@ |ƒ}|r¤t| |ƒ g dA¢}|D ]<\}}}|| d0kr°t|| ||ƒ}|r°t| ||ƒ q°t|d |d |d |dB |dC ||ƒ}|r&t| |ƒ |dD d'kr`t|dD ||dE |dFdG}|r`t| dH|ƒ |dI d'kršt|dI ||dJ |dKdG}|ršt| dL|ƒ |dM d'krÐt|dM ||dN |ƒ}|rÐt| dO|ƒ |dP d'kr t|dP ||ƒ}|r t| dQ|ƒ dRdSg}|dT } | dUkr,t ¡ }!|!  | ¡ |dV }"|"dUkrPt ¡ }#|# !| ¡ |dW }$|$dUkrtt ¡ }#|# "| ¡ |D ]D\}}}}%|| d0krxt#|| |||% |ƒ}|rxt$| ||ƒ qxg dX¢}&|&D ]<\}}}|| d0krÊt%|| ||ƒ}|rÊt$| ||ƒ qÊ|dY d'kr<t&|dY ||dZ |ƒ}'|'r<t'| |'ƒ |d[ d'krjt(|d[ ||ƒ}(|(rjt)| |(ƒ g d\¢}|D ]<\}}}|| d0krvt*|| ||ƒ}|rvt+| ||ƒ qvt,||d] |d^ ||ƒ})|)rÜt-| |)ƒ |d_ d'krt.|d_ ||ƒ}*|*rt/| d`|*ƒ g da¢}|D ]<\}}}|| d0krt0|| ||ƒ}|rt/| ||ƒ q|db d'kr†t1|db |||ƒ}+|+r†t2| |+ƒ t | ƒ}|dc d'krÂt3|dc ||dd |ƒ},|,rÂt4| |,ƒ W dFS  tyü }- zt5de|-› ƒ ‚ W Y dU}-~-n
dU}-~-0 0 dUS )fuB   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_idxZ
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  sV   ÷æú	
ü	


ü
ü
ü
ü
ýù	
ûûüýþ





üýü
ý
ýû
ýýü
ü
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i |¤Ž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_datarr  ry  ÚCotizacionBreakers_datars  rz  ÚCotizacionControl_datart  r{  ÚCotizacionEnclosure_dataru  r|  ÚCotizacionAccesories_datarv  r}  ÚCotizacionTank_datarw  r~  ÚGenset_priceÚCotizacionWarrantyAndTest_datarx  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   ro     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>  ó    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_infoÚ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®  û  r¯  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š  ô  sD    
ÿ
ÿ
þ
þ
ý
ýÿúþ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 u 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®  ^  r¯  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@  rA  ÚShunt_trip2DESCÚShunt_trip2_QTYTOTrB  rC  rD  rE  rF  ÚShunt_trip_wiring2DESCÚShunt_trip_wiring2_QTYTOTrG  rH  rI  rJ  rK  ÚItem_GFI2DESCÚItem_GFI2_QTYTOTrL  rM  rN  rO  rP  ÚProtection_type2_QTYTOTrQ  rR  rS  rT  rU  ÚAuxiliary_contacts2DESCÚAuxiliary_contacts2_QTYTOTrV  rW  rX  rY  rZ  ÚBreaker_Lock2DESCÚBreaker_Lock2_QTYTOTr[  r\  r]  r^  r_  ÚMotorized_Breaker2DESCÚMotorized_Breaker2_QTYTOTr`  ra  rb  )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)0rv  rw  ÚShunt_trip3DESCÚShunt_trip3_QTYTOTrx  ry  rz  r{  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˜  )rr  rÓ  ÚBreaker3QTYTOTrs  rt  ru  ÚConfigAndAccesories_Breaker3rÔ  )r°   rå  ©r]   ri  )-r°   rj  r:  r-  r.  r/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  rp  rc  rd  re  rf  rg  rh  ri  rj  rk  rl  rm  rn  ro  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vr|||  d¡|  d¡|  d	¡|  d
¡|  d¡|  d¡ƒ7 }d|v r|d }|  d¡dvrÔ|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dvr|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dvrh|||  d¡|  d¡|  d ¡|  d!¡|  d"¡|  d#¡ƒ7 }|  d$¡dvr²|||  d%¡|  d$¡|  d&¡|  d'¡|  d(¡|  d)¡ƒ7 }|  d*¡dvrü|||  d+¡|  d,¡|  d-¡|  d.¡|  d/¡|  d0¡ƒ7 }|  d1¡dvrF|||  d2¡|  d3¡|  d4¡|  d5¡|  d6¡|  d7¡ƒ7 }|  d8¡dvr|||  d9¡|  d:¡|  d;¡|  d<¡|  d=¡|  d>¡ƒ7 }|  d?i ¡}|r|  d?¡dvr|||  d@¡|  d?¡|  dA¡|  dB¡|  dC¡|  dD¡ƒ7 }dE|v r|dE }|  dF¡dvrH|||  dG¡|  dH¡|  dI¡|  dJ¡|  dK¡|  dL¡ƒ7 }|  dM¡dvr’|||  dN¡|  dO¡|  dP¡|  dQ¡|  dR¡|  dS¡ƒ7 }|  dT¡dvrÜ|||  dU¡|  dV¡|  dW¡|  dX¡|  dY¡|  dZ¡ƒ7 }|  d[¡dvr&|||  d\¡|  d[¡|  d]¡|  d^¡|  d_¡|  d`¡ƒ7 }|  da¡dvrp|||  db¡|  dc¡|  dd¡|  de¡|  df¡|  dg¡ƒ7 }|  dh¡dvrº|||  di¡|  dj¡|  dk¡|  dl¡|  dm¡|  dn¡ƒ7 }|  do¡dvr|||  dp¡|  dq¡|  dr¡|  ds¡|  dt¡|  du¡ƒ7 }|  dvi ¡}|rx|  dv¡dvrx|||  dw¡|  dv¡|  dx¡|  dy¡|  dz¡|  d{¡ƒ7 }d||v rx|d| }|  d}¡dvr¼|||  d~¡|  d¡|  d€¡|  d¡|  d‚¡|  dƒ¡ƒ7 }|  d„¡dvr|||  d…¡|  d†¡|  d‡¡|  dˆ¡|  d‰¡|  dŠ¡ƒ7 }|  d‹¡dvrP|||  dŒ¡|  d¡|  dŽ¡|  d¡|  d¡|  d‘¡ƒ7 }|  d’¡dvrš|||  d“¡|  d’¡|  d”¡|  d•¡|  d–¡|  d—¡ƒ7 }|  d˜¡dvrä|||  d™¡|  dš¡|  d›¡|  dœ¡|  d¡|  dž¡ƒ7 }|  dŸ¡dvr.|||  d ¡|  d¡¡|  d¢¡|  d£¡|  d¤¡|  d¥¡ƒ7 }|  d¦¡dv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 u s|dks|dkrdS |dv 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  r:  r  r
  r	  r;  r  ©Nrì  rì   r  r-  r.  r  r  r  r  r  r/  r0  r  r  r  r  r  r1  r2  r  r  r  r  r  r3  r  r  r  r   r  r4  r5  r!  r#  r"  r$  r  r6  r7  r%  r'  r&  r)  r(  r8  r9  r*  r,  r+  rÒ  r<  rp  r=  r?  r>  rq  rA  r@  rc  rd  rB  rD  rC  rF  rE  re  rf  rG  rI  rH  rK  rJ  rg  rh  rL  rN  rM  rP  rO  ri  rQ  rS  rR  rU  rT  rj  rk  rV  rX  rW  rZ  rY  rl  rm  r[  r]  r\  r_  r^  rn  ro  r`  rb  ra  rÓ  rr  r¦  rs  ru  rt  r§  rw  rv  r™  rš  rx  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¡  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®  Ø  r¯  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vrœ|||  d¡|  d¡|  d	¡|  d
¡|  d¡|  d¡ƒ7 }d|v rœ|d }|  d¡dvrÈ|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dvr|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dvr\|||  d¡|  d¡|  d¡|  d ¡|  d!¡|  d"¡ƒ7 }|  d#¡dvr¦|||  d#¡|  d$¡|  d%¡|  d&¡|  d'¡|  d(¡ƒ7 }|  d)¡dvrð|||  d*¡|  d+¡|  d,¡|  d-¡|  d.¡|  d/¡ƒ7 }|  d0¡dvr:|||  d1¡|  d2¡|  d3¡|  d4¡|  d5¡|  d6¡ƒ7 }d7|v r|d7 }|  d8¡dvr–|||  d9¡|  d:¡|  d;¡|  d<¡|  d=¡|  d>¡ƒ7 }|  d?¡dvrà|||  d?¡|  d@¡|  dA¡|  dB¡|  dC¡|  dD¡ƒ7 }|  dE¡dvr*|||  dF¡|  dG¡|  dH¡|  dI¡|  dJ¡|  dK¡ƒ7 }|  dL¡dvrt|||  dM¡|  dN¡|  dO¡|  dP¡|  dQ¡|  dR¡ƒ7 }|  dS¡dvr¾|||  dT¡|  dU¡|  dV¡|  dW¡|  dX¡|  dY¡ƒ7 }|  dZ¡dvr|||  d[¡|  d\¡|  d]¡|  d^¡|  d_¡|  d`¡ƒ7 }|  da¡dbvrR|||  dc¡|  dd¡|  de¡|  df¡|  dg¡|  dh¡ƒ7 }|  di¡dv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 u s|dks|dkrdS |dv 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®  ’  r¯  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ÚBaseHeaterDESCr0  r1  r2  r3  r4  ÚBatterySwitchQTYTOTÚBatterySwitchDESCr5  r6  r7  r8  r9  ÚBatteryHolderQTYTOTÚBatteryHolderDESCr:  r;  r<  r=  r>  ÚOilHeaterQTYTOTÚOilHeaterDESCr?  r@  rA  rB  rC  ÚOilLevelSwitchQTYTOTÚOilLevelSwitchDESCrD  rE  rF  rG  rH  ÚCommonAlarmRelayQTYTOTÚCommonAlarmRelayDESCrI  rJ  rK  rL  rM  ÚFunctionRelayQTYTOTÚFunctionRelayDESCrN  rO  rP  rQ  rR  ÚCoolantQTYTOTÚCoolantDESCrS  rT  rU  rV  rW  Ú	OilQTYTOTÚOilDESCrX  rY  rZ  r[  r\  ÚDisconnectSwitchesQTYTOTÚDisconnectSwitchesDESCr]  r^  r_  r`  ra  rb  ÚEStopQTYTOTrc  rd  re  rf  rg  ÚRemoteEStopQTYTOTÚRemoteEStopDESCrh  ri  rj  rk  rl  ÚSpringIsolatorQTYTOTrm  rn  ro  )r°   ÚAdditionalAccesories_Gensetr¨  )%r°   rj  rq  rp  rs  rr  ru  rt  rw  rv  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¬  rw   rx   r–  Œ  sR   € àþ 'z7get_optionsimput.<locals>.Get_CotizacionAccesories_datac              
      sX  d}d…‡ fdd„	}|   di ¡}|  d¡dvrf|||  d¡|  d	¡|  d
¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dvr®|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dvrö|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dvr@|||  d¡|  d¡|  d¡|  d ¡|  d!¡|  d"¡ƒ7 }|  d#¡dvrŠ|||  d$¡|  d%¡|  d&¡|  d'¡|  d(¡|  d)¡ƒ7 }|  d*¡dvrÔ|||  d+¡|  d,¡|  d-¡|  d.¡|  d/¡|  d0¡ƒ7 }|  d1¡dvr|||  d2¡|  d3¡|  d4¡|  d5¡|  d6¡|  d7¡ƒ7 }|  d8¡dvrh|||  d9¡|  d:¡|  d;¡|  d<¡|  d=¡|  d>¡ƒ7 }|  d?¡dvr²|||  d@¡|  dA¡|  dB¡|  dC¡|  dD¡|  dE¡ƒ7 }|  dF¡dvrü|||  dG¡|  dH¡|  dI¡|  dJ¡|  dK¡|  dL¡ƒ7 }|  dM¡dvrF|||  dN¡|  dO¡|  dP¡|  dQ¡|  dR¡|  dS¡ƒ7 }|  dT¡dvr|||  dU¡|  dV¡|  dW¡|  dX¡|  dY¡|  dZ¡ƒ7 }|  d[¡dvrÚ|||  d\¡|  d]¡|  d^¡|  d_¡|  d`¡|  da¡ƒ7 }|  db¡dvr$|||  dc¡|  dd¡|  de¡|  df¡|  dg¡|  dh¡ƒ7 }|  di¡dvrn|||  dj¡|  dk¡|  dl¡|  dm¡|  dn¡|  do¡ƒ7 }|  dp¡dqvr¸|||  dr¡|  dp¡|  ds¡|  dt¡|  du¡|  dv¡ƒ7 }|  dw¡dvr|||  dx¡|  dy¡|  dz¡|  d{¡|  d|¡|  d}¡ƒ7 }|  d~¡dqv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 u s|dks|dkrdS |dv 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  rq  rp  r  r  r  r  r  rs  rr  r  r  r  r   r  ru  rt  r!  r#  r"  r%  r$  rw  rv  r&  r(  r'  r*  r)  ry  rx  r+  r-  r,  r/  r.  r{  rz  r0  r2  r1  r4  r3  r}  r|  r5  r7  r6  r9  r8  r  r~  r:  r<  r;  r>  r=  r  r€  r?  rA  r@  rC  rB  rƒ  r‚  rD  rF  rE  rH  rG  r…  r„  rI  rK  rJ  rM  rL  r‡  r†  rN  rP  rO  rR  rQ  r‰  rˆ  rS  rU  rT  rW  rV  r‹  rŠ  rX  rZ  rY  r\  r[  r  rŒ  r]  r_  r^  ra  r  r`  rŽ  rc  re  rd  rg  rf  r  r  rh  rj  ri  rl  rk  r‘  rm  ro  rn  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
  r¯  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_inrl  Úlouvers_in_priceÚlouvers_in_tsheetÚlouvers_in_pricetotÚItem_louvers_outrm  Ú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Õ  rl  zlouvers_in_price:r×  rØ  rÙ  rm  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vr4|||  d¡|  d	¡|  d
¡|  d¡|  d¡|  d¡ƒ7 }d|v r4|d }|  d¡dvrÈ|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dvr|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dvr\|||  d ¡|  d¡|  d!¡|  d"¡|  d#¡|  d$¡ƒ7 }|  d%¡dvr¦|||  d&¡|  d%¡|  d'¡|  d(¡|  d)¡|  d*¡ƒ7 }|  d+¡dvrð|||  d,¡|  d+¡|  d-¡|  d.¡|  d/¡|  d0¡ƒ7 }|  d1¡dvr:|||  d2¡|  d1¡|  d3¡|  d4¡|  d5¡|  d6¡ƒ7 }|  d7¡dvr„|||  d8¡|  d9¡|  d:¡|  d;¡|  d<¡|  d=¡ƒ7 }|  d>¡dvrÎ|||  d?¡|  d@¡|  dA¡|  dB¡|  dC¡|  dD¡ƒ7 }|  dE¡dvr|||  dF¡|  dE¡|  dG¡|  dH¡|  dI¡|  dJ¡ƒ7 }|  dK¡dvrb|||  dL¡|  dM¡|  dN¡|  dO¡|  dP¡|  dQ¡ƒ7 }|  dR¡dvr¬|||  dS¡|  dT¡|  dU¡|  dV¡|  dW¡|  dX¡ƒ7 }|  dY¡dvrð|||  dZ¡|  dY¡d[|  d\¡|  d]¡|  d^¡ƒ7 }|  d_¡dv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 u s|dks|dkrdS |dv 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É  rl  rÕ  Ú1rÖ  rØ  r×  rm  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®  ð  r¯  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/  r0  ÚTankNumberDESCÚTankNumberQTYTOTr1  r2  r3  r4  r5  ÚFluidContainmentDESCÚFluidContainmentQTYTOTr6  r7  r8  )ró  rô  ÚTankDESCÚ
TankQTYTOTrõ  rö  r÷  ÚConfigAndAccesories_Tank)r°   rç  )r]   ri  r¬   rü  )r°   rj  rR  rS  r9  r:  r;  r<  r>  r?  r@  rA  rB  rC  rD  rE  rF  rG  rH  rI  rJ  rK  rL  rM  rN  rO  rP  rQ  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vr@|||  d¡|  d	¡|  d
¡|  d¡|  d¡|  d¡ƒ7 }d|v r@|d }|  d¡dvrÈ|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dvr|||  d¡|  d¡|  d¡|  d¡|  d¡|  d¡ƒ7 }|  d¡dvr\|||  d ¡|  d¡|  d!¡|  d"¡|  d#¡|  d$¡ƒ7 }|  d%¡dvr¦|||  d&¡|  d'¡|  d(¡|  d)¡|  d*¡|  d+¡ƒ7 }|  d,¡dvrð|||  d-¡|  d.¡|  d/¡|  d0¡|  d1¡|  d2¡ƒ7 }|  d3¡dvr:|||  d4¡|  d5¡|  d6¡|  d7¡|  d8¡|  d9¡ƒ7 }|  d:¡dvr„|||  d;¡|  d<¡|  d=¡|  d>¡|  d?¡|  d@¡ƒ7 }|  dA¡dvrÎ|||  dB¡|  dC¡|  dD¡|  dE¡|  dF¡|  dG¡ƒ7 }|  dH¡dvr|||  dI¡|  dJ¡|  dK¡|  dL¡|  dM¡|  dN¡ƒ7 }|  dO¡dvrb|||  dP¡|  dQ¡|  dR¡|  dS¡|  dT¡|  dU¡ƒ7 }|  dV¡dvr¬|||  dW¡|  dX¡|  dY¡|  dZ¡|  d[¡|  d\¡ƒ7 }|  d]¡dvrö|||  d^¡|  d_¡|  d`¡|  da¡|  db¡|  dc¡ƒ7 }|  dd¡dv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 u s|dks|dkrdS |dv 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 tanquerU  rô  rR  rS  rõ  r÷  rö  rT  rù  r«  rø  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@  rA  r  r  r  r  r  rB  rC  r  r  r  r  r  rD  rE  r  r  r  r  r  rF  rG  r  r  r  r!  r   rH  rI  r"  r$  r#  r&  r%  rJ  rK  r'  r)  r(  r+  r*  rL  rM  r,  r.  r-  r0  r/  rN  rO  r1  r3  r2  r5  r4  rP  rQ  r6  r8  r7  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®  ~  r¯  zNget_optionsimput.<locals>.Get_warranty_and_testing_pricing.<locals>.<dictcomp>ÚGaranty_Percentagerí  ÚItem_PrjWar_WarrantyÚGarantyÚGaranty_priceÚGaranty_PriceTot)rW  rX  ÚGarantyQTYTOTrV  ZGaranty_priceTABrY  ZGaranty_PriceTotTABrZ  ÚItem_PrjWar_TestingÚTeastingÚTeasting_ConfigIDÚTeasting_priceÚTeasting_DocumentÚTeasting_PriceTot)r\  r]  r^  ÚTestingQTYTOTr_  r`  ra  )r°   ÚWarrantyÚTestingZPriceWarrantyAndTest)r]   ri  Ú
isinstancert   Úfloat)
r°   r’  rj  rV  r[  Zunitaryprice_gensetrY  rZ  rb  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   ri  Ú0rh  T)rp  Zdiscountrh  rp  )r]   re   r   rt   )	r°   r€  rj  Zcountry_discount_dataZrCountryDatarp  ZgranTotalDecimalri  Úpayloadrw   rw   rx   r¥  ¥  s.    ü
ýÿ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 u 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_rowrc  rX  rW  r[  rY  rZ  rd  r]  r\  rb  r_  ra  r`  r  )Nr  )r“  r  r  ZwarrantyÚtestingr   rw   rx   r£  ×  s0    
ú
ú	z1get_optionsimput.<locals>.generate_quote_table_WTc              	   S   sr   ddl }d}d}| || |j¡}|D ]H}d dd„ |D ƒ¡}z|rRt|ƒ}||7 }W q$ tyj   Y q$Y q$0 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  r¯  z=get_optionsimput.<locals>.sum_total_prices.<locals>.<genexpr>)ÚreÚfindallÚDOTALLÚjoinrf  Ú
ValueError)Z
html_tablerq  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u rdS zd  t| ƒ¡W S  ttfy4   Y dS 0 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})Úformatrf  Ú	TypeErrorru  )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)re  r   rf  )Úobjrw   rw   rx   r­  W  s    
z)get_optionsimput.<locals>.convert_decimalz(/Ventas/VentasEUA/generar_pdf/<quote_id>c           ?         s(  zÀ| 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|d|› ddd}d}d}d|› d| › }t||||ƒ}|d rn|d }t|| ƒ |}ˆ	|ƒ}|}||g}tj d d!¡ }td!kr’zˆd"}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¡rŠzVt |¡}
|
 ¡  td!dd5"}5|5  |
j!¡ |5j"}6W d   ƒ n1 s@0    Y  W n: t#y† }7 z t$d6t|7ƒ› ƒ ‚ W Y d }7~7n
d }7~70 0 n2t
j %|¡s¸t$d7|› d8ƒ t&d9|› d8ƒ‚|}6t'd:|4d;}8t(|ˆjd< |d=}9|8|9_)t
j *|¡pòd>}:zHt|6dƒ(};|; +¡ }<|9j,|:d?|<d@ W d   ƒ n1 s00    Y  W n: t#yv }7 z t$dAt|7ƒ› ƒ ‚ W Y d }7~7n
d }7~70 0 zˆ -|9¡ W nT t#yÚ }7 z:t$dBt|7ƒ› ƒ dCd l.}=t$dD|= /¡ › ƒ ‚ W Y d }7~7n
d }7~70 0 | d4¡r t
j %|6¡r t
 0|6¡ W nh t#yj }7 zNdEt1ƒ v rDt
j %|6¡rD| d4¡rDt
 0|6¡ t$dFt|7ƒ› ƒ W Y d }7~7n
d }7~70 0 n$t d|dG iƒdfW  d   ƒ W S W d   ƒ n1 s¨0    Y  t dH|dIdJœƒW S  t#y" }7 zFdCd l.}=|= /¡ }>t$dK|>› ƒ t ddLt|7ƒ› dœƒdMfW  Y d }7~7S d }7~70 0 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_Discountrq  )ry  rz  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:----------------------------ÚmensajeÚ
processingu#   La generaciÃ³n del PDF ha iniciado.)r{  Útokenr±   zError detallado: zError: rr   )2r   r   rt   ÚuuidÚuuid4r   Úhost_urlÚrstripr   Ú	root_pathÚosÚpathrt  Ú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_codeÚ	respuestaZcorreo_customerZcorreo_SellerZruta_archivo_localÚfZtechnicalSheetZruta_pdfZcarpetarþ  Ú	resultador…  Ú
directorioZurl_pdfZcorreos_destinoÚis_productionZasunto_correorj  rŒ  rr  ry  r  rs  rz  rŽ  rt  r{  r  ru  r|  r  rv  r}  r‘  rw  r~  r’  r“  rx  r  r€  r”  r¶  r³   Ú	temp_filer  rv   Úcuerpo_htmlÚmsgÚ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]  sX   þý
ÿûú
ý




ÿþûýôë%
*ýý*&
*Dý
þý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)r{  Ú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yX   |d7 }Y q$ ty‚ } z|d7 }W Y d }~q$d }~0 0 q$||dœS )Nz*.pdfr   r¶   )Ú
eliminadosÚfallidos)r™  rš  rt  ÚglobÚremoveÚPermissionErrorrs   )r·  Zpatron_busquedaZarchivos_pdfrÅ  rÆ  Ú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µ   ro  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*   (ÿ ]