-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalterLSF.py
More file actions
88 lines (75 loc) · 4.31 KB
/
alterLSF.py
File metadata and controls
88 lines (75 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from datetime import date, datetime
from app.models.notes import Notes
from app.models.department import Department
from app.models.adjustedForm import AdjustedForm
from app.models.activePosition import ActivePosition
from app.controllers.main_routes.laborHistory import *
from app.logic.emailHandler import *
from app.logic.utils import makeThirdPartyLink
from app.logic.userInsertFunctions import createSupervisorFromTracy
from app.logic.tracy import Tracy
from app.logic.statusFormFunctions import createOverloadForm
def modifyLSF(fieldsChanged, fieldName, lsf, currentUser, host=None):
if fieldName == "supervisorNotes":
noteEntry = Notes.create(formID = lsf.laborStatusFormID,
createdBy = currentUser,
date = datetime.now().strftime("%Y-%m-%d"),
notesContents = fieldsChanged[fieldName]["newValue"],
noteType = "Supervisor Note")
noteEntry.save()
lsf.supervisorNotes = noteEntry.notesContents
lsf.save()
if fieldName == "supervisor":
supervisor = Supervisor.get(Supervisor.ID == fieldsChanged[fieldName]["newValue"])
lsf.supervisor = supervisor.ID
lsf.save()
if fieldName == "department":
department = Department.get(Department.ORG==fieldsChanged[fieldName]['newValue'])
lsf.department = department.departmentID
lsf.save()
if fieldName == "position":
position = ActivePosition.get_or_none(ActivePosition.POSN_CODE == fieldsChanged[fieldName]["newValue"])
lsf.POSN_CODE = position.POSN_CODE
lsf.POSN_TITLE = position.POSN_TITLE
lsf.WLS = position.WLS
lsf.save()
if fieldName == "weeklyHours":
newWeeklyHours = int(fieldsChanged[fieldName]['newValue'])
createOverloadForm(newWeeklyHours, lsf, currentUser, host=host)
lsf.weeklyHours = newWeeklyHours
lsf.save()
if fieldName == "contractHours":
lsf.contractHours = int(fieldsChanged[fieldName]["newValue"])
lsf.save()
if fieldName == "startDate":
lsf.startDate = datetime.strptime(fieldsChanged[fieldName]["newValue"], "%m/%d/%Y").strftime('%Y-%m-%d')
lsf.save()
if fieldName == "endDate":
lsf.endDate = datetime.strptime(fieldsChanged[fieldName]["newValue"], "%m/%d/%Y").strftime('%Y-%m-%d')
lsf.save()
def adjustLSF(fieldsChanged, fieldName, lsf, currentUser, host=None):
if fieldName == "supervisorNotes":
newNoteEntry = Notes.create(formID = lsf.laborStatusFormID,
createdBy = currentUser,
date = datetime.now().strftime("%Y-%m-%d"),
notesContents = fieldsChanged[fieldName]["newValue"],
noteType = "Supervisor Note")
newNoteEntry.save()
return None
else:
adjustedforms = AdjustedForm.create(fieldAdjusted = fieldName,
oldValue = fieldsChanged[fieldName]["oldValue"],
newValue = fieldsChanged[fieldName]["newValue"],
effectiveDate = datetime.strptime(fieldsChanged[fieldName]["date"], "%m/%d/%Y").strftime("%Y-%m-%d"))
historyType = HistoryType.get(HistoryType.historyTypeName == "Labor Adjustment Form")
status = Status.get(Status.statusName == "Pending")
adjustedFormHistory = FormHistory.create(formID = lsf.laborStatusFormID,
historyType = historyType.historyTypeName,
adjustedForm = adjustedforms.adjustedFormID,
createdBy = currentUser,
createdDate = date.today(),
status = status.statusName)
if fieldName == "weeklyHours":
newWeeklyHours = int(fieldsChanged[fieldName]['newValue'])
createOverloadForm(newWeeklyHours, lsf, currentUser, adjustedforms.adjustedFormID, adjustedFormHistory,host=host)
return adjustedFormHistory.formHistoryID