diff --git a/client/src/components/jobs-available-table/jobs-available-table.container.jsx b/client/src/components/jobs-available-table/jobs-available-table.container.jsx index 656109857..bde60ffef 100644 --- a/client/src/components/jobs-available-table/jobs-available-table.container.jsx +++ b/client/src/components/jobs-available-table/jobs-available-table.container.jsx @@ -402,98 +402,98 @@ function replaceEmpty(someObj, replaceValue = null) { } async function CheckTaxRates(estData, bodyshop) { - //LKQ Check - if ( - !estData.parts_tax_rates?.PAL || - estData.parts_tax_rates?.PAL?.prt_tax_rt === null || - estData.parts_tax_rates?.PAL?.prt_tax_rt === 0 - ) { - const res = await confirmDialog( - `Rome Online has detected that there is a missing tax rate for LKQ parts. Pressing OK will set the tax rate to ${bodyshop.bill_tax_rates.state_tax_rate}% and enable the rate. Pressing cancel will keep the tax rate as is.` - ); - if (res) { - if (!estData.parts_tax_rates.PAL) { - estData.parts_tax_rates.PAL = { - prt_discp: 0, - prt_mktyp: true, - prt_mkupp: 0, - prt_type: "PAL", - }; - } - estData.parts_tax_rates.PAL.prt_tax_rt = - bodyshop.bill_tax_rates.state_tax_rate / 100; - estData.parts_tax_rates.PAL.prt_tax_in = true; - } - } - //PAC Check - if ( - !estData.parts_tax_rates?.PAC || - estData.parts_tax_rates?.PAC?.prt_tax_rt === null || - estData.parts_tax_rates?.PAC?.prt_tax_rt === 0 - ) { - const res = await confirmDialog( - `Rome Online has detected that there is a missing tax rate for rechromed parts. Pressing OK will set the tax rate to ${bodyshop.bill_tax_rates.state_tax_rate}% and enable the rate. Pressing cancel will keep the tax rate as is.` - ); - if (res) { - if (!estData.parts_tax_rates.PAC) { - estData.parts_tax_rates.PAC = { - prt_discp: 0, - prt_mktyp: true, - prt_mkupp: 0, - prt_type: "PAC", - }; - } - estData.parts_tax_rates.PAC.prt_tax_rt = - bodyshop.bill_tax_rates.state_tax_rate / 100; - estData.parts_tax_rates.PAC.prt_tax_in = true; - } - } - //PAM Check - if ( - !estData.parts_tax_rates?.PAM || - estData.parts_tax_rates?.PAM?.prt_tax_rt === null || - estData.parts_tax_rates?.PAM?.prt_tax_rt === 0 - ) { - const res = await confirmDialog( - `Rome Online has detected that there is a missing tax rate for remanufactured parts. Pressing OK will set the tax rate to ${bodyshop.bill_tax_rates.state_tax_rate}% and enable the rate. Pressing cancel will keep the tax rate as is.` - ); - if (res) { - if (!estData.parts_tax_rates.PAM) { - estData.parts_tax_rates.PAM = { - prt_discp: 0, - prt_mktyp: true, - prt_mkupp: 0, - prt_type: "PAM", - }; - } - estData.parts_tax_rates.PAM.prt_tax_rt = - bodyshop.bill_tax_rates.state_tax_rate / 100; - estData.parts_tax_rates.PAM.prt_tax_in = true; - } - } + // //LKQ Check + // if ( + // !estData.parts_tax_rates?.PAL || + // estData.parts_tax_rates?.PAL?.prt_tax_rt === null || + // estData.parts_tax_rates?.PAL?.prt_tax_rt === 0 + // ) { + // const res = await confirmDialog( + // `Rome Online has detected that there is a missing tax rate for LKQ parts. Pressing OK will set the tax rate to ${bodyshop.bill_tax_rates.state_tax_rate}% and enable the rate. Pressing cancel will keep the tax rate as is.` + // ); + // if (res) { + // if (!estData.parts_tax_rates.PAL) { + // estData.parts_tax_rates.PAL = { + // prt_discp: 0, + // prt_mktyp: true, + // prt_mkupp: 0, + // prt_type: "PAL", + // }; + // } + // estData.parts_tax_rates.PAL.prt_tax_rt = + // bodyshop.bill_tax_rates.state_tax_rate / 100; + // estData.parts_tax_rates.PAL.prt_tax_in = true; + // } + // } + // //PAC Check + // if ( + // !estData.parts_tax_rates?.PAC || + // estData.parts_tax_rates?.PAC?.prt_tax_rt === null || + // estData.parts_tax_rates?.PAC?.prt_tax_rt === 0 + // ) { + // const res = await confirmDialog( + // `Rome Online has detected that there is a missing tax rate for rechromed parts. Pressing OK will set the tax rate to ${bodyshop.bill_tax_rates.state_tax_rate}% and enable the rate. Pressing cancel will keep the tax rate as is.` + // ); + // if (res) { + // if (!estData.parts_tax_rates.PAC) { + // estData.parts_tax_rates.PAC = { + // prt_discp: 0, + // prt_mktyp: true, + // prt_mkupp: 0, + // prt_type: "PAC", + // }; + // } + // estData.parts_tax_rates.PAC.prt_tax_rt = + // bodyshop.bill_tax_rates.state_tax_rate / 100; + // estData.parts_tax_rates.PAC.prt_tax_in = true; + // } + // } + // //PAM Check + // if ( + // !estData.parts_tax_rates?.PAM || + // estData.parts_tax_rates?.PAM?.prt_tax_rt === null || + // estData.parts_tax_rates?.PAM?.prt_tax_rt === 0 + // ) { + // const res = await confirmDialog( + // `Rome Online has detected that there is a missing tax rate for remanufactured parts. Pressing OK will set the tax rate to ${bodyshop.bill_tax_rates.state_tax_rate}% and enable the rate. Pressing cancel will keep the tax rate as is.` + // ); + // if (res) { + // if (!estData.parts_tax_rates.PAM) { + // estData.parts_tax_rates.PAM = { + // prt_discp: 0, + // prt_mktyp: true, + // prt_mkupp: 0, + // prt_type: "PAM", + // }; + // } + // estData.parts_tax_rates.PAM.prt_tax_rt = + // bodyshop.bill_tax_rates.state_tax_rate / 100; + // estData.parts_tax_rates.PAM.prt_tax_in = true; + // } + // } - if ( - !estData.parts_tax_rates?.PAR || - estData.parts_tax_rates?.PAR?.prt_tax_rt === null || - estData.parts_tax_rates?.PAR?.prt_tax_rt === 0 - ) { - const res = await confirmDialog( - `Rome Online has detected that there is a missing tax rate for recored parts. Pressing OK will set the tax rate to ${bodyshop.bill_tax_rates.state_tax_rate}% and enable the rate. Pressing cancel will keep the tax rate as is.` - ); - if (res) { - if (!estData.parts_tax_rates.PAR) { - estData.parts_tax_rates.PAR = { - prt_discp: 0, - prt_mktyp: true, - prt_mkupp: 0, - prt_type: "PAR", - }; - } - estData.parts_tax_rates.PAR.prt_tax_rt = - bodyshop.bill_tax_rates.state_tax_rate / 100; - estData.parts_tax_rates.PAR.prt_tax_in = true; - } - } + // if ( + // !estData.parts_tax_rates?.PAR || + // estData.parts_tax_rates?.PAR?.prt_tax_rt === null || + // estData.parts_tax_rates?.PAR?.prt_tax_rt === 0 + // ) { + // const res = await confirmDialog( + // `Rome Online has detected that there is a missing tax rate for recored parts. Pressing OK will set the tax rate to ${bodyshop.bill_tax_rates.state_tax_rate}% and enable the rate. Pressing cancel will keep the tax rate as is.` + // ); + // if (res) { + // if (!estData.parts_tax_rates.PAR) { + // estData.parts_tax_rates.PAR = { + // prt_discp: 0, + // prt_mktyp: true, + // prt_mkupp: 0, + // prt_type: "PAR", + // }; + // } + // estData.parts_tax_rates.PAR.prt_tax_rt = + // bodyshop.bill_tax_rates.state_tax_rate / 100; + // estData.parts_tax_rates.PAR.prt_tax_in = true; + // } + // } //IO-1387 If a sublet line is NOT R&R, use the labor tax. If it is, use the sublet tax rate. //Currently limited to SK shops only. diff --git a/job-totals-testing-util.js b/job-totals-testing-util.js index e4510aea5..0e1f419d0 100644 --- a/job-totals-testing-util.js +++ b/job-totals-testing-util.js @@ -20,7 +20,7 @@ require("dotenv").config({ async function RunTheTest() { const bodyshopids = ["6c63a820-542c-497e-8c82-0cc38fb2bbca"]; - const bearerToken = `Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImQwNTU5YzU5MDgzZDc3YWI2NDUxOThiNTIxZmM4ZmVmZmVlZmJkNjIiLCJ0eXAiOiJKV1QifQ.eyJuYW1lIjoiUGF0cmljayBGaWMgKERFVikiLCJodHRwczovL2hhc3VyYS5pby9qd3QvY2xhaW1zIjp7IngtaGFzdXJhLWRlZmF1bHQtcm9sZSI6InVzZXIiLCJ4LWhhc3VyYS1hbGxvd2VkLXJvbGVzIjpbInVzZXIiXSwieC1oYXN1cmEtdXNlci1pZCI6ImhOSjhBRHB0REhRQkRFcXNCOFFNWVRqaURuZjEifSwiaXNzIjoiaHR0cHM6Ly9zZWN1cmV0b2tlbi5nb29nbGUuY29tL2ltZXgtZGV2IiwiYXVkIjoiaW1leC1kZXYiLCJhdXRoX3RpbWUiOjE2NzE1Njc4NzUsInVzZXJfaWQiOiJoTko4QURwdERIUUJERXFzQjhRTVlUamlEbmYxIiwic3ViIjoiaE5KOEFEcHRESFFCREVxc0I4UU1ZVGppRG5mMSIsImlhdCI6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jhRTVlUamlEbmYxIiwic3ViIjoiaE5KOEFEcHRESFFCREVxc0I4UU1ZVGppRG5mMSIsImlhdCI6MTY3NDY3MzYyOSwiZXhwIjoxNjc0Njc3MjI5LCJlbWFpbCI6InBhdHJpY2tAaW1leC5kZXYiLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsImZpcmViYXNlIjp7ImlkZW50aXRpZXMiOnsiZW1haWwiOlsicGF0cmlja0BpbWV4LmRldiJdfSwic2lnbl9pbl9wcm92aWRlciI6InBhc3N3b3JkIn19.UGFIwVz_B8Q2m7_lmpT8U4Kq0LG3N-yiv4eRhWybme46y1OCiUpw1dJct-vjunprGTrRXdRlWsEOBEmPULYYbKektcHs60boxQxPty9YghageMcknj14ujoLE98Gz3pN6De4mAQMtqYdWaC20OWrH8wIDGkoFMN7PHhY-c2QWdt-UQH_OUW0dqY0vSSJIlC9QNI3Rjn0N6if40j2jnTF9qgIClRjoWN9OBh1s1qIou6yNchnA2v9ni1Js_kGmMJfixmkTxUau3THCxVQAdPtuwURYRn1Xa8Eo5feo0FLoFbPtylHUZyaoogE7q6ZQkHA2A3ylIxWhYUspyPzkIyf_g`; const { jobs } = await client.request( gql` query GET_JOBS($bodyshopids: [uuid!]!) { diff --git a/server/job/job-totals.js b/server/job/job-totals.js index afdf62b0f..b0b5dbb6f 100644 --- a/server/job/job-totals.js +++ b/server/job/job-totals.js @@ -1,4 +1,3 @@ -const { objectLength } = require("@oozcitak/util"); const Dinero = require("dinero.js"); const queries = require("../graphql-client/queries"); const GraphQLClient = require("graphql-request").GraphQLClient; @@ -380,6 +379,7 @@ function CalculatePartsTotals(jobLines, parts_tax_rates) { const ret = jl.reduce( (acc, value) => { + console.log(JSON.stringify(acc, null, 2)); switch (value.part_type) { case "PAS": case "PASL": @@ -535,7 +535,7 @@ function CalculatePartsTotals(jobLines, parts_tax_rates) { //Check if there's any parts in this part type. if (ret.parts.list[key] !== undefined) { markup = ret.parts.list[key].total.percentage( - parts_tax_rates[key].prt_mkupp + parts_tax_rates[key].prt_mkupp * 100 //Seems that mark up is written as decimal not %. ); } } @@ -543,14 +543,15 @@ function CalculatePartsTotals(jobLines, parts_tax_rates) { adjustments[key] = adjustment; }); - Object.keys(adjustments).forEach((key) => { - if (ret.parts.list[key] !== undefined) { - ret.parts.list[key].total = ret.parts.list[key].total.add( - adjustments[key] - ); - ret.parts.subtotal = ret.parts.subtotal.add(adjustments[key]); - } - }); + //Temporarily commenting this out since these totals appear to be already included in the calculation. + // Object.keys(adjustments).forEach((key) => { + // if (ret.parts.list[key] !== undefined) { + // ret.parts.list[key].total = ret.parts.list[key].total.add( + // adjustments[key] + // ); + // ret.parts.subtotal = ret.parts.subtotal.add(adjustments[key]); + // } + // }); return { adjustments, @@ -575,19 +576,12 @@ function IsAdditionalCost(jobLine) { const isPaintOrShopMat = jobLine.db_ref === "936008" || jobLine.db_ref === "936007"; - // if (process.env.COUNTRY === "USA") { - // return ( - // jobLine.lbr_op === "OP13" || //Added to resolve manual job lines coming into other totals because they have no reference. - // (jobLine.part_type === null && (jobLine.act_price || 0 > 0)) - // ); - // } else { return ( (jobLine.lbr_op === "OP13" || //Added to resolve manual job lines coming into other totals because they have no reference. (jobLine.part_type === null && (jobLine.act_price || 0 > 0)) || (jobLine.db_ref && jobLine.db_ref.startsWith("9360"))) && //This ref works in Canada, but DB_REFS in the US do not fill in. !isPaintOrShopMat ); - //} } function CalculateAdditional(job) { @@ -800,6 +794,16 @@ function DiscountNotAlreadyCounted(jobline, joblines) { ) return true; + if (jobline.unq_seq === '68') { + console.log("stophere"); + } + //CCC already factors in the discount. If the difference between the 2 is exactly the discount, it's all good. + if ( + Math.round(jobline.prt_dsmk_m / jobline.act_price - jobline.prt_dsmk_m) === + Math.abs(jobline.prt_dsmk_p) + ) + return false; + const ParentLine = joblines.find((j) => j.unq_seq === jobline.line_ref); return ParentLine && !(ParentLine.prt_dsmk_m && ParentLine.prt_dsmk_m !== 0);