ProManager WIP.
This commit is contained in:
@@ -38,7 +38,7 @@ class ErrorBoundary extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleErrorSubmit = () => {
|
handleErrorSubmit = () => {
|
||||||
InstanceRenderManager({executeFunction:true, imex: () => {
|
InstanceRenderManager({executeFunction:true,args:[], imex: () => {
|
||||||
window.$crisp.push([
|
window.$crisp.push([
|
||||||
"do",
|
"do",
|
||||||
"message:send",
|
"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") {
|
// if (process.env.VITE_APP_COUNTRY === "USA") {
|
||||||
//Massage the CCC file set to remove duplicate UNQ_SEQ.
|
//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 {
|
// } else {
|
||||||
//IO-539 Check for Parts Rate on PAL for SGI use case.
|
//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.
|
//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 = (
|
// const newTotals = (
|
||||||
@@ -238,8 +240,8 @@ export function JobsAvailableContainer({bodyshop, currentUser, insertAuditTrail,
|
|||||||
let supp = replaceEmpty({...estData.est_data});
|
let supp = replaceEmpty({...estData.est_data});
|
||||||
//IO-539 Check for Parts Rate on PAL for SGI use case.
|
//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)})
|
await InstanceRenderManager({executeFunction:true, imex: CheckTaxRates, rome: CheckTaxRatesUSA, promanager: CheckTaxRatesUSA, args: [(supp, bodyshop)]})
|
||||||
InstanceRenderManager({executeFunction:true ,rome: ResolveCCCLineIssues(supp, bodyshop) })
|
await InstanceRenderManager({executeFunction:true, rome: ResolveCCCLineIssues,promanager: ResolveCCCLineIssues ,args:[(supp, bodyshop)] })
|
||||||
|
|
||||||
delete supp.owner;
|
delete supp.owner;
|
||||||
delete supp.vehicle;
|
delete supp.vehicle;
|
||||||
@@ -599,8 +601,43 @@ async function CheckTaxRates(estData, bodyshop) {
|
|||||||
line.act_price = line.act_price + line.misc_amt;
|
line.act_price = line.act_price + line.misc_amt;
|
||||||
line.tax_part = !!line.misc_tax;
|
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.
|
//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");
|
const unqSeqHash = _.groupBy(estData.joblines.data, "unq_seq");
|
||||||
const duplicatedUnqSeq = Object.keys(unqSeqHash).filter(
|
const duplicatedUnqSeq = Object.keys(unqSeqHash).filter(
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ export function* SetAuthLevelFromShopDetails({payload}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
InstanceRenderManager({executeFunction:true, imex: () => {
|
InstanceRenderManager({executeFunction:true,args:[], imex: () => {
|
||||||
window.$crisp.push(["set", "user:company", [payload.shopname]]);
|
window.$crisp.push(["set", "user:company", [payload.shopname]]);
|
||||||
if (authRecord[0] && authRecord[0].user.validemail) {
|
if (authRecord[0] && authRecord[0].user.validemail) {
|
||||||
window.$crisp.push(["set", "user:email", [authRecord[0].user.email]]);
|
window.$crisp.push(["set", "user:email", [authRecord[0].user.email]]);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export default function InstanceRenderManager({
|
|||||||
imex,
|
imex,
|
||||||
debug,
|
debug,
|
||||||
instance,
|
instance,
|
||||||
|
args,
|
||||||
}) {
|
}) {
|
||||||
let propToReturn = null;
|
let propToReturn = null;
|
||||||
|
|
||||||
@@ -38,17 +39,17 @@ export default function InstanceRenderManager({
|
|||||||
break;
|
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) {
|
if (debug) {
|
||||||
console.log('InstanceRenderManager Debugger');
|
console.log('InstanceRenderManager Debugger');
|
||||||
console.log('=========================');
|
console.log('=========================');
|
||||||
console.log({ executeFunction, rome, promanager, imex, debug, propToReturn });
|
console.log({ executeFunction, rome, promanager, imex, debug, propToReturn });
|
||||||
console.log('=========================');
|
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;
|
return propToReturn === undefined ? null : propToReturn;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ exports.sendNotification = async (req, res) => {
|
|||||||
.send({
|
.send({
|
||||||
topic: "PRD_PATRICK-messaging",
|
topic: "PRD_PATRICK-messaging",
|
||||||
notification: {
|
notification: {
|
||||||
title: `ImEX Online Message - ,
|
title: `ImEX Online Message - `,
|
||||||
body: "Test Noti.",
|
body: "Test Noti.",
|
||||||
//imageUrl: "https://thinkimex.com/img/io-fcm.png",
|
//imageUrl: "https://thinkimex.com/img/io-fcm.png",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -892,8 +892,8 @@ function CalculateTaxesTotals(job, otherTotals) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log("*** Taxable Amounts***");
|
console.log("*** Taxable Amounts***");
|
||||||
// console.table(JSON.parse(JSON.stringify(taxableAmounts)));
|
console.table(JSON.parse(JSON.stringify(taxableAmounts)));
|
||||||
|
|
||||||
//For the taxable amounts, figure out which tax type applies.
|
//For the taxable amounts, figure out which tax type applies.
|
||||||
//Then sum up the total of that tax type and then calculate the thresholds.
|
//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;
|
const remainingTaxableAmounts = taxableAmountsByTier;
|
||||||
// console.log("*** Taxable Amounts by Tier***");
|
console.log("*** Taxable Amounts by Tier***");
|
||||||
// console.table(JSON.parse(JSON.stringify(taxableAmountsByTier)));
|
console.table(JSON.parse(JSON.stringify(taxableAmountsByTier)));
|
||||||
|
|
||||||
Object.keys(taxableAmountsByTier).forEach((taxTierKey) => {
|
Object.keys(taxableAmountsByTier).forEach((taxTierKey) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ async function TotalsServerSide(req, res) {
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
} catch (error) {
|
} 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,
|
jobid: job.id,
|
||||||
error,
|
error,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
const RenderInstanceManager = require("../utils/instanceMgr").default;
|
const RenderInstanceManager = require('../utils/instanceMgr').default;
|
||||||
|
|
||||||
exports.totals = RenderInstanceManager({
|
exports.totals = RenderInstanceManager({
|
||||||
imex: require("./job-totals").default,
|
imex: require('./job-totals').default,
|
||||||
rome: require("./job-totals-USA").default,
|
rome: require('./job-totals-USA').default,
|
||||||
|
promanager: require('./job-totals-USA').default,
|
||||||
});
|
});
|
||||||
exports.totalsSsu = require("./job-totals").totalsSsu;
|
exports.totalsSsu = RenderInstanceManager({
|
||||||
exports.costing = require("./job-costing").JobCosting;
|
imex: require('./job-totals').totalsSsu,
|
||||||
exports.costingmulti = require("./job-costing").JobCostingMulti;
|
rome: require('./job-totals-USA').totalsSsu,
|
||||||
exports.statustransition = require("./job-status-transition").statustransition;
|
promanager: require('./job-totals-USA').totalsSsu,
|
||||||
exports.lifecycle = require("./job-lifecycle");
|
});
|
||||||
|
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.
|
* @property { string | object | function } imex Return this prop if Rome.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function InstanceManager({ rome, promanager, imex }) {
|
function InstanceManager({ instance, debug, executeFunction, rome, promanager, imex }) {
|
||||||
let propToReturn = null;
|
let propToReturn = null;
|
||||||
|
|
||||||
switch (process.env.INSTANCE) {
|
switch (instance || process.env.INSTANCE) {
|
||||||
case "IMEX":
|
case 'IMEX':
|
||||||
propToReturn = imex;
|
propToReturn = imex;
|
||||||
break;
|
break;
|
||||||
case "ROME":
|
case 'ROME':
|
||||||
propToReturn = rome;
|
propToReturn = rome; //TODO:AIO Implement USE_IMEX
|
||||||
break;
|
break;
|
||||||
case "PROMANAGER":
|
case 'PROMANAGER':
|
||||||
propToReturn = promanager;
|
//Return the rome prop if USE_ROME.
|
||||||
break;
|
//If not USE_ROME, we want to default back to the rome prop if it's undefined.
|
||||||
default:
|
//If null, we might want to show nothing, so make sure we return null.
|
||||||
propToReturn = imex;
|
propToReturn =
|
||||||
break;
|
promanager === 'USE_ROME' ? rome : promanager !== undefined ? promanager : rome;
|
||||||
}
|
break;
|
||||||
// if (!propToReturn) {
|
default:
|
||||||
// throw new Error(
|
propToReturn = imex;
|
||||||
// `Prop to return is not valid for this instance (${process.env.INSTANCE}).`
|
break;
|
||||||
// );
|
}
|
||||||
// }
|
|
||||||
return propToReturn;
|
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