Created
March 2, 2016 23:21
-
-
Save ajwagner777/0d904f59ffa85fd02c59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getDiff: function (fromFile, fromSafe) { | |
var diffs = []; | |
if (fromFile.users) | |
fromFile = fromFile.users; | |
if (fromSafe.Response) | |
fromSafe = fromSafe.Response.EmployeeData.Employee; | |
for (let i = 0; i < fromFile.length; i++) { | |
let EmployeeType = fromFile[i].Level === "M" ? " Manager " : " Clerk "; | |
if (_.findWhere(fromSafe, {"Name": " " + fromFile[i].Name + " ", "EmployeeType": EmployeeType}) === undefined) { | |
diffs.push({ | |
"EmployeeType": fromFile[i].Level === "M" ? "Manager" : "Clerk", | |
"Name": fromFile[i].Name, | |
"PIN": fromFile[i].PIN, | |
"action": "add" | |
}); | |
} | |
} | |
for (let i = 0; i < fromSafe.length; i++) { | |
let EmployeeType = fromSafe[i].EmployeeType === " Manager " ? "M" : "C"; | |
if (_.findWhere(fromFile, {"Name": fromSafe[i].Name.trim(), "Level": EmployeeType}) === undefined) { | |
diffs.push({ | |
"EmployeeType": fromSafe[i].EmployeeType, | |
"Name": fromSafe[i].Name, | |
"action": "delete" | |
}); | |
} | |
} | |
return diffs; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment