Improve labor deduction for enhanced payroll.

This commit is contained in:
Patrick Fic
2023-10-18 17:28:48 -07:00
parent b9a6a98fee
commit e05b72615e
6 changed files with 95 additions and 54 deletions

View File

@@ -1,4 +1,4 @@
<babeledit_project version="1.2" be_version="2.7.1"> <babeledit_project be_version="2.7.1" version="1.2">
<!-- <!--
BabelEdit project file BabelEdit project file
@@ -2250,6 +2250,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>mod_lbr_adjustment</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> <concept_node>
<name>other</name> <name>other</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>

View File

@@ -29,6 +29,7 @@ import BillFormContainer from "../bill-form/bill-form.container";
import { CalculateBillTotal } from "../bill-form/bill-form.totals.utility"; import { CalculateBillTotal } from "../bill-form/bill-form.totals.utility";
import { handleUpload as handleLocalUpload } from "../documents-local-upload/documents-local-upload.utility"; import { handleUpload as handleLocalUpload } from "../documents-local-upload/documents-local-upload.utility";
import { handleUpload } from "../documents-upload/documents-upload.utility"; import { handleUpload } from "../documents-upload/documents-upload.utility";
import { useTreatments } from "@splitsoftware/splitio-react";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
billEnterModal: selectBillEnterModal, billEnterModal: selectBillEnterModal,
@@ -63,6 +64,11 @@ function BillEnterModalContainer({
"enter_bill_generate_label", "enter_bill_generate_label",
false false
); );
const { Enhanced_Payroll } = useTreatments(
["Enhanced_Payroll"],
{},
bodyshop.imexshopid
);
const formValues = useMemo(() => { const formValues = useMemo(() => {
return { return {
...billEnterModal.context.bill, ...billEnterModal.context.bill,
@@ -117,27 +123,26 @@ function BillEnterModalContainer({
...restI ...restI
} = i; } = i;
if (deductedfromlbr) { if (Enhanced_Payroll.treatment === "on") {
adjustmentsToInsert[lbr_adjustment.mod_lbr_ty] = if (
(adjustmentsToInsert[lbr_adjustment.mod_lbr_ty] || 0) - deductedfromlbr &&
restI.actual_price / lbr_adjustment.rate; true //payroll is on
} ) {
payrollAdjustmentsToInsert.push({
//If deduct from labor has lines, id: i.joblineid,
// convertedtolbr: true,
if ( convertedtolbr_data: {
deductedfromlbr && mod_lb_hrs: lbr_adjustment.mod_lb_hrs * -1,
true //payroll is on mod_lbr_ty: lbr_adjustment.mod_lbr_ty,
) { },
payrollAdjustmentsToInsert.push({ });
id: i.joblineid, }
convertedtolbr: true, } else {
convertedtolbr_data: { if (deductedfromlbr) {
mod_lb_hrs: adjustmentsToInsert[lbr_adjustment.mod_lbr_ty] =
(restI.actual_price / lbr_adjustment.rate) * -1, (adjustmentsToInsert[lbr_adjustment.mod_lbr_ty] || 0) -
mod_lbr_ty: lbr_adjustment.mod_lbr_ty, restI.actual_price / lbr_adjustment.rate;
}, }
});
} }
return { return {

View File

@@ -46,6 +46,13 @@ export function BillEnterModalLinesComponent({
{}, {},
bodyshop && bodyshop.imexshopid bodyshop && bodyshop.imexshopid
); );
const { Enhanced_Payroll } = useTreatments(
["Enhanced_Payroll"],
{},
bodyshop.imexshopid
);
const columns = (remove) => { const columns = (remove) => {
return [ return [
{ {
@@ -393,29 +400,14 @@ export function BillEnterModalLinesComponent({
{t("joblines.fields.assigned_team", { {t("joblines.fields.assigned_team", {
name: employeeTeamName?.name, name: employeeTeamName?.name,
})} })}
{`${jobline.mod_lb_hrs} units`} {`${jobline.mod_lb_hrs} units/${t(
<Button `joblines.fields.lbr_types.${jobline.mod_lbr_ty}`
onClick={() => { )}`}
const applicableRate =
billline.actual_price / jobline.mod_lb_hrs;
setFieldValue(
[
"billlines",
record.name,
"lbr_adjustment",
"rate",
],
applicableRate
);
}}
>
{t("bills.actions.deductallhours")}
</Button>
</Space> </Space>
<Form.Item <Form.Item
label={t("joblines.fields.mod_lbr_ty")} label={t("joblines.fields.mod_lbr_ty")}
key={`${index}modlbrty`} key={`${index}modlbrty`}
initialValue={jobline ? jobline.mod_lbr_ty : null}
rules={[ rules={[
{ {
required: true, required: true,
@@ -469,19 +461,39 @@ export function BillEnterModalLinesComponent({
</Select.Option> </Select.Option>
</Select> </Select>
</Form.Item> </Form.Item>
<Form.Item {Enhanced_Payroll.treatment === "on" ? (
label={t("jobs.labels.adjustmentrate")} <Form.Item
name={[record.name, "lbr_adjustment", "rate"]} label={t("billlines.labels.mod_lbr_adjustment")}
initialValue={bodyshop.default_adjustment_rate} name={[record.name, "lbr_adjustment", "mod_lb_hrs"]}
rules={[ rules={[
{ {
required: true, required: true,
//message: t("general.validation.required"), //message: t("general.validation.required"),
}, },
]} ]}
> >
<InputNumber precision={2} min={0.01} /> <InputNumber
</Form.Item> precision={5}
min={0.01}
max={jobline ? jobline.mod_lb_hrs : 0}
/>
</Form.Item>
) : (
<Form.Item
label={t("jobs.labels.adjustmentrate")}
name={[record.name, "lbr_adjustment", "rate"]}
initialValue={bodyshop.default_adjustment_rate}
rules={[
{
required: true,
//message: t("general.validation.required"),
},
]}
>
<InputNumber precision={2} min={0.01} />
</Form.Item>
)}
<Space> <Space>
{price && {price &&
adjustmentRate && adjustmentRate &&

View File

@@ -145,6 +145,7 @@
"deductedfromlbr": "Deduct from Labor?", "deductedfromlbr": "Deduct from Labor?",
"entered": "Entered", "entered": "Entered",
"from": "From", "from": "From",
"mod_lbr_adjustment": "Adjustment Units",
"other": "-- Not On Estimate --", "other": "-- Not On Estimate --",
"reconciled": "Reconciled!", "reconciled": "Reconciled!",
"unreconciled": "Unreconciled" "unreconciled": "Unreconciled"

View File

@@ -145,6 +145,7 @@
"deductedfromlbr": "", "deductedfromlbr": "",
"entered": "", "entered": "",
"from": "", "from": "",
"mod_lbr_adjustment": "",
"other": "", "other": "",
"reconciled": "", "reconciled": "",
"unreconciled": "" "unreconciled": ""

View File

@@ -145,6 +145,7 @@
"deductedfromlbr": "", "deductedfromlbr": "",
"entered": "", "entered": "",
"from": "", "from": "",
"mod_lbr_adjustment": "",
"other": "", "other": "",
"reconciled": "", "reconciled": "",
"unreconciled": "" "unreconciled": ""