From 68106d8d93d14fa06f863bf69124da4ed6735a89 Mon Sep 17 00:00:00 2001
From: Patrick Fic <>
Date: Mon, 8 Feb 2021 13:39:50 -0800
Subject: [PATCH] Allow individual locations for bill enter.
---
.../bill-enter-modal.container.jsx | 54 +++++++++++++------
.../bill-form/bill-form.component.jsx | 2 +-
.../bill-form/bill-form.lines.component.jsx | 13 +++++
client/src/graphql/jobs-lines.queries.js | 1 +
4 files changed, 53 insertions(+), 17 deletions(-)
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 2f661e150..6aa8e579c 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
@@ -6,7 +6,10 @@ import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { INSERT_NEW_BILL } from "../../graphql/bills.queries";
-import { UPDATE_JOB_LINE_STATUS } from "../../graphql/jobs-lines.queries";
+import {
+ UPDATE_JOB_LINE,
+ UPDATE_JOB_LINE_STATUS,
+} from "../../graphql/jobs-lines.queries";
import {
QUERY_JOB_LBR_ADJUSTMENTS,
UPDATE_JOB,
@@ -39,7 +42,7 @@ function BillEnterModalContainer({
const { t } = useTranslation();
const [enterAgain, setEnterAgain] = useState(false);
const [insertBill] = useMutation(INSERT_NEW_BILL);
- const [updateJobLines] = useMutation(UPDATE_JOB_LINE_STATUS);
+ const [updateJobLines] = useMutation(UPDATE_JOB_LINE);
const [loading, setLoading] = useState(false);
const client = useApolloClient();
@@ -62,11 +65,13 @@ function BillEnterModalContainer({
data:
remainingValues.billlines &&
remainingValues.billlines.map((i) => {
- const { deductfromlabor, lbr_adjustment, ...restI } = i;
- console.log(
- "🚀 ~ file: bill-enter-modal.container.jsx ~ line 60 ~ remainingValues.billlines.map ~ lbr_adjustment",
- lbr_adjustment
- );
+ const {
+ deductfromlabor,
+ lbr_adjustment,
+ location: lineLocation,
+ ...restI
+ } = i;
+
if (deductfromlabor) {
adjustmentsToInsert[lbr_adjustment.mod_lbr_ty] =
(adjustmentsToInsert[lbr_adjustment.mod_lbr_ty] || 0) -
@@ -131,15 +136,32 @@ function BillEnterModalContainer({
const billId = r1.data.insert_bills.returning[0].id;
- await updateJobLines({
- variables: {
- ids: remainingValues.billlines
- .filter((il) => il.joblineid !== "noline")
- .map((li) => li.joblineid),
- status: bodyshop.md_order_statuses.default_received || "Received*",
- location: location,
- },
- });
+ await Promise.all(
+ remainingValues.billlines
+ .filter((il) => il.joblineid !== "noline")
+ .map((li) => {
+ return updateJobLines({
+ variables: {
+ lineId: li.joblineid,
+ line: {
+ location: li.location || location,
+ status:
+ bodyshop.md_order_statuses.default_received || "Received*",
+ },
+ },
+ });
+ })
+ );
+
+ // await updateJobLines({
+ // variables: {
+ // ids: remainingValues.billlines
+ // .filter((il) => il.joblineid !== "noline")
+ // .map((li) => li.joblineid),
+ // status: bodyshop.md_order_statuses.default_received || "Received*",
+ // location: location,
+ // },
+ // });
/////////////////////////
if (upload && upload.length > 0) {
diff --git a/client/src/components/bill-form/bill-form.component.jsx b/client/src/components/bill-form/bill-form.component.jsx
index 0c6770d8e..794cabd4e 100644
--- a/client/src/components/bill-form/bill-form.component.jsx
+++ b/client/src/components/bill-form/bill-form.component.jsx
@@ -209,7 +209,7 @@ export function BillFormComponent({