IO-2217 Part Price Changes for CCC.

This commit is contained in:
Patrick Fic
2023-03-20 14:10:06 -07:00
parent 4e2ad3bc62
commit 0ec099cdf5
11 changed files with 163 additions and 20 deletions

View File

@@ -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
@@ -26425,6 +26425,27 @@
<folder_node>
<name>labels</name>
<children>
<concept_node>
<name>act_price_ppc</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>actual_completion_inferred</name>
<definition_loaded>false</definition_loaded>
@@ -29059,6 +29080,27 @@
</concept_node>
</children>
</folder_node>
<concept_node>
<name>ppc</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>profileadjustments</name>
<definition_loaded>false</definition_loaded>

View File

@@ -0,0 +1,97 @@
import { useMutation } from "@apollo/client";
import { Button, Form, notification, Popover, Tooltip } from "antd";
import { t } from "i18next";
import React, { useState } from "react";
import { UPDATE_LINE_PPC } from "../../graphql/jobs-lines.queries";
import CurrencyFormatter from "../../utils/CurrencyFormatter";
import CurrencyFormItemComponent from "../form-items-formatted/currency-form-item.component";
import JobLineConvertToLabor from "../job-line-convert-to-labor/job-line-convert-to-labor.component";
import axios from "axios";
export default function JobLinesPartPriceChange({ job, line, refetch }) {
const [loading, setLoading] = useState(false);
const [updatePartPrice] = useMutation(UPDATE_LINE_PPC);
const handleFinish = async (values) => {
try {
setLoading(true);
const result = await updatePartPrice({
variables: {
id: line.id,
jobline: {
act_price_before_ppc: line.act_price_before_ppc
? line.act_price_before_ppc
: line.act_price,
act_price: values.act_price,
},
},
});
await axios.post("/job/totalsssu", {
id: job.id,
});
if (result.errors) {
notification.open({
type: "error",
message: t("joblines.errors.saving", {
error: JSON.stringify(result.errors),
}),
});
if (refetch) refetch();
} else {
notification.open({
type: "success",
message: t("joblines.successes.saved"),
});
}
} catch (error) {
notification.open({
type: "error",
message: t("joblines.errors.saving", { error: JSON.stringify(error) }),
});
} finally {
setLoading(false);
}
};
const popcontent = (
<Form layout="vertical" onFinish={handleFinish} initialValues={{ act_price: line.act_price }}>
<Form.Item
name="act_price"
label={t("jobs.labels.act_price_ppc")}
rules={[{ required: true }]}
>
<CurrencyFormItemComponent />
</Form.Item>
<Button loading={loading} htmlType="primary">
{t("general.actions.save")}
</Button>
</Form>
);
return (
<JobLineConvertToLabor jobline={line} job={job}>
<Popover trigger="click" disabled={line.manual_line} content={popcontent}>
<CurrencyFormatter>
{line.db_ref === "900510" || line.db_ref === "900511"
? line.prt_dsmk_m
: line.act_price}
</CurrencyFormatter>
{line.prt_dsmk_p && line.prt_dsmk_p !== 0 ? (
<span style={{ marginLeft: ".2rem" }}>{`(${line.prt_dsmk_p}%)`}</span>
) : (
<></>
)}
{line.act_price_before_ppc && line.act_price_before_ppc !== 0 ? (
<Tooltip title={t("jobs.labels.ppc")}>
<span style={{ marginLeft: ".2rem", color: "tomato" }}>
(
<CurrencyFormatter>{line.act_price_before_ppc}</CurrencyFormatter>
)
</span>
</Tooltip>
) : (
<></>
)}
</Popover>
</JobLineConvertToLabor>
);
}

View File

