Skip to content

Instantly share code, notes, and snippets.

@ajwagner777
Created March 2, 2016 23:21
Show Gist options
  • Save ajwagner777/0d904f59ffa85fd02c59 to your computer and use it in GitHub Desktop.
Save ajwagner777/0d904f59ffa85fd02c59 to your computer and use it in GitHub Desktop.
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