Added job line ignore.
This commit is contained in:
@@ -326,28 +326,27 @@ async function DecodeLinFile(extensionlessFilePath) {
|
||||
}
|
||||
);
|
||||
})
|
||||
.filter(
|
||||
(jobline) =>
|
||||
jobline.part_type &&
|
||||
!jobline.db_ref.startsWith("900") &&
|
||||
!jobline.line_desc.toLowerCase().startsWith("urethane") &&
|
||||
!jobline.line_desc.toLowerCase().startsWith("wheel") &&
|
||||
!jobline.line_desc.toLowerCase().startsWith("hazardous") &&
|
||||
!jobline.line_desc.toLowerCase().startsWith("detail") &&
|
||||
!jobline.line_desc.toLowerCase().startsWith("clean") &&
|
||||
jobline.part_type.toUpperCase() !== "PAG" &&
|
||||
jobline.part_type.toUpperCase() !== "PAS" &&
|
||||
jobline.part_type.toUpperCase() !== "PASL" &&
|
||||
jobline.part_type.toUpperCase() !== "PAE" &&
|
||||
jobline.glass_flag === false
|
||||
)
|
||||
// .filter(
|
||||
// (jobline) =>
|
||||
// jobline.part_type &&
|
||||
// !jobline.db_ref.startsWith("900") &&
|
||||
// !jobline.line_desc.toLowerCase().startsWith("urethane") &&
|
||||
// !jobline.line_desc.toLowerCase().startsWith("wheel") &&
|
||||
// !jobline.line_desc.toLowerCase().startsWith("hazardous") &&
|
||||
// !jobline.line_desc.toLowerCase().startsWith("detail") &&
|
||||
// !jobline.line_desc.toLowerCase().startsWith("clean") &&
|
||||
// jobline.part_type.toUpperCase() !== "PAG" &&
|
||||
// jobline.part_type.toUpperCase() !== "PAS" &&
|
||||
// jobline.part_type.toUpperCase() !== "PASL" &&
|
||||
// jobline.part_type.toUpperCase() !== "PAE" &&
|
||||
// jobline.glass_flag === false
|
||||
// )
|
||||
.map((jobline) => {
|
||||
if (
|
||||
(jobline.db_price === null || jobline.db_price === 0) &&
|
||||
!!jobline.act_price &&
|
||||
jobline.act_price > 0
|
||||
) {
|
||||
console.log(1, jobline.line_desc, jobline.db_price, jobline.act_price);
|
||||
log.info(
|
||||
"DB Price null/lower than act price",
|
||||
jobline.line_desc,
|
||||
@@ -368,10 +367,25 @@ async function DecodeLinFile(extensionlessFilePath) {
|
||||
jobline.db_price,
|
||||
jobline.act_price
|
||||
);
|
||||
console.log(2, jobline.line_desc, jobline.db_price, jobline.act_price);
|
||||
jobline.db_price = jobline.act_price;
|
||||
}
|
||||
|
||||
if (
|
||||
!jobline.part_type ||
|
||||
jobline.db_ref.startsWith("900") ||
|
||||
jobline.line_desc.toLowerCase().startsWith("urethane") ||
|
||||
jobline.line_desc.toLowerCase().startsWith("wheel") ||
|
||||
jobline.line_desc.toLowerCase().startsWith("hazardous") ||
|
||||
jobline.line_desc.toLowerCase().startsWith("detail") ||
|
||||
jobline.line_desc.toLowerCase().startsWith("clean") ||
|
||||
jobline.part_type.toUpperCase() === "PAG" ||
|
||||
jobline.part_type.toUpperCase() === "PAS" ||
|
||||
jobline.part_type.toUpperCase() === "PASL" ||
|
||||
jobline.part_type.toUpperCase() === "PAE" ||
|
||||
jobline.glass_flag === true
|
||||
)
|
||||
jobline.ignore = true;
|
||||
|
||||
delete jobline.glass_flag;
|
||||
return jobline;
|
||||
});
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
- args:
|
||||
cascade: false
|
||||
read_only: false
|
||||
sql: ALTER TABLE "public"."joblines" DROP COLUMN "ignore";
|
||||
type: run_sql
|
||||
@@ -0,0 +1,6 @@
|
||||
- args:
|
||||
cascade: false
|
||||
read_only: false
|
||||
sql: ALTER TABLE "public"."joblines" ADD COLUMN "ignore" boolean NOT NULL DEFAULT
|
||||
false;
|
||||
type: run_sql
|
||||
@@ -0,0 +1,39 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: drop_insert_permission
|
||||
- args:
|
||||
permission:
|
||||
backend_only: false
|
||||
check:
|
||||
job:
|
||||
bodyshop:
|
||||
associations:
|
||||
user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
columns:
|
||||
- act_price
|
||||
- created_at
|
||||
- db_price
|
||||
- db_ref
|
||||
- id
|
||||
- jobid
|
||||
- line_desc
|
||||
- line_ind
|
||||
- line_no
|
||||
- oem_partno
|
||||
- part_qty
|
||||
- part_type
|
||||
- price_diff
|
||||
- price_diff_pc
|
||||
- unq_seq
|
||||
- updated_at
|
||||
set: {}
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: create_insert_permission
|
||||
@@ -0,0 +1,40 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: drop_insert_permission
|
||||
- args:
|
||||
permission:
|
||||
backend_only: false
|
||||
check:
|
||||
job:
|
||||
bodyshop:
|
||||
associations:
|
||||
user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
columns:
|
||||
- act_price
|
||||
- created_at
|
||||
- db_price
|
||||
- db_ref
|
||||
- id
|
||||
- ignore
|
||||
- jobid
|
||||
- line_desc
|
||||
- line_ind
|
||||
- line_no
|
||||
- oem_partno
|
||||
- part_qty
|
||||
- part_type
|
||||
- price_diff
|
||||
- price_diff_pc
|
||||
- unq_seq
|
||||
- updated_at
|
||||
set: {}
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: create_insert_permission
|
||||
@@ -0,0 +1,39 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: drop_select_permission
|
||||
- args:
|
||||
permission:
|
||||
allow_aggregations: false
|
||||
columns:
|
||||
- act_price
|
||||
- created_at
|
||||
- db_price
|
||||
- db_ref
|
||||
- id
|
||||
- jobid
|
||||
- line_desc
|
||||
- line_ind
|
||||
- line_no
|
||||
- oem_partno
|
||||
- part_qty
|
||||
- part_type
|
||||
- price_diff
|
||||
- price_diff_pc
|
||||
- unq_seq
|
||||
- updated_at
|
||||
computed_fields: []
|
||||
filter:
|
||||
job:
|
||||
bodyshop:
|
||||
associations:
|
||||
user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: create_select_permission
|
||||
@@ -0,0 +1,40 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: drop_select_permission
|
||||
- args:
|
||||
permission:
|
||||
allow_aggregations: false
|
||||
columns:
|
||||
- act_price
|
||||
- created_at
|
||||
- db_price
|
||||
- db_ref
|
||||
- id
|
||||
- ignore
|
||||
- jobid
|
||||
- line_desc
|
||||
- line_ind
|
||||
- line_no
|
||||
- oem_partno
|
||||
- part_qty
|
||||
- part_type
|
||||
- price_diff
|
||||
- price_diff_pc
|
||||
- unq_seq
|
||||
- updated_at
|
||||
computed_fields: []
|
||||
filter:
|
||||
job:
|
||||
bodyshop:
|
||||
associations:
|
||||
user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: create_select_permission
|
||||
@@ -0,0 +1,38 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: drop_update_permission
|
||||
- args:
|
||||
permission:
|
||||
columns:
|
||||
- act_price
|
||||
- created_at
|
||||
- db_price
|
||||
- db_ref
|
||||
- id
|
||||
- jobid
|
||||
- line_desc
|
||||
- line_ind
|
||||
- line_no
|
||||
- oem_partno
|
||||
- part_qty
|
||||
- part_type
|
||||
- price_diff
|
||||
- price_diff_pc
|
||||
- unq_seq
|
||||
- updated_at
|
||||
filter:
|
||||
job:
|
||||
bodyshop:
|
||||
associations:
|
||||
user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
set: {}
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: create_update_permission
|
||||
@@ -0,0 +1,39 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: drop_update_permission
|
||||
- args:
|
||||
permission:
|
||||
columns:
|
||||
- act_price
|
||||
- created_at
|
||||
- db_price
|
||||
- db_ref
|
||||
- id
|
||||
- ignore
|
||||
- jobid
|
||||
- line_desc
|
||||
- line_ind
|
||||
- line_no
|
||||
- oem_partno
|
||||
- part_qty
|
||||
- part_type
|
||||
- price_diff
|
||||
- price_diff_pc
|
||||
- unq_seq
|
||||
- updated_at
|
||||
filter:
|
||||
job:
|
||||
bodyshop:
|
||||
associations:
|
||||
user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
set: {}
|
||||
role: user
|
||||
table:
|
||||
name: joblines
|
||||
schema: public
|
||||
type: create_update_permission
|
||||
@@ -89,6 +89,7 @@ tables:
|
||||
- db_price
|
||||
- db_ref
|
||||
- id
|
||||
- ignore
|
||||
- jobid
|
||||
- line_desc
|
||||
- line_ind
|
||||
@@ -110,6 +111,7 @@ tables:
|
||||
- db_price
|
||||
- db_ref
|
||||
- id
|
||||
- ignore
|
||||
- jobid
|
||||
- line_desc
|
||||
- line_ind
|
||||
@@ -137,6 +139,7 @@ tables:
|
||||
- db_price
|
||||
- db_ref
|
||||
- id
|
||||
- ignore
|
||||
- jobid
|
||||
- line_desc
|
||||
- line_ind
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { message, Switch } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { UPDATE_JOB_LINE } from "../../../graphql/joblines.queries";
|
||||
const { log } = window;
|
||||
|
||||
export default function IgnoreJobLineAtom({ ignore, lineId }) {
|
||||
const [updateJobLine] = useMutation(UPDATE_JOB_LINE);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const handleChange = async (checked) => {
|
||||
setLoading(true);
|
||||
const result = await updateJobLine({
|
||||
variables: { lineId: lineId, line: { ignore: checked } },
|
||||
});
|
||||
if (result.errors) {
|
||||
message.error("Error updating line.");
|
||||
log.error("Error updating job.", result.errors);
|
||||
} else {
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return <Switch checked={ignore} onChange={handleChange} loading={loading} />;
|
||||
}
|
||||
@@ -12,17 +12,19 @@ export default function JobPartsGraphAtom({
|
||||
const data = useMemo(() => {
|
||||
if (!job) return [];
|
||||
|
||||
const sums = job.joblines.reduce((acc, val) => {
|
||||
if (!acc[val.part_type]) {
|
||||
acc[val.part_type] = Dinero();
|
||||
}
|
||||
const sums = job.joblines
|
||||
.filter((j) => !j.ignore)
|
||||
.reduce((acc, val) => {
|
||||
if (!acc[val.part_type]) {
|
||||
acc[val.part_type] = Dinero();
|
||||
}
|
||||
|
||||
acc[val.part_type] = acc[val.part_type].add(
|
||||
Dinero({ amount: Math.round((val[price] || 0) * 100) })
|
||||
);
|
||||
acc[val.part_type] = acc[val.part_type].add(
|
||||
Dinero({ amount: Math.round((val[price] || 0) * 100) })
|
||||
);
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return Object.keys(sums).map((key) => {
|
||||
return {
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
import { Table } from "antd";
|
||||
import React from "react";
|
||||
import { Input, Table } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import CurrencyFormatterAtom from "../../atoms/currency-formatter/currency-formatter.atom";
|
||||
import IgnoreJobLine from "../../atoms/ignore-job-line/ignore-job-line.atom";
|
||||
import partTypeConverterAtom from "../../atoms/part-type-converter/part-type-converter.atom";
|
||||
import PriceDiffPcFormatterAtom from "../../atoms/price-diff-pc-formatter/price-diff-pc-formatter.atom";
|
||||
|
||||
export default function JobLinesTableMolecule({ loading, job }) {
|
||||
const [searchText, setSearchText] = useState("");
|
||||
|
||||
const { joblines } = job;
|
||||
const columns = [
|
||||
{
|
||||
title: "#",
|
||||
dataIndex: "unq_seq",
|
||||
key: "unq_seq",
|
||||
dataIndex: "line_no",
|
||||
key: "line_no",
|
||||
},
|
||||
{
|
||||
title: "S#",
|
||||
@@ -73,17 +76,47 @@ export default function JobLinesTableMolecule({ loading, job }) {
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "Ignore?",
|
||||
dataIndex: "ignore",
|
||||
key: "ignore",
|
||||
filters: [
|
||||
{ text: "True", value: true },
|
||||
{ text: "False", value: false },
|
||||
],
|
||||
onFilter: (value, record) => value === record.ignore,
|
||||
render: (text, record) => (
|
||||
<IgnoreJobLine lineId={record.id} ignore={record.ignore} />
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
const data =
|
||||
searchText !== ""
|
||||
? joblines.filter((j) =>
|
||||
j.line_desc.toLowerCase().includes(searchText.toLowerCase())
|
||||
)
|
||||
: joblines;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Table
|
||||
title={() => (
|
||||
<Input.Search
|
||||
placeholder="Search"
|
||||
onSearch={(val) => {
|
||||
setSearchText(val);
|
||||
}}
|
||||
enterButton
|
||||
allowClear
|
||||
/>
|
||||
)}
|
||||
columns={columns}
|
||||
rowKey="id"
|
||||
loading={loading}
|
||||
size="small"
|
||||
pagination={false}
|
||||
dataSource={joblines}
|
||||
dataSource={data}
|
||||
scroll={{
|
||||
x: true,
|
||||
y: "20rem",
|
||||
|
||||
@@ -26,15 +26,17 @@ export function JobsTargetsStatsMolecule({
|
||||
if (!job) {
|
||||
return 0;
|
||||
}
|
||||
return job.joblines.reduce((acc, val) => {
|
||||
if (val.price_diff > 0) {
|
||||
return acc.add(
|
||||
Dinero({ amount: Math.round((val.price_diff || 0) * 100) })
|
||||
);
|
||||
} else {
|
||||
return acc;
|
||||
}
|
||||
}, Dinero());
|
||||
return job.joblines
|
||||
.filter((j) => !j.ignore)
|
||||
.reduce((acc, val) => {
|
||||
if (val.price_diff > 0) {
|
||||
return acc.add(
|
||||
Dinero({ amount: Math.round((val.price_diff || 0) * 100) })
|
||||
);
|
||||
} else {
|
||||
return acc;
|
||||
}
|
||||
}, Dinero());
|
||||
}, [job]);
|
||||
|
||||
const currentRpsPc = useMemo(() => {
|
||||
@@ -42,9 +44,11 @@ export function JobsTargetsStatsMolecule({
|
||||
if (!job) {
|
||||
return 0;
|
||||
}
|
||||
const dbPriceSum = job.joblines.reduce((acc, val) => {
|
||||
return acc + val.db_price;
|
||||
}, 0);
|
||||
const dbPriceSum = job.joblines
|
||||
.filter((j) => !j.ignore)
|
||||
.reduce((acc, val) => {
|
||||
return acc + val.db_price;
|
||||
}, 0);
|
||||
return (currentRpsDollars.getAmount() / dbPriceSum).toFixed(1);
|
||||
}, [job, currentRpsDollars]);
|
||||
|
||||
|
||||
23
src/graphql/joblines.queries.js
Normal file
23
src/graphql/joblines.queries.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import gql from "graphql-tag";
|
||||
|
||||
export const UPDATE_JOB_LINE = gql`
|
||||
mutation UPDATE_JOB_LINE($lineId: uuid!, $line: joblines_set_input!) {
|
||||
update_joblines(where: { id: { _eq: $lineId } }, _set: $line) {
|
||||
returning {
|
||||
id
|
||||
line_no
|
||||
act_price
|
||||
db_price
|
||||
line_desc
|
||||
line_ind
|
||||
oem_partno
|
||||
part_qty
|
||||
part_type
|
||||
unq_seq
|
||||
price_diff
|
||||
price_diff_pc
|
||||
ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -10,21 +10,6 @@ export const INSERT_NEW_JOB = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
// on_conflict: {
|
||||
// constraint: jobs_clm_no_bodyshopid_key
|
||||
// update_columns: [
|
||||
// ins_co_nm
|
||||
// clm_no
|
||||
// clm_total
|
||||
// ownr_ln
|
||||
// ownr_fn
|
||||
// v_vin
|
||||
// v_make_desc
|
||||
// v_model_desc
|
||||
// v_type
|
||||
// ]
|
||||
// }
|
||||
|
||||
export const QUERY_ALL_JOBS_PAGINATED = gql`
|
||||
query QUERY_ALL_JOBS_PAGINATED(
|
||||
$offset: Int
|
||||
@@ -106,6 +91,7 @@ export const QUERY_JOB_BY_PK = gql`
|
||||
close_date
|
||||
joblines(order_by: { line_no: asc }) {
|
||||
id
|
||||
line_no
|
||||
act_price
|
||||
db_price
|
||||
line_desc
|
||||
@@ -116,6 +102,7 @@ export const QUERY_JOB_BY_PK = gql`
|
||||
unq_seq
|
||||
price_diff
|
||||
price_diff_pc
|
||||
ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user