From 45e9df6a48512e339349ed8d20a5017e91a2441a Mon Sep 17 00:00:00 2001 From: murraydr Date: Wed, 11 Oct 2023 15:41:12 -0400 Subject: [PATCH] Added error-check if replacement is already assigned elsewhere --- driver.py | 4 ---- helperFunctions.py | 9 +++++++++ lastUpdatedToken.txt | 2 +- substitutionApprovalWindow.py | 6 ++++++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/driver.py b/driver.py index 1b7ef7e..e145e14 100644 --- a/driver.py +++ b/driver.py @@ -13,10 +13,6 @@ import scheduledPayrollWindow as PWin #TODO document how to get through the cert expiration every week #TODO do error checking within while loop (update text color / valid status) -#TODO make an error if try to sub in a person if they are already working elsewhere at that time - - -#TODO delete filename parameters in window functions (only helper functions need it) #---LOW PRIORITY (due to payroll being entered by ULAs directly)--- diff --git a/helperFunctions.py b/helperFunctions.py index 32b94e0..63a581c 100644 --- a/helperFunctions.py +++ b/helperFunctions.py @@ -88,6 +88,15 @@ def isAssigned(netID,period,date): ret=True return ret +#Test if a ULA is assigned to ANY section at the given date-time, return the section if True, else return False +def isBusy(netID,time,date): + secD = pd.read_csv(sectionDatabaseFilename,dtype=str,index_col=False) + filt = secD.loc[(secD['Time']==time) & (secD['Date']==date)].apply(lambda r: r.astype('string').str.contains(netID).any(),axis=1) + if filt.any(): + return secD.loc[(secD['Time']==time) & (secD['Date']==date) & (secD.isin([netID]).any(axis=1))]['Section'].to_string(index=False) + else: + return False + #Overwrite a netID in one row of the section database with another def reassign(date,period,oldID,newID): secD = pd.read_csv(sectionDatabaseFilename,dtype=str,index_col=False) diff --git a/lastUpdatedToken.txt b/lastUpdatedToken.txt index 9df1bdd..53d5ce0 100644 --- a/lastUpdatedToken.txt +++ b/lastUpdatedToken.txt @@ -1 +1 @@ -2023-10-11 14:08:24.903282 \ No newline at end of file +2023-10-11 15:40:17.780872 \ No newline at end of file diff --git a/substitutionApprovalWindow.py b/substitutionApprovalWindow.py index d71ca83..a1ed30d 100644 --- a/substitutionApprovalWindow.py +++ b/substitutionApprovalWindow.py @@ -53,6 +53,12 @@ def subAppWin(staffDatabaseFilename,secDFilename,subRequestsFilename,subRequests subRequests[i][6]+=oldID+" not assigned\n" #Add to the list of errors with this request if newID != "" and HF.isAssigned(newID,period,date): subRequests[i][6]+=newID+" already assigned\n" #Add to the list of errors with this request + #Test if replacement is already busy with a different section + if newID != "": + elsewhere = HF.isBusy(newID,HF.getTimeFromSection(period),date) + if elsewhere != False: + subRequests[i][6]+=newID+" assigned elsewhere ("+elsewhere+")\n" #Add to the list of errors with this request + #--------------------------------------------------------------------------