Improve backwards compatibility for job totals calculations.

This commit is contained in:
Patrick Fic
2023-01-20 07:59:47 -08:00
parent 018f8a19bb
commit 41c63cbfe9
4 changed files with 4316 additions and 33 deletions

View File

@@ -13,9 +13,11 @@ export default function JobTotalsTableParts({ job }) {
});
const insuranceAdjustments = useMemo(() => {
if (!job.job_totals) return [];
if (!job.job_totals?.parts?.adjustments) return [];
const adjs = [];
Object.keys(job.job_totals.parts.adjustments).forEach((key) => {
if (Dinero(job.job_totals.parts.adjustments[key]).getAmount() !== 0) {
Object.keys(job.job_totals?.parts?.adjustments).forEach((key) => {
if (Dinero(job.job_totals?.parts?.adjustments[key]).getAmount() !== 0) {
adjs.push({
id: key,
amount: Dinero(job.job_totals.parts.adjustments[key]),
@@ -25,10 +27,6 @@ export default function JobTotalsTableParts({ job }) {
return adjs;
}, [job.job_totals.parts.adjustments]);
console.log(
"🚀 ~ file: job-totals.table.parts.component.jsx:16 ~ insuranceAdjustments ~ insuranceAdjustments",
insuranceAdjustments
);
const data = useMemo(() => {
return Object.keys(job.job_totals.parts.parts.list)