Further work to refactor job costing + qb posting. BOD-383

This commit is contained in:
Patrick Fic
2020-09-14 16:57:40 -07:00
parent eff49e3d25
commit 379c12c7bb
13 changed files with 239 additions and 96 deletions

View File

@@ -153,19 +153,20 @@ export default function AccountingPayablesTableComponent({
loading={loading}
title={() => {
return (
<div>
<div className="imex-table-header">
<PaymentsExportAllButton
paymentIds={selectedPayments}
disabled={transInProgress || selectedPayments.length === 0}
loadingCallback={setTransInProgress}
completedCallback={setSelectedPayments}
/>
<Input
className="imex-table-header__search"
value={state.search}
onChange={handleSearch}
placeholder={t("general.labels.search")}
allowClear
/>
<PaymentsExportAllButton
paymentIds={selectedPayments}
disabled={transInProgress}
loadingCallback={setTransInProgress}
completedCallback={setSelectedPayments}
/>
</div>
);
}}

View File

@@ -38,6 +38,7 @@ function JobLinesUpsertModalContainer({
.then((r) => {
if (jobLineEditModal.actions.refetch)
jobLineEditModal.actions.refetch();
//Need to recalcuate totals.
toggleModalVisible();
notification["success"]({
message: t("joblines.successes.created"),

View File

@@ -80,27 +80,32 @@ export function JobsCloseExportButton({ bodyshop, jobId, disabled }) {
})
);
} else {
const jobUpdateResponse = await updateJob({
variables: {
jobId: jobId,
job: {
status: bodyshop.md_ro_statuses.default_exported || "Exported*",
date_exported: new Date(),
},
},
});
if (!!!jobUpdateResponse.errors) {
notification["success"]({
message: t("jobs.successes.exported"),
});
} else {
notification["error"]({
message: t("jobs.errors.exporting", {
error: JSON.stringify(jobUpdateResponse.error),
}),
});
}
// const jobUpdateResponse = await updateJob({
// variables: {
// jobId: jobId,
// job: {
// status: bodyshop.md_ro_statuses.default_exported || "Exported*",
// date_exported: new Date(),
// },
// },
// });
// if (!!!jobUpdateResponse.errors) {
// notification["success"]({
// message: t("jobs.successes.exported"),
// });
// } else {
// notification["error"]({
// message: t("jobs.errors.exporting", {
// error: JSON.stringify(jobUpdateResponse.error),
// }),
// });
// }
}
setLoading(false);

View File

@@ -73,14 +73,21 @@ export function JobsCloseLines({ bodyshop, joblines }) {
name={[field.name, "profitcenter_part"]}
rules={[
{
required:
!!joblines[index].part_type &&
!!joblines[index].act_price,
required: !!joblines[index].act_price,
message: t("general.validation.required"),
},
]}
>
<Select allowClear>
<Select
allowClear
optionFilterProp="children"
showSearch
filterOption={(input, option) =>
option.children
.toLowerCase()
.indexOf(input.toLowerCase()) >= 0
}
>
{bodyshop.md_responsibility_centers.profits.map((p) => (
<Select.Option key={p.name} value={p.name}>
{p.name}
@@ -99,7 +106,16 @@ export function JobsCloseLines({ bodyshop, joblines }) {
},
]}
>
<Select allowClear>
<Select
allowClear
optionFilterProp="children"
showSearch
filterOption={(input, option) =>
option.children
.toLowerCase()
.indexOf(input.toLowerCase()) >= 0
}
>
{bodyshop.md_responsibility_centers.profits.map((p) => (
<Select.Option key={p.name} value={p.name}>
{p.name}

View File

@@ -151,7 +151,6 @@ export const GET_JOB_LINES_TO_ENTER_INVOICE = gql`
// }
export const generateJobLinesUpdatesForInvoicing = (joblines) => {
console.log("generateJobLinesUpdatesForInvoicing -> joblines", joblines);
const updates = joblines.reduce((acc, jl, idx) => {
return (
acc +

View File

@@ -1,5 +1,5 @@
import { Button, Form, Space, notification, Popconfirm } from "antd";
import React from "react";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
@@ -24,22 +24,33 @@ export function JobsCloseComponent({ job, bodyshop }) {
const client = useApolloClient();
const history = useHistory();
const [closeJob] = useMutation(UPDATE_JOB);
const [loading, setLoading] = useState(false);
// useEffect(() => {
// //if (job && form) form.setFields({ joblines: job.joblines });
// }, [job, form]);
const handleFinish = async (values) => {
console.log(values);
setLoading(true);
const result = await client.mutate({
mutation: generateJobLinesUpdatesForInvoicing(values.joblines),
});
console.log("result.data", result.data);
if (!!!result.errors) {
notification["success"]({ message: t("job.successes.saved") });
form.resetFields();
} else {
notification["error"]({
message: t("job.errors.saving", {
error: JSON.stringify(result.errors),
}),
});
}
form.resetFields();
form.resetFields();
setLoading(false);
};
const handleClose = async () => {
setLoading(true);
const result = await closeJob({
variables: {
jobId: job.id,
@@ -54,6 +65,7 @@ export function JobsCloseComponent({ job, bodyshop }) {
notification["success"]({ message: t("job.successes.closed") });
history.push(`/manage/jobs/${job.id}`);
} else {
setLoading(false);
notification["error"]({
message: t("job.errors.closing", {
error: JSON.stringify(result.errors),
@@ -69,6 +81,7 @@ export function JobsCloseComponent({ job, bodyshop }) {
form={form}
onFinish={handleFinish}
initialValues={{ joblines: job.joblines }}
scrollToFirstError
>
<Space>
<JobsCloseAutoAllocate
@@ -77,7 +90,7 @@ export function JobsCloseComponent({ job, bodyshop }) {
disabled={!!job.date_exported}
/>
<Button onClick={() => form.submit()}>
<Button loading={loading} onClick={() => form.submit()}>
{t("general.actions.save")}
</Button>
@@ -87,7 +100,9 @@ export function JobsCloseComponent({ job, bodyshop }) {
cancelText={t("general.labels.no")}
title={t("jobs.labels.closeconfirm")}
>
<Button type="danger">{t("general.actions.close")}</Button>
<Button loading={loading} type="danger">
{t("general.actions.close")}
</Button>
</Popconfirm>
<JobsScoreboardAdd job={job} disabled={false} />

View File

@@ -1242,6 +1242,9 @@
}
},
"payments": {
"errors": {
"exporting": "Error exporting payment(s). {{error}}"
},
"fields": {
"amount": "Amount",
"created_at": "Created At",

View File

@@ -1242,6 +1242,9 @@
}
},
"payments": {
"errors": {
"exporting": ""
},
"fields": {
"amount": "",
"created_at": "",

View File

@@ -1242,6 +1242,9 @@
}
},
"payments": {
"errors": {
"exporting": ""
},
"fields": {
"amount": "",
"created_at": "",