Allow individual locations for bill enter.
This commit is contained in:
@@ -6,7 +6,10 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { INSERT_NEW_BILL } from "../../graphql/bills.queries";
|
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 {
|
import {
|
||||||
QUERY_JOB_LBR_ADJUSTMENTS,
|
QUERY_JOB_LBR_ADJUSTMENTS,
|
||||||
UPDATE_JOB,
|
UPDATE_JOB,
|
||||||
@@ -39,7 +42,7 @@ function BillEnterModalContainer({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [enterAgain, setEnterAgain] = useState(false);
|
const [enterAgain, setEnterAgain] = useState(false);
|
||||||
const [insertBill] = useMutation(INSERT_NEW_BILL);
|
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 [loading, setLoading] = useState(false);
|
||||||
const client = useApolloClient();
|
const client = useApolloClient();
|
||||||
|
|
||||||
@@ -62,11 +65,13 @@ function BillEnterModalContainer({
|
|||||||
data:
|
data:
|
||||||
remainingValues.billlines &&
|
remainingValues.billlines &&
|
||||||
remainingValues.billlines.map((i) => {
|
remainingValues.billlines.map((i) => {
|
||||||
const { deductfromlabor, lbr_adjustment, ...restI } = i;
|
const {
|
||||||
console.log(
|
deductfromlabor,
|
||||||
"🚀 ~ file: bill-enter-modal.container.jsx ~ line 60 ~ remainingValues.billlines.map ~ lbr_adjustment",
|
lbr_adjustment,
|
||||||
lbr_adjustment
|
location: lineLocation,
|
||||||
);
|
...restI
|
||||||
|
} = i;
|
||||||
|
|
||||||
if (deductfromlabor) {
|
if (deductfromlabor) {
|
||||||
adjustmentsToInsert[lbr_adjustment.mod_lbr_ty] =
|
adjustmentsToInsert[lbr_adjustment.mod_lbr_ty] =
|
||||||
(adjustmentsToInsert[lbr_adjustment.mod_lbr_ty] || 0) -
|
(adjustmentsToInsert[lbr_adjustment.mod_lbr_ty] || 0) -
|
||||||
@@ -131,15 +136,32 @@ function BillEnterModalContainer({
|
|||||||
|
|
||||||
const billId = r1.data.insert_bills.returning[0].id;
|
const billId = r1.data.insert_bills.returning[0].id;
|
||||||
|
|
||||||
await updateJobLines({
|
await Promise.all(
|
||||||
variables: {
|
remainingValues.billlines
|
||||||
ids: remainingValues.billlines
|
.filter((il) => il.joblineid !== "noline")
|
||||||
.filter((il) => il.joblineid !== "noline")
|
.map((li) => {
|
||||||
.map((li) => li.joblineid),
|
return updateJobLines({
|
||||||
status: bodyshop.md_order_statuses.default_received || "Received*",
|
variables: {
|
||||||
location: location,
|
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) {
|
if (upload && upload.length > 0) {
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ export function BillFormComponent({
|
|||||||
<CurrencyInput min={0} />
|
<CurrencyInput min={0} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label={t("bills.fields.allpartslocation")} name="location">
|
<Form.Item label={t("bills.fields.allpartslocation")} name="location">
|
||||||
<Select style={{ width: "10rem" }} disabled={disabled}>
|
<Select style={{ width: "10rem" }} disabled={disabled} allowClear>
|
||||||
{bodyshop.md_parts_locations.map((loc, idx) => (
|
{bodyshop.md_parts_locations.map((loc, idx) => (
|
||||||
<Select.Option key={idx} value={loc}>
|
<Select.Option key={idx} value={loc}>
|
||||||
{loc}
|
{loc}
|
||||||
|
|||||||
@@ -335,6 +335,19 @@ export function BillEnterModalLinesComponent({
|
|||||||
return <span />;
|
return <span />;
|
||||||
}}
|
}}
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
label={t("billlines.fields.location")}
|
||||||
|
key={`${index}location`}
|
||||||
|
name={[field.name, "location"]}
|
||||||
|
>
|
||||||
|
<Select style={{ width: "10rem" }} disabled={disabled}>
|
||||||
|
{bodyshop.md_parts_locations.map((loc, idx) => (
|
||||||
|
<Select.Option key={idx} value={loc}>
|
||||||
|
{loc}
|
||||||
|
</Select.Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
</LayoutFormRow>
|
</LayoutFormRow>
|
||||||
<FormListMoveArrows
|
<FormListMoveArrows
|
||||||
move={move}
|
move={move}
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ export const UPDATE_JOB_LINE_STATUS = gql`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const INSERT_NEW_JOB_LINE = gql`
|
export const INSERT_NEW_JOB_LINE = gql`
|
||||||
mutation INSERT_NEW_JOB_LINE($lineInput: [joblines_insert_input!]!) {
|
mutation INSERT_NEW_JOB_LINE($lineInput: [joblines_insert_input!]!) {
|
||||||
insert_joblines(objects: $lineInput) {
|
insert_joblines(objects: $lineInput) {
|
||||||
|
|||||||
Reference in New Issue
Block a user