Browse Source

corrected bug with service name when not a product

ash 1 year ago
parent
commit
567b05d3f7
1 changed files with 12 additions and 3 deletions
  1. 12 3
      main.py

+ 12 - 3
main.py

@@ -262,8 +262,15 @@ for link in invoice_links :
 
     contract_lines = driver.find_elements(By.XPATH,"//div[contains(@id,'contrat-lines-container')]/div")
     logger.info(str(len(contract_lines)) + " service line found")
-    for line in contract_lines : 
-        service_name   = line.find_element(By.CLASS_NAME,"classfortooltip").text
+    for line in contract_lines :
+        
+        try :
+            service_name   = line.find_element(By.CLASS_NAME,"classfortooltip").text
+        except Exception :
+            element = line.find_element(By.CLASS_NAME,"fa-concierge-bell")
+            service_name = element.find_element(By.XPATH,'..').text
+            
+            
         service_status = line.find_element(By.CLASS_NAME,"badge-status").text
 
         logger.info(service_name)
@@ -447,7 +454,9 @@ for link in invoice_links :
             if args.mail:
                 logger.info("sending email to client...")
                 driver.find_element(By.XPATH, "//*[text()='Envoyer email']").click()
-                driver.find_element(By.ID, "sendto").send_keys(link.stripe_customer_mail)
+                if link.is_stripe_link :
+                    #here we add the stripe mail, if there is not stripe mail the crm mail will prevail. 
+                    driver.find_element(By.ID, "sendto").send_keys(link.stripe_customer_mail)
                 if contact_mail is not None : 
                     driver.find_element(By.ID, "sendtocc").send_keys(contact_mail)
                 driver.find_element(By.ID, "sendmail").click()