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 { 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) {
|
||||
|
||||
@@ -209,7 +209,7 @@ export function BillFormComponent({
|
||||
<CurrencyInput min={0} />
|
||||
</Form.Item>
|
||||
<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) => (
|
||||
<Select.Option key={idx} value={loc}>
|
||||
{loc}
|
||||
|
||||
@@ -335,6 +335,19 @@ export function BillEnterModalLinesComponent({
|
||||
return <span />;
|
||||
}}
|
||||
</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>
|
||||
<FormListMoveArrows
|
||||
move={move}
|
||||
|
||||
@@ -99,6 +99,7 @@ export const UPDATE_JOB_LINE_STATUS = gql`
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const INSERT_NEW_JOB_LINE = gql`
|
||||
mutation INSERT_NEW_JOB_LINE($lineInput: [joblines_insert_input!]!) {
|
||||
insert_joblines(objects: $lineInput) {
|
||||
|
||||
Reference in New Issue
Block a user