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