From 5c643515c058d5a528ea6eda0cf4ce8d0ecbacdc Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Thu, 27 Aug 2020 10:51:29 -0700 Subject: [PATCH] Added parts location to receiving an invoice. BOD-357 --- .../invoice-enter-modal.container.jsx | 3 +- .../invoice-form/invoice-form.component.jsx | 33 +++++++++++++++++-- .../job-invoices-total.component.jsx | 8 ++--- client/src/graphql/jobs-lines.queries.js | 17 ++++++++-- 4 files changed, 52 insertions(+), 9 deletions(-) diff --git a/client/src/components/invoice-enter-modal/invoice-enter-modal.container.jsx b/client/src/components/invoice-enter-modal/invoice-enter-modal.container.jsx index 56f30fbc0..2ec74d89b 100644 --- a/client/src/components/invoice-enter-modal/invoice-enter-modal.container.jsx +++ b/client/src/components/invoice-enter-modal/invoice-enter-modal.container.jsx @@ -39,7 +39,7 @@ function InvoiceEnterModalContainer({ const handleFinish = (values) => { setLoading(true); - const { upload, ...remainingValues } = values; + const { upload, location, ...remainingValues } = values; insertInvoice({ variables: { invoice: [ @@ -67,6 +67,7 @@ function InvoiceEnterModalContainer({ .filter((il) => il.joblineid !== "noline") .map((li) => li.joblineid), status: bodyshop.md_order_statuses.default_received || "Received*", + location: location, }, }).then((joblineresult) => { ///////////////////////// diff --git a/client/src/components/invoice-form/invoice-form.component.jsx b/client/src/components/invoice-form/invoice-form.component.jsx index 02bf469fb..e3b145bd6 100644 --- a/client/src/components/invoice-form/invoice-form.component.jsx +++ b/client/src/components/invoice-form/invoice-form.component.jsx @@ -1,6 +1,9 @@ -import { Button, Form, Input, Statistic, Switch, Upload } from "antd"; +import { Button, Form, Input, Select, Statistic, Switch, Upload } from "antd"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; import AlertComponent from "../alert/alert.component"; import FormDatePicker from "../form-date-picker/form-date-picker.component"; import CurrencyInput from "../form-items-formatted/currency-form-item.component"; @@ -9,8 +12,16 @@ import VendorSearchSelect from "../vendor-search-select/vendor-search-select.com import InvoiceFormLines from "./invoice-form.lines.component"; import "./invoice-form.styles.scss"; import { CalculateInvoiceTotal } from "./invoice-form.totals.utility"; +const mapStateToProps = createStructuredSelector({ + //currentUser: selectCurrentUser + bodyshop: selectBodyshop, +}); +const mapDispatchToProps = (dispatch) => ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) +}); -export default function InvoiceFormComponent({ +export function InvoiceFormComponent({ + bodyshop, form, vendorAutoCompleteOptions, lineData, @@ -143,6 +154,19 @@ export default function InvoiceFormComponent({ > + + + + ); } + +export default connect( + mapStateToProps, + mapDispatchToProps +)(InvoiceFormComponent); diff --git a/client/src/components/job-invoices-total/job-invoices-total.component.jsx b/client/src/components/job-invoices-total/job-invoices-total.component.jsx index d50a4411c..e095a8ca3 100644 --- a/client/src/components/job-invoices-total/job-invoices-total.component.jsx +++ b/client/src/components/job-invoices-total/job-invoices-total.component.jsx @@ -12,10 +12,10 @@ export default function JobInvoiceTotals({ loading, invoices, jobTotals }) { if (loading) return ; if (!!!jobTotals) return ( - + ); - - const totals = JSON.parse(jobTotals); + + const totals = jobTotals; let invoiceTotals = Dinero({ amount: 0 }); invoices.forEach((i) => @@ -33,7 +33,7 @@ export default function JobInvoiceTotals({ loading, invoices, jobTotals }) { const discrepancy = Dinero(totals.parts.parts.total).subtract(invoiceTotals); return ( -
+