IO-1708 Add shop timezone & update server side calculations.
This commit is contained in:
@@ -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",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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");
|
||||
var builder = require("xmlbuilder2");
|
||||
const _ = require("lodash");
|
||||
const logger = require("../utils/logger");
|
||||
@@ -267,27 +267,50 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
||||
},
|
||||
Dates: {
|
||||
DateofLoss:
|
||||
(job.loss_date && moment(job.loss_date).format(AhDateFormat)) || "",
|
||||
(job.loss_date &&
|
||||
moment(job.loss_date)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(AhDateFormat)) ||
|
||||
"",
|
||||
InitialCustomerContactDate: null,
|
||||
FirstFollowUpDate: null,
|
||||
ReferralDate: null,
|
||||
EstimateAppointmentDate: null,
|
||||
SecondFollowUpDate: null,
|
||||
AssignedDate:
|
||||
(job.asgn_date && moment(job.asgn_date).format(AhDateFormat)) || "",
|
||||
(job.asgn_date &&
|
||||
moment(job.asgn_date)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(AhDateFormat)) ||
|
||||
"",
|
||||
EstComplete: null,
|
||||
CustomerAuthorizationDate: null,
|
||||
InsuranceAuthorizationDate: null,
|
||||
DateOpened:
|
||||
(job.date_open && moment(job.date_open).format(AhDateFormat)) || "",
|
||||
(job.date_open &&
|
||||
moment(job.date_open)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(AhDateFormat)) ||
|
||||
"",
|
||||
ScheduledArrivalDate:
|
||||
(job.scheduled_in && moment(job.scheduled_in).format(AhDateFormat)) ||
|
||||
(job.scheduled_in &&
|
||||
moment(job.scheduled_in)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(AhDateFormat)) ||
|
||||
"",
|
||||
CarinShop:
|
||||
(job.actual_in && moment(job.actual_in).format(AhDateFormat)) || "",
|
||||
(job.actual_in &&
|
||||
moment(job.actual_in)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(AhDateFormat)) ||
|
||||
"",
|
||||
InsInspDate: null,
|
||||
StartDate:
|
||||
(job.actual_in && moment(job.actual_in).format(AhDateFormat)) || "",
|
||||
(job.actual_in &&
|
||||
moment(job.actual_in)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(AhDateFormat)) ||
|
||||
"",
|
||||
PartsOrder: null,
|
||||
TeardownHold: null,
|
||||
SupplementSubmittedDate: null,
|
||||
@@ -303,24 +326,35 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
||||
//InsuranceTargetOut: null,
|
||||
CarComplete:
|
||||
(job.actual_completion &&
|
||||
moment(job.actual_completion).format(AhDateFormat)) ||
|
||||
moment(job.actual_completion)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(AhDateFormat)) ||
|
||||
"",
|
||||
DeliveryAppointmentDate:
|
||||
(job.scheduled_delivery &&
|
||||
moment(job.scheduled_delivery).format(AhDateFormat)) ||
|
||||
moment(job.scheduled_delivery)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(AhDateFormat)) ||
|
||||
"",
|
||||
DateClosed:
|
||||
(job.date_invoiced &&
|
||||
moment(job.date_invoiced).format(AhDateFormat)) ||
|
||||
moment(job.date_invoiced)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(AhDateFormat)) ||
|
||||
"",
|
||||
CustomerPaidInFullDate: null,
|
||||
InsurancePaidInFullDate: null,
|
||||
CustPickup:
|
||||
(job.actual_delivery &&
|
||||
moment(job.actual_delivery).format(AhDateFormat)) ||
|
||||
moment(job.actual_delivery)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(AhDateFormat)) ||
|
||||
"",
|
||||
AccountPostedDate:
|
||||
job.date_exported && moment(job.date_exported).format(AhDateFormat),
|
||||
job.date_exported &&
|
||||
moment(job.date_exported)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(AhDateFormat),
|
||||
CSIProcessedDate: null,
|
||||
ThankYouLetterSent: null,
|
||||
AdditionalFollowUpDate: null,
|
||||
@@ -760,9 +794,9 @@ const GenerateDetailLines = (line, statuses) => {
|
||||
MarkUp: null,
|
||||
OrderedOn:
|
||||
(line.parts_order_lines[0] &&
|
||||
moment(line.parts_order_lines[0].parts_order.order_date).format(
|
||||
AhDateFormat
|
||||
)) ||
|
||||
moment(line.parts_order_lines[0].parts_order.order_date)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(AhDateFormat)) ||
|
||||
"",
|
||||
OriginalCost: null,
|
||||
OriginalInvoiceNumber: null,
|
||||
@@ -786,7 +820,9 @@ const GenerateDetailLines = (line, statuses) => {
|
||||
ExpectedOn: null,
|
||||
ReceivedOn:
|
||||
line.billlines[0] &&
|
||||
moment(line.billlines[0].bill.date).format(AhDateFormat),
|
||||
moment(line.billlines[0].bill.date)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(AhDateFormat),
|
||||
OrderedBy: null,
|
||||
ShipVia: null,
|
||||
VendorContact: null,
|
||||
|
||||
Reference in New Issue
Block a user