Merge remote-tracking branch 'origin/master-AIO' into feature/Reynolds-and-Reynolds-DMS-API-Integration

This commit is contained in:
Dave
2025-09-30 12:57:23 -04:00
6 changed files with 81 additions and 61 deletions

View File

@@ -51,12 +51,13 @@
comment: "" comment: ""
- name: Rome Usage Report - name: Rome Usage Report
webhook: '{{HASURA_API_URL}}/data/usagereport' webhook: '{{HASURA_API_URL}}/data/usagereport'
schedule: 0 12 * * 5 schedule: 0 12 * * 3,5
include_in_metadata: true include_in_metadata: true
payload: {} payload: {}
headers: headers:
- name: x-imex-auth - name: x-imex-auth
value_from_env: DATAPUMP_AUTH value_from_env: DATAPUMP_AUTH
comment: ""
- name: Task Reminders - name: Task Reminders
webhook: '{{HASURA_API_URL}}/tasks-remind-handler' webhook: '{{HASURA_API_URL}}/tasks-remind-handler'
schedule: '*/15 * * * *' schedule: '*/15 * * * *'

View File

@@ -944,6 +944,7 @@
- autohouseid - autohouseid
- bill_allow_post_to_closed - bill_allow_post_to_closed
- bill_tax_rates - bill_tax_rates
- carfax_exclude
- cdk_configuration - cdk_configuration
- cdk_dealerid - cdk_dealerid
- chatterid - chatterid

View File

@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."bodyshops" add column "carfax_exclude" boolean
-- not null default 'false';

View File

@@ -0,0 +1,2 @@
alter table "public"."bodyshops" add column "carfax_exclude" boolean
not null default 'false';

View File

