Mark part as received when invoice entered BOD-124
This commit is contained in:
@@ -7,10 +7,13 @@ import { createStructuredSelector } from "reselect";
|
|||||||
import { INSERT_NEW_INVOICE } from "../../graphql/invoices.queries";
|
import { INSERT_NEW_INVOICE } from "../../graphql/invoices.queries";
|
||||||
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
||||||
import { selectInvoiceEnterModal } from "../../redux/modals/modals.selectors";
|
import { selectInvoiceEnterModal } from "../../redux/modals/modals.selectors";
|
||||||
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
|
import {
|
||||||
|
selectBodyshop,
|
||||||
|
selectCurrentUser,
|
||||||
|
} from "../../redux/user/user.selectors";
|
||||||
import { handleUpload } from "../documents-upload/documents-upload.utility";
|
import { handleUpload } from "../documents-upload/documents-upload.utility";
|
||||||
import InvoiceFormContainer from "../invoice-form/invoice-form.container";
|
import InvoiceFormContainer from "../invoice-form/invoice-form.container";
|
||||||
|
import { UPDATE_JOB_LINE_STATUS } from "../../graphql/jobs-lines.queries";
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
invoiceEnterModal: selectInvoiceEnterModal,
|
invoiceEnterModal: selectInvoiceEnterModal,
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
@@ -30,6 +33,7 @@ function InvoiceEnterModalContainer({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [enterAgain, setEnterAgain] = useState(false);
|
const [enterAgain, setEnterAgain] = useState(false);
|
||||||
const [insertInvoice] = useMutation(INSERT_NEW_INVOICE);
|
const [insertInvoice] = useMutation(INSERT_NEW_INVOICE);
|
||||||
|
const [updateJobLines] = useMutation(UPDATE_JOB_LINE_STATUS);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const handleFinish = (values) => {
|
const handleFinish = (values) => {
|
||||||
@@ -53,38 +57,47 @@ function InvoiceEnterModalContainer({
|
|||||||
})
|
})
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
const invoiceId = r.data.insert_invoices.returning[0].id;
|
const invoiceId = r.data.insert_invoices.returning[0].id;
|
||||||
console.log("invoiceId", invoiceId);
|
|
||||||
/////////////////////////
|
|
||||||
if (upload && upload.length > 0) {
|
|
||||||
//insert Each of the documents?
|
|
||||||
upload.forEach((u) => {
|
|
||||||
handleUpload(
|
|
||||||
{ file: u.originFileObj },
|
|
||||||
{
|
|
||||||
bodyshop: bodyshop,
|
|
||||||
uploaded_by: currentUser.email,
|
|
||||||
jobId: values.jobid,
|
|
||||||
invoiceId: invoiceId,
|
|
||||||
tagsArray: null,
|
|
||||||
callback: null,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
///////////////////////////
|
|
||||||
setLoading(false);
|
|
||||||
notification["success"]({
|
|
||||||
message: t("invoices.successes.created"),
|
|
||||||
});
|
|
||||||
if (invoiceEnterModal.actions.refetch)
|
|
||||||
invoiceEnterModal.actions.refetch();
|
|
||||||
|
|
||||||
if (enterAgain) {
|
updateJobLines({
|
||||||
form.resetFields();
|
variables: {
|
||||||
} else {
|
ids: remainingValues.invoicelines
|
||||||
toggleModalVisible();
|
.filter((il) => il.joblineid !== " noline")
|
||||||
}
|
.map((li) => li.joblineid),
|
||||||
setEnterAgain(false);
|
status: bodyshop.md_order_statuses.default_received || "Received*",
|
||||||
|
},
|
||||||
|
}).then((joblineresult) => {
|
||||||
|
/////////////////////////
|
||||||
|
if (upload && upload.length > 0) {
|
||||||
|
//insert Each of the documents?
|
||||||
|
upload.forEach((u) => {
|
||||||
|
handleUpload(
|
||||||
|
{ file: u.originFileObj },
|
||||||
|
{
|
||||||
|
bodyshop: bodyshop,
|
||||||
|
uploaded_by: currentUser.email,
|
||||||
|
jobId: values.jobid,
|
||||||
|
invoiceId: invoiceId,
|
||||||
|
tagsArray: null,
|
||||||
|
callback: null,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
///////////////////////////
|
||||||
|
setLoading(false);
|
||||||
|
notification["success"]({
|
||||||
|
message: t("invoices.successes.created"),
|
||||||
|
});
|
||||||
|
if (invoiceEnterModal.actions.refetch)
|
||||||
|
invoiceEnterModal.actions.refetch();
|
||||||
|
|
||||||
|
if (enterAgain) {
|
||||||
|
form.resetFields();
|
||||||
|
} else {
|
||||||
|
toggleModalVisible();
|
||||||
|
}
|
||||||
|
setEnterAgain(false);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -122,19 +135,17 @@ function InvoiceEnterModalContainer({
|
|||||||
</Button>
|
</Button>
|
||||||
{invoiceEnterModal.context && invoiceEnterModal.context.id ? null : (
|
{invoiceEnterModal.context && invoiceEnterModal.context.id ? null : (
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type='primary'
|
||||||
loading={loading}
|
loading={loading}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setEnterAgain(true);
|
setEnterAgain(true);
|
||||||
}}
|
}}>
|
||||||
>
|
|
||||||
{t("general.actions.saveandnew")}
|
{t("general.actions.saveandnew")}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
destroyOnClose
|
destroyOnClose>
|
||||||
>
|
|
||||||
<Form
|
<Form
|
||||||
onFinish={handleFinish}
|
onFinish={handleFinish}
|
||||||
autoComplete={"off"}
|
autoComplete={"off"}
|
||||||
@@ -151,8 +162,7 @@ function InvoiceEnterModalContainer({
|
|||||||
federal_tax_rate: bodyshop.invoice_tax_rates.federal_tax_rate || 0,
|
federal_tax_rate: bodyshop.invoice_tax_rates.federal_tax_rate || 0,
|
||||||
state_tax_rate: bodyshop.invoice_tax_rates.state_tax_rate || 0,
|
state_tax_rate: bodyshop.invoice_tax_rates.state_tax_rate || 0,
|
||||||
local_tax_rate: bodyshop.invoice_tax_rates.local_tax_rate || 0,
|
local_tax_rate: bodyshop.invoice_tax_rates.local_tax_rate || 0,
|
||||||
}}
|
}}>
|
||||||
>
|
|
||||||
<InvoiceFormContainer form={form} />
|
<InvoiceFormContainer form={form} />
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|||||||
Reference in New Issue
Block a user