Resolve deduct from labor calculations.

This commit is contained in:
Patrick Fic
2023-10-18 09:51:17 -07:00
parent acc9145d52
commit b9a6a98fee
8 changed files with 75 additions and 8 deletions

View File

@@ -40,7 +40,7 @@ export function BillEnterModalLinesComponent({
billid,
}) {
const { t } = useTranslation();
const { setFieldsValue, getFieldsValue, getFieldValue } = form;
const { setFieldsValue, getFieldsValue, getFieldValue, setFieldValue } = form;
const { Simple_Inventory } = useTreatments(
["Simple_Inventory"],
{},
@@ -376,9 +376,43 @@ export function BillEnterModalLinesComponent({
"rate",
]);
const billline = getFieldValue(["billlines", record.name]);
const jobline = lineData.find(
(line) => line.id === billline?.joblineid
);
const employeeTeamName = bodyshop.employee_teams.find(
(team) => team.id === jobline?.assigned_team
);
if (getFieldValue(["billlines", record.name, "deductedfromlbr"]))
return (
<div>
<Space>
{t("joblines.fields.assigned_team", {
name: employeeTeamName?.name,
})}
{`${jobline.mod_lb_hrs} units`}
<Button
onClick={() => {
const applicableRate =
billline.actual_price / jobline.mod_lb_hrs;
setFieldValue(
[
"billlines",
record.name,
"lbr_adjustment",
"rate",
],
applicableRate
);
}}
>
{t("bills.actions.deductallhours")}
</Button>
</Space>
<Form.Item
label={t("joblines.fields.mod_lbr_ty")}
key={`${index}modlbrty`}
@@ -448,9 +482,11 @@ export function BillEnterModalLinesComponent({
>
<InputNumber precision={2} min={0.01} />
</Form.Item>
{price &&
adjustmentRate &&
`${(price / adjustmentRate).toFixed(1)} hrs`}
<Space>
{price &&
adjustmentRate &&
`${(price / adjustmentRate).toFixed(1)} hrs`}
</Space>
</div>
);
return <></>;