ProManager WIP.
This commit is contained in:
@@ -38,7 +38,7 @@ class ErrorBoundary extends React.Component {
|
||||
}
|
||||
|
||||
handleErrorSubmit = () => {
|
||||
InstanceRenderManager({executeFunction:true, imex: () => {
|
||||
InstanceRenderManager({executeFunction:true,args:[], imex: () => {
|
||||
window.$crisp.push([
|
||||
"do",
|
||||
"message:send",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -111,12 +111,14 @@ export function JobsAvailableContainer({bodyshop, currentUser, insertAuditTrail,
|
||||
}
|
||||
// if (process.env.VITE_APP_COUNTRY === "USA") {
|
||||
//Massage the CCC file set to remove duplicate UNQ_SEQ.
|
||||
InstanceRenderManager({executeFunction:true,rome: ResolveCCCLineIssues(estData.est_data, bodyshop) })
|
||||
InstanceRenderManager({executeFunction:true,rome: ResolveCCCLineIssues, args: [estData.est_data, bodyshop], promanager: ResolveCCCLineIssues })
|
||||
|
||||
// } else {
|
||||
//IO-539 Check for Parts Rate on PAL for SGI use case.
|
||||
//TODO:AIO Check that the async function is actually waiting before moving on.
|
||||
InstanceRenderManager({executeFunction: true, imex: await CheckTaxRates(estData.est_data, bodyshop), rome: await CheckTaxRatesUSA(estData.est_data, bodyshop)})
|
||||
await InstanceRenderManager({executeFunction: true,
|
||||
debug:true,
|
||||
imex: CheckTaxRates, rome: CheckTaxRatesUSA, promanager: CheckTaxRatesUSA, args: [estData.est_data, bodyshop]})
|
||||
|
||||
// }
|
||||
// const newTotals = (
|
||||
@@ -238,8 +240,8 @@ export function JobsAvailableContainer({bodyshop, currentUser, insertAuditTrail,
|
||||
let supp = replaceEmpty({...estData.est_data});
|
||||
//IO-539 Check for Parts Rate on PAL for SGI use case.
|
||||
|
||||
InstanceRenderManager({executeFunction:true, imex: await CheckTaxRates(supp, bodyshop), rome: await CheckTaxRatesUSA(supp, bodyshop)})
|
||||
InstanceRenderManager({executeFunction:true ,rome: ResolveCCCLineIssues(supp, bodyshop) })
|
||||
await InstanceRenderManager({executeFunction:true, imex: CheckTaxRates, rome: CheckTaxRatesUSA, promanager: CheckTaxRatesUSA, args: [(supp, bodyshop)]})
|
||||
await InstanceRenderManager({executeFunction:true, rome: ResolveCCCLineIssues,promanager: ResolveCCCLineIssues ,args:[(supp, bodyshop)] })
|
||||
|
||||
delete supp.owner;
|
||||
delete supp.vehicle;
|
||||
@@ -599,7 +601,42 @@ async function CheckTaxRates(estData, bodyshop) {
|
||||
line.act_price = line.act_price + line.misc_amt;
|
||||
line.tax_part = !!line.misc_tax;
|
||||
}
|
||||
//WEB EST SPECIFIC CLEAN UP
|
||||
InstanceRenderManager({executeFunction: true, args:[], promanager: () => {
|
||||
|
||||
if (line.mod_lbr_ty === "LAET" || line.mod_lbr_ty === "LAUT") {
|
||||
line.notes += ` | ET/UT Update (prev = ${line.mod_lbr_ty})`;
|
||||
line.mod_lbr_ty = "LAR";
|
||||
}
|
||||
}})
|
||||
});
|
||||
|
||||
//Group by line no
|
||||
// For everything but the first one, strip out the price number in
|
||||
|
||||
InstanceRenderManager({executeFunction:true, args:[], promanager: () => {
|
||||
|
||||
|
||||
|
||||
const groupedByLineRef = _.groupBy(estData.joblines.data, "line_ref");
|
||||
Object.keys(groupedByLineRef).forEach((lineRef) => {
|
||||
groupedByLineRef[lineRef].forEach((line, index) => {
|
||||
//Let the first one keep it
|
||||
if (index === 0) return;
|
||||
//Web Est seems to have additional costs with UNQ_SEQ 0. Keep them all?
|
||||
if (line.unq_seq === 0) return;
|
||||
const indexInEstData = estData.joblines.data.findIndex(
|
||||
(l) => l.unq_seq === line.unq_seq
|
||||
);
|
||||
estData.joblines.data[
|
||||
indexInEstData
|
||||
].notes += ` | Scrubbed due to the line_ref issue. (prev act price = ${estData.joblines.data[indexInEstData].act_price})`;
|
||||
estData.joblines.data[indexInEstData].act_price = 0;
|
||||
estData.joblines.data[indexInEstData].db_price = 0;
|
||||
});
|
||||
})
|
||||
}})
|
||||
|
||||
|
||||
//Generate the list of duplicated UNQ_SEQ that will feed into the next section to scrub the lines.
|
||||
const unqSeqHash = _.groupBy(estData.joblines.data, "unq_seq");
|
||||
|
||||
@@ -327,7 +327,7 @@ export function* SetAuthLevelFromShopDetails({payload}) {
|
||||
}
|
||||
|
||||
try {
|
||||
InstanceRenderManager({executeFunction:true, imex: () => {
|
||||
InstanceRenderManager({executeFunction:true,args:[], imex: () => {
|
||||
window.$crisp.push(["set", "user:company", [payload.shopname]]);
|
||||
if (authRecord[0] && authRecord[0].user.validemail) {
|
||||
window.$crisp.push(["set", "user:email", [authRecord[0].user.email]]);
|
||||
|
||||
@@ -16,6 +16,7 @@ export default function InstanceRenderManager({
|
||||
imex,
|
||||
debug,
|
||||
instance,
|
||||
args,
|
||||
}) {
|
||||
let propToReturn = null;
|
||||
|
||||
@@ -38,17 +39,17 @@ export default function InstanceRenderManager({
|
||||
break;
|
||||
}
|
||||
|
||||
if (executeFunction && typeof propToReturn === 'function') propToReturn();
|
||||
|
||||
//Checking to see if we need to default to another one.
|
||||
if (propToReturn === 'imex') {
|
||||
propToReturn = imex;
|
||||
}
|
||||
if (debug) {
|
||||
console.log('InstanceRenderManager Debugger');
|
||||
console.log('=========================');
|
||||
console.log({ executeFunction, rome, promanager, imex, debug, propToReturn });
|
||||
console.log('=========================');
|
||||
}
|
||||
|
||||
//Checking to see if we need to default to another one.
|
||||
if (propToReturn === 'imex') {
|
||||
propToReturn = imex;
|
||||
}
|
||||
if (executeFunction && typeof propToReturn === 'function') return propToReturn(...args);
|
||||
return propToReturn === undefined ? null : propToReturn;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ exports.sendNotification = async (req, res) => {
|
||||
.send({
|
||||
topic: "PRD_PATRICK-messaging",
|
||||
notification: {
|
||||
title: `ImEX Online Message - ,
|
||||
title: `ImEX Online Message - `,
|
||||
body: "Test Noti.",
|
||||
//imageUrl: "https://thinkimex.com/img/io-fcm.png",
|
||||
},
|
||||
|
||||
@@ -892,8 +892,8 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
}
|
||||
});
|
||||
|
||||
// console.log("*** Taxable Amounts***");
|
||||
// console.table(JSON.parse(JSON.stringify(taxableAmounts)));
|
||||
console.log("*** Taxable Amounts***");
|
||||
console.table(JSON.parse(JSON.stringify(taxableAmounts)));
|
||||
|
||||
//For the taxable amounts, figure out which tax type applies.
|
||||
//Then sum up the total of that tax type and then calculate the thresholds.
|
||||
@@ -976,8 +976,8 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
});
|
||||
|
||||
const remainingTaxableAmounts = taxableAmountsByTier;
|
||||
// console.log("*** Taxable Amounts by Tier***");
|
||||
// console.table(JSON.parse(JSON.stringify(taxableAmountsByTier)));
|
||||
console.log("*** Taxable Amounts by Tier***");
|
||||
console.table(JSON.parse(JSON.stringify(taxableAmountsByTier)));
|
||||
|
||||
Object.keys(taxableAmountsByTier).forEach((taxTierKey) => {
|
||||
try {
|
||||
|
||||
@@ -78,7 +78,7 @@ async function TotalsServerSide(req, res) {
|
||||
|
||||
return ret;
|
||||
} catch (error) {
|
||||
logger.log("job-totals-ssu-error", "ERROR", req.user.email, job.id, {
|
||||
logger.log("job-totals-ssu-error", "ERROR", req?.user?.email, job.id, {
|
||||
jobid: job.id,
|
||||
error,
|
||||
});
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
const RenderInstanceManager = require("../utils/instanceMgr").default;
|
||||
const RenderInstanceManager = require('../utils/instanceMgr').default;
|
||||
|
||||
exports.totals = RenderInstanceManager({
|
||||
imex: require("./job-totals").default,
|
||||
rome: require("./job-totals-USA").default,
|
||||
imex: require('./job-totals').default,
|
||||
rome: require('./job-totals-USA').default,
|
||||
promanager: require('./job-totals-USA').default,
|
||||
});
|
||||
exports.totalsSsu = require("./job-totals").totalsSsu;
|
||||
exports.costing = require("./job-costing").JobCosting;
|
||||
exports.costingmulti = require("./job-costing").JobCostingMulti;
|
||||
exports.statustransition = require("./job-status-transition").statustransition;
|
||||
exports.lifecycle = require("./job-lifecycle");
|
||||
exports.totalsSsu = RenderInstanceManager({
|
||||
imex: require('./job-totals').totalsSsu,
|
||||
rome: require('./job-totals-USA').totalsSsu,
|
||||
promanager: require('./job-totals-USA').totalsSsu,
|
||||
});
|
||||
exports.costing = require('./job-costing').JobCosting;
|
||||
exports.costingmulti = require('./job-costing').JobCostingMulti;
|
||||
exports.statustransition = require('./job-status-transition').statustransition;
|
||||
exports.lifecycle = require('./job-lifecycle');
|
||||
|
||||
@@ -8,29 +8,41 @@
|
||||
* @property { string | object | function } imex Return this prop if Rome.
|
||||
*/
|
||||
|
||||
function InstanceManager({ rome, promanager, imex }) {
|
||||
let propToReturn = null;
|
||||
function InstanceManager({ instance, debug, executeFunction, rome, promanager, imex }) {
|
||||
let propToReturn = null;
|
||||
|
||||
switch (process.env.INSTANCE) {
|
||||
case "IMEX":
|
||||
propToReturn = imex;
|
||||
break;
|
||||
case "ROME":
|
||||
propToReturn = rome;
|
||||
break;
|
||||
case "PROMANAGER":
|
||||
propToReturn = promanager;
|
||||
break;
|
||||
default:
|
||||
propToReturn = imex;
|
||||
break;
|
||||
}
|
||||
// if (!propToReturn) {
|
||||
// throw new Error(
|
||||
// `Prop to return is not valid for this instance (${process.env.INSTANCE}).`
|
||||
// );
|
||||
// }
|
||||
return propToReturn;
|
||||
switch (instance || process.env.INSTANCE) {
|
||||
case 'IMEX':
|
||||
propToReturn = imex;
|
||||
break;
|
||||
case 'ROME':
|
||||
propToReturn = rome; //TODO:AIO Implement USE_IMEX
|
||||
break;
|
||||
case 'PROMANAGER':
|
||||
//Return the rome prop if USE_ROME.
|
||||
//If not USE_ROME, we want to default back to the rome prop if it's undefined.
|
||||
//If null, we might want to show nothing, so make sure we return null.
|
||||
propToReturn =
|
||||
promanager === 'USE_ROME' ? rome : promanager !== undefined ? promanager : rome;
|
||||
break;
|
||||
default:
|
||||
propToReturn = imex;
|
||||
break;
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
console.log('InstanceRenderManager Debugger');
|
||||
console.log('=========================');
|
||||
console.log({ executeFunction, rome, promanager, imex, debug, propToReturn });
|
||||
console.log('=========================');
|
||||
}
|
||||
|
||||
//Checking to see if we need to default to another one.
|
||||
if (propToReturn === 'imex') {
|
||||
propToReturn = imex;
|
||||
}
|
||||
if (executeFunction && typeof propToReturn === 'function') return propToReturn(...args);
|
||||
return propToReturn === undefined ? null : propToReturn;
|
||||
}
|
||||
|
||||
exports.default = InstanceManager
|
||||
exports.default = InstanceManager;
|
||||
|
||||
Reference in New Issue
Block a user