From 7b99de804651c23b176c1cfbfd074dd940520c30 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Mon, 3 Jun 2024 11:50:44 -0700 Subject: [PATCH 01/13] IO-2801 os-loader bills data add in job object to bills in opensearch for ro_number to be searchable again Signed-off-by: Allan Carr --- os-loader.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/os-loader.js b/os-loader.js index 54a799ce2..865a617ae 100644 --- a/os-loader.js +++ b/os-loader.js @@ -174,10 +174,7 @@ async function OpenSearchUpdateHandler(req, res) { const bulkOperation = []; slicedArray.forEach((bill) => { bulkOperation.push({ index: { _index: "bills", _id: bill.id } }); - bulkOperation.push({ - ...omit(bill, ["job"]), - bodyshopid: bill.job.bodyshopid - }); + bulkOperation.push({ ...bill, bodyshopid: bill.job.bodyshopid }); }); promiseQueue.push(bulkOperation); } From e46c304f7c8ca729d92c35f79966472c394ee2f8 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Mon, 3 Jun 2024 17:23:33 -0700 Subject: [PATCH 02/13] IO-2793 State Tax to QBO refactor Signed-off-by: Allan Carr --- server/accounting/qb-receivables-lines.js | 37 ++++++++++++++--------- server/graphql-client/queries.js | 5 +++ 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/server/accounting/qb-receivables-lines.js b/server/accounting/qb-receivables-lines.js index b0f5b90fe..4162dfd35 100644 --- a/server/accounting/qb-receivables-lines.js +++ b/server/accounting/qb-receivables-lines.js @@ -72,15 +72,22 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes local: false, federal: InstanceManager({ imex: true, rome: false }), state: - !jobs_by_pk.state_tax_rate || jobs_by_pk.state_tax_rate === 0 + jobline.tax_part === false ? false - : jobline.db_ref === "900511" || - jobline.db_ref === "900510" || - (jobline.mod_lb_hrs === 0 && //Extending IO-1375 as a part of IO-2023 - jobline.act_price > 0 && - jobline.lbr_op === "OP14") - ? true - : jobline.tax_part + : jobline.part_type.toUpperCase() === "PAS" || jobline.part_type.toUpperCase() === "PASL" + ? jobs_by_pk.tax_sub_rt === 0 + ? false + : true + : jobs_by_pk.parts_tax_rates[`${jobline.part_type.toUpperCase()}`].prt_tax_in === false || + jobs_by_pk.parts_tax_rates[`${jobline.part_type.toUpperCase()}`].prt_tax_rt === 0 + ? false + : jobline.db_ref === "900511" || + jobline.db_ref === "900510" || + (jobline.mod_lb_hrs === 0 && //Extending IO-1375 as a part of IO-2023 + jobline.act_price > 0 && + jobline.lbr_op === "OP14") + ? true + : jobline.tax_part }, bodyshop.md_responsibility_centers.sales_tax_codes ); @@ -156,7 +163,7 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes { local: false, federal: InstanceManager({ imex: true, rome: false }), - state: !jobs_by_pk.state_tax_rate || jobs_by_pk.state_tax_rate === 0 ? false : true + state: jobs_by_pk.tax_lbr_rt === 0 ? false : true }, bodyshop.md_responsibility_centers.sales_tax_codes ); @@ -224,7 +231,7 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes { local: false, federal: InstanceManager({ imex: true, rome: false }), - state: !jobs_by_pk.state_tax_rate || jobs_by_pk.state_tax_rate === 0 ? false : true + state: jobs_by_pk.tax_paint_mat_rt === 0 ? false : true }, bodyshop.md_responsibility_centers.sales_tax_codes ); @@ -293,7 +300,7 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes { local: false, federal: InstanceManager({ imex: true, rome: false }), - state: !jobs_by_pk.state_tax_rate || jobs_by_pk.state_tax_rate === 0 ? false : true + state: jobs_by_pk.tax_shop_mat_rt === 0 ? false : true }, bodyshop.md_responsibility_centers.sales_tax_codes ); @@ -379,7 +386,7 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes { local: false, federal: InstanceManager({ imex: true, rome: false }), - state: !jobs_by_pk.state_tax_rate || jobs_by_pk.state_tax_rate === 0 ? false : true + state: jobs_by_pk.tax_tow_rt === 0 ? false : true }, bodyshop.md_responsibility_centers.sales_tax_codes ); @@ -439,7 +446,7 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes { local: false, federal: InstanceManager({ imex: true, rome: false }), - state: !jobs_by_pk.state_tax_rate || jobs_by_pk.state_tax_rate === 0 ? false : true + state: jobs_by_pk.tax_str_rt === 0 ? false : true }, bodyshop.md_responsibility_centers.sales_tax_codes ); @@ -499,7 +506,7 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes { local: false, federal: InstanceManager({ imex: true, rome: false }), - state: !jobs_by_pk.state_tax_rate || jobs_by_pk.state_tax_rate === 0 ? false : true + state: jobs_by_pk.state_tax_rate === 0 ? false : true }, bodyshop.md_responsibility_centers.sales_tax_codes ); @@ -670,7 +677,7 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes { local: false, federal: process.env.COUNTRY === "USA" ? false : true, - state: !jobs_by_pk.state_tax_rate || jobs_by_pk.state_tax_rate === 0 ? false : true + state: jobs_by_pk.state_tax_rate === 0 ? false : true }, bodyshop.md_responsibility_centers.sales_tax_codes ); diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js index d26db1405..5fd698b61 100644 --- a/server/graphql-client/queries.js +++ b/server/graphql-client/queries.js @@ -206,8 +206,13 @@ query QUERY_JOBS_FOR_RECEIVABLES_EXPORT($ids: [uuid!]!) { adjustment_bottom_line state_tax_rate qb_multiple_payers + parts_tax_rates tax_paint_mat_rt tax_lbr_rt + tax_shop_mat_rt + tax_sub_rt + tax_tow_rt + tax_str_rt owner { accountingid } From fdf0ecf6f6113ea004ef8c57c2f6acfe404d97cf Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Thu, 6 Jun 2024 14:51:44 -0700 Subject: [PATCH 03/13] IO-2814 Job Cost Correction Signed-off-by: Allan Carr --- server/job/job-costing.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/job/job-costing.js b/server/job/job-costing.js index d82d0ac42..274012e2f 100644 --- a/server/job/job-costing.js +++ b/server/job/job-costing.js @@ -269,7 +269,7 @@ function GenerateCostingData(job) { job && job.joblines.reduce( (acc, val) => { - //Parts Lines + //Shop or Paint Material Flags if (val.db_ref === "936008") { //If either of these DB REFs change, they also need to change in job-totals/job-costing calculations. hasMapaLine = true; @@ -277,6 +277,8 @@ function GenerateCostingData(job) { if (val.db_ref === "936007") { hasMashLine = true; } + + //Labor Profit Center if (val.mod_lbr_ty) { const laborProfitCenter = val.profitcenter_labor || defaultProfits[val.mod_lbr_ty] || "Unknown"; @@ -307,6 +309,7 @@ function GenerateCostingData(job) { } } + // Part Profit Center if (val.part_type && val.part_type !== "PAE" && val.part_type !== "PAS" && val.part_type !== "PASL") { const partsProfitCenter = val.profitcenter_part || defaultProfits[val.part_type] || "Unknown"; @@ -334,6 +337,8 @@ function GenerateCostingData(job) { if (!acc.parts[partsProfitCenter]) acc.parts[partsProfitCenter] = Dinero(); acc.parts[partsProfitCenter] = acc.parts[partsProfitCenter].add(partsAmount); } + + //Sublet Profit Center if (val.part_type && val.part_type !== "PAE" && (val.part_type === "PAS" || val.part_type === "PASL")) { const partsProfitCenter = val.profitcenter_part || defaultProfits[val.part_type] || "Unknown"; @@ -362,8 +367,8 @@ function GenerateCostingData(job) { acc.sublet[partsProfitCenter] = acc.sublet[partsProfitCenter].add(partsAmount); } - //To deal with additional costs. - if (!val.part_type && !val.mod_lbr_ty) { + //Additional Profit Center + if ((!val.part_type && !val.mod_lbr_ty) || (!val.part_type && val.mod_lbr_ty)) { //Does it already have a defined profit center? //If so, use it, otherwise try to use the same from the auto-allocate logic in IO app jobs-close-auto-allocate. const partsProfitCenter = val.profitcenter_part || getAdditionalCostCenter(val, defaultProfits) || "Unknown"; From 1ea4d616d7409bd9d992538e680ff6d9a65e831f Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Thu, 6 Jun 2024 15:00:58 -0700 Subject: [PATCH 04/13] IO-2793 State Tax Null QBO Signed-off-by: Allan Carr --- server/accounting/qb-receivables-lines.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/accounting/qb-receivables-lines.js b/server/accounting/qb-receivables-lines.js index 4162dfd35..5091e0136 100644 --- a/server/accounting/qb-receivables-lines.js +++ b/server/accounting/qb-receivables-lines.js @@ -506,7 +506,7 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes { local: false, federal: InstanceManager({ imex: true, rome: false }), - state: jobs_by_pk.state_tax_rate === 0 ? false : true + state: jobs_by_pk.tax_lbr_rt === 0 ? false : true }, bodyshop.md_responsibility_centers.sales_tax_codes ); From 755acd24f091f3fd71b027a3d0ef2490a19ad7c6 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Fri, 7 Jun 2024 11:40:39 -0700 Subject: [PATCH 05/13] IO-2814 Correct Parts Price and add Console Log Signed-off-by: Allan Carr --- server/graphql-client/queries.js | 1 + server/job/job-costing.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js index d26db1405..6d7f447df 100644 --- a/server/graphql-client/queries.js +++ b/server/graphql-client/queries.js @@ -1534,6 +1534,7 @@ exports.QUERY_JOB_COSTING_DETAILS = ` query QUERY_JOB_COSTING_DETAILS($id: uuid! op_code_desc profitcenter_part profitcenter_labor + act_price_before_ppc } bills { id diff --git a/server/job/job-costing.js b/server/job/job-costing.js index 274012e2f..1fbb92271 100644 --- a/server/job/job-costing.js +++ b/server/job/job-costing.js @@ -318,7 +318,7 @@ function GenerateCostingData(job) { if (!partsProfitCenter) console.log("Unknown cost/profit center mapping for parts.", val.line_desc, val.part_type); const partsAmount = Dinero({ - amount: Math.round((val.act_price || 0) * 100) + amount: val.act_price_before_ppc ? Math.round(val.act_price_before_ppc * 100) : Math.round(val.act_price * 100) }) .multiply(val.part_qty || 1) .add( @@ -327,7 +327,7 @@ function GenerateCostingData(job) { ? val.prt_dsmk_m ? Dinero({ amount: Math.round(val.prt_dsmk_m * 100) }) : Dinero({ - amount: Math.round(val.act_price * 100) + amount: val.act_price_before_ppc ? Math.round(val.act_price_before_ppc * 100) : Math.round(val.act_price * 100) }) .multiply(val.part_qty || 0) .percentage(Math.abs(val.prt_dsmk_p || 0)) @@ -396,6 +396,8 @@ function GenerateCostingData(job) { if (!acc.additional[partsProfitCenter]) acc.additional[partsProfitCenter] = Dinero(); acc.additional[partsProfitCenter] = acc.additional[partsProfitCenter].add(partsAmount); + + console.log("line_desc", val.line_desc, "partsProfitCenter", partsProfitCenter, "partsAmount", partsAmount.toUnit(), "acc", acc.additional[partsProfitCenter].add(partsAmount).toUnit()); } return acc; From f4c4005a2a853d79740a3a1d613b74536ca052e1 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Fri, 7 Jun 2024 12:16:59 -0700 Subject: [PATCH 06/13] IO-2814 Remove Comment as api.test.romeonline.io doesn't update w/ CICD Signed-off-by: Allan Carr --- server/job/job-costing.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/job/job-costing.js b/server/job/job-costing.js index 1fbb92271..8b966140e 100644 --- a/server/job/job-costing.js +++ b/server/job/job-costing.js @@ -396,8 +396,6 @@ function GenerateCostingData(job) { if (!acc.additional[partsProfitCenter]) acc.additional[partsProfitCenter] = Dinero(); acc.additional[partsProfitCenter] = acc.additional[partsProfitCenter].add(partsAmount); - - console.log("line_desc", val.line_desc, "partsProfitCenter", partsProfitCenter, "partsAmount", partsAmount.toUnit(), "acc", acc.additional[partsProfitCenter].add(partsAmount).toUnit()); } return acc; From 35046f11c2697aca18f312ce5929688d0a3fdd1f Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Fri, 7 Jun 2024 14:31:33 -0700 Subject: [PATCH 07/13] IO-2793 Add Comment to see output for testing Signed-off-by: Allan Carr --- server/accounting/qb-receivables-lines.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/accounting/qb-receivables-lines.js b/server/accounting/qb-receivables-lines.js index 5091e0136..8702dba33 100644 --- a/server/accounting/qb-receivables-lines.js +++ b/server/accounting/qb-receivables-lines.js @@ -67,6 +67,7 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes //Determine the Tax code grouping. //Going to always assume that we need to apply GST. + console.log("jobline", jobline) const taxAccountCode = findTaxCode( { local: false, From 5b76473cbc7dffa0fe13d30b16add51496a30d9a Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Fri, 7 Jun 2024 15:59:51 -0700 Subject: [PATCH 08/13] IO-2793 Correct Parts Side for Taxes Signed-off-by: Allan Carr --- server/accounting/qb-receivables-lines.js | 43 ++++++++++++++++------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/server/accounting/qb-receivables-lines.js b/server/accounting/qb-receivables-lines.js index 8702dba33..7c6c239ad 100644 --- a/server/accounting/qb-receivables-lines.js +++ b/server/accounting/qb-receivables-lines.js @@ -67,7 +67,12 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes //Determine the Tax code grouping. //Going to always assume that we need to apply GST. - console.log("jobline", jobline) + + //Find out CIECA Code based on profitcenter_part to determine if state tax applies or not. + const cieca_code = Object.keys(responsibilityCenters.defaults.profits).find( + (key) => responsibilityCenters.defaults.profits[key].toLowerCase() === jobline.profitcenter_part.toLowerCase() + ); + const taxAccountCode = findTaxCode( { local: false, @@ -75,20 +80,34 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes state: jobline.tax_part === false ? false - : jobline.part_type.toUpperCase() === "PAS" || jobline.part_type.toUpperCase() === "PASL" + : cieca_code === "PAS" || cieca_code === "PASL" ? jobs_by_pk.tax_sub_rt === 0 ? false : true - : jobs_by_pk.parts_tax_rates[`${jobline.part_type.toUpperCase()}`].prt_tax_in === false || - jobs_by_pk.parts_tax_rates[`${jobline.part_type.toUpperCase()}`].prt_tax_rt === 0 - ? false - : jobline.db_ref === "900511" || - jobline.db_ref === "900510" || - (jobline.mod_lb_hrs === 0 && //Extending IO-1375 as a part of IO-2023 - jobline.act_price > 0 && - jobline.lbr_op === "OP14") - ? true - : jobline.tax_part + : cieca_code.startsWith("LA") + ? jobs_by_pk.tax_lbr_rt === 0 + ? false + : true + : cieca_code === "MAPA" + ? jobs_by_pk.tax_paint_mat_rt === 0 + ? false + : true + : cieca_code === "MASH" + ? jobs_by_pk.tax_shop_mat_rt === 0 + ? false + : true + : cieca_code.startsWith("PA") + ? jobs_by_pk.parts_tax_rates[`${cieca_code}`].prt_tax_in === false || + jobs_by_pk.parts_tax_rates[`${cieca_code}`].prt_tax_rt === 0 + ? false + : true + : jobline.db_ref === "900511" || + jobline.db_ref === "900510" || + (jobline.mod_lb_hrs === 0 && //Extending IO-1375 as a part of IO-2023 + jobline.act_price > 0 && + jobline.lbr_op === "OP14") + ? true + : jobline.tax_part }, bodyshop.md_responsibility_centers.sales_tax_codes ); From ea604a5e641a817dff3cbc0b47eb99c20f53cb36 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Mon, 10 Jun 2024 09:59:45 -0700 Subject: [PATCH 09/13] IO-2793 Change to function for better clarity Signed-off-by: Allan Carr --- server/accounting/qb-receivables-lines.js | 105 ++++++++++++++-------- 1 file changed, 68 insertions(+), 37 deletions(-) diff --git a/server/accounting/qb-receivables-lines.js b/server/accounting/qb-receivables-lines.js index 7c6c239ad..73e7bf7a4 100644 --- a/server/accounting/qb-receivables-lines.js +++ b/server/accounting/qb-receivables-lines.js @@ -67,47 +67,11 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes //Determine the Tax code grouping. //Going to always assume that we need to apply GST. - - //Find out CIECA Code based on profitcenter_part to determine if state tax applies or not. - const cieca_code = Object.keys(responsibilityCenters.defaults.profits).find( - (key) => responsibilityCenters.defaults.profits[key].toLowerCase() === jobline.profitcenter_part.toLowerCase() - ); - const taxAccountCode = findTaxCode( { local: false, federal: InstanceManager({ imex: true, rome: false }), - state: - jobline.tax_part === false - ? false - : cieca_code === "PAS" || cieca_code === "PASL" - ? jobs_by_pk.tax_sub_rt === 0 - ? false - : true - : cieca_code.startsWith("LA") - ? jobs_by_pk.tax_lbr_rt === 0 - ? false - : true - : cieca_code === "MAPA" - ? jobs_by_pk.tax_paint_mat_rt === 0 - ? false - : true - : cieca_code === "MASH" - ? jobs_by_pk.tax_shop_mat_rt === 0 - ? false - : true - : cieca_code.startsWith("PA") - ? jobs_by_pk.parts_tax_rates[`${cieca_code}`].prt_tax_in === false || - jobs_by_pk.parts_tax_rates[`${cieca_code}`].prt_tax_rt === 0 - ? false - : true - : jobline.db_ref === "900511" || - jobline.db_ref === "900510" || - (jobline.mod_lb_hrs === 0 && //Extending IO-1375 as a part of IO-2023 - jobline.act_price > 0 && - jobline.lbr_op === "OP14") - ? true - : jobline.tax_part + state: checkStateTax(jobline, responsibilityCenters.defaults.profits, jobline.profitcenter_part) }, bodyshop.md_responsibility_centers.sales_tax_codes ); @@ -906,6 +870,73 @@ exports.createMultiQbPayerLines = function ({ bodyshop, jobs_by_pk, qbo = false, return InvoiceLineAdd; }; +function checkStateTax(jobline, defaultsProfits, profitCenter) { + //Find out CIECA Code based on profitcenter_part to determine if state tax applies or not. + const cieca_code = Object.keys(defaultsProfits).find( + (key) => defaultsProfits[key].toLowerCase() === profitCenter.toLowerCase() + ); + //Check Labor Tax Rate + if (cieca_code.startsWith("LA")) { + if (jobs_by_pk.tax_lbr_rt === 0) { + return false; + } else return true; + } + + //Check Material Tax Rate + if (cieca_code === "MAPA" || cieca_code === "MASH") { + if (cieca_code === "MAPA") { + if (jobs_by_pk.tax_paint_mat_rt === 0) { + return false; + } else { + return true; + } + } + if (cieca_code === "MASH") { + if (jobs_by_pk.tax_shop_mat_rt === 0) { + return false; + } else { + return true; + } + } + } + + //Check that line is a part type + if (cieca_code.startsWith("PA")) { + //Check if jobline is taxable + if (jobline.tax_part === false) { + return false; + } else { + //Check Tax rate for Sublet + if (cieca_code === "PAS" || cieca_code === "PASL") { + if (jobs_by_pk.tax_sub_rt === 0) { + return false; + } else { + return true; + } + } + //Extending IO-1375 as a part of IO-2023 + else if ( + jobline.db_ref === "900511" || + jobline.db_ref === "900510" || + (jobline.mod_lb_hrs === 0 && jobline.act_price > 0 && jobline.lbr_op === "OP14") + ) { + return true; + } + // Line is to be sent to QBO as Parts + else { + if ( + jobs_by_pk.parts_tax_rates[`${cieca_code}`].prt_tax_in === false || + jobs_by_pk.parts_tax_rates[`${cieca_code}`].prt_tax_rt === 0 + ) { + return false; + } else { + return true; + } + } + } + } +} + function CheckQBOUSATaxID({ jobline, job, type }) { //Replacing this to be all non-taxable items with the refactor of parts tax rates. return "NON"; From 9f565686805da977db32d6977d1b553e0d0eba61 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Mon, 10 Jun 2024 10:58:01 -0700 Subject: [PATCH 10/13] IO-2793 Correct variables Signed-off-by: Allan Carr --- server/accounting/qb-receivables-lines.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/accounting/qb-receivables-lines.js b/server/accounting/qb-receivables-lines.js index 73e7bf7a4..446832c66 100644 --- a/server/accounting/qb-receivables-lines.js +++ b/server/accounting/qb-receivables-lines.js @@ -71,7 +71,7 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes { local: false, federal: InstanceManager({ imex: true, rome: false }), - state: checkStateTax(jobline, responsibilityCenters.defaults.profits, jobline.profitcenter_part) + state: checkStateTax(jobline, jobs_by_pk.parts_tax_rates, responsibilityCenters.defaults.profits, jobline.profitcenter_part) }, bodyshop.md_responsibility_centers.sales_tax_codes ); @@ -870,7 +870,7 @@ exports.createMultiQbPayerLines = function ({ bodyshop, jobs_by_pk, qbo = false, return InvoiceLineAdd; }; -function checkStateTax(jobline, defaultsProfits, profitCenter) { +function checkStateTax(jobline, parts_tax_rates, defaultsProfits, profitCenter) { //Find out CIECA Code based on profitcenter_part to determine if state tax applies or not. const cieca_code = Object.keys(defaultsProfits).find( (key) => defaultsProfits[key].toLowerCase() === profitCenter.toLowerCase() @@ -925,8 +925,8 @@ function checkStateTax(jobline, defaultsProfits, profitCenter) { // Line is to be sent to QBO as Parts else { if ( - jobs_by_pk.parts_tax_rates[`${cieca_code}`].prt_tax_in === false || - jobs_by_pk.parts_tax_rates[`${cieca_code}`].prt_tax_rt === 0 + parts_tax_rates[`${cieca_code}`].prt_tax_in === false || + parts_tax_rates[`${cieca_code}`].prt_tax_rt === 0 ) { return false; } else { From 40a1a86f72fb8f1fbb87e6ce421c67ad49237213 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Mon, 10 Jun 2024 11:25:06 -0700 Subject: [PATCH 11/13] IO-2793 Correct passed Variable Signed-off-by: Allan Carr --- server/accounting/qb-receivables-lines.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/accounting/qb-receivables-lines.js b/server/accounting/qb-receivables-lines.js index 446832c66..593b5bc2e 100644 --- a/server/accounting/qb-receivables-lines.js +++ b/server/accounting/qb-receivables-lines.js @@ -71,7 +71,7 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes { local: false, federal: InstanceManager({ imex: true, rome: false }), - state: checkStateTax(jobline, jobs_by_pk.parts_tax_rates, responsibilityCenters.defaults.profits, jobline.profitcenter_part) + state: checkStateTax(jobline, jobs_by_pk, responsibilityCenters.defaults.profits, jobline.profitcenter_part) }, bodyshop.md_responsibility_centers.sales_tax_codes ); @@ -870,7 +870,7 @@ exports.createMultiQbPayerLines = function ({ bodyshop, jobs_by_pk, qbo = false, return InvoiceLineAdd; }; -function checkStateTax(jobline, parts_tax_rates, defaultsProfits, profitCenter) { +function checkStateTax(jobline, jobs_by_pk, defaultsProfits, profitCenter) { //Find out CIECA Code based on profitcenter_part to determine if state tax applies or not. const cieca_code = Object.keys(defaultsProfits).find( (key) => defaultsProfits[key].toLowerCase() === profitCenter.toLowerCase() @@ -925,8 +925,8 @@ function checkStateTax(jobline, parts_tax_rates, defaultsProfits, profitCenter) // Line is to be sent to QBO as Parts else { if ( - parts_tax_rates[`${cieca_code}`].prt_tax_in === false || - parts_tax_rates[`${cieca_code}`].prt_tax_rt === 0 + jobs_by_pk.parts_tax_rates[`${cieca_code}`].prt_tax_in === false || + jobs_by_pk.parts_tax_rates[`${cieca_code}`].prt_tax_rt === 0 ) { return false; } else { From 269ef25ece5ae42f65ea03d939439e5a77a4bfbd Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Mon, 10 Jun 2024 14:14:15 -0700 Subject: [PATCH 12/13] IO-2793 Better tax handling Signed-off-by: Allan Carr --- server/accounting/qb-receivables-lines.js | 75 ++++++++++++----------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/server/accounting/qb-receivables-lines.js b/server/accounting/qb-receivables-lines.js index 593b5bc2e..bb8fa8259 100644 --- a/server/accounting/qb-receivables-lines.js +++ b/server/accounting/qb-receivables-lines.js @@ -71,7 +71,7 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes { local: false, federal: InstanceManager({ imex: true, rome: false }), - state: checkStateTax(jobline, jobs_by_pk, responsibilityCenters.defaults.profits, jobline.profitcenter_part) + state: checkStateTax(jobline, jobs_by_pk) }, bodyshop.md_responsibility_centers.sales_tax_codes ); @@ -870,28 +870,18 @@ exports.createMultiQbPayerLines = function ({ bodyshop, jobs_by_pk, qbo = false, return InvoiceLineAdd; }; -function checkStateTax(jobline, jobs_by_pk, defaultsProfits, profitCenter) { - //Find out CIECA Code based on profitcenter_part to determine if state tax applies or not. - const cieca_code = Object.keys(defaultsProfits).find( - (key) => defaultsProfits[key].toLowerCase() === profitCenter.toLowerCase() - ); - //Check Labor Tax Rate - if (cieca_code.startsWith("LA")) { - if (jobs_by_pk.tax_lbr_rt === 0) { - return false; - } else return true; - } +function checkStateTax(jobline, jobs_by_pk) { + const isPaintOrShopMat = jobline.db_ref === "936008" || jobline.db_ref === "936007"; - //Check Material Tax Rate - if (cieca_code === "MAPA" || cieca_code === "MASH") { - if (cieca_code === "MAPA") { + if (isPaintOrShopMat) { + if (jobline.db_ref === "936008") { if (jobs_by_pk.tax_paint_mat_rt === 0) { return false; } else { return true; } } - if (cieca_code === "MASH") { + if (jobline.db_ref === "936007") { if (jobs_by_pk.tax_shop_mat_rt === 0) { return false; } else { @@ -900,38 +890,49 @@ function checkStateTax(jobline, jobs_by_pk, defaultsProfits, profitCenter) { } } - //Check that line is a part type - if (cieca_code.startsWith("PA")) { - //Check if jobline is taxable - if (jobline.tax_part === false) { + const isAdditionalCost = + (jobline.lbr_op === "OP13" || (jobline.db_ref && jobline.db_ref.startsWith("9360"))) && !isPaintOrShopMat; + + if (!jobline.part_type && isAdditionalCost) { + if (jobs_by_pk.tax_lbr_rt === 0) { return false; } else { - //Check Tax rate for Sublet - if (cieca_code === "PAS" || cieca_code === "PASL") { + return true; + } + } + + if ( + jobline.db_ref === "900511" || + jobline.db_ref === "900510" || + (jobline.mod_lb_hrs === 0 && jobline.act_price > 0 && jobline.lbr_op === "OP14") + ) + return true; //Extending IO-1375 as a part of IO-2023 + + if (jobline.tax_part === false) { + return false; + } else { + if (jobline.part_type) { + if (jobline.part_type === "PAS" || jobline.part_type === "PASL") { if (jobs_by_pk.tax_sub_rt === 0) { return false; } else { return true; } } - //Extending IO-1375 as a part of IO-2023 - else if ( - jobline.db_ref === "900511" || - jobline.db_ref === "900510" || - (jobline.mod_lb_hrs === 0 && jobline.act_price > 0 && jobline.lbr_op === "OP14") + + if ( + jobs_by_pk.parts_tax_rates[`${jobline.part_type.toUpperCase()}`].prt_tax_in === false || + jobs_by_pk.parts_tax_rates[`${jobline.part_type.toUpperCase()}`].prt_tax_rt === 0 ) { + return false; + } else { return true; } - // Line is to be sent to QBO as Parts - else { - if ( - jobs_by_pk.parts_tax_rates[`${cieca_code}`].prt_tax_in === false || - jobs_by_pk.parts_tax_rates[`${cieca_code}`].prt_tax_rt === 0 - ) { - return false; - } else { - return true; - } + } else { + if (jobs_by_pk.tax_lbr_rt === 0) { + return false; + } else { + return true; } } } From 0d2cdec75c0a545991f0bed280446638f326bce7 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Mon, 10 Jun 2024 14:42:21 -0700 Subject: [PATCH 13/13] IO-2793 Correction for Sublet Part Tax Signed-off-by: Allan Carr --- server/accounting/qb-receivables-lines.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/server/accounting/qb-receivables-lines.js b/server/accounting/qb-receivables-lines.js index bb8fa8259..4be412ac9 100644 --- a/server/accounting/qb-receivables-lines.js +++ b/server/accounting/qb-receivables-lines.js @@ -912,14 +912,6 @@ function checkStateTax(jobline, jobs_by_pk) { return false; } else { if (jobline.part_type) { - if (jobline.part_type === "PAS" || jobline.part_type === "PASL") { - if (jobs_by_pk.tax_sub_rt === 0) { - return false; - } else { - return true; - } - } - if ( jobs_by_pk.parts_tax_rates[`${jobline.part_type.toUpperCase()}`].prt_tax_in === false || jobs_by_pk.parts_tax_rates[`${jobline.part_type.toUpperCase()}`].prt_tax_rt === 0