IO-233 WIP CDK
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<babeledit_project be_version="2.7.1" version="1.2">
|
<babeledit_project version="1.2" be_version="2.7.1">
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
BabelEdit project file
|
BabelEdit project file
|
||||||
@@ -7550,6 +7550,32 @@
|
|||||||
<folder_node>
|
<folder_node>
|
||||||
<name>dms</name>
|
<name>dms</name>
|
||||||
<children>
|
<children>
|
||||||
|
<folder_node>
|
||||||
|
<name>cdk</name>
|
||||||
|
<children>
|
||||||
|
<concept_node>
|
||||||
|
<name>payers</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>
|
||||||
|
</children>
|
||||||
|
</folder_node>
|
||||||
<concept_node>
|
<concept_node>
|
||||||
<name>cdk_dealerid</name>
|
<name>cdk_dealerid</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
import { Button, Table } from "antd";
|
import { Button, Table, Typography } from "antd";
|
||||||
import React, { useState } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import Dinero from "dinero.js";
|
import Dinero from "dinero.js";
|
||||||
|
import { SyncOutlined } from "@ant-design/icons";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
//currentUser: selectCurrentUser
|
//currentUser: selectCurrentUser
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
mapDispatchToProps
|
mapDispatchToProps
|
||||||
@@ -20,6 +24,15 @@ export default connect(
|
|||||||
export function DmsAllocationsSummary({ socket, bodyshop, jobId }) {
|
export function DmsAllocationsSummary({ socket, bodyshop, jobId }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [allocationsSummary, setAllocationsSummary] = useState([]);
|
const [allocationsSummary, setAllocationsSummary] = useState([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (socket.connected) {
|
||||||
|
socket.emit("cdk-calculate-allocations", jobId, (ack) =>
|
||||||
|
setAllocationsSummary(ack)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, [socket, socket.connected, jobId]);
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: t("jobs.fields.dms.center"),
|
title: t("jobs.fields.dms.center"),
|
||||||
@@ -71,13 +84,45 @@ export function DmsAllocationsSummary({ socket, bodyshop, jobId }) {
|
|||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Get
|
<SyncOutlined />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
pagination={{ position: "top", defaultPageSize: 50 }}
|
pagination={{ position: "top", defaultPageSize: 50 }}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
rowKey="center"
|
rowKey="center"
|
||||||
dataSource={allocationsSummary}
|
dataSource={allocationsSummary}
|
||||||
|
summary={() => {
|
||||||
|
const totals = allocationsSummary.reduce(
|
||||||
|
(acc, val) => {
|
||||||
|
return {
|
||||||
|
totalSale: acc.totalSale.add(Dinero(val.sale)),
|
||||||
|
totalCost: acc.totalCost.add(Dinero(val.cost)),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
{
|
||||||
|
totalSale: Dinero(),
|
||||||
|
totalCost: Dinero(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Table.Summary.Row>
|
||||||
|
<Table.Summary.Cell>
|
||||||
|
<Typography.Title level={4}>
|
||||||
|
{t("general.labels.totals")}
|
||||||
|
</Typography.Title>
|
||||||
|
</Table.Summary.Cell>
|
||||||
|
<Table.Summary.Cell>
|
||||||
|
{totals.totalSale.toFormat()}
|
||||||
|
</Table.Summary.Cell>
|
||||||
|
<Table.Summary.Cell>
|
||||||
|
{totals.totalCost.toFormat()}
|
||||||
|
</Table.Summary.Cell>
|
||||||
|
<Table.Summary.Cell></Table.Summary.Cell>
|
||||||
|
<Table.Summary.Cell></Table.Summary.Cell>
|
||||||
|
</Table.Summary.Row>
|
||||||
|
);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
import { DeleteFilled } from "@ant-design/icons";
|
import { DeleteFilled } from "@ant-design/icons";
|
||||||
import { Button, Form, Input } from "antd";
|
import {
|
||||||
|
Button,
|
||||||
|
Form,
|
||||||
|
Input,
|
||||||
|
InputNumber,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
Statistic,
|
||||||
|
} from "antd";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -8,7 +16,8 @@ import { selectBodyshop } from "../../redux/user/user.selectors";
|
|||||||
import DmsCdkMakes from "../dms-cdk-makes/dms-cdk-makes.component";
|
import DmsCdkMakes from "../dms-cdk-makes/dms-cdk-makes.component";
|
||||||
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
|
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
|
||||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||||
|
import Dinero from "dinero.js";
|
||||||
|
import { determineDmsType } from "../../pages/dms/dms.container";
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
});
|
});
|
||||||
@@ -17,11 +26,38 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
});
|
});
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(DmsPostForm);
|
export default connect(mapStateToProps, mapDispatchToProps)(DmsPostForm);
|
||||||
|
|
||||||
export function DmsPostForm({ bodyshop, socket, jobId }) {
|
export function DmsPostForm({ bodyshop, socket, job }) {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const handlePayerSelect = (value, index) => {
|
||||||
|
form.setFieldsValue({
|
||||||
|
payers: form.getFieldValue("payers").map((payer, mapIndex) => {
|
||||||
|
if (index !== mapIndex) return payer;
|
||||||
|
const cdkPayer =
|
||||||
|
bodyshop.cdk_configuration.payers &&
|
||||||
|
bodyshop.cdk_configuration.payers.find((i) => i.name === value);
|
||||||
|
|
||||||
|
if (!cdkPayer) return payer;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...cdkPayer,
|
||||||
|
dms_acctnumber: cdkPayer.dms_acctnumber,
|
||||||
|
controlnumber: job && job[cdkPayer.control_type],
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleFinish = (values) => {
|
||||||
|
socket.emit(`${determineDmsType(bodyshop)}-export-job`, {
|
||||||
|
jobId: job.id,
|
||||||
|
...values,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form form={form} layout="vertical">
|
<Form form={form} layout="vertical" onFinish={handleFinish}>
|
||||||
<LayoutFormRow>
|
<LayoutFormRow>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="journal"
|
name="journal"
|
||||||
@@ -39,6 +75,32 @@ export function DmsPostForm({ bodyshop, socket, jobId }) {
|
|||||||
>
|
>
|
||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="kmin"
|
||||||
|
label={t("jobs.fields.kmin")}
|
||||||
|
initialValue={job && job.kmin}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<InputNumber disabled />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="kmout"
|
||||||
|
label={t("jobs.fields.kmout")}
|
||||||
|
initialValue={job && job.kmout}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<InputNumber disabled />
|
||||||
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="dms_make"
|
name="dms_make"
|
||||||
label={t("jobs.fields.dms.dms_make")}
|
label={t("jobs.fields.dms.dms_make")}
|
||||||
@@ -81,20 +143,30 @@ export function DmsPostForm({ bodyshop, socket, jobId }) {
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Input />
|
<Select
|
||||||
|
onSelect={(value) => handlePayerSelect(value, index)}
|
||||||
|
>
|
||||||
|
{bodyshop.cdk_configuration &&
|
||||||
|
bodyshop.cdk_configuration.payers &&
|
||||||
|
bodyshop.cdk_configuration.payers.map((payer) => (
|
||||||
|
<Select.Option key={payer.name}>
|
||||||
|
{payer.name}
|
||||||
|
</Select.Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("jobs.fields.dms.payer.account")}
|
label={t("jobs.fields.dms.payer.dms_acctnumber")}
|
||||||
key={`${index}account`}
|
key={`${index}dms_acctnumber`}
|
||||||
name={[field.name, "account"]}
|
name={[field.name, "dms_acctnumber"]}
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Input />
|
<Input disabled />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
@@ -107,8 +179,9 @@ export function DmsPostForm({ bodyshop, socket, jobId }) {
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<CurrencyInput />
|
<CurrencyInput min={0} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("jobs.fields.dms.payer.controlnumber")}
|
label={t("jobs.fields.dms.payer.controlnumber")}
|
||||||
key={`${index}controlnumber`}
|
key={`${index}controlnumber`}
|
||||||
@@ -122,6 +195,27 @@ export function DmsPostForm({ bodyshop, socket, jobId }) {
|
|||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item shouldUpdate>
|
||||||
|
{() => {
|
||||||
|
const payers = form.getFieldValue("payers");
|
||||||
|
|
||||||
|
const row = payers && payers[index];
|
||||||
|
|
||||||
|
const cdkPayer =
|
||||||
|
bodyshop.cdk_configuration.payers &&
|
||||||
|
bodyshop.cdk_configuration.payers.find(
|
||||||
|
(i) => i && row && i.name === row.name
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{cdkPayer &&
|
||||||
|
t(`jobs.fields.${cdkPayer.control_type}`)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
<DeleteFilled
|
<DeleteFilled
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
remove(field.name);
|
remove(field.name);
|
||||||
@@ -133,18 +227,58 @@ export function DmsPostForm({ bodyshop, socket, jobId }) {
|
|||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Button
|
<Button
|
||||||
type="dashed"
|
type="dashed"
|
||||||
|
disabled={!(fields.length < 3)}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
add();
|
if (fields.length < 3) add();
|
||||||
}}
|
}}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
>
|
>
|
||||||
{t("general.actions.add")}
|
{t("dms.actions.addpayer")}
|
||||||
</Button>
|
</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
</Form.List>
|
</Form.List>
|
||||||
|
<Form.Item shouldUpdate>
|
||||||
|
{() => {
|
||||||
|
//Perform Calculation to determine discrepancy.
|
||||||
|
let totalAllocated = Dinero();
|
||||||
|
|
||||||
|
const payers = form.getFieldValue("payers");
|
||||||
|
payers &&
|
||||||
|
payers.forEach((payer) => {
|
||||||
|
totalAllocated = totalAllocated.add(
|
||||||
|
Dinero({ amount: Math.round((payer?.amount || 0) * 100) })
|
||||||
|
);
|
||||||
|
});
|
||||||
|
const discrep = Dinero(job.job_totals.totals.total_repairs).subtract(
|
||||||
|
totalAllocated
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<Space>
|
||||||
|
<Statistic
|
||||||
|
title={t("jobs.labels.dms.totalallocated")}
|
||||||
|
value={totalAllocated.toFormat()}
|
||||||
|
/>
|
||||||
|
<Statistic
|
||||||
|
title={t("jobs.fields.subtotal")}
|
||||||
|
value={Dinero(job.job_totals.totals.total_repairs).toFormat()}
|
||||||
|
/>
|
||||||
|
<Statistic
|
||||||
|
title={t("jobs.labels.dms.notallocated")}
|
||||||
|
valueStyle={{
|
||||||
|
color: discrep.getAmount() === 0 ? "green" : "red",
|
||||||
|
}}
|
||||||
|
value={discrep.toFormat()}
|
||||||
|
/>
|
||||||
|
<Button disabled={discrep.getAmount() !== 0} htmlType="submit">
|
||||||
|
{t("jobs.actions.dms.post")}
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1725,6 +1725,8 @@ export const QUERY_JOB_CLOSE_DETAILS = gql`
|
|||||||
actual_delivery
|
actual_delivery
|
||||||
scheduled_in
|
scheduled_in
|
||||||
actual_in
|
actual_in
|
||||||
|
kmin
|
||||||
|
kmout
|
||||||
joblines(where: { removed: { _eq: false } }) {
|
joblines(where: { removed: { _eq: false } }) {
|
||||||
id
|
id
|
||||||
removed
|
removed
|
||||||
@@ -1877,98 +1879,15 @@ export const FIND_JOBS_BY_CLAIM = gql`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export const QUERY_JOB_EXPORT_DMS = gql`
|
export const QUERY_JOB_EXPORT_DMS = gql`
|
||||||
query QUERY_JOB_CLOSE_DETAILS($id: uuid!) {
|
query QUERY_JOB_EXPORT_DMS($id: uuid!) {
|
||||||
jobs_by_pk(id: $id) {
|
jobs_by_pk(id: $id) {
|
||||||
ro_number
|
|
||||||
invoice_allocation
|
|
||||||
ins_co_id
|
|
||||||
id
|
id
|
||||||
ded_amt
|
ro_number
|
||||||
ded_status
|
po_number
|
||||||
depreciation_taxes
|
clm_no
|
||||||
other_amount_payable
|
|
||||||
towing_payable
|
|
||||||
storage_payable
|
|
||||||
adjustment_bottom_line
|
|
||||||
federal_tax_rate
|
|
||||||
state_tax_rate
|
|
||||||
local_tax_rate
|
|
||||||
tax_tow_rt
|
|
||||||
tax_str_rt
|
|
||||||
tax_paint_mat_rt
|
|
||||||
tax_sub_rt
|
|
||||||
tax_lbr_rt
|
|
||||||
tax_levies_rt
|
|
||||||
parts_tax_rates
|
|
||||||
job_totals
|
job_totals
|
||||||
rate_la1
|
kmin
|
||||||
rate_la2
|
kmout
|
||||||
rate_la3
|
|
||||||
rate_la4
|
|
||||||
rate_laa
|
|
||||||
rate_lab
|
|
||||||
rate_lad
|
|
||||||
rate_lae
|
|
||||||
rate_laf
|
|
||||||
rate_lag
|
|
||||||
rate_lam
|
|
||||||
rate_lar
|
|
||||||
rate_las
|
|
||||||
rate_lau
|
|
||||||
rate_ma2s
|
|
||||||
rate_ma2t
|
|
||||||
rate_ma3s
|
|
||||||
rate_mabl
|
|
||||||
rate_macs
|
|
||||||
rate_mahw
|
|
||||||
rate_mapa
|
|
||||||
rate_mash
|
|
||||||
rate_matd
|
|
||||||
status
|
|
||||||
date_exported
|
|
||||||
date_invoiced
|
|
||||||
voided
|
|
||||||
scheduled_completion
|
|
||||||
actual_completion
|
|
||||||
scheduled_delivery
|
|
||||||
actual_delivery
|
|
||||||
scheduled_in
|
|
||||||
actual_in
|
|
||||||
bills {
|
|
||||||
id
|
|
||||||
federal_tax_rate
|
|
||||||
local_tax_rate
|
|
||||||
state_tax_rate
|
|
||||||
is_credit_memo
|
|
||||||
billlines {
|
|
||||||
actual_cost
|
|
||||||
cost_center
|
|
||||||
id
|
|
||||||
quantity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
joblines(where: { removed: { _eq: false } }) {
|
|
||||||
id
|
|
||||||
removed
|
|
||||||
tax_part
|
|
||||||
line_desc
|
|
||||||
prt_dsmk_p
|
|
||||||
prt_dsmk_m
|
|
||||||
part_type
|
|
||||||
oem_partno
|
|
||||||
db_price
|
|
||||||
act_price
|
|
||||||
part_qty
|
|
||||||
mod_lbr_ty
|
|
||||||
db_hrs
|
|
||||||
mod_lb_hrs
|
|
||||||
lbr_op
|
|
||||||
lbr_amt
|
|
||||||
op_code_desc
|
|
||||||
profitcenter_labor
|
|
||||||
profitcenter_part
|
|
||||||
prt_dsmk_p
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//import { useQuery } from "@apollo/client";
|
import { useQuery } from "@apollo/client";
|
||||||
import { Button, Col, Result, Row, Select, Space } from "antd";
|
import { Button, Col, Result, Row, Select, Space } from "antd";
|
||||||
import queryString from "query-string";
|
import queryString from "query-string";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
@@ -7,14 +7,14 @@ import { connect } from "react-redux";
|
|||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import SocketIO from "socket.io-client";
|
import SocketIO from "socket.io-client";
|
||||||
//import AlertComponent from "../../components/alert/alert.component";
|
import AlertComponent from "../../components/alert/alert.component";
|
||||||
import DmsAllocationsSummary from "../../components/dms-allocations-summary/dms-allocations-summary.component";
|
import DmsAllocationsSummary from "../../components/dms-allocations-summary/dms-allocations-summary.component";
|
||||||
import DmsCustomerSelector from "../../components/dms-customer-selector/dms-customer-selector.component";
|
import DmsCustomerSelector from "../../components/dms-customer-selector/dms-customer-selector.component";
|
||||||
import DmsLogEvents from "../../components/dms-log-events/dms-log-events.component";
|
import DmsLogEvents from "../../components/dms-log-events/dms-log-events.component";
|
||||||
import DmsPostForm from "../../components/dms-post-form/dms-post-form.component";
|
import DmsPostForm from "../../components/dms-post-form/dms-post-form.component";
|
||||||
//import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||||
import { auth } from "../../firebase/firebase.utils";
|
import { auth } from "../../firebase/firebase.utils";
|
||||||
//import { QUERY_JOB_EXPORT_DMS } from "../../graphql/jobs.queries";
|
import { QUERY_JOB_EXPORT_DMS } from "../../graphql/jobs.queries";
|
||||||
import {
|
import {
|
||||||
setBreadcrumbs,
|
setBreadcrumbs,
|
||||||
setSelectedHeader,
|
setSelectedHeader,
|
||||||
@@ -52,10 +52,10 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
|||||||
const search = queryString.parse(useLocation().search);
|
const search = queryString.parse(useLocation().search);
|
||||||
const { jobId } = search;
|
const { jobId } = search;
|
||||||
|
|
||||||
// const { loading, error } = useQuery(QUERY_JOB_EXPORT_DMS, {
|
const { loading, error, data } = useQuery(QUERY_JOB_EXPORT_DMS, {
|
||||||
// variables: { id: jobId },
|
variables: { id: jobId },
|
||||||
// skip: true, //!jobId,
|
skip: !jobId,
|
||||||
// });
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.title = t("titles.dms");
|
document.title = t("titles.dms");
|
||||||
@@ -73,7 +73,6 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
|||||||
console.log("Connected again.");
|
console.log("Connected again.");
|
||||||
});
|
});
|
||||||
socket.on("reconnect", () => {
|
socket.on("reconnect", () => {
|
||||||
console.log("Connected again.");
|
|
||||||
setLogs((logs) => {
|
setLogs((logs) => {
|
||||||
return [
|
return [
|
||||||
...logs,
|
...logs,
|
||||||
@@ -106,44 +105,38 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
|||||||
|
|
||||||
const dmsType = determineDmsType(bodyshop);
|
const dmsType = determineDmsType(bodyshop);
|
||||||
|
|
||||||
// if (loading) return <LoadingSpinner />;
|
if (loading) return <LoadingSpinner />;
|
||||||
// if (error) return <AlertComponent message={error.message} type="error" />;
|
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Space>
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
socket.emit(
|
|
||||||
`${dmsType}-export-job`,
|
|
||||||
"752a4f5f-22ab-414b-b182-98d4e62227ef"
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Export
|
|
||||||
</Button>
|
|
||||||
<Select
|
|
||||||
placeholder="Log Level"
|
|
||||||
value={logLevel}
|
|
||||||
onChange={(value) => {
|
|
||||||
setLogLevel(value);
|
|
||||||
socket.emit("set-log-level", value);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Select.Option key="TRACE">TRACE</Select.Option>
|
|
||||||
<Select.Option key="DEBUG">DEBUG</Select.Option>
|
|
||||||
<Select.Option key="INFO">INFO</Select.Option>
|
|
||||||
<Select.Option key="WARNING">WARNING</Select.Option>
|
|
||||||
<Select.Option key="ERROR">ERROR</Select.Option>
|
|
||||||
</Select>
|
|
||||||
<Button onClick={() => setLogs([])}>Clear Logs</Button>
|
|
||||||
</Space>
|
|
||||||
<Row gutter={32}>
|
<Row gutter={32}>
|
||||||
<Col span={18}>
|
<Col span={18}>
|
||||||
<DmsAllocationsSummary socket={socket} jobId={jobId} />
|
<DmsAllocationsSummary socket={socket} jobId={jobId} />
|
||||||
<DmsPostForm socket={socket} jobId={jobId} />
|
<DmsPostForm
|
||||||
|
socket={socket}
|
||||||
|
jobId={jobId}
|
||||||
|
job={data && data.jobs_by_pk}
|
||||||
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={6}>
|
<Col span={6}>
|
||||||
|
<Space>
|
||||||
|
<Select
|
||||||
|
placeholder="Log Level"
|
||||||
|
value={logLevel}
|
||||||
|
onChange={(value) => {
|
||||||
|
setLogLevel(value);
|
||||||
|
socket.emit("set-log-level", value);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Select.Option key="TRACE">TRACE</Select.Option>
|
||||||
|
<Select.Option key="DEBUG">DEBUG</Select.Option>
|
||||||
|
<Select.Option key="INFO">INFO</Select.Option>
|
||||||
|
<Select.Option key="WARNING">WARNING</Select.Option>
|
||||||
|
<Select.Option key="ERROR">ERROR</Select.Option>
|
||||||
|
</Select>
|
||||||
|
<Button onClick={() => setLogs([])}>Clear Logs</Button>
|
||||||
|
</Space>
|
||||||
<div style={{ maxHeight: "500px", overflowY: "auto" }}>
|
<div style={{ maxHeight: "500px", overflowY: "auto" }}>
|
||||||
<DmsLogEvents socket={socket} logs={logs} />
|
<DmsLogEvents socket={socket} logs={logs} />
|
||||||
</div>
|
</div>
|
||||||
@@ -155,7 +148,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const determineDmsType = (bodyshop) => {
|
export const determineDmsType = (bodyshop) => {
|
||||||
if (bodyshop.cdk_dealerid) return "cdk";
|
if (bodyshop.cdk_dealerid) return "cdk";
|
||||||
else {
|
else {
|
||||||
return "pbs";
|
return "pbs";
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
Alert,
|
Alert,
|
||||||
Divider,
|
Divider,
|
||||||
PageHeader,
|
PageHeader,
|
||||||
|
InputNumber,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -56,6 +57,8 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
|
|||||||
actual_in: values.actual_in,
|
actual_in: values.actual_in,
|
||||||
actual_completion: values.actual_completion,
|
actual_completion: values.actual_completion,
|
||||||
actual_delivery: values.actual_delivery,
|
actual_delivery: values.actual_delivery,
|
||||||
|
kmin: values.kmin,
|
||||||
|
kmout: values.kmout,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
refetchQueries: ["QUERY_JOB_CLOSE_DETAILS"],
|
refetchQueries: ["QUERY_JOB_CLOSE_DETAILS"],
|
||||||
@@ -112,6 +115,8 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
|
|||||||
actual_delivery: job.actual_delivery
|
actual_delivery: job.actual_delivery
|
||||||
? moment(job.actual_delivery)
|
? moment(job.actual_delivery)
|
||||||
: job.scheduled_delivery && moment(job.scheduled_delivery),
|
: job.scheduled_delivery && moment(job.scheduled_delivery),
|
||||||
|
kmin: job.kmin,
|
||||||
|
kmout: job.kmout,
|
||||||
}}
|
}}
|
||||||
scrollToFirstError
|
scrollToFirstError
|
||||||
>
|
>
|
||||||
@@ -203,6 +208,45 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
|
|||||||
>
|
>
|
||||||
<DateTimePicker disabled={jobRO} />
|
<DateTimePicker disabled={jobRO} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
{bodyshop.cdk_dealerid && (
|
||||||
|
<Form.Item
|
||||||
|
label={t("jobs.fields.kmin")}
|
||||||
|
name="kmin"
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<InputNumber />
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
|
{bodyshop.cdk_dealerid && (
|
||||||
|
<Form.Item
|
||||||
|
label={t("jobs.fields.kmout")}
|
||||||
|
name="kmout"
|
||||||
|
dependencies={["kmin"]}
|
||||||
|
hasFeedback
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
({ getFieldValue }) => ({
|
||||||
|
validator(_, value) {
|
||||||
|
if (!value || getFieldValue("kmin") <= value) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.reject(
|
||||||
|
new Error(t("jobs.labels.dms.kmoutnotgreaterthankmin"))
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<InputNumber />
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
</LayoutFormRow>
|
</LayoutFormRow>
|
||||||
<Divider />
|
<Divider />
|
||||||
<JobsCloseLines job={job} />
|
<JobsCloseLines job={job} />
|
||||||
|
|||||||
@@ -474,6 +474,9 @@
|
|||||||
"defaultprofitsmapping": "Default Profits Mapping",
|
"defaultprofitsmapping": "Default Profits Mapping",
|
||||||
"deliverchecklist": "Delivery Checklist",
|
"deliverchecklist": "Delivery Checklist",
|
||||||
"dms": {
|
"dms": {
|
||||||
|
"cdk": {
|
||||||
|
"payers": "CDK Payers"
|
||||||
|
},
|
||||||
"cdk_dealerid": "CDK Dealer ID",
|
"cdk_dealerid": "CDK Dealer ID",
|
||||||
"title": "DMS"
|
"title": "DMS"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -474,6 +474,9 @@
|
|||||||
"defaultprofitsmapping": "",
|
"defaultprofitsmapping": "",
|
||||||
"deliverchecklist": "",
|
"deliverchecklist": "",
|
||||||
"dms": {
|
"dms": {
|
||||||
|
"cdk": {
|
||||||
|
"payers": ""
|
||||||
|
},
|
||||||
"cdk_dealerid": "",
|
"cdk_dealerid": "",
|
||||||
"title": ""
|
"title": ""
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -474,6 +474,9 @@
|
|||||||
"defaultprofitsmapping": "",
|
"defaultprofitsmapping": "",
|
||||||
"deliverchecklist": "",
|
"deliverchecklist": "",
|
||||||
"dms": {
|
"dms": {
|
||||||
|
"cdk": {
|
||||||
|
"payers": ""
|
||||||
|
},
|
||||||
"cdk_dealerid": "",
|
"cdk_dealerid": "",
|
||||||
"title": ""
|
"title": ""
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ exports.default = async function (socket, jobid) {
|
|||||||
`Received Job export request for id ${jobid}`
|
`Received Job export request for id ${jobid}`
|
||||||
);
|
);
|
||||||
//The following values will be stored on the socket to allow callbacks.
|
//The following values will be stored on the socket to allow callbacks.
|
||||||
//let clVFV, clADPV, clADPC;
|
//let DMSVid, DMSVeh, clADPC;
|
||||||
const JobData = await QueryJobData(socket, jobid);
|
const JobData = await QueryJobData(socket, jobid);
|
||||||
const DealerId = JobData.bodyshop.cdk_dealerid;
|
const DealerId = JobData.bodyshop.cdk_dealerid;
|
||||||
CdkBase.createLogEvent(
|
CdkBase.createLogEvent(
|
||||||
@@ -33,18 +33,18 @@ exports.default = async function (socket, jobid) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
//{1} Begin Calculate DMS Vehicle Id
|
//{1} Begin Calculate DMS Vehicle Id
|
||||||
socket.clVFV = await CalculateDmsVid(socket, JobData);
|
socket.DMSVid = await CalculateDmsVid(socket, JobData);
|
||||||
if (socket.clVFV.newId === "Y") {
|
if (socket.DMSVid.newId === "Y") {
|
||||||
//{1.2} This is a new Vehicle ID
|
//{1.2} This is a new Vehicle ID
|
||||||
CdkBase.createLogEvent(
|
CdkBase.createLogEvent(
|
||||||
socket,
|
socket,
|
||||||
"DEBUG",
|
"DEBUG",
|
||||||
`{1.2} clVFV DMSVid does *not* exist.`
|
`{1.2} DMSVid DMSVid does *not* exist.`
|
||||||
);
|
);
|
||||||
CdkBase.createLogEvent(
|
CdkBase.createLogEvent(
|
||||||
socket,
|
socket,
|
||||||
"TRACE",
|
"TRACE",
|
||||||
`{1.2} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
|
`{1.2} DMSVid: ${JSON.stringify(socket.DMSVid, null, 2)}`
|
||||||
);
|
);
|
||||||
//Check if DMSCustId is Empty - which it should always be?
|
//Check if DMSCustId is Empty - which it should always be?
|
||||||
//{6.6} Should check to see if a customer exists so that we can marry it to the new vehicle.
|
//{6.6} Should check to see if a customer exists so that we can marry it to the new vehicle.
|
||||||
@@ -55,7 +55,7 @@ exports.default = async function (socket, jobid) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
//Array
|
//Array
|
||||||
const strIDS = await FindCustomerIdFromDms(socket, JobData);
|
const strIDS = await QueryDmsCustomerByName(socket, JobData);
|
||||||
if (strIDS && strIDS.length > 0) {
|
if (strIDS && strIDS.length > 0) {
|
||||||
CdkBase.createLogEvent(
|
CdkBase.createLogEvent(
|
||||||
socket,
|
socket,
|
||||||
@@ -120,18 +120,22 @@ exports.default = async function (socket, jobid) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CdkBase.createLogEvent(socket, "DEBUG", `{1.1} clVFV DMSVid does exist.`);
|
CdkBase.createLogEvent(
|
||||||
|
socket,
|
||||||
|
"DEBUG",
|
||||||
|
`{1.1} DMSVid DMSVid does exist.`
|
||||||
|
);
|
||||||
CdkBase.createLogEvent(
|
CdkBase.createLogEvent(
|
||||||
socket,
|
socket,
|
||||||
"TRACE",
|
"TRACE",
|
||||||
`{1.1} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
|
`{1.1} DMSVid: ${JSON.stringify(socket.DMSVid, null, 2)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
//{2} Begin Find Vehicle in DMS
|
//{2} Begin Find Vehicle in DMS
|
||||||
socket.clADPV = await FindVehicleInDms(socket, JobData, socket.clVFV); //TODO: Verify that this should always return a result. If an ID was found previously, it should be correct?
|
socket.DMSVeh = await QueryDmsVehicleById(socket, JobData, socket.DMSVid); //TODO: Verify that this should always return a result. If an ID was found previously, it should be correct?
|
||||||
|
|
||||||
//{2.2} Check if the vehicle was found in the DMS.
|
//{2.2} Check if the vehicle was found in the DMS.
|
||||||
if (socket.clADPV.AppErrorNo === "0") {
|
if (socket.DMSVeh.AppErrorNo === "0") {
|
||||||
//Vehicle was found.
|
//Vehicle was found.
|
||||||
CdkBase.createLogEvent(
|
CdkBase.createLogEvent(
|
||||||
socket,
|
socket,
|
||||||
@@ -141,7 +145,7 @@ exports.default = async function (socket, jobid) {
|
|||||||
CdkBase.createLogEvent(
|
CdkBase.createLogEvent(
|
||||||
socket,
|
socket,
|
||||||
"TRACE",
|
"TRACE",
|
||||||
`{1.4} clADPV: ${JSON.stringify(socket.clADPV, null, 2)}`
|
`{1.4} DMSVeh: ${JSON.stringify(socket.DMSVeh, null, 2)}`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
//Vehicle was not found.
|
//Vehicle was not found.
|
||||||
@@ -153,7 +157,7 @@ exports.default = async function (socket, jobid) {
|
|||||||
CdkBase.createLogEvent(
|
CdkBase.createLogEvent(
|
||||||
socket,
|
socket,
|
||||||
"TRACE",
|
"TRACE",
|
||||||
`{6.4} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
|
`{6.4} DMSVid: ${JSON.stringify(socket.DMSVid, null, 2)}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -308,7 +312,7 @@ async function GenerateCustomerNumberFromDms(socket, JobData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function FindCustomerIdFromDms(socket, JobData) {
|
async function QueryDmsCustomerByName(socket, JobData) {
|
||||||
const ownerName = `${JobData.ownr_ln},${JobData.ownr_fn}`;
|
const ownerName = `${JobData.ownr_ln},${JobData.ownr_fn}`;
|
||||||
CdkBase.createLogEvent(
|
CdkBase.createLogEvent(
|
||||||
socket,
|
socket,
|
||||||
@@ -352,23 +356,24 @@ async function FindCustomerIdFromDms(socket, JobData) {
|
|||||||
CdkBase.createLogEvent(
|
CdkBase.createLogEvent(
|
||||||
socket,
|
socket,
|
||||||
"ERROR",
|
"ERROR",
|
||||||
`Error in FindCustomerIdFromDms - ${JSON.stringify(error, null, 2)}`
|
`Error in QueryDmsCustomerByName - ${JSON.stringify(error, null, 2)}`
|
||||||
);
|
);
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function FindVehicleInDms(socket, JobData, clVFV) {
|
async function QueryDmsVehicleById(socket, JobData, DMSVid) {
|
||||||
CdkBase.createLogEvent(
|
CdkBase.createLogEvent(
|
||||||
socket,
|
socket,
|
||||||
"DEBUG",
|
"DEBUG",
|
||||||
`{2}/{6} Begin Find Vehicle In DMS using clVFV: ${clVFV}`
|
`{2}/{6} Begin Find Vehicle In DMS using DMSVid: ${DMSVid}`
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const soapClientVehicleInsertUpdate = await soap.createClientAsync(
|
const soapClientVehicleInsertUpdate = await soap.createClientAsync(
|
||||||
CdkWsdl.VehicleInsertUpdate
|
CdkWsdl.VehicleInsertUpdate
|
||||||
);
|
);
|
||||||
|
|
||||||
const soapResponseVehicleInsertUpdate =
|
const soapResponseVehicleInsertUpdate =
|
||||||
await soapClientVehicleInsertUpdate.readBulkAsync(
|
await soapClientVehicleInsertUpdate.readBulkAsync(
|
||||||
{
|
{
|
||||||
@@ -376,7 +381,7 @@ async function FindVehicleInDms(socket, JobData, clVFV) {
|
|||||||
arg1: { id: JobData.bodyshop.cdk_dealerid },
|
arg1: { id: JobData.bodyshop.cdk_dealerid },
|
||||||
arg2: {
|
arg2: {
|
||||||
fileType: "VEHICLES",
|
fileType: "VEHICLES",
|
||||||
vehiclesVehicleId: clVFV.vehiclesVehId,
|
vehiclesVehicleId: DMSVid.vehiclesVehId,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -401,7 +406,7 @@ async function FindVehicleInDms(socket, JobData, clVFV) {
|
|||||||
CdkBase.createLogEvent(
|
CdkBase.createLogEvent(
|
||||||
socket,
|
socket,
|
||||||
"ERROR",
|
"ERROR",
|
||||||
`Error in FindVehicleInDms - ${JSON.stringify(error, null, 2)}`
|
`Error in QueryDmsVehicleById - ${JSON.stringify(error, null, 2)}`
|
||||||
);
|
);
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user