IO-233 CDK updates.

This commit is contained in:
Patrick Fic
2021-12-02 10:50:11 -08:00
parent a77e664ab1
commit 39ec9d92ec
23 changed files with 688 additions and 201 deletions

View File

@@ -14,6 +14,7 @@ import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import CiecaSelect, { GetPartTypeName } from "../../utils/Ciecaselect";
import BillLineSearchSelect from "../bill-line-search-select/bill-line-search-select.component";
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
@@ -72,11 +73,13 @@ export function BillEnterModalLinesComponent({
quantity: opt.part_qty || 1,
actual_price: opt.cost,
cost_center: opt.part_type
? responsibilityCenters.defaults &&
(responsibilityCenters.defaults.costs[
opt.part_type
] ||
null)
? bodyshop.pbs_serialnumber || bodyshop.cdk_dealerid
? GetPartTypeName(opt.part_type)
: responsibilityCenters.defaults &&
(responsibilityCenters.defaults.costs[
opt.part_type
] ||
null)
: null,
};
}
@@ -224,6 +227,7 @@ export function BillEnterModalLinesComponent({
key: `${field.index}cost_center`,
name: [field.name, "cost_center"],
label: t("billlines.fields.cost_center"),
valuePropName: "value",
rules: [
{
required: true,
@@ -233,10 +237,12 @@ export function BillEnterModalLinesComponent({
};
},
formInput: (record, index) => (
<Select style={{ minWidth: "3rem" }} disabled={disabled}>
{responsibilityCenters.costs.map((item) => (
<Select.Option key={item.name}>{item.name}</Select.Option>
))}
<Select showSearch style={{ minWidth: "3rem" }} disabled={disabled}>
{bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
? CiecaSelect(true, false)
: responsibilityCenters.costs.map((item) => (
<Select.Option key={item.name}>{item.name}</Select.Option>
))}
</Select>
),
},

View File

@@ -95,6 +95,7 @@ export function DmsAllocationsSummary({ socket, bodyshop, jobId, title }) {
columns={columns}
rowKey="center"
dataSource={allocationsSummary}
locale={{ emptyText: t("dms.labels.refreshallocations") }}
summary={() => {
const totals = allocationsSummary.reduce(
(acc, val) => {

View File

@@ -221,7 +221,47 @@ export function DmsPostForm({ bodyshop, socket, job }) {
</Form.Item>
<Form.Item
label={t("jobs.fields.dms.payer.controlnumber")}
label={
<div>
{t("jobs.fields.dms.payer.controlnumber")}{" "}
<Dropdown
overlay={
<Menu>
{bodyshop.cdk_configuration.controllist &&
bodyshop.cdk_configuration.controllist.map(
(key, idx) => (
<Menu.Item
key={idx}
onClick={() => {
form.setFieldsValue({
payers: form
.getFieldValue("payers")
.map((row, mapIndex) => {
if (index !== mapIndex)
return row;
return {
...row,
controlnumber:
key.controlnumber,
};
}),
});
}}
>
{key.name}
</Menu.Item>
)
)}
</Menu>
}
>
<a href=" #" onClick={(e) => e.preventDefault()}>
<DownOutlined />
</a>
</Dropdown>
</div>
}
key={`${index}controlnumber`}
name={[field.name, "controlnumber"]}
rules={[
@@ -254,42 +294,6 @@ export function DmsPostForm({ bodyshop, socket, job }) {
}}
</Form.Item>
<Dropdown
overlay={
<Menu>
{bodyshop.cdk_configuration.controllist &&
bodyshop.cdk_configuration.controllist.map(
(key, idx) => (
<Menu.Item
key={idx}
onClick={() => {
form.setFieldsValue({
payers: form
.getFieldValue("payers")
.map((row, mapIndex) => {
if (index !== mapIndex) return row;
return {
...row,
controlnumber: key.controlnumber,
};
}),
});
}}
>
{key.name}
</Menu.Item>
)
)}
</Menu>
}
>
<a href=" #" onClick={(e) => e.preventDefault()}>
{t("bodyshop.labels.dms.cdk.controllist")}{" "}
<DownOutlined />
</a>
</Dropdown>
<DeleteFilled
onClick={() => {
remove(field.name);

View File

@@ -54,6 +54,7 @@ export function JobsCloseAutoAllocate({ bodyshop, joblines, form, disabled }) {
const handleMenuClick = ({ item, key, keyPath, domEvent }) => {
logImEXEvent("jobs_close_allocate_auto_dms");
form.setFieldsValue({ dms_allocation: key });
handleAllocate(
bodyshop.md_responsibility_centers.dms_defaults.find(
(x) => x.name === key
@@ -64,7 +65,9 @@ export function JobsCloseAutoAllocate({ bodyshop, joblines, form, disabled }) {
const overlay = (bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && (
<Menu onClick={handleMenuClick}>
{bodyshop.md_responsibility_centers.dms_defaults.map((mapping) => (
<Menu.Item key={mapping.name}>{mapping.name}</Menu.Item>
<Menu.Item disabled={disabled} key={mapping.name}>
{mapping.name}
</Menu.Item>
))}
</Menu>
);

View File

@@ -38,12 +38,7 @@ export function LaborAllocationsTable({
useEffect(() => {
if (!!joblines && !!timetickets && !!bodyshop);
setTotals(
CalculateAllocationsTotals(
bodyshop.md_responsibility_centers,
joblines,
timetickets,
adjustments
)
CalculateAllocationsTotals(bodyshop, joblines, timetickets, adjustments)
);
if (!jobId) setTotals([]);
}, [joblines, timetickets, bodyshop, adjustments, jobId]);

View File

@@ -1,9 +1,12 @@
import i18next from "i18next";
export const CalculateAllocationsTotals = (
responsibilitycenters,
bodyshop,
joblines,
timetickets,
adjustments = []
) => {
const responsibilitycenters = bodyshop.md_responsibility_centers;
const jobCodes = joblines.map((item) => item.mod_lbr_ty);
//.filter((value, index, self) => self.indexOf(value) === index && !!value);
const ticketCodes = timetickets.map((item) => item.ciecacode);
@@ -15,7 +18,12 @@ export const CalculateAllocationsTotals = (
const r = allCodes.reduce((acc, value) => {
const r = {
opcode: value,
cost_center: responsibilitycenters.defaults.costs[value],
cost_center:
bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
? i18next.t(
`joblines.fields.lbr_types.${value && value.toUpperCase()}`
)
: responsibilitycenters.defaults.costs[value],
mod_lbr_ty: value,
total: joblines.reduce((acc2, val2) => {
return val2.mod_lbr_ty === value ? acc2 + val2.mod_lb_hrs : acc2;

View File

@@ -23,6 +23,7 @@ import { DELETE_PARTS_ORDER } from "../../graphql/parts-orders.queries";
import { selectJobReadOnly } from "../../redux/application/application.selectors";
import { setModalContext } from "../../redux/modals/modals.actions";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { GetPartTypeName } from "../../utils/Ciecaselect";
import CurrencyFormatter from "../../utils/CurrencyFormatter";
import { DateFormatter } from "../../utils/DateFormatter";
import { alphaSort } from "../../utils/sorters";
@@ -165,10 +166,15 @@ export function PartsOrderListTableComponent({
quantity: pol.quantity,
actual_price: pol.act_price,
cost_center: pol.jobline?.part_type
? responsibilityCenters.defaults.costs[
pol.jobline.part_type
] || null
? bodyshop.pbs_serialnumber || bodyshop.cdk_dealerid
? GetPartTypeName(pol.jobline.part_type)
: responsibilityCenters.defaults &&
(responsibilityCenters.defaults.costs[
pol.jobline.part_type
] ||
null)
: null,
};
}),

View File

@@ -14,6 +14,7 @@ import { selectBodyshop } from "../../redux/user/user.selectors";
import FormDatePicker from "../form-date-picker/form-date-picker.component";
import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component";
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
import CiecaSelect from "../../utils/Ciecaselect";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
@@ -218,6 +219,7 @@ export function ShopEmployeesFormComponent({
label={t("employees.fields.cost_center")}
key={`${index}`}
name={[field.name, "cost_center"]}
valuePropName="value"
rules={[
{
required: true,
@@ -232,11 +234,16 @@ export function ShopEmployeesFormComponent({
>
{t("timetickets.labels.shift")}
</Select.Option>
{bodyshop.md_responsibility_centers.costs.map((c) => (
<Select.Option key={c.name} value={c.name}>
{c.name}
</Select.Option>
))}
{bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
? CiecaSelect(false, true)
: bodyshop.md_responsibility_centers.costs.map(
(c) => (
<Select.Option key={c.name} value={c.name}>
{c.name}
</Select.Option>
)
)}
</Select>
</Form.Item>
<Form.Item

View File

@@ -47,9 +47,13 @@ export function TimeTicketModalComponent({
>
{emps &&
emps.rates.map((item) => (
<Select.Option key={item.cost_center}>
<Select.Option key={item.cost_center} value={item.cost_center}>
{item.cost_center === "timetickets.labels.shift"
? t(item.cost_center)
: bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
? t(
`joblines.fields.lbr_types.${item.cost_center.toUpperCase()}`
)
: item.cost_center}
</Select.Option>
))}
@@ -137,6 +141,7 @@ export function TimeTicketModalComponent({
<Form.Item
name="cost_center"
label={t("timetickets.fields.cost_center")}
valuePropName="value"
rules={[
{
required: true,

View File

@@ -143,13 +143,16 @@ export function TimeTicketModalContainer({
}
if (!!changedFields.cost_center && !!EmployeeAutoCompleteData) {
form.setFieldsValue({
ciecacode: Object.keys(
bodyshop.md_responsibility_centers.defaults.costs
).find(
(key) =>
bodyshop.md_responsibility_centers.defaults.costs[key] ===
changedFields.cost_center
),
ciecacode:
bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
? changedFields.cost_center
: Object.keys(
bodyshop.md_responsibility_centers.defaults.costs
).find(
(key) =>
bodyshop.md_responsibility_centers.defaults.costs[key] ===
changedFields.cost_center
),
});
}
};