IO-3627 Courtesy Car Create RO
Signed-off-by: Allan Carr <allan@imexsystems.ca>
This commit is contained in:
@@ -10,6 +10,7 @@ import { createStructuredSelector } from "reselect";
|
|||||||
import { INSERT_NEW_JOB } from "../../graphql/jobs.queries";
|
import { INSERT_NEW_JOB } from "../../graphql/jobs.queries";
|
||||||
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
|
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
|
||||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||||
|
import InstanceRenderManager from "../../utils/instanceRenderMgr.js";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
//currentUser: selectCurrentUser
|
//currentUser: selectCurrentUser
|
||||||
@@ -156,6 +157,8 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract, disabled
|
|||||||
joblines: {
|
joblines: {
|
||||||
data: billingLines
|
data: billingLines
|
||||||
},
|
},
|
||||||
|
...InstanceRenderManager({
|
||||||
|
imex: {
|
||||||
parts_tax_rates: {
|
parts_tax_rates: {
|
||||||
PAA: {
|
PAA: {
|
||||||
prt_type: "PAA",
|
prt_type: "PAA",
|
||||||
@@ -254,6 +257,27 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract, disabled
|
|||||||
prt_tax_rt: bodyshop.bill_tax_rates.state_tax_rate / 100
|
prt_tax_rt: bodyshop.bill_tax_rates.state_tax_rate / 100
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
rome: {
|
||||||
|
cieca_pft: {
|
||||||
|
...bodyshop.md_responsibility_centers.taxes.tax_ty1,
|
||||||
|
...bodyshop.md_responsibility_centers.taxes.tax_ty2,
|
||||||
|
...bodyshop.md_responsibility_centers.taxes.tax_ty3,
|
||||||
|
...bodyshop.md_responsibility_centers.taxes.tax_ty4,
|
||||||
|
...bodyshop.md_responsibility_centers.taxes.tax_ty5
|
||||||
|
},
|
||||||
|
materials: bodyshop.md_responsibility_centers.cieca_pfm,
|
||||||
|
cieca_pfl: bodyshop.md_responsibility_centers.cieca_pfl,
|
||||||
|
parts_tax_rates: bodyshop.md_responsibility_centers.parts_tax_rates,
|
||||||
|
tax_tow_rt: bodyshop.md_responsibility_centers.tax_tow_rt,
|
||||||
|
tax_str_rt: bodyshop.md_responsibility_centers.tax_str_rt,
|
||||||
|
tax_paint_mat_rt: bodyshop.md_responsibility_centers.tax_paint_mat_rt,
|
||||||
|
tax_shop_mat_rt: bodyshop.md_responsibility_centers.tax_shop_mat_rt,
|
||||||
|
tax_sub_rt: bodyshop.md_responsibility_centers.tax_sub_rt,
|
||||||
|
tax_lbr_rt: bodyshop.md_responsibility_centers.tax_lbr_rt,
|
||||||
|
tax_levies_rt: bodyshop.md_responsibility_centers.tax_levies_rt
|
||||||
|
}
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
if (currentUser?.email) {
|
if (currentUser?.email) {
|
||||||
@@ -287,7 +311,7 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract, disabled
|
|||||||
notification.success({
|
notification.success({
|
||||||
title: t("jobs.successes.created"),
|
title: t("jobs.successes.created"),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
history.push(`/manage/jobs/${result.data.insert_jobs.returning[0].id}`);
|
history(`/manage/jobs/${result.data.insert_jobs.returning[0].id}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -885,6 +885,8 @@ function CalculateTaxesTotals(job, otherTotals) {
|
|||||||
STOR: Dinero()
|
STOR: Dinero()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const pfp = job.parts_tax_rates;
|
||||||
|
|
||||||
//For each line, determine if it's taxable, and if it is, add the line amount to the taxable amounts total.
|
//For each line, determine if it's taxable, and if it is, add the line amount to the taxable amounts total.
|
||||||
job.joblines
|
job.joblines
|
||||||
.filter((jl) => !jl.removed)
|
.filter((jl) => !jl.removed)
|
||||||
@@ -916,7 +918,17 @@ function CalculateTaxesTotals(job, otherTotals) {
|
|||||||
})
|
})
|
||||||
.multiply(val.part_qty || 0)
|
.multiply(val.part_qty || 0)
|
||||||
.add(discMarkupAmount);
|
.add(discMarkupAmount);
|
||||||
|
if (taxableAmounts[typeOfPart]) {
|
||||||
taxableAmounts[typeOfPart] = taxableAmounts[typeOfPart].add(partAmount);
|
taxableAmounts[typeOfPart] = taxableAmounts[typeOfPart].add(partAmount);
|
||||||
|
} else {
|
||||||
|
const isTaxableCustomType =
|
||||||
|
IsTrueOrYes(pfp?.[typeOfPart]?.prt_tax_in) || pfp?.[typeOfPart]?.prt_tax_in === true;
|
||||||
|
|
||||||
|
if (isTaxableCustomType) {
|
||||||
|
if (!taxableAmounts[typeOfPart]) taxableAmounts[typeOfPart] = Dinero();
|
||||||
|
taxableAmounts[typeOfPart] = taxableAmounts[typeOfPart].add(partAmount);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -969,13 +981,15 @@ function CalculateTaxesTotals(job, otherTotals) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const pfp = job.parts_tax_rates;
|
|
||||||
|
|
||||||
//For any profile level markups/discounts, add them in now as well.
|
//For any profile level markups/discounts, add them in now as well.
|
||||||
Object.keys(otherTotals.parts.adjustments).forEach((key) => {
|
Object.keys(otherTotals.parts.adjustments).forEach((key) => {
|
||||||
const adjustmentAmount = otherTotals.parts.adjustments[key];
|
const adjustmentAmount = otherTotals.parts.adjustments[key];
|
||||||
if (adjustmentAmount.getAmount() !== 0 && pfp[key]?.prt_tax_in) {
|
if (adjustmentAmount.getAmount() !== 0 && pfp[key]?.prt_tax_in) {
|
||||||
|
if (taxableAmounts[key]) {
|
||||||
taxableAmounts[key] = taxableAmounts[key].add(adjustmentAmount);
|
taxableAmounts[key] = taxableAmounts[key].add(adjustmentAmount);
|
||||||
|
} else {
|
||||||
|
taxableAmounts[key] = Dinero().add(adjustmentAmount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1072,6 +1086,21 @@ function CalculateTaxesTotals(job, otherTotals) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (pfp[key]) {
|
||||||
|
//Custom part types (e.g. CC*) should flow through taxableAmountsByTier too.
|
||||||
|
let assignedToTier = false;
|
||||||
|
for (let tyCounter = 1; tyCounter <= 5; tyCounter++) {
|
||||||
|
if (IsTrueOrYes(pfp[key][`prt_tx_in${tyCounter}`])) {
|
||||||
|
taxableAmountsByTier[`ty${tyCounter}Tax`] = taxableAmountsByTier[`ty${tyCounter}Tax`].add(
|
||||||
|
taxableAmounts[key]
|
||||||
|
);
|
||||||
|
assignedToTier = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!assignedToTier && (IsTrueOrYes(pfp[key].prt_tax_in) || pfp[key].prt_tax_in === true)) {
|
||||||
|
taxableAmountsByTier.ty1Tax = taxableAmountsByTier.ty1Tax.add(taxableAmounts[key]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("job-totals-USA Key with issue", "warn", null, job.id, {
|
logger.log("job-totals-USA Key with issue", "warn", null, job.id, {
|
||||||
|
|||||||
Reference in New Issue
Block a user