IO-1914 Consume from inventory screen.

This commit is contained in:
Patrick Fic
2022-06-07 12:14:24 -07:00
parent fe5e2a247a
commit d32fd9e697
8 changed files with 115 additions and 5 deletions

View File

@@ -17287,6 +17287,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>addtoro</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>consumefrominventory</name>
<definition_loaded>false</definition_loaded>

View File

@@ -7,9 +7,11 @@ import "./bill-inventory-table.styles.scss";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { selectBillEnterModal } from "../../redux/modals/modals.selectors";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
billEnterModal: selectBillEnterModal,
});
const mapDispatchToProps = (dispatch) => ({
//setUserLanguage: language => dispatch(setUserLanguage(language))
@@ -17,6 +19,7 @@ const mapDispatchToProps = (dispatch) => ({
export default connect(mapStateToProps, mapDispatchToProps)(BillInventoryTable);
export function BillInventoryTable({
billEnterModal,
bodyshop,
form,
billEdit,
@@ -28,11 +31,18 @@ export function BillInventoryTable({
useEffect(() => {
if (inventoryData) {
form.setFieldsValue({
inventory: inventoryData.inventory,
inventory: billEnterModal.context.consumeinventoryid
? inventoryData.inventory.map((i) => {
if (i.id === billEnterModal.context.consumeinventoryid)
i.consumefrominventory = true;
return i;
})
: inventoryData.inventory,
});
}
}, [inventoryData, form]);
}, [inventoryData, form, billEnterModal.context.consumeinventoryid]);
console.log(form.getFieldsValue());
return (
<Form.Item
shouldUpdate={(prev, cur) => prev.vendorid !== cur.vendorid}

View File

@@ -0,0 +1,65 @@
import { Button } from "antd";
import React from "react";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { setModalContext } from "../../redux/modals/modals.actions";
import { selectBodyshop } from "../../redux/user/user.selectors";
import moment from "moment";
import { useTranslation } from "react-i18next";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
});
const mapDispatchToProps = (dispatch) => ({
setBillEnterContext: (context) =>
dispatch(setModalContext({ context: context, modal: "billEnter" })),
});
export default connect(mapStateToProps, mapDispatchToProps)(InventoryBillRo);
export function InventoryBillRo({
bodyshop,
setBillEnterContext,
inventoryline,
}) {
const { t } = useTranslation();
return (
<Button
onClick={() => {
setBillEnterContext({
actions: {
//refetch: refetch
},
context: {
disableInvNumber: true,
//job: { id: job.id },
consumeinventoryid: inventoryline.id,
bill: {
vendorid: bodyshop.inhousevendorid,
invoice_number: "ih",
isinhouse: true,
date: moment(),
total: 0,
// billlines: selectedLines.map((p) => {
// return {
// joblineid: p.id,
// actual_price: p.act_price,
// actual_cost: 0, //p.act_price,
// line_desc: p.line_desc,
// line_remarks: p.line_remarks,
// part_type: p.part_type,
// quantity: p.quantity || 1,
// applicable_taxes: {
// local: false,
// state: false,
// federal: false,
// },
// };
// }),
},
},
});
}}
>
{t("inventory.actions.addtoro")}
</Button>
);
}

View File

@@ -4,10 +4,11 @@ import queryString from "query-string";
import React from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { useHistory, useLocation } from "react-router-dom";
import { Link, useHistory, useLocation } from "react-router-dom";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import CurrencyFormatter from "../../utils/CurrencyFormatter";
import InventoryBillRo from "../inventory-bill-ro/inventory-bill-ro.component";
const mapStateToProps = createStructuredSelector({
//currentUser: selectCurrentUser
bodyshop: selectBodyshop,
@@ -75,7 +76,14 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
key: "consumedbyjob",
ellipsis: true,
render: (text, record) => record.bill?.job?.ro_number,
render: (text, record) =>
record.bill?.job?.ro_number ? (
<Link to={`/manage/jobs/${record.bill?.job?.id}`}>
{record.bill?.job?.ro_number}
</Link>
) : (
<InventoryBillRo inventoryline={record} />
),
},
];

View File

@@ -42,7 +42,10 @@ export const UPDATE_INVENTORY_LINES = gql`
export const QUERY_OUTSTANDING_INVENTORY = gql`
query QUERY_OUTSTANDING_INVENTORY {
inventory(where: { consumedbybillid: { _is_null: true } }) {
inventory(
where: { consumedbybillid: { _is_null: true } }
order_by: { line_desc: asc }
) {
id
actual_cost
actual_price

View File

@@ -1076,6 +1076,7 @@
"inventory": {
"actions": {
"addtoinventory": "Add to Inventory",
"addtoro": "Add to RO",
"consumefrominventory": "Consume from Inventory?"
},
"errors": {

View File

@@ -1076,6 +1076,7 @@
"inventory": {
"actions": {
"addtoinventory": "",
"addtoro": "",
"consumefrominventory": ""
},
"errors": {

View File

@@ -1076,6 +1076,7 @@
"inventory": {
"actions": {
"addtoinventory": "",
"addtoro": "",
"consumefrominventory": ""
},
"errors": {