feature/IO-3255-simplified-parts-management - Checkpoint
This commit is contained in:
@@ -23,17 +23,21 @@ const KNOWN_PART_RATE_TYPES = [
|
|||||||
* @returns {object} The parts tax rates object.
|
* @returns {object} The parts tax rates object.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//PF: Major validation would be required on this - EMS files are inconsistent with things like 5% being passed as 5.0 or .05.
|
//TODO: Major validation would be required on this - EMS files are inconsistent with things like 5% being passed as 5.0 or .05.
|
||||||
//PF: Is this data being sent by them now?
|
|
||||||
const extractPartsTaxRates = (profile = {}) => {
|
const extractPartsTaxRates = (profile = {}) => {
|
||||||
const rateInfos = Array.isArray(profile.RateInfo) ? profile.RateInfo : [profile.RateInfo || {}];
|
const rateInfos = Array.isArray(profile.RateInfo) ? profile.RateInfo : [profile.RateInfo || {}];
|
||||||
const partsTaxRates = {};
|
const partsTaxRates = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In this context, r.RateType._ accesses the property named _ on the RateType object.
|
||||||
|
* This pattern is common when handling data parsed from XML, where element values are stored under the _ key. So,
|
||||||
|
* _ aligns to the actual value/content of the RateType field when RateType is an object (not a string).
|
||||||
|
*/
|
||||||
for (const r of rateInfos) {
|
for (const r of rateInfos) {
|
||||||
const rateTypeRaw =
|
const rateTypeRaw =
|
||||||
typeof r?.RateType === "string"
|
typeof r?.RateType === "string"
|
||||||
? r.RateType
|
? r.RateType
|
||||||
: typeof r?.RateType === "object" && r?.RateType._ //PF: what does _ align to?
|
: typeof r?.RateType === "object" && r?.RateType._
|
||||||
? r.RateType._
|
? r.RateType._
|
||||||
: "";
|
: "";
|
||||||
const rateType = (rateTypeRaw || "").toUpperCase();
|
const rateType = (rateTypeRaw || "").toUpperCase();
|
||||||
|
|||||||
@@ -83,46 +83,46 @@ const deleteJobsByIds = async (jobIds) => {
|
|||||||
*/
|
*/
|
||||||
const partsManagementDeprovisioning = async (req, res) => {
|
const partsManagementDeprovisioning = async (req, res) => {
|
||||||
const { logger } = req;
|
const { logger } = req;
|
||||||
const p = req.body; //Same as other file, can p be renamed to be more descriptive?
|
const body = req.body;
|
||||||
|
|
||||||
if (process.env.NODE_ENV === "production") {
|
if (process.env.NODE_ENV === "production") {
|
||||||
return res.status(403).json({ error: "Deprovisioning not allowed in production environment." });
|
return res.status(403).json({ error: "Deprovisioning not allowed in production environment." });
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!p.shopId) {
|
if (!body.shopId) {
|
||||||
throw { status: 400, message: "shopId is required." };
|
throw { status: 400, message: "shopId is required." };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch bodyshop and check external_shop_id
|
// Fetch bodyshop and check external_shop_id
|
||||||
const shopResp = await client.request(GET_BODYSHOP, { id: p.shopId });
|
const shopResp = await client.request(GET_BODYSHOP, { id: body.shopId });
|
||||||
const shop = shopResp.bodyshops_by_pk;
|
const shop = shopResp.bodyshops_by_pk;
|
||||||
if (!shop) {
|
if (!shop) {
|
||||||
throw { status: 404, message: `Bodyshop with id ${p.shopId} not found.` };
|
throw { status: 404, message: `Bodyshop with id ${body.shopId} not found.` };
|
||||||
}
|
}
|
||||||
if (!shop.external_shop_id) {
|
if (!shop.external_shop_id) {
|
||||||
throw { status: 400, message: "Cannot delete bodyshop without external_shop_id." };
|
throw { status: 400, message: "Cannot delete bodyshop without external_shop_id." };
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log("admin-delete-shop", "debug", null, null, {
|
logger.log("admin-delete-shop", "debug", null, null, {
|
||||||
shopId: p.shopId,
|
shopId: body.shopId,
|
||||||
shopname: shop.shopname,
|
shopname: shop.shopname,
|
||||||
ioadmin: true
|
ioadmin: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get vendors
|
// Get vendors
|
||||||
const vendorsResp = await client.request(GET_VENDORS, { shopId: p.shopId });
|
const vendorsResp = await client.request(GET_VENDORS, { shopId: body.shopId });
|
||||||
const deletedVendors = vendorsResp.vendors.map((v) => v.name);
|
const deletedVendors = vendorsResp.vendors.map((v) => v.name);
|
||||||
|
|
||||||
// Get associated users
|
// Get associated users
|
||||||
const assocResp = await client.request(GET_ASSOCIATED_USERS, { shopId: p.shopId });
|
const assocResp = await client.request(GET_ASSOCIATED_USERS, { shopId: body.shopId });
|
||||||
const associatedUsers = assocResp.associations.map((assoc) => ({
|
const associatedUsers = assocResp.associations.map((assoc) => ({
|
||||||
authId: assoc.user.authid,
|
authId: assoc.user.authid,
|
||||||
email: assoc.user.email
|
email: assoc.user.email
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Delete associations for the shop
|
// Delete associations for the shop
|
||||||
const assocDeleteResp = await client.request(DELETE_ASSOCIATIONS_BY_SHOP, { shopId: p.shopId });
|
const assocDeleteResp = await client.request(DELETE_ASSOCIATIONS_BY_SHOP, { shopId: body.shopId });
|
||||||
const associationsDeleted = assocDeleteResp.delete_associations.affected_rows;
|
const associationsDeleted = assocDeleteResp.delete_associations.affected_rows;
|
||||||
|
|
||||||
// For each user, check if they have remaining associations; if not, delete user and Firebase account
|
// For each user, check if they have remaining associations; if not, delete user and Firebase account
|
||||||
@@ -138,23 +138,23 @@ const partsManagementDeprovisioning = async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get all job ids for this shop, then delete joblines and jobs (joblines first)
|
// Get all job ids for this shop, then delete joblines and jobs (joblines first)
|
||||||
const jobIds = await getJobIdsForShop(p.shopId);
|
const jobIds = await getJobIdsForShop(body.shopId);
|
||||||
const joblinesDeleted = await deleteJoblinesForJobs(jobIds);
|
const joblinesDeleted = await deleteJoblinesForJobs(jobIds);
|
||||||
const jobsDeleted = await deleteJobsByIds(jobIds);
|
const jobsDeleted = await deleteJobsByIds(jobIds);
|
||||||
|
|
||||||
// Delete any audit trail entries tied to this bodyshop to avoid FK violations
|
// Delete any audit trail entries tied to this bodyshop to avoid FK violations
|
||||||
const auditResp = await client.request(DELETE_AUDIT_TRAIL_BY_SHOP, { shopId: p.shopId });
|
const auditResp = await client.request(DELETE_AUDIT_TRAIL_BY_SHOP, { shopId: body.shopId });
|
||||||
const auditDeleted = auditResp.delete_audit_trail.affected_rows;
|
const auditDeleted = auditResp.delete_audit_trail.affected_rows;
|
||||||
|
|
||||||
// Delete vendors
|
// Delete vendors
|
||||||
await deleteVendorsByShop(p.shopId);
|
await deleteVendorsByShop(body.shopId);
|
||||||
|
|
||||||
// Delete shop
|
// Delete shop
|
||||||
await deleteBodyshop(p.shopId);
|
await deleteBodyshop(body.shopId);
|
||||||
|
|
||||||
// Summary log
|
// Summary log
|
||||||
logger.log("admin-delete-shop-summary", "info", null, null, {
|
logger.log("admin-delete-shop-summary", "info", null, null, {
|
||||||
shopId: p.shopId,
|
shopId: body.shopId,
|
||||||
shopname: shop.shopname,
|
shopname: shop.shopname,
|
||||||
associationsDeleted,
|
associationsDeleted,
|
||||||
deletedUsers,
|
deletedUsers,
|
||||||
@@ -165,8 +165,8 @@ const partsManagementDeprovisioning = async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
message: `Bodyshop ${p.shopId} and associated resources deleted successfully.`,
|
message: `Bodyshop ${body.shopId} and associated resources deleted successfully.`,
|
||||||
deletedShop: { id: p.shopId, name: shop.shopname },
|
deletedShop: { id: body.shopId, name: shop.shopname },
|
||||||
deletedAssociationsCount: associationsDeleted,
|
deletedAssociationsCount: associationsDeleted,
|
||||||
deletedUsers: deletedUsers,
|
deletedUsers: deletedUsers,
|
||||||
deletedVendors: deletedVendors,
|
deletedVendors: deletedVendors,
|
||||||
|
|||||||
@@ -139,12 +139,11 @@ const insertUserAssociation = async (uid, email, shopId) => {
|
|||||||
*/
|
*/
|
||||||
const partsManagementProvisioning = async (req, res) => {
|
const partsManagementProvisioning = async (req, res) => {
|
||||||
const { logger } = req;
|
const { logger } = req;
|
||||||
const p = { ...req.body, userEmail: req.body.userEmail?.toLowerCase() };
|
const body = { ...req.body, userEmail: req.body.userEmail?.toLowerCase() };
|
||||||
// Can p be renamed to be more descriptive?
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ensureEmailNotRegistered(p.userEmail);
|
await ensureEmailNotRegistered(body.userEmail);
|
||||||
requireFields(p, [
|
requireFields(body, [
|
||||||
"external_shop_id",
|
"external_shop_id",
|
||||||
"shopname",
|
"shopname",
|
||||||
"address1",
|
"address1",
|
||||||
@@ -156,27 +155,27 @@ const partsManagementProvisioning = async (req, res) => {
|
|||||||
"phone",
|
"phone",
|
||||||
"userEmail"
|
"userEmail"
|
||||||
]);
|
]);
|
||||||
await ensureExternalIdUnique(p.external_shop_id);
|
await ensureExternalIdUnique(body.external_shop_id);
|
||||||
|
|
||||||
logger.log("admin-create-shop-user", "debug", p.userEmail, null, {
|
logger.log("admin-create-shop-user", "debug", body.userEmail, null, {
|
||||||
request: req.body,
|
request: req.body,
|
||||||
ioadmin: true
|
ioadmin: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const shopInput = {
|
const shopInput = {
|
||||||
shopname: p.shopname,
|
shopname: body.shopname,
|
||||||
address1: p.address1,
|
address1: body.address1,
|
||||||
address2: p.address2 || null,
|
address2: body.address2 || null,
|
||||||
city: p.city,
|
city: body.city,
|
||||||
state: p.state,
|
state: body.state,
|
||||||
zip_post: p.zip_post,
|
zip_post: body.zip_post,
|
||||||
country: p.country,
|
country: body.country,
|
||||||
email: p.email,
|
email: body.email,
|
||||||
external_shop_id: p.external_shop_id,
|
external_shop_id: body.external_shop_id,
|
||||||
timezone: p.timezone || DefaultNewShop.timezone,
|
timezone: body.timezone || DefaultNewShop.timezone,
|
||||||
phone: p.phone,
|
phone: body.phone,
|
||||||
logo_img_path: {
|
logo_img_path: {
|
||||||
src: p.logoUrl,
|
src: body.logoUrl,
|
||||||
width: "",
|
width: "",
|
||||||
height: "",
|
height: "",
|
||||||
headerMargin: DefaultNewShop.logo_img_path.headerMargin
|
headerMargin: DefaultNewShop.logo_img_path.headerMargin
|
||||||
@@ -201,7 +200,7 @@ const partsManagementProvisioning = async (req, res) => {
|
|||||||
appt_alt_transport: DefaultNewShop.appt_alt_transport,
|
appt_alt_transport: DefaultNewShop.appt_alt_transport,
|
||||||
md_jobline_presets: DefaultNewShop.md_jobline_presets,
|
md_jobline_presets: DefaultNewShop.md_jobline_presets,
|
||||||
vendors: {
|
vendors: {
|
||||||
data: p.vendors.map((v) => ({ //Many of these will be empty, but good to call out explicitly to self document.
|
data: body.vendors.map((v) => ({
|
||||||
name: v.name,
|
name: v.name,
|
||||||
street1: v.street1 || null,
|
street1: v.street1 || null,
|
||||||
street2: v.street2 || null,
|
street2: v.street2 || null,
|
||||||
@@ -222,23 +221,22 @@ const partsManagementProvisioning = async (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const newShopId = await insertBodyshop(shopInput);
|
const newShopId = await insertBodyshop(shopInput);
|
||||||
const userRecord = await createFirebaseUser(p.userEmail, p.userPassword);
|
const userRecord = await createFirebaseUser(body.userEmail, body.userPassword);
|
||||||
let resetLink = null;
|
let resetLink = null;
|
||||||
if (!p.userPassword) resetLink = await generateResetLink(p.userEmail);
|
if (!body.userPassword) resetLink = await generateResetLink(body.userEmail);
|
||||||
|
|
||||||
const createdUser = await insertUserAssociation(userRecord.uid, p.userEmail, newShopId);
|
const createdUser = await insertUserAssociation(userRecord.uid, body.userEmail, newShopId);
|
||||||
//Association can be included in shop creation call, but this is also prescriptive and fine.
|
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
shop: { id: newShopId, shopname: p.shopname },
|
shop: { id: newShopId, shopname: body.shopname },
|
||||||
user: {
|
user: {
|
||||||
id: createdUser.id,
|
id: createdUser.id,
|
||||||
email: createdUser.email,
|
email: createdUser.email,
|
||||||
resetLink: resetLink || undefined //Does WE know to expect this?
|
resetLink: resetLink || undefined
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.log("admin-create-shop-user-error", "error", p.userEmail, null, {
|
logger.log("admin-create-shop-user-error", "error", body.userEmail, null, {
|
||||||
message: err.message,
|
message: err.message,
|
||||||
detail: err.detail || err
|
detail: err.detail || err
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const {
|
|||||||
} = require("../partsManagement.queries");
|
} = require("../partsManagement.queries");
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
const FALLBACK_DEFAULT_ORDER_STATUS = "Open";
|
const FALLBACK_DEFAULT_JOB_STATUS = "Open";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the default order status for a bodyshop.
|
* Fetches the default order status for a bodyshop.
|
||||||
@@ -22,13 +22,13 @@ const FALLBACK_DEFAULT_ORDER_STATUS = "Open";
|
|||||||
* @param {object} logger - The logger instance.
|
* @param {object} logger - The logger instance.
|
||||||
* @returns {Promise<string>} The default status or fallback.
|
* @returns {Promise<string>} The default status or fallback.
|
||||||
*/
|
*/
|
||||||
const getDefaultOrderStatus = async (shopId, logger) => {
|
const getDefaultJobStatus = async (shopId, logger) => {
|
||||||
try {
|
try {
|
||||||
const { bodyshop_by_pk } = await client.request(GET_BODYSHOP_STATUS, { id: shopId });
|
const { bodyshop_by_pk } = await client.request(GET_BODYSHOP_STATUS, { id: shopId });
|
||||||
return bodyshop_by_pk?.md_order_statuses?.default_open || FALLBACK_DEFAULT_ORDER_STATUS; //I think this is intended to be called job status, not order status.
|
return bodyshop_by_pk?.md_ro_statuses?.default_imported || FALLBACK_DEFAULT_JOB_STATUS;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.log("parts-bodyshop-fetch-failed", "warn", shopId, null, { error: err });
|
logger.log("parts-bodyshop-fetch-failed", "warn", shopId, null, { error: err });
|
||||||
return FALLBACK_DEFAULT_ORDER_STATUS;
|
return FALLBACK_DEFAULT_JOB_STATUS;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@@ -66,6 +66,7 @@ const extractJobData = (rq) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
shopId: rq.ShopID || rq.shopId,
|
shopId: rq.ShopID || rq.shopId,
|
||||||
|
// status: ci.ClaimStatus || null, Proper, setting it default for now
|
||||||
refClaimNum: rq.RefClaimNum,
|
refClaimNum: rq.RefClaimNum,
|
||||||
ciecaid: rq.RqUID || null,
|
ciecaid: rq.RqUID || null,
|
||||||
// Pull Cieca_ttl from ClaimInfo per schema/sample
|
// Pull Cieca_ttl from ClaimInfo per schema/sample
|
||||||
@@ -81,8 +82,6 @@ const extractJobData = (rq) => {
|
|||||||
scheduled_in: ev.RepairEvent?.RequestedPickUpDateTime || null,
|
scheduled_in: ev.RepairEvent?.RequestedPickUpDateTime || null,
|
||||||
scheduled_completion: ev.RepairEvent?.TargetCompletionDateTime || null,
|
scheduled_completion: ev.RepairEvent?.TargetCompletionDateTime || null,
|
||||||
clm_no: ci.ClaimNum || null,
|
clm_no: ci.ClaimNum || null,
|
||||||
// status: ci.ClaimStatus || null, Proper, setting it default for now
|
|
||||||
status: FALLBACK_DEFAULT_ORDER_STATUS,
|
|
||||||
policy_no: ci.PolicyInfo?.PolicyInfo?.PolicyNum || ci.PolicyInfo?.PolicyNum || null,
|
policy_no: ci.PolicyInfo?.PolicyInfo?.PolicyNum || ci.PolicyInfo?.PolicyNum || null,
|
||||||
ded_amt: parseFloat(ci.PolicyInfo?.CoverageInfo?.Coverage?.DeductibleInfo?.DeductibleAmt || 0)
|
ded_amt: parseFloat(ci.PolicyInfo?.CoverageInfo?.Coverage?.DeductibleInfo?.DeductibleAmt || 0)
|
||||||
};
|
};
|
||||||
@@ -101,17 +100,19 @@ const extractOwnerData = (rq, shopId) => {
|
|||||||
const personName = personInfo.PersonName || {};
|
const personName = personInfo.PersonName || {};
|
||||||
const address = personInfo.Communications?.Address || {};
|
const address = personInfo.Communications?.Address || {};
|
||||||
|
|
||||||
let ownr_ph1, ownr_ph2, ownr_ea, ownr_alt_ph;
|
let ownr_ph1, ownr_ph2, ownr_ea;
|
||||||
|
|
||||||
const comms = Array.isArray(ownerOrClaimant.ContactInfo?.Communications)
|
const comms = Array.isArray(ownerOrClaimant.ContactInfo?.Communications)
|
||||||
? ownerOrClaimant.ContactInfo.Communications
|
? ownerOrClaimant.ContactInfo.Communications
|
||||||
: [ownerOrClaimant.ContactInfo?.Communications || {}];
|
: [ownerOrClaimant.ContactInfo?.Communications || {}];
|
||||||
|
|
||||||
for (const c of comms) {
|
for (const c of comms) {
|
||||||
if (c.CommQualifier === "CP") ownr_ph1 = c.CommPhone; //PF: Should document this logic. 1 and 2 don't typically indicate type in EMS. This makes sense, but good to document.
|
// TODO: Should document this logic. 1 and 2 don't
|
||||||
|
// typically indicate type in EMS. This makes sense, but good to document.
|
||||||
|
if (c.CommQualifier === "CP") ownr_ph1 = c.CommPhone;
|
||||||
if (c.CommQualifier === "WP") ownr_ph2 = c.CommPhone;
|
if (c.CommQualifier === "WP") ownr_ph2 = c.CommPhone;
|
||||||
if (c.CommQualifier === "EM") ownr_ea = c.CommEmail;
|
if (c.CommQualifier === "EM") ownr_ea = c.CommEmail;
|
||||||
if (c.CommQualifier === "AL") ownr_alt_ph = c.CommPhone;
|
// if (c.CommQualifier === "AL") ownr_alt_ph = c.CommPhone;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -127,8 +128,8 @@ const extractOwnerData = (rq, shopId) => {
|
|||||||
ownr_ctry: address.Country || null,
|
ownr_ctry: address.Country || null,
|
||||||
ownr_ph1,
|
ownr_ph1,
|
||||||
ownr_ph2,
|
ownr_ph2,
|
||||||
ownr_ea,
|
ownr_ea
|
||||||
ownr_alt_ph //PF: This is not in the DB, if this object is inserted in place, this will fail.
|
// ownr_alt_ph
|
||||||
// ownr_id_qualifier: ownerOrClaimant.IDInfo?.IDQualifierCode || null // New
|
// ownr_id_qualifier: ownerOrClaimant.IDInfo?.IDQualifierCode || null // New
|
||||||
// ownr_id_num: ownerOrClaimant.IDInfo?.IDNum || null, // New
|
// ownr_id_num: ownerOrClaimant.IDInfo?.IDNum || null, // New
|
||||||
// ownr_preferred_contact: ownerOrClaimant.PreferredContactMethod || null // New
|
// ownr_preferred_contact: ownerOrClaimant.PreferredContactMethod || null // New
|
||||||
@@ -159,38 +160,40 @@ const extractEstimatorData = (rq) => {
|
|||||||
* @param {object} rq - The VehicleDamageEstimateAddRq object.
|
* @param {object} rq - The VehicleDamageEstimateAddRq object.
|
||||||
* @returns {object} Adjuster data.
|
* @returns {object} Adjuster data.
|
||||||
*/
|
*/
|
||||||
const extractAdjusterData = (rq) => {
|
// const extractAdjusterData = (rq) => {
|
||||||
const adjParty = rq.AdminInfo?.Adjuster?.Party || {};
|
// const adjParty = rq.AdminInfo?.Adjuster?.Party || {};
|
||||||
const adjComms = Array.isArray(adjParty.ContactInfo?.Communications)
|
// const adjComms = Array.isArray(adjParty.ContactInfo?.Communications)
|
||||||
? adjParty.ContactInfo.Communications
|
// ? adjParty.ContactInfo.Communications
|
||||||
: [adjParty.ContactInfo?.Communications || {}];
|
// : [adjParty.ContactInfo?.Communications || {}];
|
||||||
|
//
|
||||||
return {
|
// return {
|
||||||
agt_ct_fn: adjParty.PersonInfo?.PersonName?.FirstName || null, //PF: I dont think we display agt_ct_* fields in app. Have they typically been sending data here?
|
// //TODO: I dont think we display agt_ct_* fields in app. Have they typically been sending data here?
|
||||||
agt_ct_ln: adjParty.PersonInfo?.PersonName?.LastName || null,
|
// agt_ct_fn: adjParty.PersonInfo?.PersonName?.FirstName || null,
|
||||||
agt_ct_ph: adjComms.find((c) => c.CommQualifier === "CP")?.CommPhone || null,
|
// agt_ct_ln: adjParty.PersonInfo?.PersonName?.LastName || null,
|
||||||
agt_ea: adjComms.find((c) => c.CommQualifier === "EM")?.CommEmail || null
|
// agt_ct_ph: adjComms.find((c) => c.CommQualifier === "CP")?.CommPhone || null,
|
||||||
};
|
// agt_ea: adjComms.find((c) => c.CommQualifier === "EM")?.CommEmail || null
|
||||||
};
|
// };
|
||||||
|
// };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts repair facility data from the XML request.
|
* Extracts repair facility data from the XML request.
|
||||||
* @param {object} rq - The VehicleDamageEstimateAddRq object.
|
* @param {object} rq - The VehicleDamageEstimateAddRq object.
|
||||||
* @returns {object} Repair facility data.
|
* @returns {object} Repair facility data.
|
||||||
*/
|
*/
|
||||||
const extractRepairFacilityData = (rq) => {
|
// const extractRepairFacilityData = (rq) => {
|
||||||
const rfParty = rq.AdminInfo?.RepairFacility?.Party || {};
|
// const rfParty = rq.AdminInfo?.RepairFacility?.Party || {};
|
||||||
const rfComms = Array.isArray(rfParty.ContactInfo?.Communications)
|
// const rfComms = Array.isArray(rfParty.ContactInfo?.Communications)
|
||||||
? rfParty.ContactInfo.Communications
|
// ? rfParty.ContactInfo.Communications
|
||||||
: [rfParty.ContactInfo?.Communications || {}];
|
// : [rfParty.ContactInfo?.Communications || {}];
|
||||||
|
//
|
||||||
return {
|
// return {
|
||||||
servicing_dealer: rfParty.OrgInfo?.CompanyName || null, //PF: The servicing dealer fields are a relic from synergy for a few folks
|
// servicing_dealer: rfParty.OrgInfo?.CompanyName || null,
|
||||||
//PF: I suspect RF data could be ignored since they are the RF.
|
// // TODO: The servicing dealer fields are a relic from synergy for a few folks
|
||||||
servicing_dealer_contact:
|
// // TODO: I suspect RF data could be ignored since they are the RF.
|
||||||
rfComms.find((c) => c.CommQualifier === "WP" || c.CommQualifier === "FX")?.CommPhone || null
|
// servicing_dealer_contact:
|
||||||
};
|
// rfComms.find((c) => c.CommQualifier === "WP" || c.CommQualifier === "FX")?.CommPhone || null
|
||||||
};
|
// };
|
||||||
|
// };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts loss information from the XML request.
|
* Extracts loss information from the XML request.
|
||||||
@@ -204,10 +207,12 @@ const extractLossInfo = (rq) => {
|
|||||||
loss_date: loss.LossDateTime || null,
|
loss_date: loss.LossDateTime || null,
|
||||||
loss_type: custom.LossTypeCode || null,
|
loss_type: custom.LossTypeCode || null,
|
||||||
loss_desc: custom.LossTypeDesc || null
|
loss_desc: custom.LossTypeDesc || null
|
||||||
// primary_poi: loss.PrimaryPOI?.POICode || null, //PF: These map back to area_of_impact.impact_#
|
// area_of_impact: {
|
||||||
// secondary_poi: loss.SecondaryPOI?.POICode || null,
|
// impact_1: loss.PrimaryPOI?.POICode || null,
|
||||||
|
// imact_2 :loss.SecondaryPOI?.POICode || null,
|
||||||
|
// },
|
||||||
|
// tlosind: rq.ClaimInfo?.LossInfo?.TotalLossInd || null,
|
||||||
// damage_memo: loss.DamageMemo || null, //(maybe ins_memo)
|
// damage_memo: loss.DamageMemo || null, //(maybe ins_memo)
|
||||||
// total_loss_ind: rq.ClaimInfo?.LossInfo?.TotalLossInd || null // New //PF: tlosind i believe is our field.
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -289,9 +294,11 @@ const extractVehicleData = (rq, shopId) => {
|
|||||||
v_color: exterior.Color?.ColorName || null,
|
v_color: exterior.Color?.ColorName || null,
|
||||||
v_bstyle: desc.BodyStyle || null,
|
v_bstyle: desc.BodyStyle || null,
|
||||||
v_engine: desc.EngineDesc || null,
|
v_engine: desc.EngineDesc || null,
|
||||||
v_options: desc.SubModelDesc || null, //PF: Need to confirm with exact data, but this is typically a list of options. Not used AFAIK.
|
// TODO Need to confirm with exact data, but this is typically a list of options. Not used AFAIK.
|
||||||
|
v_options: desc.SubModelDesc || null,
|
||||||
v_type: desc.FuelType || null,
|
v_type: desc.FuelType || null,
|
||||||
v_cond: rq.VehicleInfo?.Condition?.DrivableInd, //PF: there is a separate driveable flag on the job.
|
// TODO there is a separate driveable flag on the job.
|
||||||
|
v_cond: rq.VehicleInfo?.Condition?.DrivableInd,
|
||||||
v_trimcode: desc.TrimCode || null,
|
v_trimcode: desc.TrimCode || null,
|
||||||
v_tone: exterior.Tone || null,
|
v_tone: exterior.Tone || null,
|
||||||
v_stage: exterior.RefinishStage || rq.VehicleInfo?.Paint?.RefinishStage || null,
|
v_stage: exterior.RefinishStage || rq.VehicleInfo?.Paint?.RefinishStage || null,
|
||||||
@@ -343,7 +350,8 @@ const extractJobLines = (rq) => {
|
|||||||
line.ManualLineInd === true ||
|
line.ManualLineInd === true ||
|
||||||
line.ManualLineInd === 1 ||
|
line.ManualLineInd === 1 ||
|
||||||
line.ManualLineInd === "1" ||
|
line.ManualLineInd === "1" ||
|
||||||
(typeof line.ManualLineInd === "string" && line.ManualLineInd.toUpperCase() === "Y"); //PF: manual line tracks manual in IO or not, this woudl presumably always be false
|
// TODO: manual line tracks manual in IO or not, this woudl presumably always be false
|
||||||
|
(typeof line.ManualLineInd === "string" && line.ManualLineInd.toUpperCase() === "Y");
|
||||||
} else {
|
} else {
|
||||||
lineOut.manual_line = null;
|
lineOut.manual_line = null;
|
||||||
}
|
}
|
||||||
@@ -356,8 +364,10 @@ const extractJobLines = (rq) => {
|
|||||||
const price = parseFloat(partInfo.PartPrice || partInfo.ListPrice || 0);
|
const price = parseFloat(partInfo.PartPrice || partInfo.ListPrice || 0);
|
||||||
lineOut.part_type = partInfo.PartType || null ? String(partInfo.PartType).toUpperCase() : null;
|
lineOut.part_type = partInfo.PartType || null ? String(partInfo.PartType).toUpperCase() : null;
|
||||||
lineOut.part_qty = parseFloat(partInfo.Quantity || 0) || 1;
|
lineOut.part_qty = parseFloat(partInfo.Quantity || 0) || 1;
|
||||||
lineOut.oem_partno = partInfo.OEMPartNum || partInfo.PartNum || null; //PF: if aftermarket part, we have alt_part_no to capture.
|
//TODO: if aftermarket part, we have alt_part_no to capture.
|
||||||
lineOut.db_price = isNaN(price) ? 0 : price; //PF: the Db and act price often are different. These should map back to their EMS equivalents.
|
lineOut.oem_partno = partInfo.OEMPartNum || partInfo.PartNum || null;
|
||||||
|
//TODO: the Db and act price often are different. These should map back to their EMS equivalents.
|
||||||
|
lineOut.db_price = isNaN(price) ? 0 : price;
|
||||||
lineOut.act_price = isNaN(price) ? 0 : price;
|
lineOut.act_price = isNaN(price) ? 0 : price;
|
||||||
|
|
||||||
// Tax flag from PartInfo.TaxableInd when provided
|
// Tax flag from PartInfo.TaxableInd when provided
|
||||||
@@ -373,8 +383,11 @@ const extractJobLines = (rq) => {
|
|||||||
partInfo.TaxableInd === "1" ||
|
partInfo.TaxableInd === "1" ||
|
||||||
(typeof partInfo.TaxableInd === "string" && partInfo.TaxableInd.toUpperCase() === "Y");
|
(typeof partInfo.TaxableInd === "string" && partInfo.TaxableInd.toUpperCase() === "Y");
|
||||||
}
|
}
|
||||||
} else if (hasSublet) {
|
}
|
||||||
const amt = parseFloat(subletInfo.SubletAmount || 0); //PF: Some nuance here. Usually a part and sublet amount shouldnt be on the same line, but they theoretically could. May require additional discussion.
|
//TODO: Some nuance here. Usually a part and sublet amount shouldnt be on the same line, but they theoretically
|
||||||
|
// could.May require additional discussion.
|
||||||
|
else if (hasSublet) {
|
||||||
|
const amt = parseFloat(subletInfo.SubletAmount || 0);
|
||||||
lineOut.part_type = "PAS"; // Sublet as parts-as-service
|
lineOut.part_type = "PAS"; // Sublet as parts-as-service
|
||||||
lineOut.part_qty = 1;
|
lineOut.part_qty = 1;
|
||||||
lineOut.act_price = isNaN(amt) ? 0 : amt;
|
lineOut.act_price = isNaN(amt) ? 0 : amt;
|
||||||
@@ -390,12 +403,14 @@ const extractJobLines = (rq) => {
|
|||||||
if (hasLabor) {
|
if (hasLabor) {
|
||||||
lineOut.mod_lbr_ty = laborInfo.LaborType || null;
|
lineOut.mod_lbr_ty = laborInfo.LaborType || null;
|
||||||
lineOut.mod_lb_hrs = isNaN(hrs) ? 0 : hrs;
|
lineOut.mod_lb_hrs = isNaN(hrs) ? 0 : hrs;
|
||||||
lineOut.lbr_op = laborInfo.LaborOperation || null; //PF: can add lbr_op_desc according to mapping available in new partner.
|
//TODO: can add lbr_op_desc according to mapping available in new partner.
|
||||||
|
lineOut.lbr_op = laborInfo.LaborOperation || null;
|
||||||
lineOut.lbr_amt = isNaN(amt) ? 0 : amt;
|
lineOut.lbr_amt = isNaN(amt) ? 0 : amt;
|
||||||
}
|
}
|
||||||
|
|
||||||
//PF: what's the BMS logic for this? Body and refinish operations can often happen to the same part, but most systems output a second line for the refinish labor.
|
//TODO: what's the BMS logic for this? Body and refinish operations can often happen to the same part,
|
||||||
//PF: 2nd line may include a duplicate of the part price, but that can be removed. This is the case for CCC.
|
// but most systems output a second line for the refinish labor.
|
||||||
|
//TODO: 2nd line may include a duplicate of the part price, but that can be removed. This is the case for CCC.
|
||||||
// Refinish labor (if present) recorded on the same line using secondary labor fields
|
// Refinish labor (if present) recorded on the same line using secondary labor fields
|
||||||
const rHrs = parseFloat(refinishInfo.LaborHours || 0);
|
const rHrs = parseFloat(refinishInfo.LaborHours || 0);
|
||||||
const rAmt = parseFloat(refinishInfo.LaborAmt || 0);
|
const rAmt = parseFloat(refinishInfo.LaborAmt || 0);
|
||||||
@@ -406,9 +421,9 @@ const extractJobLines = (rq) => {
|
|||||||
!isNaN(rAmt) ||
|
!isNaN(rAmt) ||
|
||||||
!!refinishInfo.LaborOperation);
|
!!refinishInfo.LaborOperation);
|
||||||
if (hasRefinish) {
|
if (hasRefinish) {
|
||||||
lineOut.lbr_typ_j = refinishInfo.LaborType || "LAR"; //PF: _j fields indicate judgement, and are bool type.
|
lineOut.lbr_typ_j = refinishInfo.LaborType || "LAR"; //TODO: _j fields indicate judgement, and are bool type.
|
||||||
lineOut.lbr_hrs_j = isNaN(rHrs) ? 0 : rHrs;//PF: _j fields indicate judgement, and are bool type.
|
lineOut.lbr_hrs_j = isNaN(rHrs) ? 0 : rHrs; //TODO: _j fields indicate judgement, and are bool type.
|
||||||
lineOut.lbr_op_j = refinishInfo.LaborOperation || null; //PF: _j fields indicate judgement, and are bool type.
|
lineOut.lbr_op_j = refinishInfo.LaborOperation || null; //TODO: _j fields indicate judgement, and are bool type.
|
||||||
// Aggregate refinish labor amount into the total labor amount for the line
|
// Aggregate refinish labor amount into the total labor amount for the line
|
||||||
if (!isNaN(rAmt)) {
|
if (!isNaN(rAmt)) {
|
||||||
lineOut.lbr_amt = (Number.isFinite(lineOut.lbr_amt) ? lineOut.lbr_amt : 0) + rAmt;
|
lineOut.lbr_amt = (Number.isFinite(lineOut.lbr_amt) ? lineOut.lbr_amt : 0) + rAmt;
|
||||||
@@ -424,26 +439,26 @@ const extractJobLines = (rq) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Helper to extract a GRAND TOTAL amount from RepairTotalsInfo
|
// Helper to extract a GRAND TOTAL amount from RepairTotalsInfo
|
||||||
const extractGrandTotal = (rq) => {
|
// const extractGrandTotal = (rq) => {
|
||||||
const rti = rq.RepairTotalsInfo;
|
// const rti = rq.RepairTotalsInfo;
|
||||||
const groups = Array.isArray(rti) ? rti : rti ? [rti] : [];
|
// const groups = Array.isArray(rti) ? rti : rti ? [rti] : [];
|
||||||
for (const grp of groups) {
|
// for (const grp of groups) {
|
||||||
const sums = Array.isArray(grp.SummaryTotalsInfo)
|
// const sums = Array.isArray(grp.SummaryTotalsInfo)
|
||||||
? grp.SummaryTotalsInfo
|
// ? grp.SummaryTotalsInfo
|
||||||
: grp.SummaryTotalsInfo
|
// : grp.SummaryTotalsInfo
|
||||||
? [grp.SummaryTotalsInfo]
|
// ? [grp.SummaryTotalsInfo]
|
||||||
: [];
|
// : [];
|
||||||
for (const s of sums) {
|
// for (const s of sums) {
|
||||||
const type = (s.TotalType || "").toString().toUpperCase();
|
// const type = (s.TotalType || "").toString().toUpperCase();
|
||||||
const desc = (s.TotalTypeDesc || "").toString().toUpperCase();
|
// const desc = (s.TotalTypeDesc || "").toString().toUpperCase();
|
||||||
if (type.includes("GRAND") || type === "TOTAL" || desc.includes("GRAND")) {
|
// if (type.includes("GRAND") || type === "TOTAL" || desc.includes("GRAND")) {
|
||||||
const amt = parseFloat(s.TotalAmt ?? "NaN");
|
// const amt = parseFloat(s.TotalAmt ?? "NaN");
|
||||||
if (!isNaN(amt)) return amt;
|
// if (!isNaN(amt)) return amt;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return null;
|
// return null;
|
||||||
};
|
// };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts an owner and returns the owner ID.
|
* Inserts an owner and returns the owner ID.
|
||||||
@@ -462,24 +477,26 @@ const insertOwner = async (ownerInput, logger) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Fallback: compute a naive total from joblines (parts + sublet + labor amounts)
|
// Fallback: compute a naive total from joblines (parts + sublet + labor amounts)
|
||||||
const computeLinesTotal = (joblines = []) => {
|
// const computeLinesTotal = (joblines = []) => {
|
||||||
let parts = 0;
|
// let parts = 0;
|
||||||
let labor = 0;
|
// let labor = 0;
|
||||||
for (const jl of joblines) {
|
// for (const jl of joblines) {
|
||||||
if (jl?.part_type) {
|
// if (jl?.part_type) {
|
||||||
const qty = Number.isFinite(jl.part_qty) ? jl.part_qty : 1;
|
// const qty = Number.isFinite(jl.part_qty) ? jl.part_qty : 1;
|
||||||
const price = Number.isFinite(jl.act_price) ? jl.act_price : 0;
|
// const price = Number.isFinite(jl.act_price) ? jl.act_price : 0;
|
||||||
parts += price * (qty || 1);
|
// parts += price * (qty || 1);
|
||||||
} else if (!jl.part_type && Number.isFinite(jl.act_price)) {
|
// } else if (!jl.part_type && Number.isFinite(jl.act_price)) {
|
||||||
parts += jl.act_price;
|
// parts += jl.act_price;
|
||||||
}
|
// }
|
||||||
if (Number.isFinite(jl.lbr_amt)) {
|
// if (Number.isFinite(jl.lbr_amt)) {
|
||||||
labor += jl.lbr_amt;
|
// labor += jl.lbr_amt;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
const total = parts + labor; //PF: clm_total is the 100% full amount of the repair including deductible, betterment and taxes. Typically provided by the source system.
|
// const total = parts + labor;
|
||||||
return Number.isFinite(total) && total > 0 ? total : 0;
|
//
|
||||||
};
|
// //TODO: clm_total is the 100% full amount of the repair including deductible, betterment and taxes. Typically provided by the source system.
|
||||||
|
// return Number.isFinite(total) && total > 0 ? total : 0;
|
||||||
|
// };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the VehicleDamageEstimateAddRq XML request from parts management.
|
* Handles the VehicleDamageEstimateAddRq XML request from parts management.
|
||||||
@@ -516,9 +533,9 @@ const vehicleDamageEstimateAddRq = async (req, res) => {
|
|||||||
scheduled_in,
|
scheduled_in,
|
||||||
scheduled_completion,
|
scheduled_completion,
|
||||||
clm_no,
|
clm_no,
|
||||||
status,
|
|
||||||
policy_no,
|
policy_no,
|
||||||
ded_amt
|
ded_amt
|
||||||
|
// status,
|
||||||
} = extractJobData(rq);
|
} = extractJobData(rq);
|
||||||
|
|
||||||
if (!shopId) {
|
if (!shopId) {
|
||||||
@@ -526,22 +543,22 @@ const vehicleDamageEstimateAddRq = async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get default status
|
// Get default status
|
||||||
const defaultStatus = await getDefaultOrderStatus(shopId, logger); //This likely should be get default job status, not order.
|
const defaultStatus = await getDefaultJobStatus(shopId, logger);
|
||||||
|
|
||||||
// Extract additional data
|
// Extract additional data
|
||||||
const parts_tax_rates = extractPartsTaxRates(rq.ProfileInfo);
|
const parts_tax_rates = extractPartsTaxRates(rq.ProfileInfo);
|
||||||
const ownerData = extractOwnerData(rq, shopId);
|
const ownerData = extractOwnerData(rq, shopId);
|
||||||
const estimatorData = extractEstimatorData(rq);
|
const estimatorData = extractEstimatorData(rq);
|
||||||
const adjusterData = extractAdjusterData(rq);
|
// const adjusterData = extractAdjusterData(rq);
|
||||||
const repairFacilityData = extractRepairFacilityData(rq);
|
// const repairFacilityData = extractRepairFacilityData(rq);
|
||||||
const vehicleData = extractVehicleData(rq, shopId);
|
const vehicleData = extractVehicleData(rq, shopId);
|
||||||
const lossInfo = extractLossInfo(rq);
|
const lossInfo = extractLossInfo(rq);
|
||||||
const joblinesData = extractJobLines(rq);
|
const joblinesData = extractJobLines(rq);
|
||||||
const insuranceData = extractInsuranceData(rq);
|
const insuranceData = extractInsuranceData(rq);
|
||||||
|
|
||||||
// Derive clm_total: prefer RepairTotalsInfo SummaryTotals GRAND TOTAL; else sum from lines
|
// Derive clm_total: prefer RepairTotalsInfo SummaryTotals GRAND TOTAL; else sum from lines
|
||||||
const grandTotal = extractGrandTotal(rq);
|
// const grandTotal = extractGrandTotal(rq);
|
||||||
const computedTotal = grandTotal ?? computeLinesTotal(joblinesData);
|
// const computedTotal = grandTotal ?? computeLinesTotal(joblinesData);
|
||||||
|
|
||||||
// Find or create relationships
|
// Find or create relationships
|
||||||
const ownerid = await insertOwner(ownerData, logger);
|
const ownerid = await insertOwner(ownerData, logger);
|
||||||
@@ -560,8 +577,8 @@ const vehicleDamageEstimateAddRq = async (req, res) => {
|
|||||||
class: classType,
|
class: classType,
|
||||||
parts_tax_rates,
|
parts_tax_rates,
|
||||||
clm_no,
|
clm_no,
|
||||||
status: status || defaultStatus,
|
status: defaultStatus,
|
||||||
clm_total: computedTotal || null,
|
clm_total: 0, // computedTotal || null,
|
||||||
policy_no,
|
policy_no,
|
||||||
ded_amt,
|
ded_amt,
|
||||||
comment,
|
comment,
|
||||||
@@ -576,8 +593,8 @@ const vehicleDamageEstimateAddRq = async (req, res) => {
|
|||||||
...lossInfo,
|
...lossInfo,
|
||||||
...ownerData,
|
...ownerData,
|
||||||
...estimatorData,
|
...estimatorData,
|
||||||
...adjusterData,
|
// ...adjusterData,
|
||||||
...repairFacilityData,
|
// ...repairFacilityData,
|
||||||
// Inline vehicle data
|
// Inline vehicle data
|
||||||
v_vin: vehicleData.v_vin,
|
v_vin: vehicleData.v_vin,
|
||||||
v_model_yr: vehicleData.v_model_yr,
|
v_model_yr: vehicleData.v_model_yr,
|
||||||
|
|||||||
@@ -38,13 +38,15 @@ const findJob = async (shopId, jobId, logger) => {
|
|||||||
const extractUpdatedJobData = (rq) => {
|
const extractUpdatedJobData = (rq) => {
|
||||||
const doc = rq.DocumentInfo || {};
|
const doc = rq.DocumentInfo || {};
|
||||||
const claim = rq.ClaimInfo || {};
|
const claim = rq.ClaimInfo || {};
|
||||||
//PF: In the full BMS world, much more can change.
|
//TODO: In the full BMS world, much more can change, this will need to be expanded
|
||||||
|
// before it can be considered an generic BMS importer, currently it is bespoke to webest
|
||||||
const policyNo = claim.PolicyInfo?.PolicyInfo?.PolicyNum || claim.PolicyInfo?.PolicyNum || null;
|
const policyNo = claim.PolicyInfo?.PolicyInfo?.PolicyNum || claim.PolicyInfo?.PolicyNum || null;
|
||||||
|
|
||||||
const out = {
|
const out = {
|
||||||
comment: doc.Comment || null,
|
comment: doc.Comment || null,
|
||||||
clm_no: claim.ClaimNum || null,
|
clm_no: claim.ClaimNum || null,
|
||||||
status: claim.ClaimStatus || null,
|
// TODO: Commented out so they do not blow over with 'Auth Cust'
|
||||||
|
// status: claim.ClaimStatus || null,
|
||||||
policy_no: policyNo
|
policy_no: policyNo
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -239,7 +241,6 @@ const partsManagementVehicleDamageEstimateChgRq = async (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// --- End fetch current notes ---
|
// --- End fetch current notes ---
|
||||||
//PF: These are several different calls that can be pulled together to make the operation faster.
|
|
||||||
|
|
||||||
const updatedJobData = extractUpdatedJobData(rq);
|
const updatedJobData = extractUpdatedJobData(rq);
|
||||||
const updatedLines = extractUpdatedJobLines(rq.AddsChgs, job.id, currentJobLineNotes);
|
const updatedLines = extractUpdatedJobLines(rq.AddsChgs, job.id, currentJobLineNotes);
|
||||||
@@ -247,12 +248,13 @@ const partsManagementVehicleDamageEstimateChgRq = async (req, res) => {
|
|||||||
|
|
||||||
await client.request(UPDATE_JOB_BY_ID, { id: job.id, job: updatedJobData });
|
await client.request(UPDATE_JOB_BY_ID, { id: job.id, job: updatedJobData });
|
||||||
|
|
||||||
//PF: for changed lines, are they deleted and then reinserted?
|
//TODO: for changed lines, are they deleted and then reinserted?
|
||||||
//PF: Updated lines should get an upsert to update things like desc, price, etc.
|
//TODO: Updated lines should get an upsert to update things like desc, price, etc.
|
||||||
if (deletedLineIds?.length || updatedSeqs?.length) {
|
if (deletedLineIds?.length || updatedSeqs?.length) {
|
||||||
const allToDelete = Array.from(new Set([...(deletedLineIds || []), ...(updatedSeqs || [])]));
|
const allToDelete = Array.from(new Set([...(deletedLineIds || []), ...(updatedSeqs || [])]));
|
||||||
if (allToDelete.length) {
|
if (allToDelete.length) {
|
||||||
await client.request(SOFT_DELETE_JOBLINES_BY_IDS, { jobid: job.id, unqSeqs: allToDelete }); //PF: appears to soft delete updated lines as well.
|
await client.request(SOFT_DELETE_JOBLINES_BY_IDS, { jobid: job.id, unqSeqs: allToDelete });
|
||||||
|
//TODO: appears to soft delete updated lines as well.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
const GET_BODYSHOP_STATUS = `
|
const GET_BODYSHOP_STATUS = `
|
||||||
query GetBodyshopStatus($id: uuid!) {
|
query GetBodyshopStatus($id: uuid!) {
|
||||||
bodyshops_by_pk(id: $id) {
|
bodyshops_by_pk(id: $id) {
|
||||||
md_order_statuses
|
md_ro_statuses
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user