diff --git a/client/src/components/bill-form/bill-form.lines.component.jsx b/client/src/components/bill-form/bill-form.lines.component.jsx index b3d6209c5..5891741d7 100644 --- a/client/src/components/bill-form/bill-form.lines.component.jsx +++ b/client/src/components/bill-form/bill-form.lines.component.jsx @@ -36,6 +36,7 @@ export function BillEnterModalLinesComponent({ form, responsibilityCenters, billEdit, + billid, }) { const { t } = useTranslation(); const { setFieldsValue, getFieldsValue, getFieldValue } = form; diff --git a/client/src/components/billline-add-inventory/billline-add-inventory.component.jsx b/client/src/components/billline-add-inventory/billline-add-inventory.component.jsx index d84bf4b0d..2a6d76355 100644 --- a/client/src/components/billline-add-inventory/billline-add-inventory.component.jsx +++ b/client/src/components/billline-add-inventory/billline-add-inventory.component.jsx @@ -7,11 +7,17 @@ import React, { useState } from "react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { INSERT_INVENTORY_AND_CREDIT } from "../../graphql/inventory.queries"; -import { selectBodyshop } from "../../redux/user/user.selectors"; +import { + selectBodyshop, + selectCurrentUser, +} from "../../redux/user/user.selectors"; import { CalculateBillTotal } from "../bill-form/bill-form.totals.utility"; +import queryString from "query-string"; +import { useLocation } from "react-router-dom"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, + currentUser: selectCurrentUser, }); const mapDispatchToProps = (dispatch) => ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) @@ -21,8 +27,15 @@ export default connect( mapDispatchToProps )(BilllineAddInventory); -export function BilllineAddInventory({ bodyshop, billline, disabled, jobid }) { +export function BilllineAddInventory({ + currentUser, + bodyshop, + billline, + disabled, + jobid, +}) { const [loading, setLoading] = useState(false); + const { billid } = queryString.parse(useLocation().search); const [insertInventoryLine] = useMutation(INSERT_INVENTORY_AND_CREDIT); @@ -51,9 +64,9 @@ export function BilllineAddInventory({ bodyshop, billline, disabled, jobid }) { cost_center: billline.cost_center, deductedfromlbr: billline.deductedfromlbr, applicable_taxes: { - local: billline.applicable_taxes.local, - state: billline.applicable_taxes.state, - federal: billline.applicable_taxes.federal, + local: false, //billline.applicable_taxes.local, + state: false, //billline.applicable_taxes.state, + federal: false, // billline.applicable_taxes.federal, }, }, ], @@ -63,6 +76,8 @@ export function BilllineAddInventory({ bodyshop, billline, disabled, jobid }) { const insertResult = await insertInventoryLine({ variables: { + joblineId: billline.joblineid, + joblineStatus: bodyshop.md_order_statuses.default_returned, inv: { shopid: bodyshop.id, billlineid: billline.id, @@ -72,6 +87,31 @@ export function BilllineAddInventory({ bodyshop, billline, disabled, jobid }) { line_desc: billline.line_desc, }, cm: { ...cm, billlines: { data: cm.billlines } }, //Fix structure for apollo insert. + pol: { + returnfrombill: billid, + vendorid: bodyshop.inhousevendorid, + deliver_by: moment().format("YYYY-MM-DD"), + parts_order_lines: { + data: [ + { + line_desc: billline.line_desc, + + act_price: billline.actual_price, + cost: billline.actual_cost, + quantity: billline.quantity, + job_line_id: billline.joblineid, + part_type: billline.jobline.part_type, + cm_received: true, + }, + ], + }, + order_date: "2022-06-01", + orderedby: currentUser.email, + jobid: jobid, + user_email: currentUser.email, + return: true, + status: "Ordered", + }, }, refetchQueries: ["QUERY_BILL_BY_PK"], }); @@ -97,7 +137,7 @@ export function BilllineAddInventory({ bodyshop, billline, disabled, jobid }) {