IO-2793 Better tax handling

Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
This commit is contained in:
Allan Carr
2024-06-10 14:14:15 -07:00
parent 40a1a86f72
commit 269ef25ece

View File

@@ -71,7 +71,7 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes
{ {
local: false, local: false,
federal: InstanceManager({ imex: true, rome: 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 bodyshop.md_responsibility_centers.sales_tax_codes
); );
@@ -870,28 +870,18 @@ exports.createMultiQbPayerLines = function ({ bodyshop, jobs_by_pk, qbo = false,
return InvoiceLineAdd; return InvoiceLineAdd;
}; };
function checkStateTax(jobline, jobs_by_pk, defaultsProfits, profitCenter) { function checkStateTax(jobline, jobs_by_pk) {
//Find out CIECA Code based on profitcenter_part to determine if state tax applies or not. const isPaintOrShopMat = jobline.db_ref === "936008" || jobline.db_ref === "936007";
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 (isPaintOrShopMat) {
if (cieca_code === "MAPA" || cieca_code === "MASH") { if (jobline.db_ref === "936008") {
if (cieca_code === "MAPA") {
if (jobs_by_pk.tax_paint_mat_rt === 0) { if (jobs_by_pk.tax_paint_mat_rt === 0) {
return false; return false;
} else { } else {
return true; return true;
} }
} }
if (cieca_code === "MASH") { if (jobline.db_ref === "936007") {
if (jobs_by_pk.tax_shop_mat_rt === 0) { if (jobs_by_pk.tax_shop_mat_rt === 0) {
return false; return false;
} else { } else {
@@ -900,38 +890,49 @@ function checkStateTax(jobline, jobs_by_pk, defaultsProfits, profitCenter) {
} }
} }
//Check that line is a part type const isAdditionalCost =
if (cieca_code.startsWith("PA")) { (jobline.lbr_op === "OP13" || (jobline.db_ref && jobline.db_ref.startsWith("9360"))) && !isPaintOrShopMat;
//Check if jobline is taxable
if (jobline.tax_part === false) { if (!jobline.part_type && isAdditionalCost) {
if (jobs_by_pk.tax_lbr_rt === 0) {
return false; return false;
} else { } else {
//Check Tax rate for Sublet return true;
if (cieca_code === "PAS" || cieca_code === "PASL") { }
}
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) { if (jobs_by_pk.tax_sub_rt === 0) {
return false; return false;
} else { } else {
return true; return true;
} }
} }
//Extending IO-1375 as a part of IO-2023
else if ( if (
jobline.db_ref === "900511" || jobs_by_pk.parts_tax_rates[`${jobline.part_type.toUpperCase()}`].prt_tax_in === false ||
jobline.db_ref === "900510" || jobs_by_pk.parts_tax_rates[`${jobline.part_type.toUpperCase()}`].prt_tax_rt === 0
(jobline.mod_lb_hrs === 0 && jobline.act_price > 0 && jobline.lbr_op === "OP14")
) { ) {
return false;
} else {
return true; return true;
} }
// Line is to be sent to QBO as Parts } else {
else { if (jobs_by_pk.tax_lbr_rt === 0) {
if ( return false;
jobs_by_pk.parts_tax_rates[`${cieca_code}`].prt_tax_in === false || } else {
jobs_by_pk.parts_tax_rates[`${cieca_code}`].prt_tax_rt === 0 return true;
) {
return false;
} else {
return true;
}
} }
} }
} }