Add claimed task name to tickets.
This commit is contained in:
@@ -14,7 +14,7 @@ Dinero.globalRoundingMode = "HALF_EVEN";
|
||||
exports.calculatelabor = async function (req, res) {
|
||||
const BearerToken = req.headers.authorization;
|
||||
const { jobid, calculateOnly } = req.body;
|
||||
logger.log("job-payroll-pay-all", "DEBUG", req.user.email, jobid, null);
|
||||
logger.log("job-payroll-calculate-labor", "DEBUG", req.user.email, jobid, null);
|
||||
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
|
||||
headers: {
|
||||
Authorization: BearerToken,
|
||||
|
||||
@@ -31,6 +31,12 @@ exports.claimtask = async function (req, res) {
|
||||
const theTaskPreset = job.bodyshop.md_tasks_presets.presets.find(
|
||||
(tp) => tp.name === task
|
||||
);
|
||||
if (!theTaskPreset) {
|
||||
res
|
||||
.status(400)
|
||||
.json({ success: false, error: "Provided task preset not found." });
|
||||
return;
|
||||
}
|
||||
|
||||
//Get all of the assignments that are filtered.
|
||||
const { assignmentHash, employeeHash } = CalculateExpectedHoursForJob(
|
||||
@@ -52,6 +58,7 @@ exports.claimtask = async function (req, res) {
|
||||
(theTaskPreset.percent / 100);
|
||||
|
||||
ticketsToInsert.push({
|
||||
task_name: task,
|
||||
jobid: job.id,
|
||||
bodyshopid: job.bodyshop.id,
|
||||
employeeid: employeeIdKey,
|
||||
|
||||
@@ -53,6 +53,7 @@ exports.payall = async function (req, res) {
|
||||
console.log("Hours", diff.val[key][Object.keys(diff.val[key])[0]]);
|
||||
console.log("Rate", Object.keys(diff.val[key])[0]);
|
||||
ticketsToInsert.push({
|
||||
task_name: "Pay All",
|
||||
jobid: job.id,
|
||||
bodyshopid: job.bodyshop.id,
|
||||
employeeid: path.employeeid,
|
||||
@@ -68,6 +69,7 @@ exports.payall = async function (req, res) {
|
||||
} else {
|
||||
//Only the 1 value to add.
|
||||
ticketsToInsert.push({
|
||||
task_name: "Pay All",
|
||||
jobid: job.id,
|
||||
bodyshopid: job.bodyshop.id,
|
||||
employeeid: path.employeeid,
|
||||
@@ -86,6 +88,7 @@ exports.payall = async function (req, res) {
|
||||
//An old ticket amount isn't sufficient
|
||||
//We can't modify the existing ticket, it might already be committed. So let's add a new one instead.
|
||||
ticketsToInsert.push({
|
||||
task_name: "Pay All",
|
||||
jobid: job.id,
|
||||
bodyshopid: job.bodyshop.id,
|
||||
employeeid: path.employeeid,
|
||||
@@ -107,12 +110,8 @@ exports.payall = async function (req, res) {
|
||||
) {
|
||||
//Multiple oldValues to add.
|
||||
Object.keys(diff.oldVal).forEach((key) => {
|
||||
console.log(
|
||||
"Hours",
|
||||
diff.oldVal[key][Object.keys(diff.oldVal[key])[0]]
|
||||
);
|
||||
console.log("Rate", Object.keys(diff.oldVal[key])[0]);
|
||||
ticketsToInsert.push({
|
||||
task_name: "Pay All",
|
||||
jobid: job.id,
|
||||
bodyshopid: job.bodyshop.id,
|
||||
employeeid: path.employeeid,
|
||||
@@ -129,6 +128,7 @@ exports.payall = async function (req, res) {
|
||||
} else {
|
||||
//Only the 1 value to add.
|
||||
ticketsToInsert.push({
|
||||
task_name: "Pay All",
|
||||
jobid: job.id,
|
||||
bodyshopid: job.bodyshop.id,
|
||||
employeeid: path.employeeid,
|
||||
|
||||
Reference in New Issue
Block a user