From bc3238aba2ca6d924c24b128cb57e1d4f72460ec Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 30 Nov 2022 08:47:20 -0800 Subject: [PATCH] IO-2116 Add account number to control types for DMS. --- .eslintrc.json | 1 - bodyshop_translations.babel | 47 +++++++++++++++++++ .../dms-post-form/dms-post-form.component.jsx | 15 +++++- ...p-info.responsibilitycenters.component.jsx | 11 ++++- client/src/translations/en_us/common.json | 4 ++ client/src/translations/es/common.json | 4 ++ client/src/translations/fr/common.json | 4 ++ server/cdk/cdk-calculate-allocations.js | 42 +++++++++++++++++ 8 files changed, 125 insertions(+), 3 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 3b158ef3e..f78694e00 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -17,5 +17,4 @@ "no-console": "off" }, "settings": {} - //"plugins": ["cypress"] } diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index f311d7e00..130470e31 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -4402,6 +4402,27 @@ + + sendmaterialscosting + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + srcco false @@ -22456,6 +22477,32 @@ + + control_type + + + account_number + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + cost false diff --git a/client/src/components/dms-post-form/dms-post-form.component.jsx b/client/src/components/dms-post-form/dms-post-form.component.jsx index 1204418b5..c9043d050 100644 --- a/client/src/components/dms-post-form/dms-post-form.component.jsx +++ b/client/src/components/dms-post-form/dms-post-form.component.jsx @@ -345,7 +345,20 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) { t(`jobs.fields.${cdkPayer?.control_type}`)} ); - else { + else if ( + i18n.exists( + `jobs.fields.dms.control_type.${cdkPayer?.control_type}` + ) + ) { + return ( +
+ {cdkPayer && + t( + `jobs.fields.dms.control_type.${cdkPayer?.control_type}` + )} +
+ ); + } else { return null; } }} diff --git a/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx b/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx index 699967383..96feb08e4 100644 --- a/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx +++ b/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx @@ -139,6 +139,12 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { > + + + {bodyshop.pbs_serialnumber && ( - {t("jobs.fields.ro_number")} @@ -210,6 +216,9 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { {t("jobs.fields.ponumber")} + + {t("jobs.fields.dms.control_type.account_number")} + diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 9c3ae03f0..247263894 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -273,6 +273,7 @@ "itc_local": "Local Tax is ITC?", "itc_state": "State Tax is ITC?", "mappingname": "DMS Mapping Name", + "sendmaterialscosting": "Materials Cost as % of Sale", "srcco": "Source Company #/Dealer #" }, "email": "General Shop Email", @@ -1360,6 +1361,9 @@ "address": "Customer Address", "amount": "Amount", "center": "Center", + "control_type": { + "account_number": "Account Number" + }, "cost": "Cost", "cost_dms_acctnumber": "Cost DMS Acct #", "dms_make": "DMS Make", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 6e7454cd0..7aee1ce3e 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -273,6 +273,7 @@ "itc_local": "", "itc_state": "", "mappingname": "", + "sendmaterialscosting": "", "srcco": "" }, "email": "", @@ -1360,6 +1361,9 @@ "address": "", "amount": "", "center": "", + "control_type": { + "account_number": "" + }, "cost": "", "cost_dms_acctnumber": "", "dms_make": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 683b09f2c..fc95cb71d 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -273,6 +273,7 @@ "itc_local": "", "itc_state": "", "mappingname": "", + "sendmaterialscosting": "", "srcco": "" }, "email": "", @@ -1360,6 +1361,9 @@ "address": "", "amount": "", "center": "", + "control_type": { + "account_number": "" + }, "cost": "", "cost_dms_acctnumber": "", "dms_make": "", diff --git a/server/cdk/cdk-calculate-allocations.js b/server/cdk/cdk-calculate-allocations.js index 5d42d0cdb..cd75dc6ec 100644 --- a/server/cdk/cdk-calculate-allocations.js +++ b/server/cdk/cdk-calculate-allocations.js @@ -209,6 +209,48 @@ exports.default = async function (socket, jobid) { // console.log("NO MASH ACCOUNT FOUND!!"); } } + console.log( + Number.isInteger(bodyshop?.cdk_configuration?.sendmaterialscosting), + typeof Number.isInteger(bodyshop?.cdk_configuration?.sendmaterialscosting) + ); + if (!!bodyshop?.cdk_configuration?.sendmaterialscosting) { + //Manually send the percentage of the costing. + + //Paint Mat + const mapaAccountName = selectedDmsAllocationConfig.costs.MAPA; + const mapaAccount = bodyshop.md_responsibility_centers.costs.find( + (c) => c.name === mapaAccountName + ); + if (mapaAccount) { + if (!costCenterHash[mapaAccountName]) + costCenterHash[mapaAccountName] = Dinero(); + costCenterHash[mapaAccountName] = costCenterHash[mapaAccountName].add( + Dinero(job.job_totals.rates.mapa.total).percentage( + bodyshop?.cdk_configuration?.sendmaterialscosting + ) + ); + } else { + //console.log("NO MAPA ACCOUNT FOUND!!"); + } + + //Shop Mat + const mashAccountName = selectedDmsAllocationConfig.costs.MASH; + const mashAccount = bodyshop.md_responsibility_centers.costs.find( + (c) => c.name === mashAccountName + ); + if (mashAccount) { + if (!costCenterHash[mashAccountName]) + costCenterHash[mashAccountName] = Dinero(); + costCenterHash[mashAccountName] = costCenterHash[mashAccountName].add( + Dinero(job.job_totals.rates.mash.total).percentage( + bodyshop?.cdk_configuration?.sendmaterialscosting + ) + ); + } else { + // console.log("NO MASH ACCOUNT FOUND!!"); + } + } + const { ca_bc_pvrt } = job; if (ca_bc_pvrt) { // const pvrtAccount = bodyshop.md_responsibility_centers.profits.find(