ソースを参照

corrected bug with service name when not a product

ash 1 年間 前
コミット
567b05d3f7
1 ファイル変更12 行追加3 行削除
  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()