IO-1552 WIP Autohouse Updates
This commit is contained in:
@@ -74,7 +74,7 @@ exports.default = async (req, res) => {
|
||||
{
|
||||
version: "1.0",
|
||||
encoding: "UTF-8",
|
||||
keepNullNodes: true,
|
||||
//keepNullNodes: true,
|
||||
},
|
||||
autoHouseObject
|
||||
)
|
||||
@@ -110,7 +110,8 @@ exports.default = async (req, res) => {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
res.json(allxmlsToUpload);
|
||||
return;
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
res.sendStatus(200);
|
||||
return;
|
||||
@@ -184,31 +185,31 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
||||
}${job.est_ct_fn ? job.est_ct_fn : ""}`,
|
||||
},
|
||||
CustomerInformation: {
|
||||
FirstName: job.ownr_fn,
|
||||
LastName: job.ownr_ln,
|
||||
Street: job.ownr_addr1,
|
||||
City: job.ownr_city,
|
||||
State: job.ownr_st,
|
||||
Zip: job.ownr_zip,
|
||||
Phone1: job.ownr_ph1,
|
||||
FirstName: job.ownr_fn || "",
|
||||
LastName: job.ownr_ln || "",
|
||||
Street: job.ownr_addr1 || "",
|
||||
City: job.ownr_city || "",
|
||||
State: job.ownr_st || "",
|
||||
Zip: job.ownr_zip || "",
|
||||
Phone1: job.ownr_ph1 || "",
|
||||
Phone2: null,
|
||||
Phone2Extension: null,
|
||||
Phone3: null,
|
||||
Phone3Extension: null,
|
||||
FileComments: null,
|
||||
Source: null,
|
||||
Email: job.ownr_ea,
|
||||
Email: job.ownr_ea || "",
|
||||
RetWhsl: null,
|
||||
Cat: null,
|
||||
InsuredorClaimantFlag: null,
|
||||
},
|
||||
VehicleInformation: {
|
||||
Year: job.v_model_yr,
|
||||
Make: job.v_make_desc,
|
||||
Model: job.v_model_desc,
|
||||
VIN: job.v_vin,
|
||||
Year: job.v_model_yr || "",
|
||||
Make: job.v_make_desc || "",
|
||||
Model: job.v_model_desc || "",
|
||||
VIN: job.v_vin || "",
|
||||
License: job.plate_no,
|
||||
MileageIn: job.kmin,
|
||||
MileageIn: job.kmin || 0,
|
||||
Vehiclecolor: job.v_color,
|
||||
VehicleProductionDate: null,
|
||||
VehiclePaintCode: null,
|
||||
@@ -218,18 +219,18 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
||||
},
|
||||
|
||||
InsuranceInformation: {
|
||||
InsuranceCo: job.ins_co_nm,
|
||||
CompanyName: job.ins_co_nm,
|
||||
Address: job.ins_addr1,
|
||||
City: job.ins_addr1,
|
||||
State: job.ins_city,
|
||||
Zip: job.ins_zip,
|
||||
Phone: job.ins_ph1,
|
||||
Fax: null,
|
||||
InsuranceCo: job.ins_co_nm || "",
|
||||
CompanyName: job.ins_co_nm || "",
|
||||
Address: job.ins_addr1 || "",
|
||||
City: job.ins_addr1 || "",
|
||||
State: job.ins_city || "",
|
||||
Zip: job.ins_zip || "",
|
||||
Phone: job.ins_ph1 || "",
|
||||
Fax: job.ins_fax || "",
|
||||
ClaimType: null,
|
||||
LossType: null,
|
||||
Policy: null,
|
||||
Claim: job.clm_no,
|
||||
LossType: job.loss_type || "",
|
||||
Policy: job.policy_no || "",
|
||||
Claim: job.clm_no || "",
|
||||
InsuredLastName: null,
|
||||
InsuredFirstName: null,
|
||||
ClaimantLastName: null,
|
||||
@@ -242,23 +243,28 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
||||
OutsideAdjuster: null,
|
||||
},
|
||||
Dates: {
|
||||
DateofLoss: job.loss_date && moment(job.loss_date).format(AhDateFormat),
|
||||
DateofLoss:
|
||||
(job.loss_date && moment(job.loss_date).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).format(AhDateFormat)) || "",
|
||||
EstComplete: null,
|
||||
CustomerAuthorizationDate: null,
|
||||
InsuranceAuthorizationDate: null,
|
||||
DateOpened: job.date_open && moment(job.date_open).format(AhDateFormat),
|
||||
DateOpened:
|
||||
(job.date_open && moment(job.date_open).format(AhDateFormat)) || "",
|
||||
ScheduledArrivalDate:
|
||||
job.scheduled_in && moment(job.scheduled_in).format(AhDateFormat),
|
||||
CarinShop: job.actual_in && moment(job.actual_in).format(AhDateFormat),
|
||||
(job.scheduled_in && moment(job.scheduled_in).format(AhDateFormat)) ||
|
||||
"",
|
||||
CarinShop:
|
||||
(job.actual_in && moment(job.actual_in).format(AhDateFormat)) || "",
|
||||
InsInspDate: null,
|
||||
StartDate: job.actual_in && moment(job.actual_in).format(AhDateFormat),
|
||||
StartDate:
|
||||
(job.actual_in && moment(job.actual_in).format(AhDateFormat)) || "",
|
||||
PartsOrder: null,
|
||||
TeardownHold: null,
|
||||
SupplementSubmittedDate: null,
|
||||
@@ -268,22 +274,28 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
||||
AssntoPaint: null,
|
||||
AssntoDetail: null,
|
||||
PromiseDate:
|
||||
job.scheduled_completion &&
|
||||
moment(job.scheduled_completion).format(AhDateFormat),
|
||||
InsuranceTargetOut: null,
|
||||
(job.scheduled_completion &&
|
||||
moment(job.scheduled_completion).format(AhDateFormat)) ||
|
||||
"",
|
||||
//InsuranceTargetOut: null,
|
||||
CarComplete:
|
||||
job.actual_completion &&
|
||||
moment(job.actual_completion).format(AhDateFormat),
|
||||
(job.actual_completion &&
|
||||
moment(job.actual_completion).format(AhDateFormat)) ||
|
||||
"",
|
||||
DeliveryAppointmentDate:
|
||||
job.scheduled_delivery &&
|
||||
moment(job.scheduled_delivery).format(AhDateFormat),
|
||||
(job.scheduled_delivery &&
|
||||
moment(job.scheduled_delivery).format(AhDateFormat)) ||
|
||||
"",
|
||||
DateClosed:
|
||||
job.date_invoiced && moment(job.date_invoiced).format(AhDateFormat),
|
||||
(job.date_invoiced &&
|
||||
moment(job.date_invoiced).format(AhDateFormat)) ||
|
||||
"",
|
||||
CustomerPaidInFullDate: null,
|
||||
InsurancePaidInFullDate: null,
|
||||
CustPickup:
|
||||
job.actual_delivery &&
|
||||
moment(job.actual_delivery).format(AhDateFormat),
|
||||
(job.actual_delivery &&
|
||||
moment(job.actual_delivery).format(AhDateFormat)) ||
|
||||
"",
|
||||
AccountPostedDate:
|
||||
job.date_exported && moment(job.date_exported).format(AhDateFormat),
|
||||
CSIProcessedDate: null,
|
||||
@@ -291,85 +303,86 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
||||
AdditionalFollowUpDate: null,
|
||||
},
|
||||
Rates: {
|
||||
BodyRate: job.rate_lab,
|
||||
RefinishRate: job.rate_lar,
|
||||
MechanicalRate: job.rate_lam,
|
||||
StructuralRate: job.rate_las,
|
||||
PMRate: job.rate_mapa,
|
||||
BMRate: job.rate_mash,
|
||||
BodyRate: job.rate_lab || 0,
|
||||
RefinishRate: job.rate_lar || 0,
|
||||
MechanicalRate: job.rate_lam || 0,
|
||||
StructuralRate: job.rate_las || 0,
|
||||
PMRate: job.rate_mapa || 0,
|
||||
BMRate: job.rate_mash || 0,
|
||||
TaxRate:
|
||||
job.parts_tax_rates &&
|
||||
job.parts_tax_rates.PAN &&
|
||||
job.parts_tax_rates.PAN.prt_tax_rt,
|
||||
StorageRateperDay: null,
|
||||
DaysStored: null,
|
||||
},
|
||||
EstimateTotals: {
|
||||
BodyHours: null,
|
||||
RefinishHours: null,
|
||||
MechanicalHours: null,
|
||||
StructuralHours: null,
|
||||
PartsTotal: null,
|
||||
PartsOEM: null,
|
||||
PartsAM: null,
|
||||
PartsReconditioned: null,
|
||||
PartsRecycled: null,
|
||||
PartsOther: null,
|
||||
SubletTotal: null,
|
||||
BodyLaborTotal: null,
|
||||
RefinishLaborTotal: null,
|
||||
MechanicalLaborTotal: null,
|
||||
StructuralLaborTotal: null,
|
||||
MiscellaneousChargeTotal: null,
|
||||
PMTotal: null,
|
||||
BMTotal: null,
|
||||
MiscTotal: null,
|
||||
TowingTotal: null,
|
||||
StorageTotal: null,
|
||||
DetailTotal: null,
|
||||
SalesTaxTotal: null,
|
||||
GrossTotal: null,
|
||||
DeductibleTotal: null,
|
||||
DepreciationTotal: null,
|
||||
Discount: null,
|
||||
CustomerPay: null,
|
||||
InsurancePay: null,
|
||||
Deposit: null,
|
||||
AmountDue: null,
|
||||
},
|
||||
SupplementTotals: {
|
||||
BodyHours: null,
|
||||
RefinishHours: null,
|
||||
MechanicalHours: null,
|
||||
StructuralHours: null,
|
||||
PartsTotal: null,
|
||||
PartsOEM: null,
|
||||
PartsAM: null,
|
||||
PartsReconditioned: null,
|
||||
PartsRecycled: null,
|
||||
PartsOther: null,
|
||||
SubletTotal: null,
|
||||
BodyLaborTotal: null,
|
||||
RefinishLaborTotal: null,
|
||||
MechanicalLaborTotal: null,
|
||||
StructuralLaborTotal: null,
|
||||
MiscellaneousChargeTotal: null,
|
||||
PMTotal: null,
|
||||
BMTotal: null,
|
||||
MiscTotal: null,
|
||||
TowingTotal: null,
|
||||
StorageTotal: null,
|
||||
DetailTotal: null,
|
||||
SalesTaxTotal: null,
|
||||
GrossTotal: null,
|
||||
DeductibleTotal: null,
|
||||
DepreciationTotal: null,
|
||||
Discount: null,
|
||||
CustomerPay: null,
|
||||
InsurancePay: null,
|
||||
Deposit: null,
|
||||
AmountDue: null,
|
||||
(job.parts_tax_rates &&
|
||||
job.parts_tax_rates.PAN &&
|
||||
job.parts_tax_rates.PAN.prt_tax_rt) ||
|
||||
0,
|
||||
StorageRateperDay: 0,
|
||||
DaysStored: 0,
|
||||
},
|
||||
// EstimateTotals: {
|
||||
// BodyHours: null,
|
||||
// RefinishHours: null,
|
||||
// MechanicalHours: null,
|
||||
// StructuralHours: null,
|
||||
// PartsTotal: null,
|
||||
// PartsOEM: null,
|
||||
// PartsAM: null,
|
||||
// PartsReconditioned: null,
|
||||
// PartsRecycled: null,
|
||||
// PartsOther: null,
|
||||
// SubletTotal: null,
|
||||
// BodyLaborTotal: null,
|
||||
// RefinishLaborTotal: null,
|
||||
// MechanicalLaborTotal: null,
|
||||
// StructuralLaborTotal: null,
|
||||
// MiscellaneousChargeTotal: null,
|
||||
// PMTotal: null,
|
||||
// BMTotal: null,
|
||||
// MiscTotal: null,
|
||||
// TowingTotal: null,
|
||||
// StorageTotal: null,
|
||||
// DetailTotal: null,
|
||||
// SalesTaxTotal: null,
|
||||
// GrossTotal: null,
|
||||
// DeductibleTotal: null,
|
||||
// DepreciationTotal: null,
|
||||
// Discount: null,
|
||||
// CustomerPay: null,
|
||||
// InsurancePay: null,
|
||||
// Deposit: null,
|
||||
// AmountDue: null,
|
||||
// },
|
||||
// SupplementTotals: {
|
||||
// BodyHours: null,
|
||||
// RefinishHours: null,
|
||||
// MechanicalHours: null,
|
||||
// StructuralHours: null,
|
||||
// PartsTotal: null,
|
||||
// PartsOEM: null,
|
||||
// PartsAM: null,
|
||||
// PartsReconditioned: null,
|
||||
// PartsRecycled: null,
|
||||
// PartsOther: null,
|
||||
// SubletTotal: null,
|
||||
// BodyLaborTotal: null,
|
||||
// RefinishLaborTotal: null,
|
||||
// MechanicalLaborTotal: null,
|
||||
// StructuralLaborTotal: null,
|
||||
// MiscellaneousChargeTotal: null,
|
||||
// PMTotal: null,
|
||||
// BMTotal: null,
|
||||
// MiscTotal: null,
|
||||
// TowingTotal: null,
|
||||
// StorageTotal: null,
|
||||
// DetailTotal: null,
|
||||
// SalesTaxTotal: null,
|
||||
// GrossTotal: null,
|
||||
// DeductibleTotal: null,
|
||||
// DepreciationTotal: null,
|
||||
// Discount: null,
|
||||
// CustomerPay: null,
|
||||
// InsurancePay: null,
|
||||
// Deposit: null,
|
||||
// AmountDue: null,
|
||||
// },
|
||||
RevisedTotals: {
|
||||
BodyHours: job.job_totals.rates.lab.hours,
|
||||
BodyRepairHours: job.joblines
|
||||
@@ -441,8 +454,8 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
||||
),
|
||||
StructuralLaborTotalCost:
|
||||
repairCosts.StructuralLaborTotalCost.toFormat(AHDineroFormat),
|
||||
MiscellaneousChargeTotal: null,
|
||||
MiscellaneousChargeTotalCost: null,
|
||||
MiscellaneousChargeTotal: 0,
|
||||
MiscellaneousChargeTotalCost: 0,
|
||||
PMTotal: Dinero(job.job_totals.rates.mapa.total).toFormat(
|
||||
AHDineroFormat
|
||||
),
|
||||
@@ -461,17 +474,17 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
||||
AHDineroFormat
|
||||
),
|
||||
StorageTotalCost: repairCosts.StorageTotalCost.toFormat(AHDineroFormat),
|
||||
DetailTotal: null,
|
||||
DetailTotalCost: null,
|
||||
DetailTotal: 0,
|
||||
DetailTotalCost: 0,
|
||||
SalesTaxTotal: Dinero(job.job_totals.totals.local_tax)
|
||||
.add(Dinero(job.job_totals.totals.state_tax))
|
||||
.add(Dinero(job.job_totals.totals.federal_tax))
|
||||
.toFormat(AHDineroFormat),
|
||||
SalesTaxTotalCost: null,
|
||||
SalesTaxTotalCost: 0,
|
||||
GrossTotal: Dinero(job.job_totals.totals.net_repairs).toFormat(
|
||||
AHDineroFormat
|
||||
),
|
||||
DeductibleTotal: job.ded_amt,
|
||||
DeductibleTotal: job.ded_amt || 0,
|
||||
DepreciationTotal: Dinero(
|
||||
job.job_totals.totals.custPayable.dep_taxes
|
||||
).toFormat(AHDineroFormat),
|
||||
@@ -496,8 +509,10 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
||||
InsScreenCommentsLine2: null,
|
||||
AssignmentCaller: null,
|
||||
AssignmentDivision: null,
|
||||
LocationofPrimaryImpact: "12",
|
||||
LocationofSecondaryImpact: null,
|
||||
LocationofPrimaryImpact:
|
||||
(job.area_of_damage && job.area_of_damage.impact1) || 0,
|
||||
LocationofSecondaryImpact:
|
||||
(job.area_of_damage && job.area_of_damage.impact2) || 0,
|
||||
PaintTechID: null,
|
||||
PaintTechName: null,
|
||||
ImportType: null,
|
||||
@@ -517,7 +532,7 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
||||
RentalDueDate: null,
|
||||
RentalActRetDate: null,
|
||||
RentalCompanyID: null,
|
||||
CSIID: null,
|
||||
// CSIID: null,
|
||||
InsGroupCode: null,
|
||||
},
|
||||
|
||||
@@ -669,36 +684,39 @@ const GenerateDetailLines = (line, statuses) => {
|
||||
const ret = {
|
||||
BackOrdered: line.status === statuses.default_bo ? "1" : "0",
|
||||
Cost:
|
||||
line.billlines[0] &&
|
||||
(line.billlines[0].actual_cost * line.billlines[0].quantity).toFixed(2),
|
||||
Critical: null,
|
||||
Description: line.line_desc,
|
||||
DiscountMarkup: null,
|
||||
(line.billlines[0] &&
|
||||
(line.billlines[0].actual_cost * line.billlines[0].quantity).toFixed(
|
||||
2
|
||||
)) ||
|
||||
0,
|
||||
//Critical: null,
|
||||
Description: line.line_desc || "",
|
||||
DiscountMarkup: line.prt_dsmk_m || "",
|
||||
InvoiceNumber: line.billlines[0] && line.billlines[0].bill.invoice_number,
|
||||
IOUPart: null,
|
||||
LineNumber: line.line_no,
|
||||
IOUPart: 0,
|
||||
LineNumber: line.line_no || 0,
|
||||
MarkUp: null,
|
||||
OrderedOn: null,
|
||||
OriginalCost: null,
|
||||
OriginalInvoiceNumber: null,
|
||||
PriceEach: line.billlines[0] && line.billlines[0].actual_cost,
|
||||
PriceEach: (line.billlines[0] && line.billlines[0].actual_cost) || 0,
|
||||
PartNumber: _.escape(line.oem_partno),
|
||||
ProfitPercent: null,
|
||||
PurchaseOrderNumber: null,
|
||||
Qty: line.part_qty,
|
||||
Status: line.status,
|
||||
SupplementNumber: null,
|
||||
Type: line.part_type,
|
||||
Vendor: line.billlines[0] && line.billlines[0].bill.vendor.name,
|
||||
Qty: line.part_qty || 0,
|
||||
Status: line.status || "",
|
||||
SupplementNumber: line.line_ind || "",
|
||||
Type: line.part_type || "",
|
||||
Vendor: (line.billlines[0] && line.billlines[0].bill.vendor.name) || "",
|
||||
VendorPaid: null,
|
||||
VendorPrice: line.billlines[0] && line.billlines[0].actual_price,
|
||||
VendorPrice: (line.billlines[0] && line.billlines[0].actual_price) || 0,
|
||||
Deleted: null,
|
||||
ExpectedOn: null,
|
||||
ReceivedOn: null,
|
||||
OrderedBy: null,
|
||||
ShipVia: null,
|
||||
VendorContact: null,
|
||||
EstimateAmount: line.act_price,
|
||||
EstimateAmount: line.act_price || 0,
|
||||
};
|
||||
return ret;
|
||||
};
|
||||
@@ -709,9 +727,9 @@ const generateNullDetailLine = () => {
|
||||
Cost: 0,
|
||||
Critical: null,
|
||||
Description: "No Lines on Estimate",
|
||||
DiscountMarkup: null,
|
||||
DiscountMarkup: 0,
|
||||
InvoiceNumber: null,
|
||||
IOUPart: null,
|
||||
IOUPart: 0,
|
||||
LineNumber: 0,
|
||||
MarkUp: null,
|
||||
OrderedOn: null,
|
||||
@@ -722,12 +740,12 @@ const generateNullDetailLine = () => {
|
||||
ProfitPercent: null,
|
||||
PurchaseOrderNumber: null,
|
||||
Qty: 0,
|
||||
Status: null,
|
||||
SupplementNumber: null,
|
||||
Type: null,
|
||||
Vendor: null,
|
||||
Status: "",
|
||||
SupplementNumber: 0,
|
||||
Type: "",
|
||||
Vendor: "",
|
||||
VendorPaid: null,
|
||||
VendorPrice: null,
|
||||
VendorPrice: 0,
|
||||
Deleted: null,
|
||||
ExpectedOn: null,
|
||||
ReceivedOn: null,
|
||||
|
||||
@@ -525,7 +525,7 @@ exports.QUERY_EMPLOYEE_PIN = `query QUERY_EMPLOYEE_PIN($shopId: uuid!, $employee
|
||||
}`;
|
||||
|
||||
exports.AUTOHOUSE_QUERY = `query AUTOHOUSE_EXPORT($start: timestamptz, $bodyshopid: uuid!) {
|
||||
jobs(where: {_and: [{converted :{_eq: true}},{updated_at: {_gt: $start}}, {shopid: {_eq: $bodyshopid}}]}) {
|
||||
jobs(where: {_and: [{converted: {_eq: true}}, {updated_at: {_gt: $start}}, {shopid: {_eq: $bodyshopid}}]}, limit: 50) {
|
||||
id
|
||||
ro_number
|
||||
status
|
||||
@@ -533,6 +533,7 @@ exports.AUTOHOUSE_QUERY = `query AUTOHOUSE_EXPORT($start: timestamptz, $bodyshop
|
||||
est_ct_ln
|
||||
ownr_zip
|
||||
referral_source
|
||||
loss_type
|
||||
v_model_yr
|
||||
v_model_desc
|
||||
v_make_desc
|
||||
@@ -607,6 +608,7 @@ exports.AUTOHOUSE_QUERY = `query AUTOHOUSE_EXPORT($start: timestamptz, $bodyshop
|
||||
joblines(where: {removed: {_eq: false}}) {
|
||||
id
|
||||
line_no
|
||||
line_ind
|
||||
status
|
||||
line_ind
|
||||
db_price
|
||||
@@ -676,6 +678,7 @@ exports.AUTOHOUSE_QUERY = `query AUTOHOUSE_EXPORT($start: timestamptz, $bodyshop
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
`;
|
||||
|
||||
exports.ENTEGRAL_EXPORT = `
|
||||
|
||||
Reference in New Issue
Block a user