import { DeleteFilled } from "@ant-design/icons";
import { useTreatmentsWithConfig } from "@splitsoftware/splitio-react";
import { Button, Col, DatePicker, Divider, Form, Input, InputNumber, Radio, Row, Select, Space, Switch } from "antd";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import styled from "styled-components";
import { selectBodyshop } from "../../redux/user/user.selectors";
import InstanceRenderManager from "../../utils/instanceRenderMgr";
import DataLabel from "../data-label/data-label.component";
import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component";
import { getFormListItemTitle } from "../form-list-move-arrows/form-list-item-title.utils";
import { buildSectionActionButton, renderListOrEmpty } from "../layout-form-row/config-list-actions.utils.jsx";
import InlineValidatedFormRow from "../layout-form-row/inline-validated-form-row.component.jsx";
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
import {
  INLINE_TITLE_GROUP_STYLE,
  INLINE_TITLE_HANDLE_STYLE,
  INLINE_TITLE_INPUT_STYLE,
  INLINE_TITLE_LABEL_STYLE,
  INLINE_TITLE_ROW_STYLE,
  INLINE_TITLE_SEPARATOR_STYLE,
  INLINE_TITLE_SWITCH_GROUP_STYLE,
  InlineTitleListIcon
} from "../layout-form-row/inline-form-row-title.utils.js";
import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component";
import ShopInfoResponsibilitycentersTaxesComponent from "./shop-info.responsibilitycenters.taxes.component";
import { bodyshopHasDmsKey } from "../../utils/dmsUtils.js";
import DatePickerRanges from "../../utils/DatePickerRanges";

const SelectorDiv = styled.div`
  .ant-form-item .ant-select {
    width: 125px;
  }
`;

const mapStateToProps = createStructuredSelector({
  bodyshop: selectBodyshop
});
const mapDispatchToProps = () => ({});

export default connect(mapStateToProps, mapDispatchToProps)(ShopInfoResponsibilityCenterComponent);

