ITK-dev-shared-components 2.13.0__tar.gz → 2.14.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/PKG-INFO +1 -1
  2. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/eflyt/eflyt_case.py +3 -3
  3. itk_dev_shared_components-2.14.1/itk_dev_shared_components/eflyt/eflyt_letter.py +132 -0
  4. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/eflyt/eflyt_login.py +1 -1
  5. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/sap/opret_kundekontakt.py +56 -18
  6. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components.egg-info/PKG-INFO +1 -1
  7. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components.egg-info/SOURCES.txt +1 -0
  8. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/pyproject.toml +1 -1
  9. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/LICENSE +0 -0
  10. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/README.md +0 -0
  11. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/__init__.py +0 -0
  12. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/eflyt/__init__.py +0 -0
  13. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/eflyt/eflyt_search.py +0 -0
  14. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/eflyt/eflyt_util.py +0 -0
  15. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/getorganized/__init__.py +0 -0
  16. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/getorganized/go_api.py +0 -0
  17. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/graph/__init__.py +0 -0
  18. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/graph/authentication.py +0 -0
  19. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/graph/common.py +0 -0
  20. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/graph/file.py +0 -0
  21. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/graph/mail.py +0 -0
  22. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/graph/site.py +0 -0
  23. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/kmd_nova/__init__.py +0 -0
  24. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/kmd_nova/authentication.py +0 -0
  25. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/kmd_nova/cpr.py +0 -0
  26. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/kmd_nova/nova_cases.py +0 -0
  27. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/kmd_nova/nova_documents.py +0 -0
  28. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/kmd_nova/nova_notes.py +0 -0
  29. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/kmd_nova/nova_objects.py +0 -0
  30. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/kmd_nova/nova_tasks.py +0 -0
  31. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/kmd_nova/util.py +0 -0
  32. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/misc/__init__.py +0 -0
  33. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/misc/address_lookup.py +0 -0
  34. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/misc/cpr_util.py +0 -0
  35. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/misc/cvr_lookup.py +0 -0
  36. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/misc/file_util.py +0 -0
  37. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/sap/__init__.py +0 -0
  38. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/sap/fmcacov.py +0 -0
  39. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/sap/gridview_util.py +0 -0
  40. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/sap/multi_session.py +0 -0
  41. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/sap/sap_login.py +0 -0
  42. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/sap/sap_util.py +0 -0
  43. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/sap/tree_util.py +0 -0
  44. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/smtp/__init__.py +0 -0
  45. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components/smtp/smtp_util.py +0 -0
  46. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components.egg-info/dependency_links.txt +0 -0
  47. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components.egg-info/requires.txt +0 -0
  48. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/itk_dev_shared_components.egg-info/top_level.txt +0 -0
  49. {itk_dev_shared_components-2.13.0 → itk_dev_shared_components-2.14.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itk_dev_shared_components
3
- Version: 2.13.0
3
+ Version: 2.14.1
4
4
  Summary: Shared components to use in RPA projects
5
5
  Author-email: ITK Development <itk-rpa@mkb.aarhus.dk>
6
6
  Project-URL: Homepage, https://github.com/itk-dev-rpa/itk-dev-shared-components
@@ -144,9 +144,9 @@ def approve_case(browser: webdriver.Chrome):
144
144
  browser.find_element(By.ID, "ctl00_ContentPlaceHolder2_ptFanePerson_stcPersonTab1_btnGodkend").click()
145
145
  browser.find_element(By.ID, "ctl00_ContentPlaceHolder2_ptFanePerson_stcPersonTab1_btnApproveYes").click()
146
146
 
147
- approve_persons_button = browser.find_element(By.ID, "ctl00_ContentPlaceHolder2_ptFanePerson_stcPersonTab1_btnGodkendAlle")
148
- if approve_persons_button.is_enabled():
149
- approve_persons_button.click()
147
+ approve_persons_button = browser.find_elements(By.ID, "ctl00_ContentPlaceHolder2_ptFanePerson_stcPersonTab1_btnGodkendAlle")
148
+ if any(approve_persons_button) and approve_persons_button[0].is_enabled():
149
+ approve_persons_button[0].click()
150
150
  else:
151
151
  # Approve each person individually
152
152
  person_count = len(browser.find_elements(By.XPATH, '//table[@id="ctl00_ContentPlaceHolder2_GridViewMovingPersons"]//tr')) - 1
@@ -0,0 +1,132 @@
1
+ """This module contains functions for sending letters from a case in eFlyt."""
2
+
3
+ from selenium import webdriver
4
+ from selenium.webdriver.common.by import By
5
+ from selenium.webdriver.support.select import Select
6
+ from selenium.webdriver.support.ui import WebDriverWait
7
+ from selenium.webdriver.support import expected_conditions as EC
8
+ from selenium.common.exceptions import TimeoutException
9
+
10
+ from itk_dev_shared_components.eflyt import eflyt_case
11
+
12
+
13
+ def send_letter_to_anmelder(browser: webdriver.Chrome, letter_text: str) -> bool:
14
+ """Open the 'Breve' tab and send a letter to the anmelder using the 'Individuelt brev'-template.
15
+
16
+ Args:
17
+ browser: The webdriver browser object.
18
+ original_letter: The title of the original logiværtserklæring.
19
+
20
+ Returns:
21
+ bool: True if the letter was sent.
22
+ """
23
+ eflyt_case.change_tab(browser, tab_index=3)
24
+
25
+ click_letter_template(browser, "- Individuelt brev")
26
+
27
+ # Select the anmelder as the receiver
28
+ select_letter_receiver(browser, "anmelder")
29
+
30
+ # Click 'Send brev'
31
+ browser.find_element(By.ID, "ctl00_ContentPlaceHolder2_ptFanePerson_bcPersonTab_btnSendBrev").click()
32
+
33
+ # Insert the correct letter text
34
+ text_area = browser.find_element(By.ID, "ctl00_ContentPlaceHolder2_ptFanePerson_bcPersonTab_txtStandardText")
35
+ text_area.clear()
36
+ text_area.send_keys(letter_text)
37
+ # Click 'Ok'
38
+ browser.find_element(By.ID, "ctl00_ContentPlaceHolder2_ptFanePerson_bcPersonTab_btnOK").click()
39
+
40
+ # Check if a warning appears
41
+ if check_digital_post_warning(browser):
42
+ # Click 'Nej'
43
+ browser.find_element(By.ID, "ctl00_ContentPlaceHolder2_ptFanePerson_bcPersonTab_btnDeleteLetter").click()
44
+ return False
45
+
46
+ # Click 'Ja'
47
+ browser.find_element(By.ID, "ctl00_ContentPlaceHolder2_ptFanePerson_bcPersonTab_btnSaveLetter").click()
48
+ return True
49
+
50
+
51
+ def click_letter_template(browser: webdriver.Chrome, letter_name: str):
52
+ """Click the letter template with the given name under the "Breve" tab.
53
+
54
+ Args:
55
+ browser: The webdriver browser object.
56
+ letter_name: The literal name of the letter template to click.
57
+
58
+ Raises:
59
+ ValueError: If the letter wasn't found in the list.
60
+ """
61
+ letter_table = browser.find_element(By.ID, "ctl00_ContentPlaceHolder2_ptFanePerson_bcPersonTab_GridViewBreveNew")
62
+ rows = letter_table.find_elements(By.TAG_NAME, "tr")
63
+
64
+ for row in rows:
65
+ text = row.find_element(By.XPATH, "td[2]").text
66
+ if text == letter_name:
67
+ row.find_element(By.XPATH, "td[1]/input").click()
68
+ return
69
+
70
+ raise ValueError(f"Template with the name '{letter_name}' was not found.")
71
+
72
+
73
+ def select_letter_receiver(browser: webdriver.Chrome, receiver_name: str) -> None:
74
+ """Select the receiver for the letter. The search is fuzzy so it's only checked
75
+ if the options contains the receiver name.
76
+
77
+ I some cases there's only one option for the receiver in which
78
+ case there's a text label instead of a select element. In this
79
+ case the predefined name is still checked against the desired receiver.
80
+
81
+ Args:
82
+ browser: The webdriver browser object.
83
+ receiver_name: The name of the receiver to select.
84
+
85
+ Raises:
86
+ ValueError: If the given name isn't found in the select options.
87
+ ValueError: If the given name doesn't match the static label.
88
+ """
89
+ # Check if there is a select for the receiver name
90
+ try:
91
+ # Wait for the dropdown to be present
92
+ name_select_element = WebDriverWait(browser, 2).until(
93
+ EC.presence_of_element_located((By.ID, "ctl00_ContentPlaceHolder2_ptFanePerson_bcPersonTab_ddlModtager"))
94
+ )
95
+ name_select = Select(name_select_element)
96
+
97
+ # Wait until the dropdown has more than one option
98
+ WebDriverWait(browser, 2).until(lambda browser: len(name_select.options) > 1)
99
+
100
+ for i, option in enumerate(name_select.options):
101
+ if receiver_name in option.text:
102
+ name_select.select_by_index(i)
103
+ return
104
+
105
+ raise ValueError(f"'{receiver_name}' wasn't found on the list of possible receivers.")
106
+
107
+ except TimeoutException:
108
+ pass # Continue to the next check if the dropdown is not found
109
+
110
+ # If there's simply a label for the receiver, check if the name matches
111
+ try:
112
+ name_label = WebDriverWait(browser, 2).until(
113
+ EC.presence_of_element_located((By.ID, "ctl00_ContentPlaceHolder2_ptFanePerson_bcPersonTab_lblModtagerName"))
114
+ )
115
+ if receiver_name not in name_label.text:
116
+ raise ValueError(f"'{receiver_name}' didn't match the predefined receiver.")
117
+ except TimeoutException as exc:
118
+ raise ValueError("Receiver name label did not load in time.") from exc
119
+
120
+
121
+ def check_digital_post_warning(browser: webdriver.Chrome) -> bool:
122
+ """Check if a red warning text has appeared warning that
123
+ a letter must be sent manually.
124
+
125
+ Args:
126
+ browser: The webdriver browser object.
127
+
128
+ Returns:
129
+ bool: True if the warning has appeared.
130
+ """
131
+ warning_text = browser.find_elements(By.XPATH, "//font[@color='red']")
132
+ return len(warning_text) != 0 and "Dokumentet skal sendes manuelt" in warning_text[0].text
@@ -1,4 +1,4 @@
1
- """Module for logging into Eflyt/Daedalus/Whatchamacallit using Selenium"""
1
+ """Module for logging into Eflyt using Selenium"""
2
2
  import time
3
3
 
4
4
  from selenium import webdriver
@@ -26,6 +26,62 @@ def opret_kundekontakter(session, fp: str, aftaler: list[str] | None,
26
26
  """
27
27
  fmcacov.open_forretningspartner(session, fp)
28
28
 
29
+ if not aftaler:
30
+ _select_no_aftaler(session)
31
+ elif len(aftaler) == 1:
32
+ _select_single_aftale(session, aftaler[0])
33
+ else:
34
+ _select_multiple_aftaler(session, aftaler)
35
+
36
+ # Set art
37
+ session.findById("wnd[0]/usr/tabsTSTRIP/tabpT_CA/ssubSUBSR_TSTRIP:SAPLBPT1:0510/cmbBCONTD-CTYPE").Value = art
38
+
39
+ # Go to editor and paste (lock if multithreaded)
40
+ session.findById("wnd[0]/usr/subNOTICE:SAPLEENO:1002/btnEENO_TEXTE-EDITOR").press()
41
+ if lock:
42
+ lock.acquire()
43
+ _set_clipboard(notat)
44
+ session.findById("wnd[0]/tbar[1]/btn[9]").press()
45
+ if lock:
46
+ lock.release()
47
+
48
+ # Back and save
49
+ session.findById("wnd[0]/tbar[0]/btn[3]").press()
50
+ session.findById("wnd[0]/tbar[0]/btn[11]").press()
51
+
52
+ _confirm_kundekontakt(session, notat, art)
53
+
54
+
55
+ def _select_no_aftaler(session):
56
+ """Right click the fp and select 'Opret kundekontakt'.
57
+
58
+ Args:
59
+ session: The sap session object.
60
+ """
61
+ session.findById("wnd[0]/shellcont/shell").nodeContextMenu("GP0000000001")
62
+ session.findById("wnd[0]/shellcont/shell").selectContextMenuItem("POPUP")
63
+
64
+
65
+ def _select_single_aftale(session, aftale: str):
66
+ """Right click a single aftale and select 'Opret kundekontakt'.
67
+
68
+ Args:
69
+ session: The sap session object.
70
+ aftale: The aftale number.
71
+ """
72
+ tree = session.findById("wnd[0]/shellcont/shell")
73
+ node_key = tree_util.get_node_key_by_text(tree, aftale)
74
+ tree.nodeContextMenu(node_key)
75
+ tree.selectContextMenuItem("POPUP")
76
+
77
+
78
+ def _select_multiple_aftaler(session, aftaler: list[str]):
79
+ """Use 'Opret kundekontakt-flere' to select multiple aftaler.
80
+
81
+ Args:
82
+ session: The sap session object.
83
+ aftaler: The list of aftaler.
84
+ """
29
85
  # Click 'Opret kundekontakt-flere
30
86
  session.findById("wnd[0]/shellcont/shell").nodeContextMenu("GP0000000001")
31
87
  session.findById("wnd[0]/shellcont/shell").selectContextMenuItem("FLERE")
@@ -49,24 +105,6 @@ def opret_kundekontakter(session, fp: str, aftaler: list[str] | None,
49
105
  aftale_tree.ChangeCheckBox(key, name, True)
50
106
  session.findById("wnd[1]/usr/cntlCONTAINER_PSOBKEY/shellcont/shell/shellcont[1]/shell[0]").pressButton("OK")
51
107
 
52
- # Set art
53
- session.findById("wnd[0]/usr/tabsTSTRIP/tabpT_CA/ssubSUBSR_TSTRIP:SAPLBPT1:0510/cmbBCONTD-CTYPE").Value = art
54
-
55
- # Go to editor and paste (lock if multithreaded)
56
- session.findById("wnd[0]/usr/subNOTICE:SAPLEENO:1002/btnEENO_TEXTE-EDITOR").press()
57
- if lock:
58
- lock.acquire()
59
- _set_clipboard(notat)
60
- session.findById("wnd[0]/tbar[1]/btn[9]").press()
61
- if lock:
62
- lock.release()
63
-
64
- # Back and save
65
- session.findById("wnd[0]/tbar[0]/btn[3]").press()
66
- session.findById("wnd[0]/tbar[0]/btn[11]").press()
67
-
68
- _confirm_kundekontakt(session, notat, art)
69
-
70
108
 
71
109
  def _set_clipboard(text: str) -> None:
72
110
  """Private function to set text to the clipboard.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itk_dev_shared_components
3
- Version: 2.13.0
3
+ Version: 2.14.1
4
4
  Summary: Shared components to use in RPA projects
5
5
  Author-email: ITK Development <itk-rpa@mkb.aarhus.dk>
6
6
  Project-URL: Homepage, https://github.com/itk-dev-rpa/itk-dev-shared-components
@@ -9,6 +9,7 @@ itk_dev_shared_components.egg-info/requires.txt
9
9
  itk_dev_shared_components.egg-info/top_level.txt
10
10
  itk_dev_shared_components/eflyt/__init__.py
11
11
  itk_dev_shared_components/eflyt/eflyt_case.py
12
+ itk_dev_shared_components/eflyt/eflyt_letter.py
12
13
  itk_dev_shared_components/eflyt/eflyt_login.py
13
14
  itk_dev_shared_components/eflyt/eflyt_search.py
14
15
  itk_dev_shared_components/eflyt/eflyt_util.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "itk_dev_shared_components"
7
- version = "2.13.0"
7
+ version = "2.14.1"
8
8
  authors = [
9
9
  { name="ITK Development", email="itk-rpa@mkb.aarhus.dk" },
10
10
  ]