IO-1708 Add shop timezone & update server side calculations.

This commit is contained in:
Patrick Fic
2022-02-07 17:43:34 -08:00
parent 356928ce77
commit 91c5560fe8
29 changed files with 303 additions and 93 deletions

View File

@@ -1,7 +1,7 @@
const path = require("path");
const queries = require("../graphql-client/queries");
const Dinero = require("dinero.js");
const moment = require("moment");
const moment = require("moment-timezone");
const fs = require("fs");
const _ = require("lodash");
@@ -66,24 +66,35 @@ exports.default = async (req, res) => {
// },
RepairEvent: {
CreatedDateTime: (job.date_open
? moment(job.date_open)
? moment(job.date_open).tz(bodyshop.timezone)
: moment()
).format(momentFormat),
ArrivalDateTime:
job.actual_in && moment(job.actual_in).format(momentFormat),
job.actual_in &&
moment(job.actual_in)
.tz(bodyshop.timezone)
.format(momentFormat),
ArrivalOdometerReading: job.kmin,
TargetCompletionDateTime:
job.scheduled_completion &&
moment(job.scheduled_completion).format(momentFormat),
moment(job.scheduled_completion)
.tz(bodyshop.timezone)
.format(momentFormat),
ActualCompletionDateTime:
job.actual_completion &&
moment(job.actual_completion).format(momentFormat),
moment(job.actual_completion)
.tz(bodyshop.timezone)
.format(momentFormat),
ActualPickUpDateTime:
job.actual_delivery &&
moment(job.actual_delivery).format(momentFormat),
moment(job.actual_delivery)
.tz(bodyshop.timezone)
.format(momentFormat),
CloseDateTime:
job.date_exported &&
moment(job.date_exported).format(momentFormat),
moment(job.date_exported)
.tz(bodyshop.timezone)
.format(momentFormat),
},
},
RepairOrderHeader: {
@@ -254,7 +265,8 @@ exports.default = async (req, res) => {
//ProductionDate: "2009-10",
ModelYear:
parseInt(job.v_model_yr) < 1900
? parseInt(job.v_model_yr) < moment().format("YY")
? parseInt(job.v_model_yr) <
moment().tz(bodyshop.timezone).format("YY")
? `20${job.v_model_yr}`
: `19${job.v_model_yr}`
: job.v_model_yr,
@@ -288,7 +300,9 @@ exports.default = async (req, res) => {
Facts: {
LossDateTime:
job.loss_date &&
moment(job.loss_date).format(momentFormat),
moment(job.loss_date)
.tz(bodyshop.timezone)
.format(momentFormat),
LossDescCode: "Collision",
PrimaryPOI: {
POICode: job.area_of_damage && job.area_of_damage.impact1,
@@ -750,13 +764,17 @@ exports.default = async (req, res) => {
ProductionStatus: {
ProductionStage: {
ProductionStageCode: GetProductionStageCode(job, bodyshop),
ProductionStageDateTime: moment().format(momentFormat),
ProductionStageDateTime: moment()
.tz(bodyshop.timezone)
.format(momentFormat),
// ProductionStageStatusComment:
// "Going to be painted this afternoon",
},
RepairStatus: {
RepairStatusCode: GetRepairStatusCode(job),
RepairStatusDateTime: moment().format(momentFormat),
RepairStatusDateTime: moment()
.tz(bodyshop.timezone)
.format(momentFormat),
// RepairStatusMemo: "Waiting on back ordered parts",
},
},