From acc9145d5296cd841f1b8190c9d287899b125e75 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Tue, 17 Oct 2023 10:45:16 -0700 Subject: [PATCH 1/3] Enhanced payroll deduct from labor correction. --- .../bill-enter-modal.container.jsx | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx b/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx index 9cad08f90..23a2e9c7f 100644 --- a/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx +++ b/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx @@ -98,6 +98,7 @@ function BillEnterModalContainer({ } = values; let adjustmentsToInsert = {}; + let payrollAdjustmentsToInsert = []; const r1 = await insertBill({ variables: { @@ -121,6 +122,24 @@ function BillEnterModalContainer({ (adjustmentsToInsert[lbr_adjustment.mod_lbr_ty] || 0) - restI.actual_price / lbr_adjustment.rate; } + + //If deduct from labor has lines, + // + if ( + deductedfromlbr && + true //payroll is on + ) { + payrollAdjustmentsToInsert.push({ + id: i.joblineid, + convertedtolbr: true, + convertedtolbr_data: { + mod_lb_hrs: + (restI.actual_price / lbr_adjustment.rate) * -1, + mod_lbr_ty: lbr_adjustment.mod_lbr_ty, + }, + }); + } + return { ...restI, deductedfromlbr: deductedfromlbr, @@ -146,6 +165,20 @@ function BillEnterModalContainer({ refetchQueries: ["QUERY_PARTS_BILLS_BY_JOBID"], }); + await Promise.all( + payrollAdjustmentsToInsert.map((li) => { + return updateJobLines({ + variables: { + lineId: li.id, + line: { + convertedtolbr: li.convertedtolbr, + convertedtolbr_data: li.convertedtolbr_data, + }, + }, + }); + }) + ); + const adjKeys = Object.keys(adjustmentsToInsert); if (adjKeys.length > 0) { //Query the adjustments, merge, and update them. From b9a6a98feef032c931a2a8f568a50b42e4f742a9 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 18 Oct 2023 09:51:17 -0700 Subject: [PATCH 2/3] Resolve deduct from labor calculations. --- bodyshop_translations.babel | 23 +++++++++- .../bill-form/bill-form.lines.component.jsx | 44 +++++++++++++++++-- .../bill-line-search-select.component.jsx | 6 +++ ...or-allocations-table.payroll.component.jsx | 2 +- client/src/graphql/jobs-lines.queries.js | 1 + client/src/translations/en_us/common.json | 5 ++- client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + 8 files changed, 75 insertions(+), 8 deletions(-) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 6d11973f7..a688deb45 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -1,4 +1,4 @@ - +