IO-1917 Autohouse handling for DMS.

This commit is contained in:
Patrick Fic
2022-06-13 11:44:35 -07:00
parent 1b2afb9e93
commit 43fbf32e99
4 changed files with 43 additions and 4 deletions

View File

@@ -216,7 +216,7 @@ server.listen(port, (error) => {
if (error) throw error;
logger.log(
`[${process.env.NODE_ENV || "DEVELOPMENT"}] Server running on port ${port}`,
"DEBUG",
"INFO",
"api"
);
});

View File

@@ -665,6 +665,7 @@ const CreateRepairOrderTag = (job, errorCallback) => {
const CreateCosts = (job) => {
//Create a mapping based on AH Requirements
//For DMS, the keys in the object below are the CIECA part types.
const billTotalsByCostCenters = job.bills.reduce((bill_acc, bill_val) => {
//At the bill level.
bill_val.billlines.map((line_val) => {
@@ -731,7 +732,7 @@ const CreateCosts = (job) => {
}).multiply(job.job_totals.rates.mash.hours)
);
}
//Uses CIECA Labor types.
const ticketTotalsByCostCenter = job.timetickets.reduce(
(ticket_acc, ticket_val) => {
//At the invoice level.
@@ -750,7 +751,43 @@ const CreateCosts = (job) => {
},
{}
);
const defaultCosts = job.bodyshop.md_responsibility_centers.defaults.costs;
//CIECA STANDARD MAPPING OBJECT.
const ciecaObj = {
ATS: "ATS",
LA1: "LA1",
LA2: "LA2",
LA3: "LA3",
LA4: "LA4",
LAA: "LAA",
LAB: "LAB",
LAD: "LAD",
LAE: "LAE",
LAF: "LAF",
LAG: "LAG",
LAM: "LAM",
LAR: "LAR",
LAS: "LAS",
LAU: "LAU",
PAA: "PAA",
PAC: "PAC",
PAG: "PAG",
PAL: "PAL",
PAM: "PAM",
PAN: "PAN",
PAO: "PAO",
PAP: "PAP",
PAR: "PAR",
PAS: "PAS",
TOW: "TOW",
MAPA: "MAPA",
MASH: "MASH",
PASL: "PASL",
};
const defaultCosts =
job.bodyshop.cdk_dealerid || job.bodyshop.pbs_serialnumber
? ciecaObj
: job.bodyshop.md_responsibility_centers.defaults.costs;
return {
PartsTotalCost: Object.keys(billTotalsByCostCenters).reduce((acc, key) => {

View File

@@ -611,6 +611,8 @@ exports.AUTOHOUSE_QUERY = `query AUTOHOUSE_EXPORT($start: timestamptz, $bodyshop
autohouseid
md_responsibility_centers
jc_hourly_rates
cdk_dealerid
pbs_serialnumber
timezone
}
jobs(where: {_and: [{converted: {_eq: true}}, {updated_at: {_gt: $start}}, {updated_at: {_lte: $end}}, {shopid: {_eq: $bodyshopid}}]}) {

View File

@@ -5,7 +5,7 @@ const logger = new graylog2.graylog({
});
function log(message, type, user, record, object) {
if (type !== "ioevent")
if (type !== "ioevent" && type !== "DEBUG")
console.log(message, {
type,
env: process.env.NODE_ENV || "development",