Merge branch 'rome/test-beta' into master-AIO. Initia
This commit is contained in:
2
server/csi/csi.js
Normal file
2
server/csi/csi.js
Normal file
@@ -0,0 +1,2 @@
|
||||
exports.lookup = require("./lookup").default;
|
||||
exports.submit = require("./submit").default;
|
||||
24
server/csi/lookup.js
Normal file
24
server/csi/lookup.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const path = require("path");
|
||||
const queries = require("../graphql-client/queries");
|
||||
const logger = require("../utils/logger");
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
`.env.${process.env.NODE_ENV || "development"}`
|
||||
),
|
||||
});
|
||||
|
||||
const client = require("../graphql-client/graphql-client").client;
|
||||
|
||||
exports.default = async (req, res) => {
|
||||
try {
|
||||
logger.log("csi-surveyID-lookup", "DEBUG", "csi", req.body.surveyId, null);
|
||||
const gql_response = await client.request(queries.QUERY_SURVEY, {
|
||||
surveyId: req.body.surveyId,
|
||||
});
|
||||
res.status(200).json(gql_response);
|
||||
} catch (error) {
|
||||
logger.log("csi-surveyID-lookup", "ERROR", "csi", req.body.surveyId, error);
|
||||
res.status(400).json(error);
|
||||
}
|
||||
};
|
||||
29
server/csi/submit.js
Normal file
29
server/csi/submit.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const path = require("path");
|
||||
const queries = require("../graphql-client/queries");
|
||||
const logger = require("../utils/logger");
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
`.env.${process.env.NODE_ENV || "development"}`
|
||||
),
|
||||
});
|
||||
|
||||
const client = require("../graphql-client/graphql-client").client;
|
||||
|
||||
exports.default = async (req, res) => {
|
||||
try {
|
||||
logger.log("csi-surveyID-submit", "DEBUG", "csi", req.body.surveyId, null);
|
||||
const gql_response = await client.request(queries.COMPLETE_SURVEY, {
|
||||
surveyId: req.body.surveyId,
|
||||
survey: {
|
||||
response: req.body.values,
|
||||
valid: false,
|
||||
completedon: new Date(),
|
||||
},
|
||||
});
|
||||
res.status(200).json(gql_response);
|
||||
} catch (error) {
|
||||
logger.log("csi-surveyID-submit", "ERROR", "csi", req.body.surveyId, error);
|
||||
res.status(400).json(error);
|
||||
}
|
||||
};
|
||||
@@ -2272,3 +2272,124 @@ exports.INSERT_TIME_TICKETS = `mutation INSERT_TIMETICKETS($timetickets: [timeti
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
exports.QUERY_JOB_PAYROLL_DATA = `query QUERY_JOB_PAYROLL_DATA($id: uuid!) {
|
||||
jobs_by_pk(id: $id) {
|
||||
bodyshop{
|
||||
id
|
||||
md_responsibility_centers
|
||||
md_tasks_presets
|
||||
employee_teams{
|
||||
id
|
||||
name
|
||||
employee_team_members{
|
||||
id
|
||||
employee{
|
||||
id
|
||||
first_name
|
||||
last_name
|
||||
}
|
||||
percentage
|
||||
labor_rates
|
||||
}
|
||||
}
|
||||
}
|
||||
timetickets{
|
||||
id
|
||||
employeeid
|
||||
rate
|
||||
productivehrs
|
||||
actualhrs
|
||||
ciecacode
|
||||
}
|
||||
lbr_adjustments
|
||||
ro_number
|
||||
id
|
||||
job_totals
|
||||
rate_la1
|
||||
rate_la2
|
||||
rate_la3
|
||||
rate_la4
|
||||
rate_laa
|
||||
rate_lab
|
||||
rate_lad
|
||||
rate_lae
|
||||
rate_laf
|
||||
rate_lag
|
||||
rate_lam
|
||||
rate_lar
|
||||
rate_las
|
||||
rate_lau
|
||||
rate_ma2s
|
||||
rate_ma2t
|
||||
rate_ma3s
|
||||
rate_mabl
|
||||
rate_macs
|
||||
rate_mahw
|
||||
rate_mapa
|
||||
rate_mash
|
||||
rate_matd
|
||||
status
|
||||
materials
|
||||
completed_tasks
|
||||
joblines(where: { removed: { _eq: false } }){
|
||||
id
|
||||
line_no
|
||||
unq_seq
|
||||
line_ind
|
||||
line_desc
|
||||
part_type
|
||||
line_ref
|
||||
oem_partno
|
||||
db_price
|
||||
act_price
|
||||
part_qty
|
||||
mod_lbr_ty
|
||||
db_hrs
|
||||
mod_lb_hrs
|
||||
lbr_op
|
||||
lbr_amt
|
||||
op_code_desc
|
||||
status
|
||||
notes
|
||||
location
|
||||
tax_part
|
||||
db_ref
|
||||
manual_line
|
||||
prt_dsmk_p
|
||||
prt_dsmk_m
|
||||
misc_amt
|
||||
misc_tax
|
||||
assigned_team
|
||||
convertedtolbr
|
||||
convertedtolbr_data
|
||||
}
|
||||
}
|
||||
}`;
|
||||
|
||||
exports.INSERT_TIME_TICKETS = `mutation INSERT_TIMETICKETS($timetickets: [timetickets_insert_input!]!) {
|
||||
insert_timetickets(objects: $timetickets) {
|
||||
affected_rows
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
exports.QUERY_SURVEY = `query QUERY_SURVEY($surveyId: uuid!) {
|
||||
csi_by_pk(id: $surveyId) {
|
||||
completedon
|
||||
csiquestion {
|
||||
id
|
||||
config
|
||||
}
|
||||
id
|
||||
relateddata
|
||||
valid
|
||||
validuntil
|
||||
}
|
||||
}`;
|
||||
|
||||
exports.COMPLETE_SURVEY = `mutation COMPLETE_SURVEY($surveyId: uuid!, $survey: csi_set_input) {
|
||||
update_csi(where: { id: { _eq: $surveyId } }, _set: $survey) {
|
||||
affected_rows
|
||||
}
|
||||
}`;
|
||||
|
||||
8
server/routes/csiRoutes.js
Normal file
8
server/routes/csiRoutes.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const express = require("express");
|
||||
const router = express.Router();
|
||||
const {lookup, submit} = require("../csi/csi");
|
||||
|
||||
router.post("/lookup", lookup);
|
||||
router.post("/submit", submit);
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user