From af03a1b4e36bded6696299eb2ca710a4fa8ad9a1 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 12 Dec 2024 09:46:01 -0800 Subject: [PATCH] IO-3020 IO-3036 Remove date restriction and lock down feature based reports. --- .../print-center-item.component.jsx | 8 ++- .../report-center-modal.component.jsx | 53 +++++++++++------ client/src/utils/TemplateConstants.js | 57 ++++++++++++------- 3 files changed, 81 insertions(+), 37 deletions(-) diff --git a/client/src/components/print-center-item/print-center-item.component.jsx b/client/src/components/print-center-item/print-center-item.component.jsx index ff0dfcbb2..9a29318be 100644 --- a/client/src/components/print-center-item/print-center-item.component.jsx +++ b/client/src/components/print-center-item/print-center-item.component.jsx @@ -8,6 +8,7 @@ import { selectPrintCenter } from "../../redux/modals/modals.selectors"; import { selectTechnician } from "../../redux/tech/tech.selectors"; import { selectBodyshop } from "../../redux/user/user.selectors"; import { GenerateDocument } from "../../utils/RenderTemplate"; +import LockWrapperComponent from "../lock-wrapper/lock-wrapper.component"; const mapStateToProps = createStructuredSelector({ printCenterModal: selectPrintCenter, @@ -42,7 +43,12 @@ export function PrintCenterItemComponent({ setLoading(false); }; - if (disabled) return
  • {item.title}
  • ; + if (disabled || item.featureNameRestricted) + return ( +
  • + {item.title} +
  • + ); return (
  • diff --git a/client/src/components/report-center-modal/report-center-modal.component.jsx b/client/src/components/report-center-modal/report-center-modal.component.jsx index af73868a6..8d4b31def 100644 --- a/client/src/components/report-center-modal/report-center-modal.component.jsx +++ b/client/src/components/report-center-modal/report-center-modal.component.jsx @@ -21,6 +21,7 @@ import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component"; import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component"; import ReportCenterModalFiltersSortersComponent from "./report-center-modal-filters-sorters-component"; import "./report-center-modal.styles.scss"; +import LockWrapperComponent from "../lock-wrapper/lock-wrapper.component"; const mapStateToProps = createStructuredSelector({ reportCenterModal: selectReportCenter, @@ -185,13 +186,23 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) { ) : (
      - {grouped[key].map((item) => ( -
    • - - {item.title} - -
    • - ))} + {grouped[key].map((item) => + item.featureNameRestricted ? ( +
    • + + + {item.title} + + +
    • + ) : ( +
    • + + {item.title} + +
    • + ) + )}
    )} @@ -297,16 +308,13 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) { }, { validator: (_, value) => { - if ( - !import.meta.env.VITE_APP_IS_TEST && - import.meta.env.PROD && - value && - value[0] && - value[1] - ) { - const diffInDays = (value[1] - value[0]) / (1000 * 3600 * 24); - if (diffInDays > 92) { - return Promise.reject(t("general.validation.dateRangeExceeded")); + if (value && value[0] && value[1]) { + const relatedRestrictedReport = restrictedReports.find((r) => r.key === key); + if (relatedRestrictedReport) { + const diffInDays = (value[1] - value[0]) / (1000 * 3600 * 24); + if (diffInDays > relatedRestrictedReport.days) { + return Promise.reject(t("general.validation.dateRangeExceeded")); + } } } return Promise.resolve(); @@ -369,3 +377,14 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) { ); } + +const restrictedReports = [ + { key: "job_costing_ro", days: 183 }, + { key: "job_costing_ro_date_summary", days: 183 }, + { key: "job_costing_ro_csr", days: 183 }, + { key: "job_costing_ro_ins_co", days: 183 }, + { key: "job_costing_ro_date_detail", days: 183 }, + { key: "job_costing_ro_estimator", days: 183 }, + { key: "job_lifecycle_date_detail", days: 183 }, + { key: "job_lifecycle_date_summary", days: 183 } +]; diff --git a/client/src/utils/TemplateConstants.js b/client/src/utils/TemplateConstants.js index 80edfdb8d..184016c1d 100644 --- a/client/src/utils/TemplateConstants.js +++ b/client/src/utils/TemplateConstants.js @@ -342,7 +342,8 @@ export const TemplateList = (type, context) => { subject: i18n.t("printcenter.jobs.purchases_by_ro_detail"), key: "purchases_by_ro_detail", disabled: false, - group: "financial" + group: "financial", + featureNameRestricted: "bills" }, purchases_by_ro_summary: { title: i18n.t("printcenter.jobs.purchases_by_ro_summary"), @@ -350,7 +351,8 @@ export const TemplateList = (type, context) => { subject: i18n.t("printcenter.jobs.purchases_by_ro_summary"), key: "purchases_by_ro_summary", disabled: false, - group: "financial" + group: "financial", + featureNameRestricted: "bills" }, filing_coversheet_portrait: { title: i18n.t("printcenter.jobs.filing_coversheet_portrait"), @@ -398,7 +400,8 @@ export const TemplateList = (type, context) => { key: "csi_invitation", subject: i18n.t("printcenter.jobs.csi_invitation"), disabled: false, - group: "post" + group: "post", + featureNameRestricted: "csi" }, window_tag_sublet: { title: i18n.t("printcenter.jobs.window_tag_sublet"), @@ -549,7 +552,8 @@ export const TemplateList = (type, context) => { subject: i18n.t("printcenter.jobs.timetickets_ro"), key: "timetickets_ro", disabled: false, - group: "financial" + group: "financial", + featureNameRestricted: "timetickets" }, dms_posting_sheet: { title: i18n.t("printcenter.jobs.dms_posting_sheet"), @@ -576,7 +580,8 @@ export const TemplateList = (type, context) => { key: "committed_timetickets_ro", disabled: false, group: "financial", - enhanced_payroll: true + enhanced_payroll: true, + featureNameRestricted: "timetickets" }, job_lifecycle_ro: { title: i18n.t("printcenter.jobs.job_lifecycle_ro"), @@ -584,7 +589,8 @@ export const TemplateList = (type, context) => { subject: i18n.t("printcenter.jobs.job_lifecycle_ro"), key: "job_lifecycle_ro", disabled: false, - group: "post" + group: "post", + featureNameRestricted: "lifecycle" }, job_tasks: { title: i18n.t("printcenter.jobs.job_tasks"), @@ -628,7 +634,8 @@ export const TemplateList = (type, context) => { description: "", key: "csi_invitation_action", subject: i18n.t("printcenter.jobs.csi_invitation_action"), - disabled: false + disabled: false, + featureNameRestricted: "csi" }, individual_job_note: { title: i18n.t("printcenter.jobs.individual_job_note"), @@ -1606,7 +1613,8 @@ export const TemplateList = (type, context) => { object: i18n.t("reportcenter.labels.objects.exportlogs"), field: i18n.t("exportlogs.fields.createdat") }, - group: "customers" + group: "customers", + featureNameRestricted: "export" }, export_receivables: { title: i18n.t("reportcenter.templates.export_receivables"), @@ -1619,7 +1627,8 @@ export const TemplateList = (type, context) => { object: i18n.t("reportcenter.labels.objects.exportlogs"), field: i18n.t("exportlogs.fields.createdat") }, - group: "sales" + group: "sales", + featureNameRestricted: "export" }, parts_backorder: { title: i18n.t("reportcenter.templates.parts_backorder"), @@ -1684,7 +1693,8 @@ export const TemplateList = (type, context) => { object: i18n.t("reportcenter.labels.objects.jobs"), field: i18n.t("jobs.fields.date_open") }, - group: "jobs" + group: "jobs", + featureNameRestricted: "timetickets" }, work_in_progress_committed_labour: { title: i18n.t("reportcenter.templates.work_in_progress_committed_labour"), @@ -1698,7 +1708,8 @@ export const TemplateList = (type, context) => { field: i18n.t("jobs.fields.date_open") }, group: "jobs", - enhanced_payroll: true + enhanced_payroll: true, + featureNameRestricted: "timetickets" }, work_in_progress_payables: { title: i18n.t("reportcenter.templates.work_in_progress_payables"), @@ -1711,7 +1722,8 @@ export const TemplateList = (type, context) => { object: i18n.t("reportcenter.labels.objects.jobs"), field: i18n.t("jobs.fields.date_open") }, - group: "jobs" + group: "jobs", + featureNameRestricted: "bills" }, lag_time: { title: i18n.t("reportcenter.templates.lag_time"), @@ -1802,7 +1814,8 @@ export const TemplateList = (type, context) => { object: i18n.t("reportcenter.labels.objects.csi"), field: i18n.t("csi.fields.created_at") // Also date invoice. }, - group: "customers" + group: "customers", + featureNameRestricted: "csi" }, estimates_written_converted: { title: i18n.t("reportcenter.templates.estimates_written_converted"), @@ -1839,7 +1852,8 @@ export const TemplateList = (type, context) => { object: i18n.t("reportcenter.labels.objects.jobs"), field: i18n.t("jobs.fields.date_invoiced") }, - group: "jobs" + group: "jobs", + featureNameRestricted: "bills" }, parts_received_not_scheduled: { title: i18n.t("reportcenter.templates.parts_received_not_scheduled"), @@ -1935,7 +1949,8 @@ export const TemplateList = (type, context) => { object: i18n.t("reportcenter.labels.objects.jobs"), field: i18n.t("jobs.fields.date_invoiced") }, - group: "jobs" + group: "jobs", + featureNameRestricted: "export" }, purchase_return_ratio_grouped_by_vendor_detail: { title: i18n.t("reportcenter.templates.purchase_return_ratio_grouped_by_vendor_detail"), @@ -1996,7 +2011,8 @@ export const TemplateList = (type, context) => { object: i18n.t("reportcenter.labels.objects.jobs"), field: i18n.t("jobs.fields.date_exported") }, - group: "sales" + group: "sales", + featureNameRestricted: "export" }, exported_gsr_by_ro_labor: { title: i18n.t("reportcenter.templates.exported_gsr_by_ro_labor"), @@ -2009,7 +2025,8 @@ export const TemplateList = (type, context) => { object: i18n.t("reportcenter.labels.objects.jobs"), field: i18n.t("jobs.fields.date_exported") }, - group: "sales" + group: "sales", + featureNameRestricted: "export" }, jobs_scheduled_completion: { title: i18n.t("reportcenter.templates.jobs_scheduled_completion"), @@ -2119,7 +2136,8 @@ export const TemplateList = (type, context) => { object: i18n.t("reportcenter.labels.objects.jobs"), field: i18n.t("jobs.fields.date_invoiced") }, - group: "jobs" + group: "jobs", + featureNameRestricted: "lifecycle" }, job_lifecycle_date_summary: { title: i18n.t("reportcenter.templates.job_lifecycle_date_summary"), @@ -2131,7 +2149,8 @@ export const TemplateList = (type, context) => { object: i18n.t("reportcenter.labels.objects.jobs"), field: i18n.t("jobs.fields.date_invoiced") }, - group: "jobs" + group: "jobs", + featureNameRestricted: "lifecycle" }, tasks_date: { title: i18n.t("reportcenter.templates.tasks_date"),