Merged in feature/payroll (pull request #914)
Add audit trail and resolve status update.
This commit is contained in:
@@ -6,14 +6,14 @@ const {
|
||||
CalculateExpectedHoursForJob,
|
||||
CalculateTicketsHoursForJob,
|
||||
} = require("./pay-all");
|
||||
|
||||
const moment = require("moment");
|
||||
// Dinero.defaultCurrency = "USD";
|
||||
// Dinero.globalLocale = "en-CA";
|
||||
Dinero.globalRoundingMode = "HALF_EVEN";
|
||||
|
||||
exports.claimtask = async function (req, res) {
|
||||
const BearerToken = req.headers.authorization;
|
||||
const { jobid, task, calculateOnly } = req.body;
|
||||
const { jobid, task, calculateOnly, employee } = req.body;
|
||||
logger.log("job-payroll-pay-all", "DEBUG", req.user.email, jobid, null);
|
||||
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
|
||||
headers: {
|
||||
@@ -70,7 +70,7 @@ exports.claimtask = async function (req, res) {
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs[
|
||||
laborTypeKey
|
||||
],
|
||||
memo: `*Claimed Task* ${theTaskPreset.memo}`,
|
||||
memo: `*Flagged Task* ${theTaskPreset.memo}`,
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -86,7 +86,16 @@ exports.claimtask = async function (req, res) {
|
||||
const updateResult = await client.request(queries.UPDATE_JOB, {
|
||||
jobId: job.id,
|
||||
job: {
|
||||
completed_tasks: [...job.completed_tasks, task],
|
||||
status: theTaskPreset.nextstatus,
|
||||
completed_tasks: [
|
||||
...job.completed_tasks,
|
||||
{
|
||||
name: task,
|
||||
completedat: moment(),
|
||||
completed_by: employee,
|
||||
useremail: req.user.email,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -46,7 +46,9 @@ exports.payall = async function (req, res) {
|
||||
//Every iteration is what we would need to insert into the time ticket hash
|
||||
//so that it would match the employee hash exactly.
|
||||
const path = diffParser(diff);
|
||||
|
||||
if (diff.op === "add") {
|
||||
console.log(Object.keys(diff.val));
|
||||
if (typeof diff.val === "object" && Object.keys(diff.val).length > 1) {
|
||||
//Multiple values to add.
|
||||
Object.keys(diff.val).forEach((key) => {
|
||||
@@ -63,7 +65,7 @@ exports.payall = async function (req, res) {
|
||||
cost_center:
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs[key],
|
||||
flat_rate: true,
|
||||
memo: `*SYS-PAY* Add unclaimed hours. (${req.user.email})`,
|
||||
memo: `*SYS-PAY* Add unflagged hours. (${req.user.email})`,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
@@ -81,7 +83,7 @@ exports.payall = async function (req, res) {
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs[
|
||||
path.mod_lbr_ty
|
||||
],
|
||||
memo: `*SYS-PAY* Add unclaimed hours. (${req.user.email})`,
|
||||
memo: `*SYS-PAY* Add unflagged hours. (${req.user.email})`,
|
||||
});
|
||||
}
|
||||
} else if (diff.op === "update") {
|
||||
@@ -100,7 +102,7 @@ exports.payall = async function (req, res) {
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs[
|
||||
path.mod_lbr_ty
|
||||
],
|
||||
memo: `*SYS-PAY* Adjust claimed hours per assignment. (${req.user.email})`,
|
||||
memo: `*SYS-PAY* Adjust flagged hours per assignment. (${req.user.email})`,
|
||||
});
|
||||
} else {
|
||||
//Has to be a delete
|
||||
@@ -122,7 +124,7 @@ exports.payall = async function (req, res) {
|
||||
cost_center:
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs[key],
|
||||
flat_rate: true,
|
||||
memo: `*SYS-PAY* Remove claimed hours per assignment. (${req.user.email})`,
|
||||
memo: `*SYS-PAY* Remove flagged hours per assignment. (${req.user.email})`,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
@@ -140,7 +142,7 @@ exports.payall = async function (req, res) {
|
||||
path.mod_lbr_ty
|
||||
],
|
||||
flat_rate: true,
|
||||
memo: `*SYS-PAY* Remove claimed hours per assignment. (${req.user.email})`,
|
||||
memo: `*SYS-PAY* Remove flagged hours per assignment. (${req.user.email})`,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -203,7 +205,14 @@ function diffParser(diff) {
|
||||
) {
|
||||
hours = diff.val;
|
||||
} else if (diff.val !== null && diff.val !== undefined) {
|
||||
hours = diff.val[Object.keys(diff.val)[0]];
|
||||
if (diff.path.length === 1) {
|
||||
hours =
|
||||
diff.val[Object.keys(diff.val)[0]][
|
||||
Object.keys(diff.val[Object.keys(diff.val)[0]])
|
||||
];
|
||||
} else {
|
||||
hours = diff.val[Object.keys(diff.val)[0]];
|
||||
}
|
||||
} else if (
|
||||
typeof diff.oldVal === "number" &&
|
||||
diff.oldVal !== null &&
|
||||
|
||||
Reference in New Issue
Block a user