@@ -29,7 +29,6 @@ import { selectJobReadOnly } from "../../redux/application/application.selectors
import { setModalContext } from "../../redux/modals/modals.actions";
import { selectTechnician } from "../../redux/tech/tech.selectors";
import { onlyUnique } from "../../utils/arrayHelper";
import CurrencyFormatter from "../../utils/CurrencyFormatter";
import { alphaSort } from "../../utils/sorters";
import JobLineLocationPopup from "../job-line-location-popup/job-line-location-popup.component";
import JobLineNotePopup from "../job-line-note-popup/job-line-note-popup.component";
@@ -42,10 +41,10 @@ import _ from "lodash";
import moment from "moment";
import { selectBodyshop } from "../../redux/user/user.selectors";
import JobCreateIOU from "../job-create-iou/job-create-iou.component";
import JobLineConvertToLabor from "../job-line-convert-to-labor/job-line-convert-to-labor.component";
import JobSendPartPriceChangeComponent from "../job-send-parts-price-change/job-send-parts-price-change.component";
import PartsOrderModalContainer from "../parts-order-modal/parts-order-modal.container";
import JobLinesExpander from "./job-lines-expander.component";
import JobLinesPartPriceChange from "./job-lines-part-price-change.component";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
@@ -218,20 +217,7 @@ export function JobLinesComponent({
state.sortedInfo.columnKey === "act_price" && state.sortedInfo.order,
ellipsis: true,
render: (text, record) => (
<JobLineConvertToLabor jobline={record} job={job}>
<CurrencyFormatter>
{record.db_ref === "900510" || record.db_ref === "900511"
? record.prt_dsmk_m
: record.act_price}
</CurrencyFormatter>
{record.prt_dsmk_p && record.prt_dsmk_p !== 0 ? (
<span
style={{ marginLeft: ".2rem" }}
>{`(${record.prt_dsmk_p}%)`}</span>
) : (
<></>
)}
</JobLineConvertToLabor>
<JobLinesPartPriceChange line={record} job={job} refetch={refetch} />
),
},
{

View File

@@ -10,7 +10,7 @@ export default function JobSendPartPriceChangeComponent({ job }) {
setLoading(true);
try {
const ppcData = await axios.post("/job/ppc", { jobid: job.id });
const result = axios.post("http://localhost:1337/ppc/", ppcData.data);
await axios.post("http://localhost:1337/ppc/", ppcData.data);
} catch (error) {
notification.open({
type: "error",

View File

@@ -25,7 +25,7 @@ export const GetSupplementDelta = async (client, jobId, newLines) => {
//Found a relevant matching line. Add it to lines to update.
linesToUpdate.push({
id: existingLines[matchingIndex].id,
newData: { ...newLine, removed: false },
newData: { ...newLine, removed: false, act_price_before_ppc: null },
});
//Splice out item we found for performance.

View File

@@ -275,3 +275,14 @@ export const UPDATE_JOB_LINES_IOU = gql`
}
}
`;
export const UPDATE_LINE_PPC = gql`
mutation UPDATE_LINE_PPC($id: uuid!, $jobline: joblines_set_input) {
update_joblines_by_pk(pk_columns: { id: $id }, _set: $jobline) {
jobid
id
act_price_before_ppc
act_price
}
}
`;

View File

@@ -721,6 +721,7 @@ export const GET_JOB_BY_PK = gql`
ioucreated
convertedtolbr
ah_detail_line
act_price_before_ppc
billlines(limit: 1, order_by: { bill: { date: desc } }) {
id
quantity

View File

@@ -1564,6 +1564,7 @@
"scheddates": "Schedule Dates"
},
"labels": {
"act_price_ppc": "New Part Price",
"actual_completion_inferred": "$t(jobs.fields.actual_completion) inferred using $t(jobs.fields.scheduled_completion).",
"actual_delivery_inferred": "$t(jobs.fields.actual_delivery) inferred using $t(jobs.fields.scheduled_delivery).",
"actual_in_inferred": "$t(jobs.fields.actual_in) inferred using $t(jobs.fields.scheduled_in).",
@@ -1700,6 +1701,7 @@
"partstotal": "This is the total of all parts and sublet amounts on the vehicle (some of these may require an in-house invoice).<br/>\nItems such as shop and paint materials, labor online lines, etc. are not included in this total.",
"totalreturns": "The total <b>retail</b> amount of returns created for this job."
},
"ppc": "This line contains a part price change.",
"profileadjustments": "Profile Disc./Mkup (Already included above)",
"prt_dsmk_total": "Line Item Adjustment",
"rates": "Rates",

View File

@@ -1564,6 +1564,7 @@
"scheddates": ""
},
"labels": {
"act_price_ppc": "",
"actual_completion_inferred": "",
"actual_delivery_inferred": "",
"actual_in_inferred": "",
@@ -1700,6 +1701,7 @@
"partstotal": "",
"totalreturns": ""
},
"ppc": "",
"profileadjustments": "",
"prt_dsmk_total": "",
"rates": "Tarifas",

View File

@@ -1564,6 +1564,7 @@
"scheddates": ""
},
"labels": {
"act_price_ppc": "",
"actual_completion_inferred": "",
"actual_delivery_inferred": "",
"actual_in_inferred": "",
@@ -1700,6 +1701,7 @@
"partstotal": "",
"totalreturns": ""
},
"ppc": "",
"profileadjustments": "",
"prt_dsmk_total": "",
"rates": "Les taux",

View File

@@ -1724,7 +1724,7 @@ exports.GET_JOB_FOR_PPC = `query GET_JOB_FOR_PPC($jobid: uuid!) {
id
ciecaid
ro_number
joblines(where: {removed: {_eq: false}}) {
joblines(where: {removed: {_eq: false}, act_price_before_ppc:{_is_null: false}}) {
id
act_price
unq_seq