Compare commits
14 Commits
feature/IO
...
feature/IO
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5310866302 | ||
|
|
e3ab229ac5 | ||
|
|
4a7bb07345 | ||
|
|
01fec9fa79 | ||
|
|
2f88d613c3 | ||
|
|
c9467b3982 | ||
|
|
ca4c48bd5c | ||
|
|
e5fd5c8bcb | ||
|
|
46945a24a7 | ||
|
|
be746500a6 | ||
|
|
71c6d9fa94 | ||
|
|
6d94ce7e5c | ||
|
|
182a8d59ab | ||
|
|
f1847ef650 |
@@ -609,7 +609,7 @@ export function JobsDetailHeaderActions({
|
|||||||
<FormDateTimePickerComponent
|
<FormDateTimePickerComponent
|
||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
const start = form.getFieldValue("start");
|
const start = form.getFieldValue("start");
|
||||||
form.setFieldsValue({ end: start.add(30, "minutes") });
|
form.setFieldsValue({ end: start?.add(30, "minutes") });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ export function ProductionListEmpAssignment({ insertAuditTrail, bodyshop, record
|
|||||||
<Spin spinning={loading}>
|
<Spin spinning={loading}>
|
||||||
{record[type] ? (
|
{record[type] ? (
|
||||||
<div>
|
<div>
|
||||||
<span>{`${theEmployee.first_name || ""} ${theEmployee.last_name || ""}`}</span>
|
<span>{`${theEmployee?.first_name || ""} ${theEmployee?.last_name || ""}`}</span>
|
||||||
<DeleteFilled style={iconStyle} onClick={() => handleRemove(type)} />
|
<DeleteFilled style={iconStyle} onClick={() => handleRemove(type)} />
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) {
|
|||||||
|
|
||||||
//TODO: Find a way to filter out / blur on demand.
|
//TODO: Find a way to filter out / blur on demand.
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="report-center-modal">
|
||||||
<Form onFinish={handleFinish} autoComplete={"off"} layout="vertical" form={form}>
|
<Form onFinish={handleFinish} autoComplete={"off"} layout="vertical" form={form}>
|
||||||
<Input.Search onChange={(e) => setSearch(e.target.value)} value={search} />
|
<Input.Search onChange={(e) => setSearch(e.target.value)} value={search} />
|
||||||
<Form.Item name="defaultSorters" hidden />
|
<Form.Item name="defaultSorters" hidden />
|
||||||
@@ -163,13 +163,14 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) {
|
|||||||
{Object.keys(grouped)
|
{Object.keys(grouped)
|
||||||
//.filter((key) => !groupExcludeKeyFilter.includes(key))
|
//.filter((key) => !groupExcludeKeyFilter.includes(key))
|
||||||
.map((key) => (
|
.map((key) => (
|
||||||
<Col md={8} sm={12} key={key}>
|
<Col xs={24} sm={12} md={Object.keys(grouped).length === 1 ? 24 : 8} key={key}>
|
||||||
<Card.Grid
|
<Card.Grid
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
maxHeight: "33vh",
|
maxHeight: "33vh",
|
||||||
overflowY: "scroll"
|
overflowY: "scroll",
|
||||||
|
minWidth: "200px"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography.Title level={4}>{t(`reportcenter.labels.groups.${key}`)}</Typography.Title>
|
<Typography.Title level={4}>{t(`reportcenter.labels.groups.${key}`)}</Typography.Title>
|
||||||
@@ -177,7 +178,7 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) {
|
|||||||
<BlurWrapperComponent
|
<BlurWrapperComponent
|
||||||
featureName={groupExcludeKeyFilter.find((g) => g.key === key).featureName}
|
featureName={groupExcludeKeyFilter.find((g) => g.key === key).featureName}
|
||||||
>
|
>
|
||||||
<ul style={{ listStyleType: "none", columns: "2 auto" }}>
|
<ul style={{ listStyleType: "none", columns: grouped[key].length > 4 ? "2 auto" : "1", padding: 0, margin: 0 }}>
|
||||||
{grouped[key].map((item) => (
|
{grouped[key].map((item) => (
|
||||||
<li key={item.key}>
|
<li key={item.key}>
|
||||||
<Radio key={item.key} value={item.key}>
|
<Radio key={item.key} value={item.key}>
|
||||||
@@ -188,7 +189,7 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) {
|
|||||||
</ul>
|
</ul>
|
||||||
</BlurWrapperComponent>
|
</BlurWrapperComponent>
|
||||||
) : (
|
) : (
|
||||||
<ul style={{ listStyleType: "none", columns: "2 auto" }}>
|
<ul style={{ listStyleType: "none", columns: grouped[key].length > 4 ? "2 auto" : "1", padding: 0, margin: 0 }}>
|
||||||
{grouped[key].map((item) =>
|
{grouped[key].map((item) =>
|
||||||
item.featureNameRestricted ? (
|
item.featureNameRestricted ? (
|
||||||
<li key={item.key}>
|
<li key={item.key}>
|
||||||
|
|||||||
@@ -11,3 +11,38 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Report center modal fixes for column layout
|
||||||
|
.report-center-modal {
|
||||||
|
.ant-form-item .ant-radio-group {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.ant-card-grid {
|
||||||
|
padding: 16px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
ul {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
li {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
break-inside: avoid;
|
||||||
|
page-break-inside: avoid;
|
||||||
|
|
||||||
|
.ant-radio-wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
span:not(.ant-radio) {
|
||||||
|
word-break: break-word;
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
hyphens: auto;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import { DeleteFilled } from "@ant-design/icons";
|
import { DeleteFilled } from "@ant-design/icons";
|
||||||
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
import { Button, Form, Input, InputNumber, Select, Space, Switch } from "antd";
|
||||||
import { Button, DatePicker, Form, Input, InputNumber, Radio, Select, Space, Switch } from "antd";
|
|
||||||
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 DatePickerRanges from "../../utils/DatePickerRanges";
|
|
||||||
import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
|
||||||
import FeatureWrapper, { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
|
import FeatureWrapper, { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
|
||||||
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
|
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
|
||||||
import FormItemEmail from "../form-items-formatted/email-form-item.component";
|
import FormItemEmail from "../form-items-formatted/email-form-item.component";
|
||||||
@@ -26,14 +23,6 @@ export default connect(mapStateToProps, mapDispatchToProps)(ShopInfoGeneral);
|
|||||||
export function ShopInfoGeneral({ form, bodyshop }) {
|
export function ShopInfoGeneral({ form, bodyshop }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const {
|
|
||||||
treatments: { ClosingPeriod, ADPPayroll }
|
|
||||||
} = useSplitTreatments({
|
|
||||||
attributes: {},
|
|
||||||
names: ["ClosingPeriod", "ADPPayroll"],
|
|
||||||
splitKey: bodyshop?.imexshopid
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<LayoutFormRow header={t("bodyshop.labels.businessinformation")} id="businessinformation">
|
<LayoutFormRow header={t("bodyshop.labels.businessinformation")} id="businessinformation">
|
||||||
@@ -143,299 +132,6 @@ export function ShopInfoGeneral({ form, bodyshop }) {
|
|||||||
<InputNumber min={0} />
|
<InputNumber min={0} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</LayoutFormRow>
|
</LayoutFormRow>
|
||||||
<LayoutFormRow header={t("bodyshop.labels.accountingsetup")} id="accountingsetup">
|
|
||||||
{[
|
|
||||||
...(HasFeatureAccess({ featureName: "export", bodyshop })
|
|
||||||
? [
|
|
||||||
<Form.Item
|
|
||||||
key="qbo"
|
|
||||||
label={t("bodyshop.labels.qbo")}
|
|
||||||
valuePropName="checked"
|
|
||||||
name={["accountingconfig", "qbo"]}
|
|
||||||
>
|
|
||||||
<Switch />
|
|
||||||
</Form.Item>,
|
|
||||||
InstanceRenderManager({
|
|
||||||
imex: (
|
|
||||||
<Form.Item key="qbo_usa_wrapper" shouldUpdate noStyle>
|
|
||||||
{() => (
|
|
||||||
<Form.Item
|
|
||||||
label={t("bodyshop.labels.qbo_usa")}
|
|
||||||
shouldUpdate
|
|
||||||
valuePropName="checked"
|
|
||||||
name={["accountingconfig", "qbo_usa"]}
|
|
||||||
>
|
|
||||||
<Switch disabled={!form.getFieldValue(["accountingconfig", "qbo"])} />
|
|
||||||
</Form.Item>
|
|
||||||
)}
|
|
||||||
</Form.Item>
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
<Form.Item
|
|
||||||
key="qbo_departmentid"
|
|
||||||
label={t("bodyshop.labels.qbo_departmentid")}
|
|
||||||
name={["accountingconfig", "qbo_departmentid"]}
|
|
||||||
>
|
|
||||||
<Input />
|
|
||||||
</Form.Item>,
|
|
||||||
<Form.Item
|
|
||||||
key="accountingtiers"
|
|
||||||
label={t("bodyshop.labels.accountingtiers")}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
name={["accountingconfig", "tiers"]}
|
|
||||||
>
|
|
||||||
<Radio.Group>
|
|
||||||
<Radio value={2}>2</Radio>
|
|
||||||
<Radio value={3}>3</Radio>
|
|
||||||
</Radio.Group>
|
|
||||||
</Form.Item>,
|
|
||||||
<Form.Item key="twotierpref_wrapper" shouldUpdate>
|
|
||||||
{() => {
|
|
||||||
return (
|
|
||||||
<Form.Item
|
|
||||||
label={t("bodyshop.labels.2tiersetup")}
|
|
||||||
shouldUpdate
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: form.getFieldValue(["accountingconfig", "tiers"]) === 2
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
name={["accountingconfig", "twotierpref"]}
|
|
||||||
>
|
|
||||||
<Radio.Group disabled={form.getFieldValue(["accountingconfig", "tiers"]) === 3}>
|
|
||||||
<Radio value="name">{t("bodyshop.labels.2tiername")}</Radio>
|
|
||||||
<Radio value="source">{t("bodyshop.labels.2tiersource")}</Radio>
|
|
||||||
</Radio.Group>
|
|
||||||
</Form.Item>
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
</Form.Item>,
|
|
||||||
<Form.Item
|
|
||||||
key="printlater"
|
|
||||||
label={t("bodyshop.labels.printlater")}
|
|
||||||
valuePropName="checked"
|
|
||||||
name={["accountingconfig", "printlater"]}
|
|
||||||
>
|
|
||||||
<Switch />
|
|
||||||
</Form.Item>,
|
|
||||||
<Form.Item
|
|
||||||
key="emaillater"
|
|
||||||
label={t("bodyshop.labels.emaillater")}
|
|
||||||
valuePropName="checked"
|
|
||||||
name={["accountingconfig", "emaillater"]}
|
|
||||||
>
|
|
||||||
<Switch />
|
|
||||||
</Form.Item>
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
<Form.Item
|
|
||||||
key="inhousevendorid"
|
|
||||||
label={t("bodyshop.fields.inhousevendorid")}
|
|
||||||
name={"inhousevendorid"}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<Input />
|
|
||||||
</Form.Item>,
|
|
||||||
<Form.Item
|
|
||||||
key="default_adjustment_rate"
|
|
||||||
label={t("bodyshop.fields.default_adjustment_rate")}
|
|
||||||
name={"default_adjustment_rate"}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<InputNumber min={0} precision={2} />
|
|
||||||
</Form.Item>,
|
|
||||||
InstanceRenderManager({
|
|
||||||
imex: (
|
|
||||||
<Form.Item key="federal_tax_id" label={t("bodyshop.fields.federal_tax_id")} name="federal_tax_id">
|
|
||||||
<Input />
|
|
||||||
</Form.Item>
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
<Form.Item key="state_tax_id" label={t("bodyshop.fields.state_tax_id")} name="state_tax_id">
|
|
||||||
<Input />
|
|
||||||
</Form.Item>,
|
|
||||||
...(HasFeatureAccess({ featureName: "bills", bodyshop })
|
|
||||||
? [
|
|
||||||
InstanceRenderManager({
|
|
||||||
imex: (
|
|
||||||
<Form.Item
|
|
||||||
key="invoice_federal_tax_rate"
|
|
||||||
label={t("bodyshop.fields.invoice_federal_tax_rate")}
|
|
||||||
name={["bill_tax_rates", "federal_tax_rate"]}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<InputNumber />
|
|
||||||
</Form.Item>
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
<Form.Item
|
|
||||||
key="invoice_state_tax_rate"
|
|
||||||
label={t("bodyshop.fields.invoice_state_tax_rate")}
|
|
||||||
name={["bill_tax_rates", "state_tax_rate"]}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<InputNumber />
|
|
||||||
</Form.Item>,
|
|
||||||
<Form.Item
|
|
||||||
key="invoice_local_tax_rate"
|
|
||||||
label={t("bodyshop.fields.invoice_local_tax_rate")}
|
|
||||||
name={["bill_tax_rates", "local_tax_rate"]}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<InputNumber />
|
|
||||||
</Form.Item>
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
<Form.Item
|
|
||||||
key="md_payment_types"
|
|
||||||
name={["md_payment_types"]}
|
|
||||||
label={t("bodyshop.fields.md_payment_types")}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
type: "array"
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<Select mode="tags" />
|
|
||||||
</Form.Item>,
|
|
||||||
<Form.Item
|
|
||||||
key="md_categories"
|
|
||||||
name={["md_categories"]}
|
|
||||||
label={t("bodyshop.fields.md_categories")}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
type: "array"
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<Select mode="tags" />
|
|
||||||
</Form.Item>,
|
|
||||||
...(HasFeatureAccess({ featureName: "export", bodyshop })
|
|
||||||
? [
|
|
||||||
<Form.Item
|
|
||||||
key="ReceivableCustomField1"
|
|
||||||
name={["accountingconfig", "ReceivableCustomField1"]}
|
|
||||||
label={t("bodyshop.fields.ReceivableCustomField", { number: 1 })}
|
|
||||||
>
|
|
||||||
{ReceivableCustomFieldSelect}
|
|
||||||
</Form.Item>,
|
|
||||||
<Form.Item
|
|
||||||
key="ReceivableCustomField2"
|
|
||||||
name={["accountingconfig", "ReceivableCustomField2"]}
|
|
||||||
label={t("bodyshop.fields.ReceivableCustomField", { number: 2 })}
|
|
||||||
>
|
|
||||||
{ReceivableCustomFieldSelect}
|
|
||||||
</Form.Item>,
|
|
||||||
<Form.Item
|
|
||||||
key="ReceivableCustomField3"
|
|
||||||
name={["accountingconfig", "ReceivableCustomField3"]}
|
|
||||||
label={t("bodyshop.fields.ReceivableCustomField", { number: 3 })}
|
|
||||||
>
|
|
||||||
{ReceivableCustomFieldSelect}
|
|
||||||
</Form.Item>,
|
|
||||||
<Form.Item
|
|
||||||
key="md_classes"
|
|
||||||
name={["md_classes"]}
|
|
||||||
label={t("bodyshop.fields.md_classes")}
|
|
||||||
rules={[
|
|
||||||
({ getFieldValue }) => {
|
|
||||||
return {
|
|
||||||
required: getFieldValue("enforce_class"),
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
type: "array"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<Select mode="tags" />
|
|
||||||
</Form.Item>,
|
|
||||||
<Form.Item
|
|
||||||
key="enforce_class"
|
|
||||||
name={["enforce_class"]}
|
|
||||||
label={t("bodyshop.fields.enforce_class")}
|
|
||||||
valuePropName="checked"
|
|
||||||
>
|
|
||||||
<Switch />
|
|
||||||
</Form.Item>,
|
|
||||||
...(ClosingPeriod.treatment === "on"
|
|
||||||
? [
|
|
||||||
<Form.Item
|
|
||||||
key="ClosingPeriod"
|
|
||||||
name={["accountingconfig", "ClosingPeriod"]}
|
|
||||||
label={t("bodyshop.fields.closingperiod")} //{t("reportcenter.labels.dates")}
|
|
||||||
>
|
|
||||||
<DatePicker.RangePicker format="MM/DD/YYYY" presets={DatePickerRanges} />
|
|
||||||
</Form.Item>
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
...(ADPPayroll.treatment === "on"
|
|
||||||
? [
|
|
||||||
<Form.Item
|
|
||||||
key="companyCode"
|
|
||||||
name={["accountingconfig", "companyCode"]}
|
|
||||||
label={t("bodyshop.fields.companycode")}
|
|
||||||
>
|
|
||||||
<Input />
|
|
||||||
</Form.Item>
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
...(ADPPayroll.treatment === "on"
|
|
||||||
? [
|
|
||||||
<Form.Item
|
|
||||||
key="batchID"
|
|
||||||
name={["accountingconfig", "batchID"]}
|
|
||||||
label={t("bodyshop.fields.batchid")}
|
|
||||||
>
|
|
||||||
<Input />
|
|
||||||
</Form.Item>
|
|
||||||
]
|
|
||||||
: [])
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
<Form.Item
|
|
||||||
key="accumulatePayableLines"
|
|
||||||
name={["accountingconfig", "accumulatePayableLines"]}
|
|
||||||
label={t("bodyshop.fields.accumulatePayableLines")}
|
|
||||||
valuePropName="checked"
|
|
||||||
>
|
|
||||||
<Switch />
|
|
||||||
</Form.Item>
|
|
||||||
]}
|
|
||||||
</LayoutFormRow>
|
|
||||||
<FeatureWrapper featureName="scoreboard" noauth={() => null}>
|
<FeatureWrapper featureName="scoreboard" noauth={() => null}>
|
||||||
<LayoutFormRow header={t("bodyshop.labels.scoreboardsetup")} id="scoreboardsetup">
|
<LayoutFormRow header={t("bodyshop.labels.scoreboardsetup")} id="scoreboardsetup">
|
||||||
<Form.Item
|
<Form.Item
|
||||||
@@ -499,6 +195,19 @@ export function ShopInfoGeneral({ form, bodyshop }) {
|
|||||||
</FeatureWrapper>
|
</FeatureWrapper>
|
||||||
<LayoutFormRow header={t("bodyshop.labels.systemsettings")} id="systemsettings">
|
<LayoutFormRow header={t("bodyshop.labels.systemsettings")} id="systemsettings">
|
||||||
{[
|
{[
|
||||||
|
<Form.Item
|
||||||
|
key="md_categories"
|
||||||
|
name={["md_categories"]}
|
||||||
|
label={t("bodyshop.fields.md_categories")}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
type: "array"
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Select mode="tags" />
|
||||||
|
</Form.Item>,
|
||||||
<Form.Item
|
<Form.Item
|
||||||
key="md_referral_sources"
|
key="md_referral_sources"
|
||||||
name={["md_referral_sources"]}
|
name={["md_referral_sources"]}
|
||||||
@@ -1568,11 +1277,3 @@ export function ShopInfoGeneral({ form, bodyshop }) {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReceivableCustomFieldSelect = (
|
|
||||||
<Select allowClear>
|
|
||||||
<Select.Option value="v_vin">VIN</Select.Option>
|
|
||||||
<Select.Option value="clm_no">Claim No.</Select.Option>
|
|
||||||
<Select.Option value="ded_amt">Deductible Amount</Select.Option>
|
|
||||||
</Select>
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { DeleteFilled } from "@ant-design/icons";
|
import { DeleteFilled } from "@ant-design/icons";
|
||||||
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
||||||
import { Button, Form, Input, InputNumber, Select, Space, Switch } from "antd";
|
import { Button, DatePicker, Form, Input, InputNumber, Radio, Select, Space, Switch } from "antd";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -14,6 +14,7 @@ import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.c
|
|||||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||||
import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component";
|
import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component";
|
||||||
import ShopInfoResponsibilitycentersTaxesComponent from "./shop-info.responsibilitycenters.taxes.component";
|
import ShopInfoResponsibilitycentersTaxesComponent from "./shop-info.responsibilitycenters.taxes.component";
|
||||||
|
import DatePickerRanges from "../../utils/DatePickerRanges";
|
||||||
|
|
||||||
const SelectorDiv = styled.div`
|
const SelectorDiv = styled.div`
|
||||||
.ant-form-item .ant-select {
|
.ant-form-item .ant-select {
|
||||||
@@ -34,11 +35,11 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
treatments: { Qb_Multi_Ar, DmsAp }
|
treatments: { ClosingPeriod, ADPPayroll, Qb_Multi_Ar, DmsAp }
|
||||||
} = useSplitTreatments({
|
} = useSplitTreatments({
|
||||||
attributes: {},
|
attributes: {},
|
||||||
names: ["Qb_Multi_Ar", "DmsAp"],
|
names: ["ClosingPeriod", "ADPPayroll", "Qb_Multi_Ar", "DmsAp"],
|
||||||
splitKey: bodyshop && bodyshop.imexshopid
|
splitKey: bodyshop?.imexshopid
|
||||||
});
|
});
|
||||||
|
|
||||||
const [costOptions, setCostOptions] = useState([
|
const [costOptions, setCostOptions] = useState([
|
||||||
@@ -58,19 +59,313 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) {
|
|||||||
setProfitOptions([...(form.getFieldValue(["md_responsibility_centers", "profits"]).map((i) => i && i.name) || [])]);
|
setProfitOptions([...(form.getFieldValue(["md_responsibility_centers", "profits"]).map((i) => i && i.name) || [])]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ReceivableCustomFieldSelect = (
|
||||||
|
<Select allowClear>
|
||||||
|
<Select.Option value="v_vin">VIN</Select.Option>
|
||||||
|
<Select.Option value="clm_no">Claim No.</Select.Option>
|
||||||
|
<Select.Option value="ded_amt">Deductible Amount</Select.Option>
|
||||||
|
</Select>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<RbacWrapper action="shop:responsibilitycenter">
|
<RbacWrapper action="shop:responsibilitycenter">
|
||||||
|
<LayoutFormRow header={t("bodyshop.labels.accountingsetup")} id="accountingsetup">
|
||||||
|
{[
|
||||||
|
...(HasFeatureAccess({ featureName: "export", bodyshop })
|
||||||
|
? !bodyshop.cdk_dealerid && !bodyshop.pbs_serialnumber
|
||||||
|
? [
|
||||||
|
<Form.Item
|
||||||
|
key="qbo"
|
||||||
|
label={t("bodyshop.labels.qbo")}
|
||||||
|
valuePropName="checked"
|
||||||
|
name={["accountingconfig", "qbo"]}
|
||||||
|
>
|
||||||
|
<Switch />
|
||||||
|
</Form.Item>,
|
||||||
|
InstanceRenderManager({
|
||||||
|
imex: (
|
||||||
|
<Form.Item key="qbo_usa_wrapper" shouldUpdate noStyle>
|
||||||
|
{() => (
|
||||||
|
<Form.Item
|
||||||
|
label={t("bodyshop.labels.qbo_usa")}
|
||||||
|
shouldUpdate
|
||||||
|
valuePropName="checked"
|
||||||
|
name={["accountingconfig", "qbo_usa"]}
|
||||||
|
>
|
||||||
|
<Switch disabled={!form.getFieldValue(["accountingconfig", "qbo"])} />
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
|
</Form.Item>
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
<Form.Item
|
||||||
|
key="qbo_departmentid"
|
||||||
|
label={t("bodyshop.labels.qbo_departmentid")}
|
||||||
|
name={["accountingconfig", "qbo_departmentid"]}
|
||||||
|
>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>,
|
||||||
|
<Form.Item
|
||||||
|
key="accountingtiers"
|
||||||
|
label={t("bodyshop.labels.accountingtiers")}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
name={["accountingconfig", "tiers"]}
|
||||||
|
>
|
||||||
|
<Radio.Group>
|
||||||
|
<Radio value={2}>2</Radio>
|
||||||
|
<Radio value={3}>3</Radio>
|
||||||
|
</Radio.Group>
|
||||||
|
</Form.Item>,
|
||||||
|
<Form.Item key="twotierpref_wrapper" shouldUpdate>
|
||||||
|
{() => {
|
||||||
|
return (
|
||||||
|
<Form.Item
|
||||||
|
label={t("bodyshop.labels.2tiersetup")}
|
||||||
|
shouldUpdate
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: form.getFieldValue(["accountingconfig", "tiers"]) === 2
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
name={["accountingconfig", "twotierpref"]}
|
||||||
|
>
|
||||||
|
<Radio.Group disabled={form.getFieldValue(["accountingconfig", "tiers"]) === 3}>
|
||||||
|
<Radio value="name">{t("bodyshop.labels.2tiername")}</Radio>
|
||||||
|
<Radio value="source">{t("bodyshop.labels.2tiersource")}</Radio>
|
||||||
|
</Radio.Group>
|
||||||
|
</Form.Item>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</Form.Item>,
|
||||||
|
<Form.Item
|
||||||
|
key="printlater"
|
||||||
|
label={t("bodyshop.labels.printlater")}
|
||||||
|
valuePropName="checked"
|
||||||
|
name={["accountingconfig", "printlater"]}
|
||||||
|
>
|
||||||
|
<Switch />
|
||||||
|
</Form.Item>,
|
||||||
|
<Form.Item
|
||||||
|
key="emaillater"
|
||||||
|
label={t("bodyshop.labels.emaillater")}
|
||||||
|
valuePropName="checked"
|
||||||
|
name={["accountingconfig", "emaillater"]}
|
||||||
|
>
|
||||||
|
<Switch />
|
||||||
|
</Form.Item>,
|
||||||
|
<Form.Item
|
||||||
|
key="ReceivableCustomField1"
|
||||||
|
name={["accountingconfig", "ReceivableCustomField1"]}
|
||||||
|
label={t("bodyshop.fields.ReceivableCustomField", { number: 1 })}
|
||||||
|
>
|
||||||
|
{ReceivableCustomFieldSelect}
|
||||||
|
</Form.Item>,
|
||||||
|
<Form.Item
|
||||||
|
key="ReceivableCustomField2"
|
||||||
|
name={["accountingconfig", "ReceivableCustomField2"]}
|
||||||
|
label={t("bodyshop.fields.ReceivableCustomField", { number: 2 })}
|
||||||
|
>
|
||||||
|
{ReceivableCustomFieldSelect}
|
||||||
|
</Form.Item>,
|
||||||
|
<Form.Item
|
||||||
|
key="ReceivableCustomField3"
|
||||||
|
name={["accountingconfig", "ReceivableCustomField3"]}
|
||||||
|
label={t("bodyshop.fields.ReceivableCustomField", { number: 3 })}
|
||||||
|
>
|
||||||
|
{ReceivableCustomFieldSelect}
|
||||||
|
</Form.Item>,
|
||||||
|
<Form.Item
|
||||||
|
key="md_classes"
|
||||||
|
name={["md_classes"]}
|
||||||
|
label={t("bodyshop.fields.md_classes")}
|
||||||
|
rules={[
|
||||||
|
({ getFieldValue }) => {
|
||||||
|
return {
|
||||||
|
required: getFieldValue("enforce_class"),
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
type: "array"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Select mode="tags" />
|
||||||
|
</Form.Item>,
|
||||||
|
<Form.Item
|
||||||
|
key="enforce_class"
|
||||||
|
name={["enforce_class"]}
|
||||||
|
label={t("bodyshop.fields.enforce_class")}
|
||||||
|
valuePropName="checked"
|
||||||
|
>
|
||||||
|
<Switch />
|
||||||
|
</Form.Item>,
|
||||||
|
<Form.Item
|
||||||
|
key="accumulatePayableLines"
|
||||||
|
name={["accountingconfig", "accumulatePayableLines"]}
|
||||||
|
label={t("bodyshop.fields.accumulatePayableLines")}
|
||||||
|
valuePropName="checked"
|
||||||
|
>
|
||||||
|
<Switch />
|
||||||
|
</Form.Item>
|
||||||
|
]
|
||||||
|
: []
|
||||||
|
: []),
|
||||||
|
<Form.Item
|
||||||
|
key="inhousevendorid"
|
||||||
|
label={t("bodyshop.fields.inhousevendorid")}
|
||||||
|
name={"inhousevendorid"}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>,
|
||||||
|
<Form.Item
|
||||||
|
key="default_adjustment_rate"
|
||||||
|
label={t("bodyshop.fields.default_adjustment_rate")}
|
||||||
|
name={"default_adjustment_rate"}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<InputNumber min={0} precision={2} />
|
||||||
|
</Form.Item>,
|
||||||
|
InstanceRenderManager({
|
||||||
|
imex: (
|
||||||
|
<Form.Item key="federal_tax_id" label={t("bodyshop.fields.federal_tax_id")} name="federal_tax_id">
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
<Form.Item key="state_tax_id" label={t("bodyshop.fields.state_tax_id")} name="state_tax_id">
|
||||||
|
<Input />
|
||||||
|
</Form.Item>,
|
||||||
|
...(HasFeatureAccess({ featureName: "bills", bodyshop })
|
||||||
|
? [
|
||||||
|
InstanceRenderManager({
|
||||||
|
imex: (
|
||||||
|
<Form.Item
|
||||||
|
key="invoice_federal_tax_rate"
|
||||||
|
label={t("bodyshop.fields.invoice_federal_tax_rate")}
|
||||||
|
name={["bill_tax_rates", "federal_tax_rate"]}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<InputNumber />
|
||||||
|
</Form.Item>
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
<Form.Item
|
||||||
|
key="invoice_state_tax_rate"
|
||||||
|
label={t("bodyshop.fields.invoice_state_tax_rate")}
|
||||||
|
name={["bill_tax_rates", "state_tax_rate"]}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<InputNumber />
|
||||||
|
</Form.Item>,
|
||||||
|
<Form.Item
|
||||||
|
key="invoice_local_tax_rate"
|
||||||
|
label={t("bodyshop.fields.invoice_local_tax_rate")}
|
||||||
|
name={["bill_tax_rates", "local_tax_rate"]}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<InputNumber />
|
||||||
|
</Form.Item>
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
<Form.Item
|
||||||
|
key="md_payment_types"
|
||||||
|
name={["md_payment_types"]}
|
||||||
|
label={t("bodyshop.fields.md_payment_types")}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
type: "array"
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Select mode="tags" />
|
||||||
|
</Form.Item>,
|
||||||
|
...(HasFeatureAccess({ featureName: "export", bodyshop })
|
||||||
|
? [
|
||||||
|
...(ClosingPeriod.treatment === "on"
|
||||||
|
? [
|
||||||
|
<Form.Item
|
||||||
|
key="ClosingPeriod"
|
||||||
|
name={["accountingconfig", "ClosingPeriod"]}
|
||||||
|
label={t("bodyshop.fields.closingperiod")} //{t("reportcenter.labels.dates")}
|
||||||
|
>
|
||||||
|
<DatePicker.RangePicker format="MM/DD/YYYY" presets={DatePickerRanges} />
|
||||||
|
</Form.Item>
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
...(ADPPayroll.treatment === "on"
|
||||||
|
? [
|
||||||
|
<Form.Item
|
||||||
|
key="companyCode"
|
||||||
|
name={["accountingconfig", "companyCode"]}
|
||||||
|
label={t("bodyshop.fields.companycode")}
|
||||||
|
>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
...(ADPPayroll.treatment === "on"
|
||||||
|
? [
|
||||||
|
<Form.Item
|
||||||
|
key="batchID"
|
||||||
|
name={["accountingconfig", "batchID"]}
|
||||||
|
label={t("bodyshop.fields.batchid")}
|
||||||
|
>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
]
|
||||||
|
: [])
|
||||||
|
]
|
||||||
|
: [])
|
||||||
|
]}
|
||||||
|
</LayoutFormRow>
|
||||||
{(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && (
|
{(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && (
|
||||||
<>
|
<>
|
||||||
{bodyshop.cdk_dealerid && (
|
<LayoutFormRow id="dmsconfiguration">
|
||||||
<DataLabel label={t("bodyshop.labels.dms.cdk_dealerid")}>{form.getFieldValue("cdk_dealerid")}</DataLabel>
|
{bodyshop.cdk_dealerid && (
|
||||||
)}
|
<DataLabel label={t("bodyshop.labels.dms.cdk_dealerid")}>
|
||||||
{bodyshop.pbs_serialnumber && (
|
{form.getFieldValue("cdk_dealerid")}
|
||||||
<DataLabel label={t("bodyshop.labels.dms.pbs_serialnumber")}>
|
</DataLabel>
|
||||||
{form.getFieldValue("pbs_serialnumber")}
|
)}
|
||||||
</DataLabel>
|
{bodyshop.pbs_serialnumber && (
|
||||||
)}
|
<DataLabel label={t("bodyshop.labels.dms.pbs_serialnumber")}>
|
||||||
|
{form.getFieldValue("pbs_serialnumber")}
|
||||||
|
</DataLabel>
|
||||||
|
)}
|
||||||
|
</LayoutFormRow>
|
||||||
<LayoutFormRow>
|
<LayoutFormRow>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("bodyshop.fields.dms.default_journal")}
|
label={t("bodyshop.fields.dms.default_journal")}
|
||||||
@@ -307,13 +602,6 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) {
|
|||||||
</LayoutFormRow>
|
</LayoutFormRow>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{bodyshop.pbs_serialnumber && (
|
|
||||||
<>
|
|
||||||
<DataLabel label={t("bodyshop.labels.dms.pbs_serialnumber")}>
|
|
||||||
{form.getFieldValue("pbs_serialnumber")}
|
|
||||||
</DataLabel>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{HasFeatureAccess({ featureName: "export", bodyshop }) && (
|
{HasFeatureAccess({ featureName: "export", bodyshop }) && (
|
||||||
<>
|
<>
|
||||||
<LayoutFormRow header={t("bodyshop.labels.responsibilitycenters.costs")} id="costs">
|
<LayoutFormRow header={t("bodyshop.labels.responsibilitycenters.costs")} id="costs">
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { getFirestore } from "@firebase/firestore";
|
|||||||
import { getMessaging, getToken, onMessage } from "@firebase/messaging";
|
import { getMessaging, getToken, onMessage } from "@firebase/messaging";
|
||||||
import { store } from "../redux/store";
|
import { store } from "../redux/store";
|
||||||
//import * as amplitude from '@amplitude/analytics-browser';
|
//import * as amplitude from '@amplitude/analytics-browser';
|
||||||
import posthog from 'posthog-js'
|
// import posthog from 'posthog-js'
|
||||||
|
|
||||||
const config = JSON.parse(import.meta.env.VITE_APP_FIREBASE_CONFIG);
|
const config = JSON.parse(import.meta.env.VITE_APP_FIREBASE_CONFIG);
|
||||||
initializeApp(config);
|
initializeApp(config);
|
||||||
@@ -74,7 +74,6 @@ onMessage(messaging, (payload) => {
|
|||||||
|
|
||||||
export const logImEXEvent = (eventName, additionalParams, stateProp = null) => {
|
export const logImEXEvent = (eventName, additionalParams, stateProp = null) => {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const state = stateProp || store.getState();
|
const state = stateProp || store.getState();
|
||||||
|
|
||||||
const eventParams = {
|
const eventParams = {
|
||||||
@@ -99,8 +98,7 @@ export const logImEXEvent = (eventName, additionalParams, stateProp = null) => {
|
|||||||
// );
|
// );
|
||||||
logEvent(analytics, eventName, eventParams);
|
logEvent(analytics, eventName, eventParams);
|
||||||
//amplitude.track(eventName, eventParams);
|
//amplitude.track(eventName, eventParams);
|
||||||
posthog.capture(eventName, eventParams);
|
//posthog.capture(eventName, eventParams);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
//If it fails, just keep going.
|
//If it fails, just keep going.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ if (!import.meta.env.DEV) {
|
|||||||
"Module specifier, 'fs' does not start",
|
"Module specifier, 'fs' does not start",
|
||||||
"Module specifier, 'zlib' does not start with",
|
"Module specifier, 'zlib' does not start with",
|
||||||
"Messaging: This browser doesn't support the API's required to use the Firebase SDK.",
|
"Messaging: This browser doesn't support the API's required to use the Firebase SDK.",
|
||||||
"Failed to update a ServiceWorker for scope"
|
"Failed to update a ServiceWorker for scope",
|
||||||
|
"Network Error"
|
||||||
],
|
],
|
||||||
integrations: [
|
integrations: [
|
||||||
// See docs for support of different versions of variation of react router
|
// See docs for support of different versions of variation of react router
|
||||||
|
|||||||
@@ -24,11 +24,13 @@ const lightningCssTargets = browserslistToTargets(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const currentDatePST = new Date()
|
const pstFormatter = new Intl.DateTimeFormat("en-CA", {
|
||||||
.toLocaleDateString("en-US", { timeZone: "America/Los_Angeles", year: "numeric", month: "2-digit", day: "2-digit" })
|
timeZone: "America/Los_Angeles",
|
||||||
.split("/")
|
year: "numeric",
|
||||||
.reverse()
|
month: "2-digit",
|
||||||
.join("-");
|
day: "2-digit"
|
||||||
|
});
|
||||||
|
const currentDatePST = pstFormatter.format(new Date());
|
||||||
|
|
||||||
const getFormattedTimestamp = () =>
|
const getFormattedTimestamp = () =>
|
||||||
new Date().toLocaleTimeString("en-US", { hour12: true }).replace("AM", "a.m.").replace("PM", "p.m.");
|
new Date().toLocaleTimeString("en-US", { hour12: true }).replace("AM", "a.m.").replace("PM", "p.m.");
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
-- Could not auto-generate a down migration.
|
||||||
|
-- Please write an appropriate down migration for the SQL below:
|
||||||
|
-- alter table "public"."jobs" add column "dms_id" text
|
||||||
|
-- null;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
alter table "public"."jobs" add column "dms_id" text
|
||||||
|
null;
|
||||||
@@ -77,9 +77,8 @@ const generateResetLink = async (email) => {
|
|||||||
*/
|
*/
|
||||||
const ensureExternalIdUnique = async (externalId) => {
|
const ensureExternalIdUnique = async (externalId) => {
|
||||||
const resp = await client.request(CHECK_EXTERNAL_SHOP_ID, { key: externalId });
|
const resp = await client.request(CHECK_EXTERNAL_SHOP_ID, { key: externalId });
|
||||||
if (resp.bodyshops.length) {
|
|
||||||
throw { status: 400, message: `external_shop_id '${externalId}' is already in use.` };
|
return !!resp.bodyshops.length;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -225,10 +224,25 @@ const patchPartsManagementProvisioning = async (req, res) => {
|
|||||||
*/
|
*/
|
||||||
const partsManagementProvisioning = async (req, res) => {
|
const partsManagementProvisioning = async (req, res) => {
|
||||||
const { logger } = req;
|
const { logger } = req;
|
||||||
const body = { ...req.body, userEmail: req.body.userEmail?.toLowerCase() };
|
|
||||||
|
// Trim and normalize email early
|
||||||
|
const body = {
|
||||||
|
...req.body,
|
||||||
|
userEmail: req.body.userEmail?.trim().toLowerCase()
|
||||||
|
};
|
||||||
|
|
||||||
|
const trim = (value) => (typeof value === "string" ? value.trim() : value);
|
||||||
|
const trimIfString = (value) =>
|
||||||
|
value !== null && value !== undefined && typeof value === "string" ? value.trim() : value;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Ensure email is present and trimmed before checking registration
|
||||||
|
if (!body.userEmail) {
|
||||||
|
throw { status: 400, message: "userEmail is required" };
|
||||||
|
}
|
||||||
|
|
||||||
await ensureEmailNotRegistered(body.userEmail);
|
await ensureEmailNotRegistered(body.userEmail);
|
||||||
|
|
||||||
requireFields(body, [
|
requireFields(body, [
|
||||||
"external_shop_id",
|
"external_shop_id",
|
||||||
"shopname",
|
"shopname",
|
||||||
@@ -242,28 +256,68 @@ const partsManagementProvisioning = async (req, res) => {
|
|||||||
"userEmail"
|
"userEmail"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// TODO add in check for early access
|
// Trim all top-level string fields
|
||||||
await ensureExternalIdUnique(body.external_shop_id);
|
const trimmedBody = {
|
||||||
|
...body,
|
||||||
|
external_shop_id: trim(body.external_shop_id),
|
||||||
|
shopname: trim(body.shopname),
|
||||||
|
address1: trim(body.address1),
|
||||||
|
address2: trimIfString(body.address2),
|
||||||
|
city: trim(body.city),
|
||||||
|
state: trim(body.state),
|
||||||
|
zip_post: trim(body.zip_post),
|
||||||
|
country: trim(body.country),
|
||||||
|
email: trim(body.email),
|
||||||
|
phone: trim(body.phone),
|
||||||
|
timezone: trimIfString(body.timezone),
|
||||||
|
logoUrl: trimIfString(body.logoUrl),
|
||||||
|
userPassword: body.userPassword, // passwords should NOT be trimmed (preserves intentional spaces if any, though rare)
|
||||||
|
vendors: Array.isArray(body.vendors)
|
||||||
|
? body.vendors.map((v) => ({
|
||||||
|
name: trim(v.name),
|
||||||
|
street1: trimIfString(v.street1),
|
||||||
|
street2: trimIfString(v.street2),
|
||||||
|
city: trimIfString(v.city),
|
||||||
|
state: trimIfString(v.state),
|
||||||
|
zip: trimIfString(v.zip),
|
||||||
|
country: trimIfString(v.country),
|
||||||
|
email: trimIfString(v.email),
|
||||||
|
cost_center: trimIfString(v.cost_center),
|
||||||
|
phone: trimIfString(v.phone),
|
||||||
|
dmsid: trimIfString(v.dmsid),
|
||||||
|
discount: v.discount ?? 0,
|
||||||
|
due_date: v.due_date ?? null,
|
||||||
|
favorite: v.favorite ?? [],
|
||||||
|
active: v.active ?? true
|
||||||
|
}))
|
||||||
|
: []
|
||||||
|
};
|
||||||
|
|
||||||
logger.log("admin-create-shop-user", "debug", body.userEmail, null, {
|
const duplicateCheck = await ensureExternalIdUnique(trimmedBody.external_shop_id);
|
||||||
|
|
||||||
|
if (duplicateCheck) {
|
||||||
|
throw { status: 400, message: `external_shop_id '${trimmedBody.external_shop_id}' is already in use.` };
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.log("admin-create-shop-user", "debug", trimmedBody.userEmail, null, {
|
||||||
request: req.body,
|
request: req.body,
|
||||||
ioadmin: true
|
ioadmin: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const shopInput = {
|
const shopInput = {
|
||||||
shopname: body.shopname,
|
shopname: trimmedBody.shopname,
|
||||||
address1: body.address1,
|
address1: trimmedBody.address1,
|
||||||
address2: body.address2 || null,
|
address2: trimmedBody.address2,
|
||||||
city: body.city,
|
city: trimmedBody.city,
|
||||||
state: body.state,
|
state: trimmedBody.state,
|
||||||
zip_post: body.zip_post,
|
zip_post: trimmedBody.zip_post,
|
||||||
country: body.country,
|
country: trimmedBody.country,
|
||||||
email: body.email,
|
email: trimmedBody.email,
|
||||||
external_shop_id: body.external_shop_id,
|
external_shop_id: trimmedBody.external_shop_id,
|
||||||
timezone: body.timezone || DefaultNewShop.timezone,
|
timezone: trimmedBody.timezone || DefaultNewShop.timezone,
|
||||||
phone: body.phone,
|
phone: trimmedBody.phone,
|
||||||
logo_img_path: {
|
logo_img_path: {
|
||||||
src: body.logoUrl,
|
src: trimmedBody.logoUrl || null, // allow empty logo
|
||||||
width: "",
|
width: "",
|
||||||
height: "",
|
height: "",
|
||||||
headerMargin: DefaultNewShop.logo_img_path.headerMargin
|
headerMargin: DefaultNewShop.logo_img_path.headerMargin
|
||||||
@@ -288,35 +342,37 @@ const partsManagementProvisioning = async (req, res) => {
|
|||||||
appt_alt_transport: DefaultNewShop.appt_alt_transport,
|
appt_alt_transport: DefaultNewShop.appt_alt_transport,
|
||||||
md_jobline_presets: DefaultNewShop.md_jobline_presets,
|
md_jobline_presets: DefaultNewShop.md_jobline_presets,
|
||||||
vendors: {
|
vendors: {
|
||||||
data: body.vendors.map((v) => ({
|
data: trimmedBody.vendors.map((v) => ({
|
||||||
name: v.name,
|
name: v.name,
|
||||||
street1: v.street1 || null,
|
street1: v.street1,
|
||||||
street2: v.street2 || null,
|
street2: v.street2,
|
||||||
city: v.city || null,
|
city: v.city,
|
||||||
state: v.state || null,
|
state: v.state,
|
||||||
zip: v.zip || null,
|
zip: v.zip,
|
||||||
country: v.country || null,
|
country: v.country,
|
||||||
email: v.email || null,
|
email: v.email,
|
||||||
discount: v.discount ?? 0,
|
discount: v.discount,
|
||||||
due_date: v.due_date ?? null,
|
due_date: v.due_date,
|
||||||
cost_center: v.cost_center || null,
|
cost_center: v.cost_center,
|
||||||
favorite: v.favorite ?? [],
|
favorite: v.favorite,
|
||||||
phone: v.phone || null,
|
phone: v.phone,
|
||||||
active: v.active ?? true,
|
active: v.active,
|
||||||
dmsid: v.dmsid || null
|
dmsid: v.dmsid
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const newShopId = await insertBodyshop(shopInput);
|
const newShopId = await insertBodyshop(shopInput);
|
||||||
const userRecord = await createFirebaseUser(body.userEmail, body.userPassword);
|
const userRecord = await createFirebaseUser(trimmedBody.userEmail, trimmedBody.userPassword);
|
||||||
let resetLink = null;
|
let resetLink = null;
|
||||||
if (!body.userPassword) resetLink = await generateResetLink(body.userEmail);
|
if (!trimmedBody.userPassword) {
|
||||||
|
resetLink = await generateResetLink(trimmedBody.userEmail);
|
||||||
|
}
|
||||||
|
|
||||||
const createdUser = await insertUserAssociation(userRecord.uid, body.userEmail, newShopId);
|
const createdUser = await insertUserAssociation(userRecord.uid, trimmedBody.userEmail, newShopId);
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
shop: { id: newShopId, shopname: body.shopname },
|
shop: { id: newShopId, shopname: trimmedBody.shopname },
|
||||||
user: {
|
user: {
|
||||||
id: createdUser.id,
|
id: createdUser.id,
|
||||||
email: createdUser.email,
|
email: createdUser.email,
|
||||||
@@ -324,7 +380,7 @@ const partsManagementProvisioning = async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.log("admin-create-shop-user-error", "error", body.userEmail, null, {
|
logger.log("admin-create-shop-user-error", "error", body.userEmail || "unknown", null, {
|
||||||
message: err.message,
|
message: err.message,
|
||||||
detail: err.detail || err
|
detail: err.detail || err
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user