export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) {
  const { t } = useTranslation();
  const taxAccountRowCol = { xs: 24, sm: 12, md: 12, lg: 6, xl: 6, xxl: 6 };
  const taxAccountFullRowCol = { xs: 24 };
  const dmsPayers = Form.useWatch(["cdk_configuration", "payers"], form) || [];

  const hasDMSKey = bodyshopHasDmsKey(bodyshop);

  const {
    treatments: { ClosingPeriod, ADPPayroll, Qb_Multi_Ar, DmsAp }
  } = useTreatmentsWithConfig({
    attributes: {},
    names: ["ClosingPeriod", "ADPPayroll", "Qb_Multi_Ar", "DmsAp"],
    splitKey: bodyshop?.imexshopid
  });

  const [costOptions, setCostOptions] = useState([
    ...((form.getFieldValue(["md_responsibility_centers", "costs"]) &&
      form.getFieldValue(["md_responsibility_centers", "costs"]).map((i) => i && i.name)) ||
      [])
  ]);

  const [profitOptions, setProfitOptions] = useState([
    ...((form.getFieldValue(["md_responsibility_centers", "profits"]) &&
      form.getFieldValue(["md_responsibility_centers", "profits"]).map((i) => i && i.name)) ||
      [])
  ]);

  const getCenterNames = (path) => {
    const centers = form.getFieldValue(path) || [];
    return centers.map((i) => i && i.name).filter(Boolean);
  };

  const handleBlur = () => {
    setCostOptions(getCenterNames(["md_responsibility_centers", "costs"]));
    setProfitOptions(getCenterNames(["md_responsibility_centers", "profits"]));
  };

  const ReceivableCustomFieldSelect = (
    <Select
      allowClear
      options={[
        { value: "v_vin", label: "VIN" },
        { value: "clm_no", label: "Claim No." },
        { value: "ded_amt", label: "Deductible Amount" }
      ]}
    />
  );

  return (
    <div>
      <RbacWrapper action="shop:responsibilitycenter">
        <LayoutFormRow header={t("bodyshop.labels.accountingsetup")} id="accountingsetup">
          <>
            <Form.Item
              key="md_payment_types"
              name={["md_payment_types"]}
              label={t("bodyshop.fields.md_payment_types")}
              rules={[
                {
                  required: true,
                  type: "array"
                }
              ]}
            >
              <Select mode="tags" />
            </Form.Item>

            <div style={{ display: "grid", gap: 16, marginTop: 16 }}>
              <Row gutter={[16, 0]} wrap>
                <Col xs={24} sm={12} xl={8}>
                  <Form.Item
                    key="inhousevendorid"
                    label={t("bodyshop.fields.inhousevendorid")}
                    name={"inhousevendorid"}
                    rules={[
                      {
                        required: true
                      }
                    ]}
                  >
                    <Input />
                  </Form.Item>
                </Col>
                <Col xs={24} sm={12} xl={8}>
                  <Form.Item
                    key="default_adjustment_rate"
                    label={t("bodyshop.fields.default_adjustment_rate")}
                    name={"default_adjustment_rate"}
                    rules={[
                      {
                        required: true
                      }
                    ]}
                  >
                    <InputNumber min={0} precision={2} />
                  </Form.Item>
                </Col>
                {InstanceRenderManager({
                  imex: (
                    <Col xs={24} sm={12} xl={8}>
                      <Form.Item key="federal_tax_id" label={t("bodyshop.fields.federal_tax_id")} name="federal_tax_id">
                        <Input />
                      </Form.Item>
                    </Col>
                  )
                })}
                <Col xs={24} sm={12} xl={8}>
                  <Form.Item key="state_tax_id" label={t("bodyshop.fields.state_tax_id")} name="state_tax_id">
                    <Input />
                  </Form.Item>
                </Col>
                {HasFeatureAccess({ featureName: "export", bodyshop }) &&
                  ClosingPeriod.treatment === "on" && (
                    <Col xs={24} sm={12} xl={8}>
                      <Form.Item
                        key="ClosingPeriod"
                        name={["accountingconfig", "ClosingPeriod"]}
                        label={t("bodyshop.fields.closingperiod")}
                      >
                        <DatePicker.RangePicker format="MM/DD/YYYY" presets={DatePickerRanges} />
                      </Form.Item>
                    </Col>
                  )}
                {HasFeatureAccess({ featureName: "export", bodyshop }) &&
                  ADPPayroll.treatment === "on" && (
                    <Col xs={24} sm={12} xl={8}>
                      <Form.Item
                        key="companyCode"
                        name={["accountingconfig", "companyCode"]}
                        label={t("bodyshop.fields.companycode")}
                      >
                        <Input />
                      </Form.Item>
                    </Col>
                  )}
                {HasFeatureAccess({ featureName: "export", bodyshop }) &&
                  ADPPayroll.treatment === "on" && (
                    <Col xs={24} sm={12} xl={8}>
                      <Form.Item key="batchID" name={["accountingconfig", "batchID"]} label={t("bodyshop.fields.batchid")}>
                        <Input />
                      </Form.Item>
                    </Col>
                  )}
                {HasFeatureAccess({ featureName: "export", bodyshop }) && !hasDMSKey && (
                  <>
                    <Col xs={24} sm={12} xl={8}>
                      <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>
                    </Col>
                    <Col xs={24} sm={12} xl={8}>
                      <Form.Item key="twotierpref_wrapper" shouldUpdate noStyle>
                        {() => {
                          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>
                    </Col>
                    <Col xs={24} sm={12} xl={8}>
                      <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>
                    </Col>
                  </>
                )}
              </Row>

              <Divider style={{ margin: "0" }} />

              <Row gutter={[16, 0]} wrap>
                {HasFeatureAccess({ featureName: "export", bodyshop }) && !hasDMSKey && (
                  <>
                    <Col xs={24} sm={12} xl={8}>
                      <Form.Item
                        key="printlater"
                        label={t("bodyshop.labels.printlater")}
                        valuePropName="checked"
                        name={["accountingconfig", "printlater"]}
                      >
                        <Switch />
                      </Form.Item>
                    </Col>
                    <Col xs={24} sm={12} xl={8}>
                      <Form.Item
                        key="emaillater"
                        label={t("bodyshop.labels.emaillater")}
                        valuePropName="checked"
                        name={["accountingconfig", "emaillater"]}
                      >
                        <Switch />
                      </Form.Item>
                    </Col>
                    <Col xs={24} sm={12} xl={8}>
                      <Form.Item
                        key="enforce_class"
                        name={["enforce_class"]}
                        label={t("bodyshop.fields.enforce_class")}
                        valuePropName="checked"
                      >
                        <Switch />
                      </Form.Item>
                    </Col>
                    <Col xs={24} sm={12} xl={8}>
                      <Form.Item
                        key="accumulatePayableLines"
                        name={["accountingconfig", "accumulatePayableLines"]}
                        label={t("bodyshop.fields.accumulatePayableLines")}
                        valuePropName="checked"
                      >
                        <Switch />
                      </Form.Item>
                    </Col>
                  </>
                )}
                {HasFeatureAccess({ featureName: "timetickets", bodyshop }) && (
                  <>
                    <Col xs={24} sm={12} xl={8}>
                      <Form.Item
                        key="tt_allow_post_to_invoiced"
                        name={["tt_allow_post_to_invoiced"]}
                        label={t("bodyshop.fields.tt_allow_post_to_invoiced")}
                        valuePropName="checked"
                      >
                        <Switch />
                      </Form.Item>
                    </Col>
                    <Col xs={24} sm={12} xl={8}>
                      <Form.Item
                        key="tt_enforce_hours_for_tech_console"
                        name={["tt_enforce_hours_for_tech_console"]}
                        label={t("bodyshop.fields.tt_enforce_hours_for_tech_console")}
                        valuePropName="checked"
                      >
                        <Switch />
                      </Form.Item>
                    </Col>
                  </>
                )}
                {HasFeatureAccess({ featureName: "bills", bodyshop }) && (
                  <>
                    <Col xs={24} sm={12} xl={8}>
                      <Form.Item
                        key="bill_allow_post_to_closed"
                        name={["bill_allow_post_to_closed"]}
                        label={t("bodyshop.fields.bill_allow_post_to_closed")}
                        valuePropName="checked"
                      >
                        <Switch />
                      </Form.Item>
                    </Col>
                    <Col xs={24} sm={12} xl={8}>
                      <Form.Item
                        key="disableBillCostCalculation"
                        name={["accountingconfig", "disableBillCostCalculation"]}
                        label={t("bodyshop.fields.disableBillCostCalculation")}
                        valuePropName="checked"
                      >
                        <Switch />
                      </Form.Item>
                    </Col>
                  </>
                )}
              </Row>

              {HasFeatureAccess({ featureName: "export", bodyshop }) && !hasDMSKey && (
                <LayoutFormRow
                  header={t("bodyshop.labels.responsibilitycenters.quickbooks_qbd")}
                  grow
                  style={{ marginBottom: 0 }}
                  extra={
                    <Space size={12} align="center" split={<span style={INLINE_TITLE_SEPARATOR_STYLE} />}>
                      <div style={INLINE_TITLE_SWITCH_GROUP_STYLE}>
                        <span style={INLINE_TITLE_LABEL_STYLE}>{t("bodyshop.labels.qbo")}</span>
                        <Form.Item noStyle valuePropName="checked" name={["accountingconfig", "qbo"]}>
                          <Switch />
                        </Form.Item>
                      </div>
                      {InstanceRenderManager({
                        imex: (
                          <div style={INLINE_TITLE_SWITCH_GROUP_STYLE}>
                            <span style={INLINE_TITLE_LABEL_STYLE}>{t("bodyshop.labels.qbo_usa")}</span>
                            <Form.Item key="qbo_usa_wrapper" shouldUpdate noStyle>
                              {() => (
                                <Form.Item noStyle valuePropName="checked" name={["accountingconfig", "qbo_usa"]}>
                                  <Switch disabled={!form.getFieldValue(["accountingconfig", "qbo"])} />
                                </Form.Item>
                              )}
                            </Form.Item>
                          </div>
                        )
                      })}
                    </Space>
                  }
                >
                  <Form.Item
                    key="qbo_departmentid"
                    label={t("bodyshop.labels.qbo_departmentid")}
                    name={["accountingconfig", "qbo_departmentid"]}
                  >
                    <Input />
                  </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>
                </LayoutFormRow>
              )}

              {HasFeatureAccess({ featureName: "bills", bodyshop }) && (
                <LayoutFormRow header={t("bodyshop.labels.responsibilitycenters.invoices")} grow style={{ marginBottom: 0 }}>
                  {InstanceRenderManager({
                    imex: (
                      <Form.Item
                        key="invoice_federal_tax_rate"
                        label={t("bodyshop.fields.responsibilitycenters.invoice_federal_tax_rate_short")}
                        name={["bill_tax_rates", "federal_tax_rate"]}
                        rules={[
                          {
                            required: true
                          }
                        ]}
                      >
                        <InputNumber suffix="%" />
                      </Form.Item>
                    )
                  })}
                  <Form.Item
                    key="invoice_state_tax_rate"
                    label={t("bodyshop.fields.responsibilitycenters.invoice_state_tax_rate_short")}
                    name={["bill_tax_rates", "state_tax_rate"]}
                    rules={[
                      {
                        required: true
                      }
                    ]}
                  >
                    <InputNumber suffix="%" />
                  </Form.Item>
                  <Form.Item
                    key="invoice_local_tax_rate"
                    label={t("bodyshop.fields.responsibilitycenters.invoice_local_tax_rate_short")}
                    name={["bill_tax_rates", "local_tax_rate"]}
                    rules={[
                      {
                        required: true
                      }
                    ]}
                  >
                    <InputNumber suffix="%" />
                  </Form.Item>
                </LayoutFormRow>
              )}
            </div>
          </>
        </LayoutFormRow>
        {hasDMSKey && (
          <LayoutFormRow header={t("bodyshop.labels.dms_setup")} id="dms_setup">
            <div>
              <LayoutFormRow id="dmsconfiguration" grow={true}>
                {bodyshop.rr_dealerid && (
                  <DataLabel label={t("bodyshop.labels.dms.rr_dealerid")}>
                    {form.getFieldValue("rr_dealerid")}
                  </DataLabel>
                )}
                {bodyshop.cdk_dealerid && (
                  <DataLabel label={t("bodyshop.labels.dms.cdk_dealerid")}>
                    {form.getFieldValue("cdk_dealerid")}
                  </DataLabel>
                )}
                {bodyshop.pbs_serialnumber && (
                  <DataLabel label={t("bodyshop.labels.dms.pbs_serialnumber")}>
                    {form.getFieldValue("pbs_serialnumber")}
                  </DataLabel>
                )}
              </LayoutFormRow>
              <LayoutFormRow>
                <Form.Item
                  label={t("bodyshop.fields.dms.default_journal")}
                  rules={[{ required: true }]}
                  name={["cdk_configuration", "default_journal"]}
                >
                  <Input />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.dms.srcco")}
                  rules={[{ required: true }]}
                  name={["cdk_configuration", "srcco"]}
                >
                  <Input />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.dms.generic_customer_number")}
                  name={["cdk_configuration", "generic_customer_number"]}
                >
                  <Input />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.dms.cashierid")}
                  rules={[{ required: true }]}
                  name={["cdk_configuration", "cashierid"]}
                >
                  <Input />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.dms.sendmaterialscosting")}
                  name={["cdk_configuration", "sendmaterialscosting"]}
                >
                  <InputNumber min={0} max={100} suffix="%" />
                </Form.Item>
                {bodyshop.pbs_serialnumber && (
                  <Form.Item
                    label={t("bodyshop.fields.dms.disablecontactvehiclecreation")}
                    valuePropName="checked"
                    name={["pbs_configuration", "disablecontactvehicle"]}
                  >
                    <Switch />
                  </Form.Item>
                )}
                {bodyshop.pbs_serialnumber && (
                  <Form.Item
                    label={t("bodyshop.fields.dms.disablebillwip")}
                    valuePropName="checked"
                    name={["pbs_configuration", "disablebillwip"]}
                  >
                    <Switch />
                  </Form.Item>
                )}
                {bodyshop.pbs_serialnumber && (
                  <Form.Item
                    label={t("bodyshop.fields.dms.ro_posting")}
                    valuePropName="checked"
                    name={["pbs_configuration", "ro_posting"]}
                  >
                    <Switch />
                  </Form.Item>
                )}
                {bodyshop.pbs_serialnumber && (
                  <Form.Item
                    label={t("bodyshop.fields.dms.appostingaccount")}
                    name={["pbs_configuration", "appostingaccount"]}
                  >
                    <Select
                      options={[
                        { value: "wip", label: "WIP" },
                        { value: "cogs", label: "COGS" }
                      ]}
                    />
                  </Form.Item>
                )}
                {bodyshop.pbs_serialnumber && (
                  <Form.Item label={t("bodyshop.fields.dms.apcontrol")} name={["pbs_configuration", "apcontrol"]}>
                    <Select
                      options={[
                        { value: "ro", label: "RO Number" },
                        { value: "vendordmsid", label: "Vendor DMS ID" }
                      ]}
                    />
                  </Form.Item>
                )}
              </LayoutFormRow>

              {!bodyshop.rr_dealerid && (
                <>
                  <Form.List name={["cdk_configuration", "payers"]}>
                    {(fields, { add, remove, move }) => {
                      return (
                        <LayoutFormRow
                          header={t("bodyshop.labels.dms.cdk.payers")}
                          actions={[
                            buildSectionActionButton("add-payer", t("jobs.actions.addpayer"), () => {
                              add();
                            })
                          ]}
                        >
                          <div>
                            {renderListOrEmpty(fields, t("jobs.actions.addpayer"), () =>
                              fields.map((field, index) => {
                                const dmsPayer = dmsPayers[field.name] || {};

                                return (
                                  <Form.Item key={field.key}>
                                    <LayoutFormRow
                                      noDivider
                                      title={getFormListItemTitle(
                                        t("jobs.fields.dms.payer.name"),
                                        index,
                                        dmsPayer.name,
                                        dmsPayer.dms_acctnumber
                                      )}
                                      extra={
                                        <Space align="center" size="small">
                                          <Button
                                            type="text"
                                            danger
                                            icon={<DeleteFilled />}
                                            onClick={() => {
                                              remove(field.name);
                                            }}
                                          />
                                          <FormListMoveArrows
                                            move={move}
                                            index={index}
                                            total={fields.length}
                                            orientation="horizontal"
                                          />
                                        </Space>
                                      }
                                    >
                                      <Form.Item
                                        label={t("jobs.fields.dms.payer.name")}
                                        key={`${index}name`}
                                        name={[field.name, "name"]}
                                        rules={[{ required: true }]}
                                      >
                                        <Input />
                                      </Form.Item>
                                      <Form.Item
                                        label={t("jobs.fields.dms.payer.dms_acctnumber")}
                                        key={`${index}dms_acctnumber`}
                                        name={[field.name, "dms_acctnumber"]}
                                        rules={[{ required: true }]}
                                      >
                                        <Input />
                                      </Form.Item>
                                      <Form.Item
                                        label={t("jobs.fields.dms.payer.control_type")}
                                        key={`${index}control_type`}
                                        name={[field.name, "control_type"]}
                                      >
                                        <Select
                                          allowClear
                                          showSearch
                                          options={[
                                            { value: "ro_number", label: t("jobs.fields.ro_number") },
                                            { value: "clm_no", label: t("jobs.fields.clm_no") },
                                            { value: "po_number", label: t("jobs.fields.ponumber") },
                                            {
                                              value: "account_number",
                                              label: t("jobs.fields.dms.control_type.account_number")
                                            }
                                          ]}
                                        />
                                      </Form.Item>
                                    </LayoutFormRow>
                                  </Form.Item>
                                );
                              })
                            )}
                          </div>
                        </LayoutFormRow>
                      );
                    }}
                  </Form.List>
                  <Form.List name={["cdk_configuration", "controllist"]}>
                    {(fields, { add, remove }) => {
                      return (
                        <LayoutFormRow
                          header={t("bodyshop.labels.dms.cdk.controllist")}
                          actions={[
                            buildSectionActionButton(
                              "add-control-number",
                              t("bodyshop.actions.add_control_number"),
                              () => {
                                add();
                              }
                            )
                          ]}
                        >
                          <div>
                            {renderListOrEmpty(fields, t("bodyshop.actions.add_control_number"), () =>
                              fields.map((field, index) => (
                                <Form.Item key={field.key}>
                                  <LayoutFormRow noDivider>
                                    <Form.Item
                                      label={t("jobs.fields.dms.payer.name")}
                                      key={`${index}name`}
                                      name={[field.name, "name"]}
                                      rules={[{ required: true }]}
                                    >
                                      <Input />
                                    </Form.Item>
                                    <Form.Item
                                      label={t("jobs.fields.dms.payer.controlnumber")}
                                      key={`${index}controlnumber`}
                                      name={[field.name, "controlnumber"]}
                                      rules={[{ required: true }]}
                                    >
                                      <Input />
                                    </Form.Item>
                                    <Button
                                      type="text"
                                      danger
                                      icon={<DeleteFilled />}
                                      onClick={() => {
                                        remove(field.name);
                                      }}
                                    />
                                  </LayoutFormRow>
                                </Form.Item>
                              ))
                            )}
                          </div>
                        </LayoutFormRow>
                      );
                    }}
                  </Form.List>
                </>
              )}
            </div>
          </LayoutFormRow>
        )}
        {HasFeatureAccess({ featureName: "export", bodyshop }) && (
          <>
            <Form.List name={["md_responsibility_centers", "costs"]}>
              {(fields, { add, remove, move }) => {
                return (
                  <LayoutFormRow
                    header={t("bodyshop.labels.responsibilitycenters.costs")}
                    id="costs"
                    actions={[
                      buildSectionActionButton("add-cost-center", t("bodyshop.actions.add_cost_center"), () => {
                        add();
                      })
                    ]}
                  >
                    <div>
                      {renderListOrEmpty(fields, t("bodyshop.actions.add_cost_center"), () =>
                        fields.map((field, index) => {
                          return (
                            <Form.Item noStyle key={field.key}>
                              <InlineValidatedFormRow
                                form={form}
                                errorNames={[
                                  ["md_responsibility_centers", "costs", field.name, "name"],
                                  ["md_responsibility_centers", "costs", field.name, "accountdesc"]
                                ]}
                                noDivider
                                title={
                                  <div style={INLINE_TITLE_ROW_STYLE}>
                                    <InlineTitleListIcon style={INLINE_TITLE_HANDLE_STYLE} />
                                    <div style={INLINE_TITLE_GROUP_STYLE}>
                                      <div style={INLINE_TITLE_LABEL_STYLE}>
                                        {t("bodyshop.fields.responsibilitycenter")}
                                      </div>
                                      <Form.Item noStyle name={[field.name, "name"]} rules={[{ required: true }]}>
                                        <Input
                                          placeholder={t("bodyshop.fields.responsibilitycenter")}
                                          onBlur={handleBlur}
                                          size="small"
                                          style={{
                                            ...INLINE_TITLE_INPUT_STYLE,
                                            width: "100%"
                                          }}
                                        />
                                      </Form.Item>
                                    </div>
                                    <div aria-hidden style={INLINE_TITLE_SEPARATOR_STYLE} />
                                    <div style={INLINE_TITLE_GROUP_STYLE}>
                                      <div style={INLINE_TITLE_LABEL_STYLE}>
                                        {t("bodyshop.fields.responsibilitycenter_accountdesc")}
                                      </div>
                                      <Form.Item
                                        noStyle
                                        name={[field.name, "accountdesc"]}
                                        rules={[{ required: true }]}
                                      >
                                        <Input
                                          placeholder={t("bodyshop.fields.responsibilitycenter_accountdesc")}
                                          onBlur={handleBlur}
                                          size="small"
                                          style={{
                                            ...INLINE_TITLE_INPUT_STYLE,
                                            width: "100%"
                                          }}
                                        />
                                      </Form.Item>
                                    </div>
                                  </div>
                                }
                                wrapTitle
                                extra={
                                  <Space align="center" size="small">
                                    <Button
                                      type="text"
                                      danger
                                      icon={<DeleteFilled />}
                                      onClick={() => {
                                        remove(field.name);
                                      }}
                                    />
                                    <FormListMoveArrows
                                      move={move}
                                      index={index}
                                      total={fields.length}
                                      orientation="horizontal"
                                    />
                                  </Space>
                                }
                              >
                                <Form.Item
                                  label={t("bodyshop.fields.responsibilitycenter_accountname")}
                                  key={`${index}accountname`}
                                  name={[field.name, "accountname"]}
                                  rules={[{ required: true }]}
                                >
                                  <Input onBlur={handleBlur} />
                                </Form.Item>
                                {hasDMSKey && !bodyshop.rr_dealerid && (
                                  <>
                                    <Form.Item
                                      label={t("bodyshop.fields.dms.dms_acctnumber")}
                                      key={`${index}dms_acctnumber`}
                                      name={[field.name, "dms_acctnumber"]}
                                      rules={[{ required: true }]}
                                    >
                                      <Input onBlur={handleBlur} />
                                    </Form.Item>
                                    <Form.Item
                                      label={t("bodyshop.fields.dms.dms_wip_acctnumber")}
                                      key={`${index}dms_wip_acctnumber`}
                                      name={[field.name, "dms_wip_acctnumber"]}
                                      rules={[
                                        {
                                          required: true
                                        }
                                      ]}
                                    >
                                      <Input onBlur={handleBlur} />
                                    </Form.Item>
                                  </>
                                )}

                                {bodyshop.cdk_dealerid && (
                                  <Form.Item
                                    label={t("bodyshop.fields.dms.dms_control_override")}
                                    key={`${index}dms_control_override`}
                                    name={[field.name, "dms_control_override"]}
                                  >
                                    <Input onBlur={handleBlur} />
                                  </Form.Item>
                                )}
                              </InlineValidatedFormRow>
                            </Form.Item>
                          );
                        })
                      )}
                    </div>
                  </LayoutFormRow>
                );
              }}
            </Form.List>
            <Form.List name={["md_responsibility_centers", "profits"]}>
              {(fields, { add, remove, move }) => {
                return (
                  <LayoutFormRow
                    header={t("bodyshop.labels.responsibilitycenters.profits")}
                    id="profits"
                    actions={[
                      buildSectionActionButton("add-profit-center", t("bodyshop.actions.add_profit_center"), () => {
                        add();
                      })
                    ]}
                  >
                    <div>
                      {renderListOrEmpty(fields, t("bodyshop.actions.add_profit_center"), () =>
                        fields.map((field, index) => {
                          return (
                            <Form.Item noStyle key={field.key}>
                              <InlineValidatedFormRow
                                form={form}
                                errorNames={[
                                  ["md_responsibility_centers", "profits", field.name, "name"],
                                  ["md_responsibility_centers", "profits", field.name, "accountdesc"]
                                ]}
                                noDivider
                                title={
                                  <div style={INLINE_TITLE_ROW_STYLE}>
                                    <InlineTitleListIcon style={INLINE_TITLE_HANDLE_STYLE} />
                                    <div style={INLINE_TITLE_GROUP_STYLE}>
                                      <div style={INLINE_TITLE_LABEL_STYLE}>
                                        {t("bodyshop.fields.responsibilitycenter")}
                                      </div>
                                      <Form.Item noStyle name={[field.name, "name"]} rules={[{ required: true }]}>
                                        <Input
                                          placeholder={t("bodyshop.fields.responsibilitycenter")}
                                          onBlur={handleBlur}
                                          size="small"
                                          style={{
                                            ...INLINE_TITLE_INPUT_STYLE,
                                            width: "100%"
                                          }}
                                        />
                                      </Form.Item>
                                    </div>
                                    <div aria-hidden style={INLINE_TITLE_SEPARATOR_STYLE} />
                                    <div style={INLINE_TITLE_GROUP_STYLE}>
                                      <div style={INLINE_TITLE_LABEL_STYLE}>
                                        {t("bodyshop.fields.responsibilitycenter_accountdesc")}
                                      </div>
                                      <Form.Item
                                        noStyle
                                        name={[field.name, "accountdesc"]}
                                        rules={[{ required: true }]}
                                      >
                                        <Input
                                          placeholder={t("bodyshop.fields.responsibilitycenter_accountdesc")}
                                          onBlur={handleBlur}
                                          size="small"
                                          style={{
                                            ...INLINE_TITLE_INPUT_STYLE,
                                            width: "100%"
                                          }}
                                        />
                                      </Form.Item>
                                    </div>
                                  </div>
                                }
                                wrapTitle
                                extra={
                                  <Space align="center" size="small">
                                    <Button
                                      type="text"
                                      danger
                                      icon={<DeleteFilled />}
                                      onClick={() => {
                                        remove(field.name);
                                      }}
                                    />
                                    <FormListMoveArrows
                                      move={move}
                                      index={index}
                                      total={fields.length}
                                      orientation="horizontal"
                                    />
                                  </Space>
                                }
                              >
                                {!hasDMSKey && (
                                  <Form.Item
                                    label={t("bodyshop.fields.responsibilitycenter_accountitem")}
                                    key={`${index}accountitem`}
                                    name={[field.name, "accountitem"]}
                                    rules={[{ required: true }]}
                                  >
                                    <Input onBlur={handleBlur} />
                                  </Form.Item>
                                )}
                                {bodyshop.rr_dealerid && (
                                  <Form.Item
                                    label={t("bodyshop.fields.responsibilitycenters.item_type")}
                                    key={`${index}rr_item_type`}
                                    name={[field.name, "rr_item_type"]}
                                    rules={[{ required: true }]}
                                  >
                                    <Select
                                      options={[
                                        {
                                          value: "G",
                                          label: t("bodyshop.fields.responsibilitycenters.item_type_gog")
                                        },
                                        {
                                          value: "P",
                                          label: t("bodyshop.fields.responsibilitycenters.item_type_paint")
                                        },
                                        {
                                          value: "F",
                                          label: t("bodyshop.fields.responsibilitycenters.item_type_freight")
                                        }
                                      ]}
                                    />
                                  </Form.Item>
                                )}
                                {hasDMSKey && !bodyshop.rr_dealerid && (
                                  <Form.Item
                                    label={t("bodyshop.fields.dms.dms_acctnumber")}
                                    key={`${index}dms_acctnumber`}
                                    name={[field.name, "dms_acctnumber"]}
                                    rules={[{ required: true }]}
                                  >
                                    <Input onBlur={handleBlur} />
                                  </Form.Item>
                                )}
                                {bodyshop.cdk_dealerid && (
                                  <Form.Item
                                    label={t("bodyshop.fields.dms.dms_control_override")}
                                    key={`${index}dms_control_override`}
                                    name={[field.name, "dms_control_override"]}
                                  >
                                    <Input onBlur={handleBlur} />
                                  </Form.Item>
                                )}
                                {bodyshop.rr_dealerid && [
                                  <Form.Item
                                    label={t("bodyshop.fields.responsibilitycenters.gogcode")}
                                    key={`${index}rr_gogcode`}
                                    name={[field.name, "rr_gogcode"]}
                                    col={{ xs: 24, md: 8, lg: 8, xl: 8, xxl: 8 }}
                                    rules={[{ required: true }]}
                                  >
                                    <Input onBlur={handleBlur} />
                                  </Form.Item>,
                                  <Form.Item
                                    label={t("bodyshop.fields.responsibilitycenters.taxable_flag")}
                                    key={`${index}rr_cust_txbl_flag`}
                                    name={[field.name, "rr_cust_txbl_flag"]}
                                    col={{ xs: 24, md: 8, lg: 8, xl: 8, xxl: 8 }}
                                    rules={[{ required: true }]}
                                  >
                                    <Select
                                      options={[
                                        { value: "T", label: t("bodyshop.fields.responsibilitycenters.taxable") },
                                        { value: "N", label: t("bodyshop.fields.responsibilitycenters.nontaxable") }
                                      ]}
                                    />
                                  </Form.Item>
                                ]}
                              </InlineValidatedFormRow>
                            </Form.Item>
                          );
                        })
                      )}
                    </div>
                  </LayoutFormRow>
                );
              }}
            </Form.List>
            <SelectorDiv>
              {hasDMSKey && (
                <Form.List name={["md_responsibility_centers", "dms_defaults"]}>
                  {(fields, { add, remove }) => {
                    return (
                      <LayoutFormRow
                        id="mappingname"
                        header={t("bodyshop.labels.dms.dms_allocations")}
                        actions={[
                          buildSectionActionButton(
                            "add-dms-allocation",
                            t("bodyshop.actions.add_dms_allocation"),
                            () => {
                              add();
                            }
                          )
                        ]}
                      >
                        <div>
                          {renderListOrEmpty(fields, t("bodyshop.actions.add_dms_allocation"), () =>
                            fields.map((field, index) => {
                              const dmsDefault = form.getFieldValue([
                                "md_responsibility_centers",
                                "dms_defaults",
                                field.name
                              ]) || { name: undefined };

                              return (
                                <Form.Item key={field.key}>
                                  <LayoutFormRow
                                    title={getFormListItemTitle(
                                      t("bodyshop.fields.dms.mappingname"),
                                      index,
                                      dmsDefault.name
                                    )}
                                    extra={
                                      <Button
                                        type="text"
                                        danger
                                        icon={<DeleteFilled />}
                                        onClick={() => {
                                          remove(field.name);
                                        }}
                                      />
                                    }
                                  >
                                    <div>
                                      <LayoutFormRow noDivider>
                                        <Form.Item
                                          label={t("bodyshop.fields.dms.mappingname")}
                                          key={`${index}name`}
                                          name={[field.name, "name"]}
                                          rules={[{ required: true }]}
                                        >
                                          <Input />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.gst_override")}
                                          name={[field.name, "gst_override"]}
                                        >
                                          <Input />
                                        </Form.Item>
                                      </LayoutFormRow>
                                      <LayoutFormRow header={t("bodyshop.labels.dms.costsmapping")}>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.ats")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-ats`}
                                          name={[field.name, "costs", "ATS"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.laa")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-LAA`}
                                          name={[field.name, "costs", "LAA"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.lab")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-LAB`}
                                          name={[field.name, "costs", "LAB"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.lad")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-LAD`}
                                          name={[field.name, "costs", "LAD"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.lae")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-LAE`}
                                          name={[field.name, "costs", "LAE"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.laf")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-LAF`}
                                          name={[field.name, "costs", "LAF"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.lag")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-LAG`}
                                          name={[field.name, "costs", "LAG"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.lam")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-LAM`}
                                          name={[field.name, "costs", "LAM"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.lar")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-LAR`}
                                          name={[field.name, "costs", "LAR"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.las")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-LAS`}
                                          name={[field.name, "costs", "LAS"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.lau")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-LAU`}
                                          name={[field.name, "costs", "LAU"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.la1")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-LA1`}
                                          name={[field.name, "costs", "LA1"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.la2")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-LA2`}
                                          name={[field.name, "costs", "LA2"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.la3")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-LA3`}
                                          name={[field.name, "costs", "LA3"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.la4")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-LA4`}
                                          name={[field.name, "costs", "LA4"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.paa")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-PAA`}
                                          name={[field.name, "costs", "PAA"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pac")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-PAC`}
                                          name={[field.name, "costs", "PAC"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pag")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-PAG`}
                                          name={[field.name, "costs", "PAG"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pal")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-PAL`}
                                          name={[field.name, "costs", "PAL"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pam")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-PAM`}
                                          name={[field.name, "costs", "PAM"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pan")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-PAN`}
                                          name={[field.name, "costs", "PAN"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pao")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-PAO`}
                                          name={[field.name, "costs", "PAO"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pap")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-PAP`}
                                          name={[field.name, "costs", "PAP"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.par")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-PAR`}
                                          name={[field.name, "costs", "PAR"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pas")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-PAS`}
                                          name={[field.name, "costs", "PAS"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pasl")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-PASL`}
                                          name={[field.name, "costs", "PASL"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.tow")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-TOW`}
                                          name={[field.name, "costs", "TOW"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.mapa")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-MAPA`}
                                          name={[field.name, "costs", "MAPA"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.mash")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (costOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}costs-MASH`}
                                          name={[field.name, "costs", "MASH"]}
                                        >
                                          <Select
                                            showSearch
                                            options={costOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                      </LayoutFormRow>
                                      <LayoutFormRow header={t("bodyshop.labels.dms.profitsmapping")}>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.ats")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-ATS`}
                                          name={[field.name, "profits", "ATS"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.laa")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-LAA`}
                                          name={[field.name, "profits", "LAA"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.lab")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-LAB`}
                                          name={[field.name, "profits", "LAB"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.lad")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-LAD`}
                                          name={[field.name, "profits", "LAD"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.lae")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-LAE`}
                                          name={[field.name, "profits", "LAE"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.laf")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-LAF`}
                                          name={[field.name, "profits", "LAF"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.lag")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-LAG`}
                                          name={[field.name, "profits", "LAG"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.lam")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-LAM`}
                                          name={[field.name, "profits", "LAM"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.lar")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-LAR`}
                                          name={[field.name, "profits", "LAR"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.las")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-LAS`}
                                          name={[field.name, "profits", "LAS"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.lau")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-LAU`}
                                          name={[field.name, "profits", "LAU"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.la1")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-LA1`}
                                          name={[field.name, "profits", "LA1"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.la2")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-LA2`}
                                          name={[field.name, "profits", "LA2"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.la3")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-LA3`}
                                          name={[field.name, "profits", "LA3"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.la4")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-LA4`}
                                          name={[field.name, "profits", "LA4"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.paa")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-PAA`}
                                          name={[field.name, "profits", "PAA"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pac")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-PAC`}
                                          name={[field.name, "profits", "PAC"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pag")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-PAG`}
                                          name={[field.name, "profits", "PAG"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pal")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-PAL`}
                                          name={[field.name, "profits", "PAL"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pam")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-PAM`}
                                          name={[field.name, "profits", "PAM"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pan")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-PAN`}
                                          name={[field.name, "profits", "PAN"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pao")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-PAO`}
                                          name={[field.name, "profits", "PAO"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pap")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-PAP`}
                                          name={[field.name, "profits", "PAP"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.par")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-PAR`}
                                          name={[field.name, "profits", "PAR"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pas")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-PAS`}
                                          name={[field.name, "profits", "PAS"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.pasl")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-PASL`}
                                          name={[field.name, "profits", "PASL"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.tow")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-TOW`}
                                          name={[field.name, "profits", "TOW"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.mapa")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-MAPA`}
                                          name={[field.name, "profits", "MAPA"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                        <Form.Item
                                          label={t("bodyshop.fields.responsibilitycenters.mash")}
                                          rules={[
                                            { required: true },
                                            () => ({
                                              validator(rule, value) {
                                                if (profitOptions.includes(value)) {
                                                  return Promise.resolve();
                                                }
                                                return Promise.reject(t("bodyshop.validation.centermustexist"));
                                              }
                                            })
                                          ]}
                                          key={`${index}profits-MASH`}
                                          name={[field.name, "profits", "MASH"]}
                                        >
                                          <Select
                                            showSearch
                                            options={profitOptions.map((item) => ({ value: item, label: item }))}
                                          />
                                        </Form.Item>
                                      </LayoutFormRow>
                                    </div>
                                  </LayoutFormRow>
                                </Form.Item>
                              );
                            })
                          )}
                        </div>
                      </LayoutFormRow>
                    );
                  }}
                </Form.List>
              )}

              <LayoutFormRow header={t("bodyshop.labels.defaultcostsmapping")}>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.ats")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "ATS"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.laa")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "LAA"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.lab")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "LAB"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.lad")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "LAD"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.lae")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "LAE"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.laf")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "LAF"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.lag")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "LAG"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.lam")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "LAM"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.lar")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "LAR"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.las")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "LAS"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.lau")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "LAU"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.la1")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "LA1"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.la2")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "LA2"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.la3")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "LA3"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.la4")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "LA4"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.paa")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "PAA"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pac")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "PAC"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pag")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "PAG"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pal")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "PAL"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pam")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "PAM"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pan")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "PAN"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pao")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "PAO"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pap")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "PAP"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.par")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "PAR"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pas")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "PAS"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pasl")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "PASL"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.tow")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "TOW"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.mapa")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "MAPA"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.mash")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (costOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "costs", "MASH"]}
                >
                  <Select showSearch options={costOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
              </LayoutFormRow>
              <LayoutFormRow header={t("bodyshop.labels.defaultprofitsmapping")}>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.ats")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "ATS"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.laa")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "LAA"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.lab")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "LAB"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.lad")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "LAD"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.lae")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "LAE"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.laf")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "LAF"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.lag")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "LAG"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.lam")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "LAM"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.lar")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "LAR"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.las")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "LAS"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.lau")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "LAU"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.la1")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "LA1"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.la2")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "LA2"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.la3")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "LA3"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.la4")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "LA4"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.paa")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "PAA"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pac")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "PAC"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pag")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "PAG"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pal")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "PAL"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pam")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "PAM"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pan")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "PAN"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pao")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "PAO"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pap")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "PAP"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.par")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "PAR"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pas")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "PAS"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.pasl")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "PASL"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.tow")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "TOW"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.mapa")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "MAPA"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenters.mash")}
                  rules={[
                    { required: true },
                    () => ({
                      validator(rule, value) {
                        if (profitOptions.includes(value)) {
                          return Promise.resolve();
                        }
                        return Promise.reject(t("bodyshop.validation.centermustexist"));
                      }
                    })
                  ]}
                  name={["md_responsibility_centers", "defaults", "profits", "MASH"]}
                >
                  <Select showSearch options={profitOptions.map((item) => ({ value: item, label: item }))} />
                </Form.Item>
              </LayoutFormRow>
            </SelectorDiv>
          </>
        )}

        <LayoutFormRow header={t("bodyshop.labels.responsibilitycenters.tax_accounts")} id="tax_accounts">
          <div style={{ display: "grid", gap: 16 }}>
            <LayoutFormRow
              header={t("bodyshop.fields.responsibilitycenters.federal_tax")}
              grow
              style={{ marginBottom: 0 }}
            >
              <Form.Item
                label={t("bodyshop.fields.responsibilitycenters.federal_tax")}
                rules={[{ required: true }]}
                name={["md_responsibility_centers", "taxes", "federal", "name"]}
                col={taxAccountRowCol}
              >
                <Input />
              </Form.Item>
              <Form.Item
                label={t("bodyshop.fields.responsibilitycenter_accountdesc")}
                rules={[{ required: true }]}
                name={["md_responsibility_centers", "taxes", "federal", "accountdesc"]}
                col={taxAccountRowCol}
              >
                <Input />
              </Form.Item>
              <Form.Item
                label={t("bodyshop.fields.responsibilitycenter_accountitem")}
                rules={[{ required: true }]}
                name={["md_responsibility_centers", "taxes", "federal", "accountitem"]}
                col={taxAccountRowCol}
              >
                <Input />
              </Form.Item>
              <Form.Item
                label={t("bodyshop.fields.responsibilitycenter_rate")}
                rules={[{ required: true }]}
                name={["md_responsibility_centers", "taxes", "federal", "rate"]}
                col={taxAccountRowCol}
              >
                <InputNumber precision={2} suffix="%" />
              </Form.Item>
              {hasDMSKey && (
                <Form.Item
                  label={t("bodyshop.fields.dms.dms_acctnumber")}
                  rules={[{ required: true }]}
                  name={["md_responsibility_centers", "taxes", "federal", "dms_acctnumber"]}
                  col={taxAccountFullRowCol}
                >
                  <Input />
                </Form.Item>
              )}
            </LayoutFormRow>

            {InstanceRenderManager({
              imex: (
                <LayoutFormRow
                  header={t("bodyshop.fields.responsibilitycenters.state_tax")}
                  grow
                  style={{ marginBottom: 0 }}
                >
                  <Form.Item
                    label={t("bodyshop.fields.responsibilitycenters.state_tax")}
                    rules={[{ required: true }]}
                    name={["md_responsibility_centers", "taxes", "state", "name"]}
                    col={taxAccountRowCol}
                  >
                    <Input />
                  </Form.Item>
                  <Form.Item
                    label={t("bodyshop.fields.responsibilitycenter_accountdesc")}
                    rules={[{ required: true }]}
                    name={["md_responsibility_centers", "taxes", "state", "accountdesc"]}
                    col={taxAccountRowCol}
                  >
                    <Input />
                  </Form.Item>
                  <Form.Item
                    label={t("bodyshop.fields.responsibilitycenter_accountitem")}
                    rules={[{ required: true }]}
                    name={["md_responsibility_centers", "taxes", "state", "accountitem"]}
                    col={taxAccountRowCol}
                  >
                    <Input />
                  </Form.Item>
                  <Form.Item
                    label={t("bodyshop.fields.responsibilitycenter_rate")}
                    rules={[{ required: true }]}
                    name={["md_responsibility_centers", "taxes", "state", "rate"]}
                    col={taxAccountRowCol}
                  >
                    <InputNumber precision={2} suffix="%" />
                  </Form.Item>
                  {hasDMSKey && (
                    <Form.Item
                      label={t("bodyshop.fields.dms.dms_acctnumber")}
                      rules={[{ required: true }]}
                      name={["md_responsibility_centers", "taxes", "state", "dms_acctnumber"]}
                      col={taxAccountFullRowCol}
                    >
                      <Input />
                    </Form.Item>
                  )}
                </LayoutFormRow>
              ),
              rome: null
            })}
          </div>
        </LayoutFormRow>

        {DmsAp.treatment === "on" && (
          <LayoutFormRow id="federal_tax_itc">
            <Form.Item
              label={t("bodyshop.fields.responsibilitycenters.federal_tax_itc")}
              rules={[{ required: true }]}
              name={["md_responsibility_centers", "taxes", "federal_itc", "name"]}
            >
              <Input />
            </Form.Item>
            <Form.Item
              label={t("bodyshop.fields.responsibilitycenter_accountdesc")}
              rules={[{ required: true }]}
              name={["md_responsibility_centers", "taxes", "federal_itc", "accountdesc"]}
            >
              <Input />
            </Form.Item>
            <Form.Item
              label={t("bodyshop.fields.responsibilitycenter_accountitem")}
              rules={[{ required: true }]}
              name={["md_responsibility_centers", "taxes", "federal_itc", "accountitem"]}
            >
              <Input />
            </Form.Item>
            {hasDMSKey && (
              <Form.Item
                label={t("bodyshop.fields.dms.dms_acctnumber")}
                rules={[{ required: true }]}
                name={["md_responsibility_centers", "taxes", "federal_itc", "dms_acctnumber"]}
              >
                <Input />
              </Form.Item>
            )}
            <Form.Item
              label={t("bodyshop.fields.responsibilitycenter_rate")}
              rules={[{ required: true }]}
              name={["md_responsibility_centers", "taxes", "federal_itc", "rate"]}
            >
              <InputNumber precision={2} suffix="%" />
            </Form.Item>
          </LayoutFormRow>
        )}
        {InstanceRenderManager({
          imex: null,
          rome: <ShopInfoResponsibilitycentersTaxesComponent form={form} />
        })}
        {HasFeatureAccess({ featureName: "export", bodyshop }) && (
          <>
            {InstanceRenderManager({
              rome: (
                <LayoutFormRow header={t("bodyshop.labels.responsibilitycenters.quickbooks_us")} id="quickbooks_us">
                  <Form.Item
                    label={t("bodyshop.fields.responsibilitycenters.itemexemptcode_short")}
                    rules={[{ required: true }]}
                    name={["md_responsibility_centers", "taxes", "itemexemptcode"]}
                  >
                    <Input />
                  </Form.Item>
                  <Form.Item
                    label={t("bodyshop.fields.responsibilitycenters.invoiceexemptcode_short")}
                    rules={[{ required: true }]}
                    name={["md_responsibility_centers", "taxes", "invoiceexemptcode"]}
                  >
                    <Input />
                  </Form.Item>
                </LayoutFormRow>
              )
            })}
            <LayoutFormRow header={<div>AR</div>} id="AR">
              <Form.Item
                label={t("bodyshop.fields.responsibilitycenter_accountname")}
                rules={[{ required: true }]}
                name={["md_responsibility_centers", "ar", "accountname"]}
              >
                <Input />
              </Form.Item>
            </LayoutFormRow>
            {DmsAp.treatment === "on" && (
              <LayoutFormRow header={t("bodyshop.fields.responsibilitycenters.ap")} id="ap">
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenter_accountname")}
                  rules={[{ required: true }]}
                  name={["md_responsibility_centers", "ap", "accountname"]}
                >
                  <Input />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenter_accountdesc")}
                  rules={[{ required: true }]}
                  name={["md_responsibility_centers", "ap", "accountdesc"]}
                >
                  <Input />
                </Form.Item>
                <Form.Item
                  label={t("bodyshop.fields.dms.dms_acctnumber")}
                  rules={[{ required: true }]}
                  name={["md_responsibility_centers", "ap", "dms_acctnumber"]}
                >
                  <Input />
                </Form.Item>
              </LayoutFormRow>
            )}
            <LayoutFormRow header={<div>Refund</div>} id="refund">
              <Form.Item
                label={t("bodyshop.fields.responsibilitycenter_accountitem")}
                rules={[{ required: true }]}
                name={["md_responsibility_centers", "refund", "accountitem"]}
              >
                <Input />
              </Form.Item>
            </LayoutFormRow>
            {InstanceRenderManager({
              rome: (
                <LayoutFormRow header={<div>Adjustments</div>} id="refund">
                  {hasDMSKey ? (
                    <>
                      <Form.Item
                        label={t("bodyshop.labels.responsibilitycenters.ttl_adjustment")}
                        rules={[{ required: true }]}
                        name={["md_responsibility_centers", "ttl_adjustment", "dms_acctnumber"]}
                      >
                        <Input />
                      </Form.Item>
                      <Form.Item
                        label={t("bodyshop.labels.responsibilitycenters.ttl_tax_adjustment")}
                        rules={[{ required: true }]}
                        name={["md_responsibility_centers", "ttl_tax_adjustment", "dms_acctnumber"]}
                      >
                        <Input />
                      </Form.Item>
                    </>
                  ) : (
                    <>
                      <Form.Item
                        label={t("bodyshop.labels.responsibilitycenters.ttl_adjustment")}
                        rules={[{ required: true }]}
                        name={["md_responsibility_centers", "ttl_adjustment", "accountitem"]}
                      >
                        <Input />
                      </Form.Item>
                      <Form.Item
                        label={t("bodyshop.labels.responsibilitycenters.ttl_tax_adjustment")}
                        rules={[{ required: true }]}
                        name={["md_responsibility_centers", "ttl_tax_adjustment", "accountitem"]}
                      >
                        <Input />
                      </Form.Item>
                    </>
                  )}
                </LayoutFormRow>
              )
            })}
            {Qb_Multi_Ar.treatment === "on" && (
              <LayoutFormRow header={<div>Multiple Payers Item</div>} id="accountitem">
                <Form.Item
                  label={t("bodyshop.fields.responsibilitycenter_accountitem")}
                  rules={[{ required: true }]}
                  name={["md_responsibility_centers", "qb_multiple_payers", "accountitem"]}
                >
                  <Input />
                </Form.Item>
              </LayoutFormRow>
            )}
            <Form.List name={["md_responsibility_centers", "sales_tax_codes"]}>
              {(fields, { add, remove }) => {
                return (
                  <LayoutFormRow
                    id="mappingname"
                    header={t("bodyshop.labels.responsibilitycenters.sales_tax_codes")}
                    actions={[
                      buildSectionActionButton("add-sales-tax-code", t("bodyshop.actions.newsalestaxcode"), () => {
                        add();
                      })
                    ]}
                  >
                    <div>
                      {renderListOrEmpty(fields, t("bodyshop.actions.newsalestaxcode"), () =>
                        fields.map((field, index) => {
                          return (
                            <Form.Item noStyle key={field.key}>
                              <InlineValidatedFormRow
                                form={form}
                                errorNames={[
                                  ["md_responsibility_centers", "sales_tax_codes", field.name, "description"],
                                  ["md_responsibility_centers", "sales_tax_codes", field.name, "code"]
                                ]}
                                id="sales_tax_codes"
                                noDivider
                                title={
                                  <div style={INLINE_TITLE_ROW_STYLE}>
                                    <InlineTitleListIcon style={INLINE_TITLE_HANDLE_STYLE} />
                                    <div style={INLINE_TITLE_GROUP_STYLE}>
                                      <div style={INLINE_TITLE_LABEL_STYLE}>
                                        {t("bodyshop.fields.responsibilitycenters.sales_tax_codes.description")}
                                      </div>
                                      <Form.Item
                                        noStyle
                                        name={[field.name, "description"]}
                                        rules={[{ required: true }]}
                                      >
                                        <Input
                                          size="small"
                                          placeholder={t(
                                            "bodyshop.fields.responsibilitycenters.sales_tax_codes.description"
                                          )}
                                          style={{
                                            ...INLINE_TITLE_INPUT_STYLE,
                                            width: "100%"
                                          }}
                                        />
                                      </Form.Item>
                                    </div>
                                    <div aria-hidden style={INLINE_TITLE_SEPARATOR_STYLE} />
                                    <div style={INLINE_TITLE_GROUP_STYLE}>
                                      <div style={INLINE_TITLE_LABEL_STYLE}>
                                        {t("bodyshop.fields.responsibilitycenters.sales_tax_codes.code")}
                                      </div>
                                      <Form.Item noStyle name={[field.name, "code"]} rules={[{ required: true }]}>
                                        <Input
                                          size="small"
                                          placeholder={t("bodyshop.fields.responsibilitycenters.sales_tax_codes.code")}
                                          style={{
                                            ...INLINE_TITLE_INPUT_STYLE,
                                            width: "100%"
                                          }}
                                        />
                                      </Form.Item>
                                    </div>
                                  </div>
                                }
                                wrapTitle
                                extra={
                                  <Button
                                    type="text"
                                    danger
                                    icon={<DeleteFilled />}
                                    onClick={() => {
                                      remove(field.name);
                                    }}
                                  />
                                }
                              >
                                <Form.Item
                                  label={t("bodyshop.fields.responsibilitycenters.sales_tax_codes.federal")}
                                  key={`${index}federal`}
                                  name={[field.name, "federal"]}
                                  valuePropName="checked"
                                >
                                  <Switch />
                                </Form.Item>
                                <Form.Item
                                  label={t("bodyshop.fields.responsibilitycenters.sales_tax_codes.state")}
                                  key={`${index}state`}
                                  name={[field.name, "state"]}
                                  valuePropName="checked"
                                >
                                  <Switch />
                                </Form.Item>
                                <Form.Item
                                  label={t("bodyshop.fields.responsibilitycenters.sales_tax_codes.local")}
                                  key={`${index}local`}
                                  name={[field.name, "local"]}
                                  valuePropName="checked"
                                >
                                  <Switch />
                                </Form.Item>
                              </InlineValidatedFormRow>
                            </Form.Item>
                          );
                        })
                      )}
                    </div>
                  </LayoutFormRow>
                );
              }}
            </Form.List>
          </>
        )}
      </RbacWrapper>
    </div>
  );
}
