Additional changes for CCC calculations.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<babeledit_project be_version="2.7.1" version="1.2">
|
||||
<babeledit_project version="1.2" be_version="2.7.1">
|
||||
<!--
|
||||
|
||||
BabelEdit project file
|
||||
@@ -28933,6 +28933,27 @@
|
||||
</concept_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<concept_node>
|
||||
<name>profileadjustments</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>prt_dsmk_total</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
|
||||
@@ -11,37 +11,46 @@ export default function JobCalculateTotals({ job, disabled }) {
|
||||
const [updateJob] = useMutation(UPDATE_JOB);
|
||||
|
||||
const handleCalculate = async () => {
|
||||
setLoading(true);
|
||||
const newTotals = (
|
||||
await Axios.post("/job/totals", {
|
||||
job: job,
|
||||
})
|
||||
).data;
|
||||
try {
|
||||
setLoading(true);
|
||||
const newTotals = (
|
||||
await Axios.post("/job/totals", {
|
||||
job: job,
|
||||
})
|
||||
).data;
|
||||
|
||||
const result = await updateJob({
|
||||
refetchQueries: ["GET_JOB_BY_PK"],
|
||||
awaitRefetchQueries: true,
|
||||
variables: {
|
||||
jobId: job.id,
|
||||
job: {
|
||||
job_totals: newTotals,
|
||||
clm_total: Dinero(newTotals.totals.total_repairs).toFormat("0.00"),
|
||||
owner_owing: Dinero(newTotals.totals.custPayable.total).toFormat(
|
||||
"0.00"
|
||||
),
|
||||
const result = await updateJob({
|
||||
refetchQueries: ["GET_JOB_BY_PK"],
|
||||
awaitRefetchQueries: true,
|
||||
variables: {
|
||||
jobId: job.id,
|
||||
job: {
|
||||
job_totals: newTotals,
|
||||
clm_total: Dinero(newTotals.totals.total_repairs).toFormat("0.00"),
|
||||
owner_owing: Dinero(newTotals.totals.custPayable.total).toFormat(
|
||||
"0.00"
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!!!result.errors) {
|
||||
notification["success"]({ message: t("jobs.successes.updated") });
|
||||
} else {
|
||||
});
|
||||
if (!!!result.errors) {
|
||||
notification["success"]({ message: t("jobs.successes.updated") });
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.updating", {
|
||||
error: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.updating", {
|
||||
error: JSON.stringify(result.errors),
|
||||
error: JSON.stringify(error),
|
||||
}),
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -124,8 +124,7 @@ export default function JobTotalsTableLabor({ job }) {
|
||||
{t("jobs.labels.mapa")}
|
||||
{job.materials &&
|
||||
job.materials.mapa &&
|
||||
job.materials.mapa.cal_maxdlr &&
|
||||
job.materials.mapa.cal_maxdlr > 0 &&
|
||||
job.materials.mapa.cal_maxdlr !== undefined &&
|
||||
t("jobs.labels.threshhold", {
|
||||
amount: job.materials.mapa.cal_maxdlr,
|
||||
})}
|
||||
@@ -149,8 +148,7 @@ export default function JobTotalsTableLabor({ job }) {
|
||||
{t("jobs.labels.mash")}
|
||||
{job.materials &&
|
||||
job.materials.mash &&
|
||||
job.materials.mash.cal_maxdlr &&
|
||||
job.materials.mash.cal_maxdlr > 0 &&
|
||||
job.materials.mash.cal_maxdlr !== undefined &&
|
||||
t("jobs.labels.threshhold", {
|
||||
amount: job.materials.mash.cal_maxdlr,
|
||||
})}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Table } from "antd";
|
||||
import { Alert, Table } from "antd";
|
||||
import Dinero from "dinero.js";
|
||||
import { object } from "prop-types";
|
||||
import React, { useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { alphaSort } from "../../utils/sorters";
|
||||
@@ -11,6 +12,24 @@ export default function JobTotalsTableParts({ job }) {
|
||||
filteredInfo: {},
|
||||
});
|
||||
|
||||
const insuranceAdjustments = useMemo(() => {
|
||||
const adjs = [];
|
||||
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]),
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
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)
|
||||
.filter(
|
||||
@@ -74,11 +93,11 @@ export default function JobTotalsTableParts({ job }) {
|
||||
<Table.Summary.Cell>
|
||||
{t("jobs.labels.prt_dsmk_total")}
|
||||
</Table.Summary.Cell>
|
||||
|
||||
<Table.Summary.Cell align="right">
|
||||
{Dinero(job.job_totals.parts.parts.prt_dsmk_total).toFormat()}
|
||||
</Table.Summary.Cell>
|
||||
</Table.Summary.Row>
|
||||
|
||||
<Table.Summary.Row>
|
||||
<Table.Summary.Cell>
|
||||
<strong>{t("jobs.labels.partstotal")}</strong>
|
||||
@@ -90,6 +109,24 @@ export default function JobTotalsTableParts({ job }) {
|
||||
</strong>
|
||||
</Table.Summary.Cell>
|
||||
</Table.Summary.Row>
|
||||
{insuranceAdjustments.length > 0 && (
|
||||
<Table.Summary.Row>
|
||||
<Table.Summary.Cell colSpan={24}>
|
||||
{t("jobs.labels.profileadjustments")}
|
||||
</Table.Summary.Cell>
|
||||
</Table.Summary.Row>
|
||||
)}
|
||||
{insuranceAdjustments.map((adj, idx) => (
|
||||
<Table.Summary.Row key={idx}>
|
||||
<Table.Summary.Cell>
|
||||
{t(`jobs.fields.${adj.id.toLowerCase()}`)}
|
||||
</Table.Summary.Cell>
|
||||
|
||||
<Table.Summary.Cell align="right">
|
||||
{adj.amount.toFormat()}
|
||||
</Table.Summary.Cell>
|
||||
</Table.Summary.Row>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
|
||||
@@ -516,6 +516,17 @@ async function CheckTaxRates(estData, bodyshop) {
|
||||
}
|
||||
|
||||
async function ResolveCCCLineIssues(estData, bodyshop) {
|
||||
//Find all misc amounts, populate them to the act price.
|
||||
//TODO Ensure that this doesnt get violated
|
||||
//This needs to be done before cleansing unq_seq since some misc prices could move over.
|
||||
estData.joblines.data.forEach((line) => {
|
||||
if (line.misc_amt && line.misc_amt > 0) {
|
||||
line.act_price = line.misc_amt;
|
||||
line.part_type = "PAS";
|
||||
line.tax_part = line.misc_tax;
|
||||
}
|
||||
});
|
||||
|
||||
//Generate the list of duplicated UNQ_SEQ that will feed into the next section to scrub the lines.
|
||||
const unqSeqHash = _.groupBy(estData.joblines.data, "unq_seq");
|
||||
const duplicatedUnqSeq = Object.keys(unqSeqHash).filter(
|
||||
@@ -537,14 +548,4 @@ async function ResolveCCCLineIssues(estData, bodyshop) {
|
||||
db_price: null,
|
||||
};
|
||||
});
|
||||
|
||||
//Find all misc amounts, populate them to the act price.
|
||||
//TODO Ensure that this doesnt get violated
|
||||
estData.joblines.data.forEach((line) => {
|
||||
if (line.misc_amt && line.misc_amt > 0) {
|
||||
line.act_price = line.misc_amt;
|
||||
line.part_type = "PAS";
|
||||
line.tax_part = line.misc_tax;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "PAA", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -42,7 +42,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "PAA", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -68,7 +68,7 @@ export function JobsDetailRatesParts({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
);
|
||||
}}
|
||||
@@ -79,7 +79,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "PAC", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -92,7 +92,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "PAC", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -118,7 +118,7 @@ export function JobsDetailRatesParts({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
);
|
||||
}}
|
||||
@@ -129,7 +129,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "PAL", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -142,7 +142,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "PAL", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -168,7 +168,7 @@ export function JobsDetailRatesParts({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
);
|
||||
}}
|
||||
@@ -179,7 +179,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "PAG", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -192,7 +192,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "PAG", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -218,7 +218,7 @@ export function JobsDetailRatesParts({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
);
|
||||
}}
|
||||
@@ -229,7 +229,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "PAM", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -242,7 +242,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "PAM", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -268,7 +268,7 @@ export function JobsDetailRatesParts({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
);
|
||||
}}
|
||||
@@ -279,7 +279,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "PAN", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -292,7 +292,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "PAN", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -318,7 +318,7 @@ export function JobsDetailRatesParts({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
);
|
||||
}}
|
||||
@@ -329,7 +329,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "PAO", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -342,7 +342,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "PAO", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -368,7 +368,7 @@ export function JobsDetailRatesParts({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
);
|
||||
}}
|
||||
@@ -379,7 +379,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "PAP", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -392,7 +392,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "PAP", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -418,7 +418,7 @@ export function JobsDetailRatesParts({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
);
|
||||
}}
|
||||
@@ -429,7 +429,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "PAR", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -442,7 +442,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "PAR", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -468,7 +468,7 @@ export function JobsDetailRatesParts({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
);
|
||||
}}
|
||||
@@ -479,7 +479,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "PAS", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -492,7 +492,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "PAS", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -518,7 +518,7 @@ export function JobsDetailRatesParts({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
);
|
||||
}}
|
||||
@@ -529,7 +529,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "PASL", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -542,7 +542,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "PASL", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -568,7 +568,7 @@ export function JobsDetailRatesParts({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
);
|
||||
}}
|
||||
@@ -579,7 +579,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "CCDR", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -592,7 +592,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "CCDR", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -605,7 +605,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_rt")}
|
||||
name={["parts_tax_rates", "CCDR", "prt_tax_rt"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
<LayoutFormRow header={t("joblines.fields.part_types.CCF")}>
|
||||
@@ -613,7 +613,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "CCF", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -626,7 +626,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "CCF", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -639,7 +639,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_rt")}
|
||||
name={["parts_tax_rates", "CCF", "prt_tax_rt"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
<LayoutFormRow header={t("joblines.fields.part_types.CCM")}>
|
||||
@@ -647,7 +647,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "CCM", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -660,7 +660,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "CCM", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -673,7 +673,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_rt")}
|
||||
name={["parts_tax_rates", "CCM", "prt_tax_rt"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
<LayoutFormRow header={t("joblines.fields.part_types.CCC")}>
|
||||
@@ -681,7 +681,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "CCC", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -694,7 +694,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "CCC", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -707,7 +707,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_rt")}
|
||||
name={["parts_tax_rates", "CCC", "prt_tax_rt"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
<LayoutFormRow header={t("joblines.fields.part_types.CCD")}>
|
||||
@@ -715,7 +715,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_discp")}
|
||||
name={["parts_tax_rates", "CCD", "prt_discp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mktyp")}
|
||||
@@ -728,7 +728,7 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_mkupp")}
|
||||
name={["parts_tax_rates", "CCD", "prt_mkupp"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_in")}
|
||||
@@ -741,39 +741,39 @@ export function JobsDetailRatesParts({
|
||||
label={t("jobs.fields.parts_tax_rates.prt_tax_rt")}
|
||||
name={["parts_tax_rates", "CCD", "prt_tax_rt"]}
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
<LayoutFormRow>
|
||||
<Form.Item label={t("jobs.fields.tax_tow_rt")} name="tax_tow_rt">
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item label={t("jobs.fields.tax_str_rt")} name="tax_str_rt">
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.tax_paint_mat_rt")}
|
||||
name="tax_paint_mat_rt"
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.tax_shop_mat_rt")}
|
||||
name="tax_shop_mat_rt"
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item label={t("jobs.fields.tax_sub_rt")} name="tax_sub_rt">
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item label={t("jobs.fields.tax_lbr_rt")} name="tax_lbr_rt">
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("jobs.fields.tax_levies_rt")}
|
||||
name="tax_levies_rt"
|
||||
>
|
||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||
<InputNumber min={0} max={100} precision={2} disabled={jobRO} />
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
</Collapse.Panel>
|
||||
|
||||
@@ -1694,6 +1694,7 @@
|
||||
"partstotal": "This is the total of all parts and sublet amounts on the vehicle (some of these may require an in-house invoice).<br/>\nItems such as shop and paint materials, labor online lines, etc. are not included in this total.",
|
||||
"totalreturns": "The total <b>retail</b> amount of returns created for this job."
|
||||
},
|
||||
"profileadjustments": "Profile Disc./Mkup (Already included above)",
|
||||
"prt_dsmk_total": "Line Item Adjustment",
|
||||
"rates": "Rates",
|
||||
"rates_subtotal": "All Rates Subtotal",
|
||||
|
||||
@@ -1694,6 +1694,7 @@
|
||||
"partstotal": "",
|
||||
"totalreturns": ""
|
||||
},
|
||||
"profileadjustments": "",
|
||||
"prt_dsmk_total": "",
|
||||
"rates": "Tarifas",
|
||||
"rates_subtotal": "",
|
||||
|
||||
@@ -1694,6 +1694,7 @@
|
||||
"partstotal": "",
|
||||
"totalreturns": ""
|
||||
},
|
||||
"profileadjustments": "",
|
||||
"prt_dsmk_total": "",
|
||||
"rates": "Les taux",
|
||||
"rates_subtotal": "",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
const { objectLength } = require("@oozcitak/util");
|
||||
const Dinero = require("dinero.js");
|
||||
const queries = require("../graphql-client/queries");
|
||||
const GraphQLClient = require("graphql-request").GraphQLClient;
|
||||
@@ -58,7 +59,7 @@ async function TotalsServerSide(req, res) {
|
||||
|
||||
try {
|
||||
let ret = {
|
||||
parts: CalculatePartsTotals(job.joblines),
|
||||
parts: CalculatePartsTotals(job.joblines, job.parts_tax_rates),
|
||||
rates: CalculateRatesTotals(job),
|
||||
additional: CalculateAdditional(job),
|
||||
};
|
||||
@@ -92,7 +93,7 @@ async function Totals(req, res) {
|
||||
await AutoAddAtsIfRequired({ job, client });
|
||||
try {
|
||||
let ret = {
|
||||
parts: CalculatePartsTotals(job.joblines),
|
||||
parts: CalculatePartsTotals(job.joblines, job.parts_tax_rates),
|
||||
rates: CalculateRatesTotals(job),
|
||||
additional: CalculateAdditional(job),
|
||||
};
|
||||
@@ -260,6 +261,8 @@ function CalculateRatesTotals(ratesList) {
|
||||
//Otherwise, calculate them and add them to the default MAPA and MASH centers.
|
||||
let hasMapaLine = false;
|
||||
let hasMashLine = false;
|
||||
let mapaOpCodes = ParseCalopCode(ratesList.materials["mapa"].cal_opcode);
|
||||
let mashOpCodes = ParseCalopCode(ratesList.materials["mash"].cal_opcode);
|
||||
|
||||
jobLines.forEach((item) => {
|
||||
//IO-1317 Use the lines on the estimate if they exist instead.
|
||||
@@ -301,10 +304,18 @@ function CalculateRatesTotals(ratesList) {
|
||||
ret[item.mod_lbr_ty.toLowerCase()].hours =
|
||||
ret[item.mod_lbr_ty.toLowerCase()].hours + item.mod_lb_hrs;
|
||||
|
||||
//Count up the number of materials/paint hours.
|
||||
|
||||
//Following change may be CCC specific.
|
||||
if (item.mod_lbr_ty === "LAR") {
|
||||
// if (mapaOpCodes.includes(item.lbr_op)) { //Unknown if this is needed. Seems to be ignored.
|
||||
ret.mapa.hours = ret.mapa.hours + item.mod_lb_hrs;
|
||||
// }
|
||||
} else {
|
||||
ret.mash.hours = ret.mash.hours + item.mod_lb_hrs; //Apparently there may be an exclusion for glass hours in BC.
|
||||
if (mashOpCodes.includes(item.lbr_op)) {
|
||||
// Added when processing CIECA ID 14A60015 to have materials match.
|
||||
ret.mash.hours = ret.mash.hours + item.mod_lb_hrs; //Apparently there may be an exclusion for glass hours in BC.
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -327,9 +338,10 @@ function CalculateRatesTotals(ratesList) {
|
||||
//Check if there is a max for this type.
|
||||
if (ratesList.materials && ratesList.materials[property]) {
|
||||
//
|
||||
|
||||
if (
|
||||
ratesList.materials[property].cal_maxdlr &&
|
||||
ratesList.materials[property].cal_maxdlr > 0
|
||||
ratesList.materials[property].cal_maxdlr !== undefined &&
|
||||
ratesList.materials[property].cal_maxdlr >= 0
|
||||
) {
|
||||
//It has an upper threshhold.
|
||||
threshold = Dinero({
|
||||
@@ -361,7 +373,7 @@ function CalculateRatesTotals(ratesList) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
function CalculatePartsTotals(jobLines) {
|
||||
function CalculatePartsTotals(jobLines, parts_tax_rates) {
|
||||
const jl = jobLines.filter((jl) => !jl.removed);
|
||||
|
||||
const ret = jl.reduce(
|
||||
@@ -486,7 +498,60 @@ function CalculatePartsTotals(jobLines) {
|
||||
}
|
||||
);
|
||||
|
||||
//Apply insurance based parts discuounts/markups.
|
||||
let adjustments = {
|
||||
PAA: Dinero(),
|
||||
PAC: Dinero(),
|
||||
PAG: Dinero(),
|
||||
PAL: Dinero(),
|
||||
PAN: Dinero(),
|
||||
PAO: Dinero(),
|
||||
PAP: Dinero(),
|
||||
PAR: Dinero(),
|
||||
PAS: Dinero(),
|
||||
PAT: Dinero(),
|
||||
};
|
||||
Object.keys(parts_tax_rates).forEach((key) => {
|
||||
//Check if there's a discount or a mark up.
|
||||
let disc = Dinero(),
|
||||
markup = Dinero();
|
||||
if (
|
||||
parts_tax_rates[key].prt_discp !== undefined &&
|
||||
parts_tax_rates[key].prt_discp >= 0
|
||||
) {
|
||||
//Check if there's any parts in this part type.
|
||||
if (ret.parts.list[key] !== undefined) {
|
||||
disc = ret.parts.list[key].total
|
||||
.percentage(parts_tax_rates[key].prt_discp)
|
||||
.multiply(-1);
|
||||
}
|
||||
}
|
||||
if (
|
||||
parts_tax_rates[key].prt_mkupp !== undefined &&
|
||||
parts_tax_rates[key].prt_mkupp >= 0
|
||||
) {
|
||||
//Check if there's any parts in this part type.
|
||||
if (ret.parts.list[key] !== undefined) {
|
||||
markup = ret.parts.list[key].total.percentage(
|
||||
parts_tax_rates[key].prt_mkupp
|
||||
);
|
||||
}
|
||||
}
|
||||
let adjustment = disc.add(markup);
|
||||
adjustments[key] = adjustment;
|
||||
});
|
||||
|
||||
Object.keys(adjustments).forEach((key) => {
|
||||
if (ret.parts.list[key] !== undefined) {
|
||||
ret.parts.list[key].total = ret.parts.list[key].total.add(
|
||||
adjustments[key]
|
||||
);
|
||||
ret.parts.subtotal = ret.parts.subtotal.add(adjustments[key]);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
adjustments,
|
||||
parts: {
|
||||
...ret.parts,
|
||||
total: ret.parts.subtotal,
|
||||
@@ -647,7 +712,7 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
let ret = {
|
||||
subtotal: subtotal,
|
||||
federal_tax: subtotal
|
||||
@@ -735,3 +800,8 @@ function DiscountNotAlreadyCounted(jobline, joblines) {
|
||||
}
|
||||
|
||||
exports.DiscountNotAlreadyCounted = DiscountNotAlreadyCounted;
|
||||
|
||||
function ParseCalopCode(opcode) {
|
||||
if (!opcode) return [];
|
||||
return opcode.trim().split(" ");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user