|
@@ -127,7 +127,7 @@ class invoice_link :
|
|
|
|
|
|
|
|
|
|
stripe_customer_ref : str
|
|
stripe_customer_ref : str
|
|
- stripe_customer_name : str
|
|
|
|
|
|
+ stripe_customer_name : str = ""
|
|
stripe_customer_mail : str
|
|
stripe_customer_mail : str
|
|
stripe_paid_amount : float
|
|
stripe_paid_amount : float
|
|
stripe_epoch_date : int
|
|
stripe_epoch_date : int
|
|
@@ -219,12 +219,16 @@ logger.info(" --- --------------------------------------------------------------
|
|
from selenium import webdriver
|
|
from selenium import webdriver
|
|
from selenium.webdriver.common.keys import Keys
|
|
from selenium.webdriver.common.keys import Keys
|
|
from selenium.webdriver.common.by import By
|
|
from selenium.webdriver.common.by import By
|
|
|
|
+from selenium.webdriver.edge.options import Options
|
|
import logging
|
|
import logging
|
|
from selenium.webdriver.remote.remote_connection import LOGGER
|
|
from selenium.webdriver.remote.remote_connection import LOGGER
|
|
LOGGER.setLevel(logging.CRITICAL)
|
|
LOGGER.setLevel(logging.CRITICAL)
|
|
|
|
|
|
-
|
|
|
|
logger.info("CRM Login")
|
|
logger.info("CRM Login")
|
|
|
|
+
|
|
|
|
+# Launch Microsoft Edge (Chromium)
|
|
|
|
+options = Options()
|
|
|
|
+options.add_experimental_option('excludeSwitches', ['enable-logging'])
|
|
driver = webdriver.Edge()
|
|
driver = webdriver.Edge()
|
|
driver.get(str(dolibarr_url) + "/index.php")
|
|
driver.get(str(dolibarr_url) + "/index.php")
|
|
assert "Identifiant" in driver.title
|
|
assert "Identifiant" in driver.title
|
|
@@ -254,14 +258,14 @@ logger.info("iterating over invoice links")
|
|
link : invoice_link
|
|
link : invoice_link
|
|
for link in invoice_links :
|
|
for link in invoice_links :
|
|
link.crm_contract_activated == False
|
|
link.crm_contract_activated == False
|
|
- logger.debug("treating contract : " + link.contract_number)
|
|
|
|
|
|
+ logger.info("treating contract : " + link.contract_number + " for " + link.stripe_customer_name)
|
|
driver.get(dolibarr_url + "/contrat/card.php?id=" + str(link.contract_number))
|
|
driver.get(dolibarr_url + "/contrat/card.php?id=" + str(link.contract_number))
|
|
logger.debug("testing if services are activated")
|
|
logger.debug("testing if services are activated")
|
|
#iterating service
|
|
#iterating service
|
|
|
|
|
|
|
|
|
|
contract_lines = driver.find_elements(By.XPATH,"//div[contains(@id,'contrat-lines-container')]/div")
|
|
contract_lines = driver.find_elements(By.XPATH,"//div[contains(@id,'contrat-lines-container')]/div")
|
|
- logger.info(str(len(contract_lines)) + " service line found")
|
|
|
|
|
|
+ logger.debug(str(len(contract_lines)) + " service line found")
|
|
for line in contract_lines :
|
|
for line in contract_lines :
|
|
|
|
|
|
try :
|
|
try :
|
|
@@ -273,8 +277,8 @@ for link in invoice_links :
|
|
|
|
|
|
service_status = line.find_element(By.CLASS_NAME,"badge-status").text
|
|
service_status = line.find_element(By.CLASS_NAME,"badge-status").text
|
|
|
|
|
|
- logger.info(service_name)
|
|
|
|
- logger.info(service_status)
|
|
|
|
|
|
+ logger.debug(service_name)
|
|
|
|
+ logger.debug(service_status)
|
|
|
|
|
|
if "En service" in service_status :
|
|
if "En service" in service_status :
|
|
logger.debug("crm contract have at least one service activated")
|
|
logger.debug("crm contract have at least one service activated")
|
|
@@ -282,7 +286,7 @@ for link in invoice_links :
|
|
|
|
|
|
|
|
|
|
if link.crm_contract_activated == False:
|
|
if link.crm_contract_activated == False:
|
|
- logger.info("the contract with number " + link.contract_number + " have all services disabled, SKIPPING CONTRACT")
|
|
|
|
|
|
+ logger.debug("the contract with number " + link.contract_number + " have all services disabled, SKIPPING CONTRACT")
|
|
continue
|
|
continue
|
|
|
|
|
|
contract_links_table = driver.find_element(By.XPATH,'//table[@data-block="showLinkedObject"]')
|
|
contract_links_table = driver.find_element(By.XPATH,'//table[@data-block="showLinkedObject"]')
|
|
@@ -307,14 +311,14 @@ for link in invoice_links :
|
|
logger.debug("invoice is unpaid")
|
|
logger.debug("invoice is unpaid")
|
|
current_invoice.unpaid = True
|
|
current_invoice.unpaid = True
|
|
|
|
|
|
- logger.info("-----")
|
|
|
|
|
|
+ logger.debug("-----")
|
|
if link.is_stripe_link :
|
|
if link.is_stripe_link :
|
|
- logger.info("CRM linked invoice for customer : " + link.stripe_customer_name + " - " + link.stripe_customer_mail)
|
|
|
|
- logger.info("CRM linked invoice url : " + current_invoice.url)
|
|
|
|
- logger.info("CRM linked invoice date : " + str(current_invoice.amount))
|
|
|
|
- logger.info("CRM linked invoice amount : " + str(current_invoice.date))
|
|
|
|
- logger.info("CRM linked invoice unpaid ? : " + str(current_invoice.unpaid))
|
|
|
|
- logger.info("-----")
|
|
|
|
|
|
+ logger.debug("CRM linked invoice for customer : " + link.stripe_customer_name + " - " + link.stripe_customer_mail)
|
|
|
|
+ logger.debug("CRM linked invoice url : " + current_invoice.url)
|
|
|
|
+ logger.debug("CRM linked invoice date : " + str(current_invoice.amount))
|
|
|
|
+ logger.debug("CRM linked invoice amount : " + str(current_invoice.date))
|
|
|
|
+ logger.debug("CRM linked invoice unpaid ? : " + str(current_invoice.unpaid))
|
|
|
|
+ logger.debug("-----")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -471,4 +475,5 @@ logger.info(" --- --------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
driver.close()
|
|
driver.close()
|
|
|
|
+driver.quit()
|
|
exit(0)
|
|
exit(0)
|