Skip to content

Commit a794a41

Browse files
authored
Merge pull request #115 from itk-dev-rpa/feature/single-kundekontakt
Feature/single kundekontakt
2 parents 6c2d70b + d39e14a commit a794a41

File tree

2 files changed

+60
-18
lines changed

2 files changed

+60
-18
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- SAP: Changed how kundekontakter are created with 0 or 1 aftaler.
13+
1014
### Added
1115

1216
- Eflyt: Added functions for sending letters.

itk_dev_shared_components/sap/opret_kundekontakt.py

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,62 @@ def opret_kundekontakter(session, fp: str, aftaler: list[str] | None,
2626
"""
2727
fmcacov.open_forretningspartner(session, fp)
2828

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+
"""
2985
# Click 'Opret kundekontakt-flere
3086
session.findById("wnd[0]/shellcont/shell").nodeContextMenu("GP0000000001")
3187
session.findById("wnd[0]/shellcont/shell").selectContextMenuItem("FLERE")
@@ -49,24 +105,6 @@ def opret_kundekontakter(session, fp: str, aftaler: list[str] | None,
49105
aftale_tree.ChangeCheckBox(key, name, True)
50106
session.findById("wnd[1]/usr/cntlCONTAINER_PSOBKEY/shellcont/shell/shellcont[1]/shell[0]").pressButton("OK")
51107

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-
70108

71109
def _set_clipboard(text: str) -> None:
72110
"""Private function to set text to the clipboard.

0 commit comments

Comments
 (0)