IO-1914 Add manual inventory and edit.
This commit is contained in:
@@ -5736,6 +5736,27 @@
|
||||
<folder_node>
|
||||
<name>inventory</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>delete</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>
|
||||
<name>list</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -17371,6 +17392,48 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>edit</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>
|
||||
<name>new</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>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
@@ -17399,6 +17462,74 @@
|
||||
</concept_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
<name>fields</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>comment</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>
|
||||
<name>manualinvoicenumber</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>
|
||||
<name>manualvendor</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>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
<name>labels</name>
|
||||
<children>
|
||||
@@ -17423,6 +17554,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>deleteconfirm</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>
|
||||
<name>frombillinvoicenumber</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -17533,6 +17685,27 @@
|
||||
<folder_node>
|
||||
<name>successes</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>deleted</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>
|
||||
<name>inserted</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -17554,6 +17727,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>updated</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>
|
||||
</children>
|
||||
</folder_node>
|
||||
</children>
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import { DeleteFilled } from "@ant-design/icons";
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { Button, notification, Popconfirm } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DELETE_INVENTORY_LINE } from "../../graphql/inventory.queries";
|
||||
import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component";
|
||||
|
||||
export default function InventoryLineDelete({
|
||||
inventoryline,
|
||||
disabled,
|
||||
refetch,
|
||||
}) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
const [deleteInventoryLine] = useMutation(DELETE_INVENTORY_LINE);
|
||||
|
||||
const handleDelete = async () => {
|
||||
setLoading(true);
|
||||
const result = await deleteInventoryLine({
|
||||
variables: { lineId: inventoryline.id },
|
||||
// update(cache, { errors }) {
|
||||
// cache.modify({
|
||||
// fields: {
|
||||
// inventory(existingInventory, { readField }) {
|
||||
// console.log(existingInventory);
|
||||
// return existingInventory.filter(
|
||||
// (invRef) => inventoryline.id !== readField("id", invRef)
|
||||
// );
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// },
|
||||
});
|
||||
|
||||
if (!!!result.errors) {
|
||||
notification["success"]({ message: t("inventory.successes.deleted") });
|
||||
} else {
|
||||
//Check if it's an fkey violation.
|
||||
|
||||
notification["error"]({
|
||||
message: t("bills.errors.deleting", {
|
||||
error: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
}
|
||||
if (refetch) refetch();
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<RbacWrapper action="inventory:delete" noauth={<></>}>
|
||||
<Popconfirm
|
||||
disabled={disabled || inventoryline.consumedbybillid}
|
||||
onConfirm={handleDelete}
|
||||
title={t("inventory.labels.deleteconfirm")}
|
||||
>
|
||||
<Button
|
||||
disabled={disabled || inventoryline.consumedbybillid}
|
||||
loading={loading}
|
||||
>
|
||||
<DeleteFilled />
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</RbacWrapper>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SyncOutlined } from "@ant-design/icons";
|
||||
import { EditFilled, SyncOutlined, FileAddFilled } from "@ant-design/icons";
|
||||
import { Button, Card, Input, Space, Table, Typography } from "antd";
|
||||
import queryString from "query-string";
|
||||
import React from "react";
|
||||
@@ -6,18 +6,28 @@ import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { Link, useHistory, useLocation } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
||||
import InventoryBillRo from "../inventory-bill-ro/inventory-bill-ro.component";
|
||||
import InventoryLineDelete from "../inventory-line-delete/inventory-line-delete.component";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
setInventoryUpsertContext: (context) =>
|
||||
dispatch(setModalContext({ context: context, modal: "inventoryUpsert" })),
|
||||
});
|
||||
|
||||
export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
||||
export function JobsList({
|
||||
bodyshop,
|
||||
refetch,
|
||||
loading,
|
||||
jobs,
|
||||
total,
|
||||
setInventoryUpsertContext,
|
||||
}) {
|
||||
const search = queryString.parse(useLocation().search);
|
||||
const { page, sortcolumn, sortorder } = search;
|
||||
const history = useHistory();
|
||||
@@ -31,6 +41,15 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
||||
|
||||
sorter: true, //(a, b) => alphaSort(a.line_desc, b.line_desc),
|
||||
sortOrder: sortcolumn === "line_desc" && sortorder,
|
||||
render: (text, record) =>
|
||||
record.billline?.bill?.job ? (
|
||||
<div>
|
||||
<div>{text}</div>
|
||||
<strong>{`(${record.billline?.bill?.job?.v_model_yr} ${record.billline?.bill?.job?.v_make_desc} ${record.billline?.bill?.job?.v_model_desc})`}</strong>
|
||||
</div>
|
||||
) : (
|
||||
text
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("inventory.labels.frombillinvoicenumber"),
|
||||
@@ -40,7 +59,12 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
||||
//sorter: true, // (a, b) => alphaSort(a.ownr_ln, b.ownr_ln),
|
||||
|
||||
//sortOrder: sortcolumn === "ownr_ln" && sortorder,
|
||||
render: (text, record) => record.billline?.bill?.invoice_number,
|
||||
render: (text, record) =>
|
||||
(
|
||||
(record.billline?.bill?.invoice_number || "") +
|
||||
" " +
|
||||
(record.manualinvoicenumber || "")
|
||||
).trim(),
|
||||
},
|
||||
{
|
||||
title: t("inventory.labels.fromvendor"),
|
||||
@@ -50,7 +74,12 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
||||
//sorter: true, // (a, b) => alphaSort(a.ownr_ln, b.ownr_ln),
|
||||
|
||||
//sortOrder: sortcolumn === "ownr_ln" && sortorder,
|
||||
render: (text, record) => record.billline?.bill?.vendor?.name,
|
||||
render: (text, record) =>
|
||||
(
|
||||
(record.billline?.bill?.vendor?.name || "") +
|
||||
" " +
|
||||
(record.manualvendor || "")
|
||||
).trim(),
|
||||
},
|
||||
{
|
||||
title: t("billlines.fields.actual_price"),
|
||||
@@ -70,6 +99,11 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
||||
<CurrencyFormatter>{record.actual_cost}</CurrencyFormatter>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("inventory.fields.comment"),
|
||||
dataIndex: "comment",
|
||||
key: "comment",
|
||||
},
|
||||
{
|
||||
title: t("inventory.labels.consumedbyjob"),
|
||||
dataIndex: "consumedbyjob",
|
||||
@@ -85,6 +119,30 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
||||
<InventoryBillRo inventoryline={record} />
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("general.labels.actions"),
|
||||
dataIndex: "actions",
|
||||
key: "actions",
|
||||
|
||||
ellipsis: true,
|
||||
render: (text, record) => (
|
||||
<Space wrap>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setInventoryUpsertContext({
|
||||
actions: { refetch: refetch },
|
||||
context: {
|
||||
existingInventory: record,
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
<EditFilled />
|
||||
</Button>
|
||||
<InventoryLineDelete inventoryline={record} refetch={refetch} />
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
const handleTableChange = (pagination, filters, sorter) => {
|
||||
@@ -113,7 +171,16 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Button
|
||||
onClick={() => {
|
||||
setInventoryUpsertContext({
|
||||
actions: { refetch: refetch },
|
||||
context: {},
|
||||
});
|
||||
}}
|
||||
>
|
||||
<FileAddFilled />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
if (search.showall) delete search.showall;
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
} from "../../redux/application/application.actions";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import InventoryListPaginated from "./inventory-list.component";
|
||||
import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//bodyshop: selectBodyshop,
|
||||
@@ -52,15 +51,13 @@ export function InventoryList({ setBreadcrumbs, setSelectedHeader }) {
|
||||
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
return (
|
||||
<RbacWrapper action="jobs:list-all">
|
||||
<InventoryListPaginated
|
||||
refetch={refetch}
|
||||
loading={loading}
|
||||
searchParams={searchParams}
|
||||
total={data ? data.search_inventory_aggregate.aggregate.count : 0}
|
||||
jobs={data ? data.search_inventory : []}
|
||||
/>
|
||||
</RbacWrapper>
|
||||
<InventoryListPaginated
|
||||
refetch={refetch}
|
||||
loading={loading}
|
||||
searchParams={searchParams}
|
||||
total={data ? data.search_inventory_aggregate.aggregate.count : 0}
|
||||
jobs={data ? data.search_inventory : []}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { Form, Input, Space } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectInventoryUpsert } from "../../redux/modals/modals.selectors";
|
||||
import FormItemCurrency from "../form-items-formatted/currency-form-item.component";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
inventoryUpsertModal: selectInventoryUpsert,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(NoteUpsertModalComponent);
|
||||
|
||||
export function NoteUpsertModalComponent({ form, inventoryUpsertModal }) {
|
||||
const { t } = useTranslation();
|
||||
const { existingInventory } = inventoryUpsertModal.context;
|
||||
|
||||
return (
|
||||
<Space wrap>
|
||||
<Form.Item
|
||||
label={t("billlines.fields.line_desc")}
|
||||
rules={[{ required: true }]}
|
||||
name="line_desc"
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item label={t("inventory.fields.comment")} name="comment">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
|
||||
{!existingInventory && (
|
||||
<>
|
||||
<Form.Item
|
||||
label={t("inventory.fields.manualinvoicenumber")}
|
||||
name="manualinvoicenumber"
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("inventory.fields.manualvendor")}
|
||||
name="manualvendor"
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
rules={[{ required: true }]}
|
||||
label={t("billlines.fields.actual_cost")}
|
||||
name="actual_cost"
|
||||
>
|
||||
<FormItemCurrency />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
rules={[{ required: true }]}
|
||||
label={t("billlines.fields.actual_price")}
|
||||
name="actual_price"
|
||||
>
|
||||
<FormItemCurrency />
|
||||
</Form.Item>
|
||||
</>
|
||||
)}
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { Form, Modal, notification } from "antd";
|
||||
import React, { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import {
|
||||
INSERT_INVENTORY_LINE,
|
||||
UPDATE_INVENTORY_LINE,
|
||||
} from "../../graphql/inventory.queries";
|
||||
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
||||
import { selectInventoryUpsert } from "../../redux/modals/modals.selectors";
|
||||
import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import InventoryUpsertModal from "./inventory-upsert-modal.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
currentUser: selectCurrentUser,
|
||||
inventoryUpsertModal: selectInventoryUpsert,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
toggleModalVisible: () => dispatch(toggleModalVisible("inventoryUpsert")),
|
||||
});
|
||||
|
||||
export function InventoryUpsertModalContainer({
|
||||
currentUser,
|
||||
bodyshop,
|
||||
inventoryUpsertModal,
|
||||
toggleModalVisible,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [insertInventory] = useMutation(INSERT_INVENTORY_LINE);
|
||||
const [updateInventoryLine] = useMutation(UPDATE_INVENTORY_LINE);
|
||||
|
||||
const { visible, context, actions } = inventoryUpsertModal;
|
||||
const { existingInventory } = context;
|
||||
const { refetch } = actions;
|
||||
|
||||
const [form] = Form.useForm();
|
||||
|
||||
useEffect(() => {
|
||||
//Required to prevent infinite looping.
|
||||
if (existingInventory && visible) {
|
||||
form.setFieldsValue(existingInventory);
|
||||
} else if (!existingInventory && visible) {
|
||||
form.resetFields();
|
||||
}
|
||||
}, [existingInventory, form, visible]);
|
||||
|
||||
const handleFinish = async (formValues) => {
|
||||
const values = formValues;
|
||||
|
||||
if (existingInventory) {
|
||||
logImEXEvent("inventory_update");
|
||||
|
||||
updateInventoryLine({
|
||||
variables: {
|
||||
inventoryId: existingInventory.id,
|
||||
inventoryItem: values,
|
||||
},
|
||||
}).then((r) => {
|
||||
notification["success"]({
|
||||
message: t("inventory.successes.updated"),
|
||||
});
|
||||
});
|
||||
// if (refetch) refetch();
|
||||
toggleModalVisible();
|
||||
} else {
|
||||
logImEXEvent("inventory_insert");
|
||||
|
||||
await insertInventory({
|
||||
variables: {
|
||||
inventoryItem: { shopid: bodyshop.id, ...values },
|
||||
},
|
||||
update(cache, { data }) {
|
||||
cache.modify({
|
||||
fields: {
|
||||
inventory(existingInv) {
|
||||
return [...existingInv, data.insert_inventory_one];
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
if (refetch) refetch();
|
||||
form.resetFields();
|
||||
toggleModalVisible();
|
||||
notification["success"]({
|
||||
message: t("inventory.successes.inserted"),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={
|
||||
existingInventory
|
||||
? t("inventory.actions.edit")
|
||||
: t("inventory.actions.new")
|
||||
}
|
||||
visible={visible}
|
||||
okText={t("general.actions.save")}
|
||||
onOk={() => {
|
||||
form.submit();
|
||||
}}
|
||||
onCancel={() => {
|
||||
toggleModalVisible();
|
||||
}}
|
||||
destroyOnClose
|
||||
>
|
||||
<Form form={form} onFinish={handleFinish} layout="vertical">
|
||||
<InventoryUpsertModal form={form} />
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(InventoryUpsertModalContainer);
|
||||
@@ -68,5 +68,6 @@ const ret = {
|
||||
"users:editaccess": 4,
|
||||
|
||||
"inventory:list": 1,
|
||||
"inventory:delete": 2,
|
||||
};
|
||||
export default ret;
|
||||
|
||||
@@ -3,9 +3,28 @@ import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||
import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component";
|
||||
export default function ShopInfoRbacComponent({ form }) {
|
||||
const { t } = useTranslation();
|
||||
import { useTreatments } from "@splitsoftware/splitio-react";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(ShopInfoRbacComponent);
|
||||
|
||||
export function ShopInfoRbacComponent({ form, bodyshop }) {
|
||||
const { t } = useTranslation();
|
||||
const { Simple_Inventory } = useTreatments(
|
||||
["Simple_Inventory"],
|
||||
{},
|
||||
bodyshop && bodyshop.imexshopid
|
||||
);
|
||||
return (
|
||||
<RbacWrapper action="shop:rbac">
|
||||
<LayoutFormRow>
|
||||
@@ -633,18 +652,34 @@ export default function ShopInfoRbacComponent({ form }) {
|
||||
>
|
||||
<InputNumber />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.rbac.inventory.list")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
//message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_rbac", "inventory:list"]}
|
||||
>
|
||||
<InputNumber />
|
||||
</Form.Item>
|
||||
{Simple_Inventory.treatment === "on" && (
|
||||
<>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.rbac.inventory.list")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
//message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_rbac", "inventory:list"]}
|
||||
>
|
||||
<InputNumber />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.rbac.inventory.delete")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
//message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_rbac", "inventory:delete"]}
|
||||
>
|
||||
<InputNumber />
|
||||
</Form.Item>
|
||||
</>
|
||||
)}
|
||||
</LayoutFormRow>
|
||||
</RbacWrapper>
|
||||
);
|
||||
|
||||
@@ -52,6 +52,10 @@ export const QUERY_OUTSTANDING_INVENTORY = gql`
|
||||
quantity
|
||||
billlineid
|
||||
line_desc
|
||||
comment
|
||||
manualinvoicenumber
|
||||
manualvendor
|
||||
consumedbybillid
|
||||
billline {
|
||||
bill {
|
||||
invoice_number
|
||||
@@ -83,6 +87,10 @@ export const QUERY_INVENTORY_PAGINATED = gql`
|
||||
line_desc
|
||||
actual_price
|
||||
actual_cost
|
||||
comment
|
||||
manualinvoicenumber
|
||||
manualvendor
|
||||
consumedbybillid
|
||||
bill {
|
||||
id
|
||||
invoice_number
|
||||
@@ -96,6 +104,12 @@ export const QUERY_INVENTORY_PAGINATED = gql`
|
||||
bill {
|
||||
id
|
||||
invoice_number
|
||||
job {
|
||||
id
|
||||
v_make_desc
|
||||
v_model_desc
|
||||
v_model_yr
|
||||
}
|
||||
vendor {
|
||||
id
|
||||
name
|
||||
@@ -113,3 +127,55 @@ export const QUERY_INVENTORY_PAGINATED = gql`
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const DELETE_INVENTORY_LINE = gql`
|
||||
mutation DELETE_INVENTORY_LINE($lineId: uuid!) {
|
||||
delete_inventory_by_pk(id: $lineId) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const INSERT_INVENTORY_LINE = gql`
|
||||
mutation INSERT_INVENTORY_LINE($inventoryItem: inventory_insert_input!) {
|
||||
insert_inventory_one(object: $inventoryItem) {
|
||||
id
|
||||
line_desc
|
||||
consumedbybillid
|
||||
billlineid
|
||||
actual_price
|
||||
actual_cost
|
||||
comment
|
||||
manualinvoicenumber
|
||||
manualvendor
|
||||
bill {
|
||||
invoice_number
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const UPDATE_INVENTORY_LINE = gql`
|
||||
mutation UPDATE_INVENTORY_LINE(
|
||||
$inventoryId: uuid!
|
||||
$inventoryItem: inventory_set_input!
|
||||
) {
|
||||
update_inventory_by_pk(
|
||||
pk_columns: { id: $inventoryId }
|
||||
_set: $inventoryItem
|
||||
) {
|
||||
id
|
||||
line_desc
|
||||
consumedbybillid
|
||||
billlineid
|
||||
actual_price
|
||||
actual_cost
|
||||
comment
|
||||
manualinvoicenumber
|
||||
manualvendor
|
||||
bill {
|
||||
invoice_number
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
setSelectedHeader,
|
||||
} from "../../redux/application/application.actions";
|
||||
import InventoryList from "../../components/inventory-list/inventory-list.container";
|
||||
import InventoryUpsertModalContainer from "../../components/inventory-upsert-modal/inventory-upsert-modal.container";
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
||||
@@ -24,6 +25,7 @@ export function InventoryPage({ setBreadcrumbs, setSelectedHeader }) {
|
||||
|
||||
return (
|
||||
<RbacWrapper action="inventory:list">
|
||||
<InventoryUpsertModalContainer />
|
||||
<InventoryList />
|
||||
</RbacWrapper>
|
||||
);
|
||||
|
||||
@@ -23,6 +23,7 @@ const INITIAL_STATE = {
|
||||
reportCenter: { ...baseModal },
|
||||
partsReceive: { ...baseModal },
|
||||
contractFinder: { ...baseModal },
|
||||
inventoryUpsert: { ...baseModal },
|
||||
ca_bc_eftTableConvert: { ...baseModal },
|
||||
};
|
||||
|
||||
|
||||
@@ -70,6 +70,10 @@ export const selectContractFinder = createSelector(
|
||||
[selectModals],
|
||||
(modals) => modals.contractFinder
|
||||
);
|
||||
export const selectInventoryUpsert = createSelector(
|
||||
[selectModals],
|
||||
(modals) => modals.inventoryUpsert
|
||||
);
|
||||
|
||||
export const selectCaBcEtfTableConvert = createSelector(
|
||||
[selectModals],
|
||||
|
||||
@@ -355,6 +355,7 @@
|
||||
"page": "Employees -> List"
|
||||
},
|
||||
"inventory": {
|
||||
"delete": "Inventory -> Delete",
|
||||
"list": "Inventory -> List"
|
||||
},
|
||||
"jobs": {
|
||||
@@ -1079,13 +1080,21 @@
|
||||
"actions": {
|
||||
"addtoinventory": "Add to Inventory",
|
||||
"addtoro": "Add to RO",
|
||||
"consumefrominventory": "Consume from Inventory?"
|
||||
"consumefrominventory": "Consume from Inventory?",
|
||||
"edit": "Edit Inventory LIne",
|
||||
"new": "New Inventory Line"
|
||||
},
|
||||
"errors": {
|
||||
"inserting": "Error inserting inventory item. {{error}}"
|
||||
},
|
||||
"fields": {
|
||||
"comment": "Comment",
|
||||
"manualinvoicenumber": "Invoice Number",
|
||||
"manualvendor": "Vendor"
|
||||
},
|
||||
"labels": {
|
||||
"consumedbyjob": "Consumed by Job",
|
||||
"deleteconfirm": "Are you sure you want to delete this from inventory? The associated bill will not be modified or deleted. ",
|
||||
"frombillinvoicenumber": "Original Bill Invoice Number",
|
||||
"fromvendor": "Original Bill Vendor",
|
||||
"inventory": "Inventory",
|
||||
@@ -1093,7 +1102,9 @@
|
||||
"showavailable": "Show Only Available Inventory"
|
||||
},
|
||||
"successes": {
|
||||
"inserted": "Added line to inventory."
|
||||
"deleted": "Inventory lined deleted.",
|
||||
"inserted": "Added line to inventory.",
|
||||
"updated": "Inventory line updated."
|
||||
}
|
||||
},
|
||||
"joblines": {
|
||||
|
||||
@@ -355,6 +355,7 @@
|
||||
"page": ""
|
||||
},
|
||||
"inventory": {
|
||||
"delete": "",
|
||||
"list": ""
|
||||
},
|
||||
"jobs": {
|
||||
@@ -1079,13 +1080,21 @@
|
||||
"actions": {
|
||||
"addtoinventory": "",
|
||||
"addtoro": "",
|
||||
"consumefrominventory": ""
|
||||
"consumefrominventory": "",
|
||||
"edit": "",
|
||||
"new": ""
|
||||
},
|
||||
"errors": {
|
||||
"inserting": ""
|
||||
},
|
||||
"fields": {
|
||||
"comment": "",
|
||||
"manualinvoicenumber": "",
|
||||
"manualvendor": ""
|
||||
},
|
||||
"labels": {
|
||||
"consumedbyjob": "",
|
||||
"deleteconfirm": "",
|
||||
"frombillinvoicenumber": "",
|
||||
"fromvendor": "",
|
||||
"inventory": "",
|
||||
@@ -1093,7 +1102,9 @@
|
||||
"showavailable": ""
|
||||
},
|
||||
"successes": {
|
||||
"inserted": ""
|
||||
"deleted": "",
|
||||
"inserted": "",
|
||||
"updated": ""
|
||||
}
|
||||
},
|
||||
"joblines": {
|
||||
|
||||
@@ -355,6 +355,7 @@
|
||||
"page": ""
|
||||
},
|
||||
"inventory": {
|
||||
"delete": "",
|
||||
"list": ""
|
||||
},
|
||||
"jobs": {
|
||||
@@ -1079,13 +1080,21 @@
|
||||
"actions": {
|
||||
"addtoinventory": "",
|
||||
"addtoro": "",
|
||||
"consumefrominventory": ""
|
||||
"consumefrominventory": "",
|
||||
"edit": "",
|
||||
"new": ""
|
||||
},
|
||||
"errors": {
|
||||
"inserting": ""
|
||||
},
|
||||
"fields": {
|
||||
"comment": "",
|
||||
"manualinvoicenumber": "",
|
||||
"manualvendor": ""
|
||||
},
|
||||
"labels": {
|
||||
"consumedbyjob": "",
|
||||
"deleteconfirm": "",
|
||||
"frombillinvoicenumber": "",
|
||||
"fromvendor": "",
|
||||
"inventory": "",
|
||||
@@ -1093,7 +1102,9 @@
|
||||
"showavailable": ""
|
||||
},
|
||||
"successes": {
|
||||
"inserted": ""
|
||||
"deleted": "",
|
||||
"inserted": "",
|
||||
"updated": ""
|
||||
}
|
||||
},
|
||||
"joblines": {
|
||||
|
||||
@@ -2166,11 +2166,14 @@
|
||||
- actual_cost
|
||||
- actual_price
|
||||
- billlineid
|
||||
- comment
|
||||
- consumedbybillid
|
||||
- created_at
|
||||
- id
|
||||
- joblineid
|
||||
- line_desc
|
||||
- manualinvoicenumber
|
||||
- manualvendor
|
||||
- quantity
|
||||
- shopid
|
||||
- updated_at
|
||||
@@ -2182,11 +2185,14 @@
|
||||
- actual_cost
|
||||
- actual_price
|
||||
- billlineid
|
||||
- comment
|
||||
- consumedbybillid
|
||||
- created_at
|
||||
- id
|
||||
- joblineid
|
||||
- line_desc
|
||||
- manualinvoicenumber
|
||||
- manualvendor
|
||||
- quantity
|
||||
- shopid
|
||||
- updated_at
|
||||
@@ -2207,11 +2213,14 @@
|
||||
- actual_cost
|
||||
- actual_price
|
||||
- billlineid
|
||||
- comment
|
||||
- consumedbybillid
|
||||
- created_at
|
||||
- id
|
||||
- joblineid
|
||||
- line_desc
|
||||
- manualinvoicenumber
|
||||
- manualvendor
|
||||
- quantity
|
||||
- shopid
|
||||
- updated_at
|
||||
@@ -2225,6 +2234,18 @@
|
||||
- active:
|
||||
_eq: true
|
||||
check: null
|
||||
delete_permissions:
|
||||
- role: user
|
||||
permission:
|
||||
filter:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
- table:
|
||||
schema: public
|
||||
name: ioevents
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- alter table "public"."inventory" add column "manualinvoicenumber" text
|
||||
-- null;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."inventory" add column "manualinvoicenumber" text
|
||||
null;
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- alter table "public"."inventory" add column "comment" text
|
||||
-- null;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."inventory" add column "comment" text
|
||||
null;
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- alter table "public"."inventory" add column "manualvendor" text
|
||||
-- null;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."inventory" add column "manualvendor" text
|
||||
null;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE "public"."inventory" ALTER COLUMN "quantity" drop default;
|
||||
@@ -0,0 +1 @@
|
||||
alter table "public"."inventory" alter column "quantity" set default '1';
|
||||
Reference in New Issue
Block a user