ProManager WIP.

This commit is contained in:
Patrick Fic
2024-03-05 08:41:52 -05:00
parent 9daf992582
commit 1ae2133d23
10 changed files with 707 additions and 690 deletions

View File

@@ -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",
},

View File

@@ -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 {

View File

@@ -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,
});

View File

@@ -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');

View File

@@ -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;