@@ -99,7 +99,7 @@ exports.default = async (req, res) => {
await processShopData(shopsToProcess, start, end, skipUpload, ignoreDateFilter, allXMLResults, allErrors); await processShopData(shopsToProcess, start, end, skipUpload, ignoreDateFilter, allXMLResults, allErrors);
await sendServerEmail({ await sendServerEmail({
subject: `CARFAX Report ${moment().format("MM-DD-YY")}`, subject: `Project Mexico Report ${moment().format("MM-DD-YY")}`,
text: `Errors:\n${JSON.stringify(allErrors, null, 2)}\n\nUploaded:\n${JSON.stringify( text: `Errors:\n${JSON.stringify(allErrors, null, 2)}\n\nUploaded:\n${JSON.stringify(
allXMLResults.map((x) => ({ allXMLResults.map((x) => ({
imexshopid: x.imexshopid, imexshopid: x.imexshopid,
@@ -164,35 +164,36 @@ async function processShopData(shopsToProcess, start, end, skipUpload, ignoreDat
if (skipUpload) { if (skipUpload) {
fs.writeFileSync(`./logs/${jsonObj.filename}`, jsonObj.json); fs.writeFileSync(`./logs/${jsonObj.filename}`, jsonObj.json);
uploadToS3(jsonObj);
} else { } else {
await uploadViaSFTP(jsonObj); await uploadViaSFTP(jsonObj);
}
await sendMexicoBillingEmail({ await sendMexicoBillingEmail({
subject: `${shopid.toUpperCase()}_Mexico${InstanceManager({ subject: `${shopid.replace(/_/g, "").toUpperCase()}_Mexico${InstanceManager({
imex: "IO", imex: "IO",
rome: "RO" rome: "RO"
})}_${moment().format("MMDDYYYY")} ROs ${jsonObj.count} Error ${errorCode(jsonObj)}`, })}_${moment().format("MMDDYYYY")} ROs ${jsonObj.count} Error ${errorCode(jsonObj)}`,
text: `Errors:\n${JSON.stringify( text: `Errors:\n${JSON.stringify(
erroredJobs.map((ej) => ({ erroredJobs.map((ej) => ({
ro_number: ej.job?.ro_number, ro_number: ej.job?.ro_number,
jobid: ej.job?.id, jobid: ej.job?.id,
error: ej.error error: ej.error
})), })),
null, null,
2 2
)}\n\nUploaded:\n${JSON.stringify( )}\n\nUploaded:\n${JSON.stringify(
{ {
bodyshopid: bodyshop.id, bodyshopid: bodyshop.id,
imexshopid: shopid, imexshopid: shopid,
count: jsonObj.count, count: jsonObj.count,
filename: jsonObj.filename, filename: jsonObj.filename,
result: jsonObj.result result: jsonObj.result
}, },
null, null,
2 2
)}` )}`
}); });
}
allXMLResults.push({ allXMLResults.push({
bodyshopid: bodyshop.id, bodyshopid: bodyshop.id,
@@ -292,17 +293,22 @@ const CreateRepairOrderTag = (job, errorCallback) => {
v_make: job.v_make_desc || "", v_make: job.v_make_desc || "",
v_model: job.v_model_desc || "", v_model: job.v_model_desc || "",
date_estimated: date_estimated: [job.date_estimated, job.created_at].find((date) => date)
(job.date_estimated && moment(job.date_estimated).tz(job.bodyshop.timezone).format(AHDateFormat)) || ? moment([job.date_open, job.created_at].find((date) => date))
(job.created_at && moment(job.created_at).tz(job.bodyshop.timezone).format(AHDateFormat)) || .tz(job.bodyshop.timezone)
"", .format(AHDateFormat)
data_opened: : "",
(job.date_open && moment(job.date_open).tz(job.bodyshop.timezone).format(AHDateFormat)) || data_opened: [job.date_open, job.created_at].find((date) => date)
(job.created_at && moment(job.created_at).tz(job.bodyshop.timezone).format(AHDateFormat)) || ? moment([job.date_open, job.created_at].find((date) => date))
"", .tz(job.bodyshop.timezone)
date_invoiced: .format(AHDateFormat)
(job.date_invoiced && moment(job.date_invoiced).tz(job.bodyshop.timezone).format(AHDateFormat)) || "", : "",
loss_date: (job.loss_date && moment(job.loss_date).format(AHDateFormat)) || "", date_invoiced: [job.date_invoiced, job.actual_delivery, job.actual_completion].find((date) => date)
? moment([job.date_invoiced, job.actual_delivery, job.actual_completion].find((date) => date))
.tz(job.bodyshop.timezone)
.format(AHDateFormat)
: "",
loss_date: job.loss_date ? moment(job.loss_date).format(AHDateFormat) : "",
ins_co_nm: job.ins_co_nm || "", ins_co_nm: job.ins_co_nm || "",
loss_desc: job.loss_desc || "", loss_desc: job.loss_desc || "",
@@ -329,7 +335,9 @@ const GenerateDetailLines = (line) => {
line_desc: line.line_desc ? line.line_desc.replace(NON_ASCII_REGEX, "") : null, line_desc: line.line_desc ? line.line_desc.replace(NON_ASCII_REGEX, "") : null,
oem_partno: line.oem_partno ? line.oem_partno.replace(NON_ASCII_REGEX, "") : null, oem_partno: line.oem_partno ? line.oem_partno.replace(NON_ASCII_REGEX, "") : null,
alt_partno: line.alt_partno ? line.alt_partno.replace(NON_ASCII_REGEX, "") : null, alt_partno: line.alt_partno ? line.alt_partno.replace(NON_ASCII_REGEX, "") : null,
op_code_desc: line.op_code_desc ? line.op_code_desc.replace(NON_ASCII_REGEX, "") : null,
lbr_ty: generateLaborType(line.mod_lbr_ty), lbr_ty: generateLaborType(line.mod_lbr_ty),
lbr_hrs: line.mod_lb_hrs || 0,
part_qty: line.part_qty || 0, part_qty: line.part_qty || 0,
part_type: generatePartType(line.part_type), part_type: generatePartType(line.part_type),
act_price: line.act_price || 0 act_price: line.act_price || 0

View File

@@ -880,39 +880,43 @@ exports.CHATTER_QUERY = `query CHATTER_EXPORT($start: timestamptz, $bodyshopid:
}`; }`;
exports.CARFAX_QUERY = `query CARFAX_EXPORT($start: timestamptz, $bodyshopid: uuid!, $end: timestamptz) { exports.CARFAX_QUERY = `query CARFAX_EXPORT($start: timestamptz, $bodyshopid: uuid!, $end: timestamptz) {
bodyshops_by_pk(id: $bodyshopid){ bodyshops_by_pk(id: $bodyshopid) {
id id
shopname shopname
imexshopid imexshopid
timezone timezone
} }
jobs(where: {_and: [{converted: {_eq: true}}, {v_vin: {_is_null: false}}, {date_invoiced: {_gt: $start}}, {date_invoiced: {_lte: $end}}, {shopid: {_eq: $bodyshopid}}]}) { jobs(where: {_and: [{_or: [{date_invoiced: {_gt: $start, _lte: $end}}, {actual_delivery: {_gt: $start, _lte: $end}, date_invoiced: {_is_null: true}}, {actual_completion: {_gt: $start, _lte: $end}, actual_delivery: {_is_null: true}, date_invoiced: {_is_null: true}}]}, {_not: {_and: [{date_invoiced: {_is_null: true}}, {actual_delivery: {_is_null: true}}, {actual_completion: {_is_null: true}}]}}, {shopid: {_eq: $bodyshopid}}, {voided: {_neq: true}}, {v_vin: {_is_null: false}}, {ro_number: {_is_null: false}}]}) {
id actual_completion
actual_delivery
area_of_damage
created_at created_at
ro_number
v_model_yr
v_model_desc
v_make_desc
v_vin
date_estimated date_estimated
date_open
date_invoiced date_invoiced
loss_date date_open
id
ins_co_nm ins_co_nm
job_totals
joblines(where: {removed: {_eq: false}}) {
act_price
alt_partno
line_desc
mod_lb_hrs
mod_lbr_ty
oem_partno
op_code_desc
part_type
part_qty
}
loss_date
loss_desc loss_desc
ro_number
theft_ind theft_ind
tlos_ind tlos_ind
job_totals v_make_desc
area_of_damage v_model_desc
joblines(where: {removed: {_eq: false}}) { v_model_yr
line_desc v_vin
oem_partno
alt_partno
mod_lbr_ty
part_qty
part_type
act_price
}
} }
}`; }`;
@@ -1859,7 +1863,7 @@ exports.GET_CHATTER_SHOPS = `query GET_CHATTER_SHOPS {
}`; }`;
exports.GET_CARFAX_SHOPS = `query GET_CARFAX_SHOPS { exports.GET_CARFAX_SHOPS = `query GET_CARFAX_SHOPS {
bodyshops(where: {external_shop_id: {_is_null: true}}){ bodyshops(where: {external_shop_id: {_is_null: true}, carfax_exclude: {_neq: "true"}}){
id id
shopname shopname
imexshopid imexshopid