diff --git a/client/src/components/bill-form-lines-extended/bill-form-lines-extended.component.jsx b/client/src/components/bill-form-lines-extended/bill-form-lines-extended.component.jsx new file mode 100644 index 000000000..ad356cae0 --- /dev/null +++ b/client/src/components/bill-form-lines-extended/bill-form-lines-extended.component.jsx @@ -0,0 +1,135 @@ +import { Form, Input, Table } from "antd"; +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; +import CurrencyFormatter from "../../utils/CurrencyFormatter"; +import { alphaSort } from "../../utils/sorters"; +import BillFormItemsExtendedFormItem from "./bill-form-lines.extended.formitem.component"; +export default function BillFormLinesExtended({ + lineData, + discount, + form, + responsibilityCenters, + disabled, +}) { + const [search, setSearch] = useState(""); + const { t } = useTranslation(); + const columns = [ + { + title: t("joblines.fields.line_desc"), + dataIndex: "line_desc", + key: "line_desc", + width: "10%", + sorter: (a, b) => alphaSort(a.line_desc, b.line_desc), + }, + { + title: t("joblines.fields.oem_partno"), + dataIndex: "oem_partno", + key: "oem_partno", + width: "10%", + sorter: (a, b) => alphaSort(a.oem_partno, b.oem_partno), + }, + { + title: t("joblines.fields.part_type"), + dataIndex: "part_type", + key: "part_type", + width: "10%", + filters: [ + { + text: t("jobs.labels.partsfilter"), + value: ["PAN", "PAP", "PAL", "PAA", "PAS", "PASL"], + }, + { + text: t("joblines.fields.part_types.PAN"), + value: ["PAN", "PAP"], + }, + { + text: t("joblines.fields.part_types.PAL"), + value: ["PAL"], + }, + { + text: t("joblines.fields.part_types.PAA"), + value: ["PAA"], + }, + { + text: t("joblines.fields.part_types.PAS"), + value: ["PAS", "PASL"], + }, + ], + onFilter: (value, record) => value.includes(record.part_type), + render: (text, record) => + record.part_type + ? t(`joblines.fields.part_types.${record.part_type}`) + : null, + }, + + { + title: t("joblines.fields.act_price"), + dataIndex: "act_price", + key: "act_price", + width: "10%", + sorter: (a, b) => a.act_price - b.act_price, + shouldCellUpdate: false, + render: (text, record) => ( + <> + + {record.db_ref === "900510" || record.db_ref === "900511" + ? record.prt_dsmk_m + : record.act_price} + + {record.part_qty ? `(x ${record.part_qty})` : null} + {record.prt_dsmk_p && record.prt_dsmk_p !== 0 ? ( + {`(${record.prt_dsmk_p}%)`} + ) : ( + <> + )} + + ), + }, + { + title: t("billlines.fields.posting"), + dataIndex: "posting", + key: "posting", + + render: (text, record, index) => ( + + + + ), + }, + ]; + + const data = + search === "" + ? lineData + : lineData.filter( + (l) => + (l.line_desc && + l.line_desc.toLowerCase().includes(search.toLowerCase())) || + (l.oem_partno && + l.oem_partno.toLowerCase().includes(search.toLowerCase())) || + (l.act_price && + l.act_price.toString().startsWith(search.toString())) + ); + + return ( + + + setSearch(e.target.value)} allowClear /> + + + ); +} diff --git a/client/src/components/bill-form-lines-extended/bill-form-lines.extended.formitem.component.jsx b/client/src/components/bill-form-lines-extended/bill-form-lines.extended.formitem.component.jsx new file mode 100644 index 000000000..32824e50e --- /dev/null +++ b/client/src/components/bill-form-lines-extended/bill-form-lines.extended.formitem.component.jsx @@ -0,0 +1,288 @@ +import React from "react"; +import { + PlusCircleFilled, + MinusCircleFilled, + WarningOutlined, +} from "@ant-design/icons"; +import { Form, Button, InputNumber, Input, Select, Switch, Space } from "antd"; +import { useTranslation } from "react-i18next"; + +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +import CurrencyInput from "../form-items-formatted/currency-form-item.component"; +import CiecaSelect from "../../utils/Ciecaselect"; + +const mapStateToProps = createStructuredSelector({ + bodyshop: selectBodyshop, +}); +const mapDispatchToProps = (dispatch) => ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) +}); +export default connect( + mapStateToProps, + mapDispatchToProps +)(BillFormItemsExtendedFormItem); + +export function BillFormItemsExtendedFormItem({ + value, + bodyshop, + form, + record, + index, + disabled, + responsibilityCenters, + discount, +}) { + // const { billlineskeys } = form.getFieldsValue("billlineskeys"); + + const { t } = useTranslation(); + if (!value) + return ( + + ); + + return ( + + + + + + + + + { + const { billlineskeys } = form.getFieldsValue("billlineskeys"); + form.setFieldsValue({ + billlineskeys: { + ...billlineskeys, + [record.id]: { + ...billlineskeys[billlineskeys], + actual_cost: !!billlineskeys[billlineskeys].actual_cost + ? billlineskeys[billlineskeys].actual_cost + : Math.round( + (parseFloat(e.target.value) * (1 - discount) + + Number.EPSILON) * + 100 + ) / 100, + }, + }, + }); + }} + /> + + + + + + {() => { + const line = value; + if (!!!line) return null; + const lineDiscount = ( + 1 - + Math.round((line.actual_cost / line.actual_price) * 100) / 100 + ).toPrecision(2); + + if (lineDiscount - discount === 0) return
; + return ; + }} + + + + + + + + + + + + {() => { + if ( + form.getFieldsValue("billlineskeys").billlineskeys[record.id] + .deductedfromlbr + ) + return ( +
+ + + + + + +
+ ); + return <>; + }} +
+ + + + + + + + + + + + + + ); +} diff --git a/client/src/components/bill-form/bill-form.component.jsx b/client/src/components/bill-form/bill-form.component.jsx index 60e48509a..c6a979d56 100644 --- a/client/src/components/bill-form/bill-form.component.jsx +++ b/client/src/components/bill-form/bill-form.component.jsx @@ -28,6 +28,8 @@ import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component"; import BillFormLines from "./bill-form.lines.component"; import { CalculateBillTotal } from "./bill-form.totals.utility"; +import { useTreatments } from "@splitsoftware/splitio-react"; +import BillFormLinesExtended from "../bill-form-lines-extended/bill-form-lines-extended.component"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -49,7 +51,11 @@ export function BillFormComponent({ const { t } = useTranslation(); const client = useApolloClient(); const [discount, setDiscount] = useState(0); - + const { Extended_Bill_Posting } = useTreatments( + ["Extended_Bill_Posting"], + {}, + bodyshop.imexshopid + ); const handleVendorSelect = (props, opt) => { setDiscount(opt.discount); }; @@ -357,13 +363,24 @@ export function BillFormComponent({ {t("bills.labels.bill_lines")} - + + {Extended_Bill_Posting.treatment === "on" ? ( + + ) : ( + + )}