Added import notes & dates. IO-556 IO-495

This commit is contained in:
Patrick Fic
2021-02-01 14:45:53 -08:00
parent 7e4faec0ff
commit be190b907e
9 changed files with 102 additions and 7 deletions

View File

@@ -18071,6 +18071,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>importnote</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>inproduction</name>
<definition_loaded>false</definition_loaded>
@@ -18853,6 +18874,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>supplementnote</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>suspense</name>
<definition_loaded>false</definition_loaded>

View File

@@ -2,7 +2,7 @@ import {
useApolloClient,
useLazyQuery,
useMutation,
useQuery
useQuery,
} from "@apollo/react-hooks";
import { notification } from "antd";
import Axios from "axios";
@@ -18,11 +18,14 @@ import { logImEXEvent } from "../../firebase/firebase.utils";
import {
DELETE_AVAILABLE_JOB,
QUERY_AVAILABLE_JOBS,
QUERY_AVAILABLE_NEW_JOBS_EST_DATA_BY_PK
QUERY_AVAILABLE_NEW_JOBS_EST_DATA_BY_PK,
} from "../../graphql/available-jobs.queries";
import { INSERT_NEW_JOB, UPDATE_JOB } from "../../graphql/jobs.queries";
import { SEARCH_VEHICLE_BY_VIN } from "../../graphql/vehicles.queries";
import { selectBodyshop } from "../../redux/user/user.selectors";
import {
selectBodyshop,
selectCurrentUser,
} from "../../redux/user/user.selectors";
import AlertComponent from "../alert/alert.component";
import JobsFindModalContainer from "../jobs-find-modal/jobs-find-modal.container";
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
@@ -30,12 +33,14 @@ import OwnerFindModalContainer from "../owner-find-modal/owner-find-modal.contai
import { GetSupplementDelta } from "./jobs-available-supplement.estlines.util";
import HeaderFields from "./jobs-available-supplement.headerfields";
import JobsAvailableTableComponent from "./jobs-available-table.component";
import moment from "moment";
import { INSERT_NEW_NOTE } from "../../graphql/notes.queries";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
currentUser: selectCurrentUser,
});
export function JobsAvailableContainer({ bodyshop }) {
export function JobsAvailableContainer({ bodyshop, currentUser }) {
const { loading, error, data, refetch } = useQuery(QUERY_AVAILABLE_JOBS, {
fetchPolicy: "network-only",
});
@@ -49,6 +54,8 @@ export function JobsAvailableContainer({ bodyshop }) {
const [selectedJob, setSelectedJob] = useState(null);
const [selectedOwner, setSelectedOwner] = useState(null);
const [insertLoading, setInsertLoading] = useState(false);
const [insertNote] = useMutation(INSERT_NEW_NOTE);
const [deleteJob] = useMutation(DELETE_AVAILABLE_JOB);
const [updateJob] = useMutation(UPDATE_JOB);
@@ -108,6 +115,16 @@ export function JobsAvailableContainer({ bodyshop }) {
clm_total: Dinero(newTotals.totals.total_repairs).toFormat("0.00"),
owner_owing: Dinero(newTotals.totals.custPayable.total).toFormat("0.00"),
job_totals: newTotals,
date_open: moment(),
notes: {
data: {
created_by: currentUser.email,
text: t("jobs.labels.importnote", {
date: moment().format("MM/DD/yyy"),
time: moment().format("hh:mm a"),
}),
},
},
queued_for_parts: true,
...(existingVehicles && existingVehicles.data.vehicles.length > 0
? { vehicleid: existingVehicles.data.vehicles[0].id, vehicle: null }
@@ -225,6 +242,7 @@ export function JobsAvailableContainer({ bodyshop }) {
},
});
//Job has been inserted. Clean up the available jobs record.
deleteJob({
variables: { id: estData.data.available_jobs_by_pk.id },
}).then((r) => {
@@ -240,6 +258,21 @@ export function JobsAvailableContainer({ bodyshop }) {
refetch();
setInsertLoading(false);
});
await insertNote({
variables: {
noteInput: [
{
jobid: selectedJob,
created_by: currentUser.email,
text: t("jobs.labels.supplementnote", {
date: moment().format("MM/DD/yyy"),
time: moment().format("hh:mm a"),
}),
},
],
},
});
}
};

View File

@@ -1,4 +1,4 @@
import { Form } from "antd";
import { DatePicker, Form } from "antd";
import React from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
@@ -22,7 +22,7 @@ export function JobsDetailDatesComponent({ jobRO, job }) {
label={t("jobs.fields.date_estimated")}
name="date_estimated"
>
<DateTimePicker disabled={jobRO} />
<DatePicker disabled={jobRO} />
</Form.Item>
<Form.Item label={t("jobs.fields.date_open")} name="date_open">
<DateTimePicker disabled={jobRO} />

View File

@@ -144,6 +144,9 @@ export function JobsDetailPage({
initialValues={{
...job,
loss_date: job.loss_date ? moment(job.loss_date) : null,
date_estimated: job.date_estimated
? moment(job.date_estimated)
: null,
}}
>
<FormFieldsChanged form={form} />

View File

@@ -1101,6 +1101,7 @@
"gppercent": "% G.P.",
"hrs_claimed": "Hours Claimed",
"hrs_total": "Hours Total",
"importnote": "The job was initially imported on {{date}} at {{time}}.",
"inproduction": "In Production",
"job": "Job Details",
"jobcosting": "Job Costing",
@@ -1140,6 +1141,7 @@
"state_tax_amt": "State/Provincial Taxes",
"subletstotal": "Sublets Total",
"subtotal": "Subtotal",
"supplementnote": "The job had a supplement imported on {{date}} at {{time}}.",
"suspense": "Suspense",
"total_cost": "Total Cost",
"total_cust_payable": "Total Customer Amount Payable",

View File

@@ -1101,6 +1101,7 @@
"gppercent": "",
"hrs_claimed": "",
"hrs_total": "",
"importnote": "",
"inproduction": "",
"job": "",
"jobcosting": "",
@@ -1140,6 +1141,7 @@
"state_tax_amt": "",
"subletstotal": "",
"subtotal": "",
"supplementnote": "",
"suspense": "",
"total_cost": "",
"total_cust_payable": "",

View File

@@ -1101,6 +1101,7 @@
"gppercent": "",
"hrs_claimed": "",
"hrs_total": "",
"importnote": "",
"inproduction": "",
"job": "",
"jobcosting": "",
@@ -1140,6 +1141,7 @@
"state_tax_amt": "",
"subletstotal": "",
"subtotal": "",
"supplementnote": "",
"suspense": "",
"total_cost": "",
"total_cust_payable": "",

View File

@@ -0,0 +1,6 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."jobs" ALTER COLUMN "date_estimated" TYPE timestamp
with time zone;
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."jobs" ALTER COLUMN "date_estimated" TYPE date;
type: run_sql