- {`ImEX Online V.${process.env.NODE_ENV}-${process.env.REACT_APP_GIT_SHA}`}{" "}
+ {`ImEX Online V.${process.env.NODE_ENV}-${process.env.REACT_APP_GIT_SHA}`}
Disclaimer
diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json
index 5185b410b..75525217b 100644
--- a/client/src/translations/en_us/common.json
+++ b/client/src/translations/en_us/common.json
@@ -393,7 +393,8 @@
},
"scheduling": "SMART Scheduling",
"shopinfo": "Shop Information",
- "speedprint": "Speed Print Configuration"
+ "speedprint": "Speed Print Configuration",
+ "workingdays": "Working Days"
},
"successes": {
"save": "Shop configuration saved successfully. "
@@ -687,6 +688,7 @@
"email": "Email",
"errors": "Errors",
"exceptiontitle": "An error has occurred.",
+ "friday": "Friday",
"hours": "hrs",
"in": "In",
"instanceconflictext": "Your $t(titles.app) account can only be used on one device at any given time. Refresh your session to take control.",
@@ -695,6 +697,7 @@
"loadingapp": "Loading $t(titles.app)",
"loadingshop": "Loading shop data...",
"loggingin": "Authorizing...",
+ "monday": "Monday",
"na": "N/A",
"no": "No",
"out": "Out",
@@ -704,15 +707,20 @@
"passwordsdonotmatch": "The passwords you have entered do not match.",
"print": "Print",
"required": "Required",
+ "saturday": "Saturday",
"search": "Search...",
"selectdate": "Select date...",
"sendagain": "Send Again",
"sendby": "Send By",
+ "sunday": "Sunday",
"text": "Text",
+ "thursday": "Thursday",
"totals": "Totals",
+ "tuesday": "Tuesday",
"unknown": "Unknown",
"username": "Username",
"view": "View",
+ "wednesday": "Wednesday",
"yes": "Yes"
},
"languages": {
diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json
index ffacc4680..da79d2f79 100644
--- a/client/src/translations/es/common.json
+++ b/client/src/translations/es/common.json
@@ -393,7 +393,8 @@
},
"scheduling": "",
"shopinfo": "",
- "speedprint": ""
+ "speedprint": "",
+ "workingdays": ""
},
"successes": {
"save": ""
@@ -687,6 +688,7 @@
"email": "",
"errors": "",
"exceptiontitle": "",
+ "friday": "",
"hours": "",
"in": "en",
"instanceconflictext": "",
@@ -695,6 +697,7 @@
"loadingapp": "Cargando $t(titles.app)",
"loadingshop": "Cargando datos de la tienda ...",
"loggingin": "Iniciando sesión ...",
+ "monday": "",
"na": "N / A",
"no": "",
"out": "Afuera",
@@ -704,15 +707,20 @@
"passwordsdonotmatch": "",
"print": "",
"required": "",
+ "saturday": "",
"search": "Buscar...",
"selectdate": "",
"sendagain": "",
"sendby": "",
+ "sunday": "",
"text": "",
+ "thursday": "",
"totals": "",
+ "tuesday": "",
"unknown": "Desconocido",
"username": "",
"view": "",
+ "wednesday": "",
"yes": ""
},
"languages": {
diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json
index 4f9a43179..785609a2f 100644
--- a/client/src/translations/fr/common.json
+++ b/client/src/translations/fr/common.json
@@ -393,7 +393,8 @@
},
"scheduling": "",
"shopinfo": "",
- "speedprint": ""
+ "speedprint": "",
+ "workingdays": ""
},
"successes": {
"save": ""
@@ -687,6 +688,7 @@
"email": "",
"errors": "",
"exceptiontitle": "",
+ "friday": "",
"hours": "",
"in": "dans",
"instanceconflictext": "",
@@ -695,6 +697,7 @@
"loadingapp": "Chargement de $t(titles.app)",
"loadingshop": "Chargement des données de la boutique ...",
"loggingin": "Vous connecter ...",
+ "monday": "",
"na": "N / A",
"no": "",
"out": "En dehors",
@@ -704,15 +707,20 @@
"passwordsdonotmatch": "",
"print": "",
"required": "",
+ "saturday": "",
"search": "Chercher...",
"selectdate": "",
"sendagain": "",
"sendby": "",
+ "sunday": "",
"text": "",
+ "thursday": "",
"totals": "",
+ "tuesday": "",
"unknown": "Inconnu",
"username": "",
"view": "",
+ "wednesday": "",
"yes": ""
},
"languages": {
diff --git a/client/src/utils/TemplateConstants.js b/client/src/utils/TemplateConstants.js
index 697664d0c..c3d9c400c 100644
--- a/client/src/utils/TemplateConstants.js
+++ b/client/src/utils/TemplateConstants.js
@@ -16,7 +16,7 @@ export const TemplateList = (type, context) => {
title: i18n.t("printcenter.jobs.estimate_detail"),
description: "Est Detail",
subject: `${i18n.t("printcenter.jobs.estimate_detail")} - ${
- context.job.ro_number
+ context && context.job && context.job.ro_number
}`,
key: "estimate_detail",
disabled: false,
@@ -25,7 +25,7 @@ export const TemplateList = (type, context) => {
title: i18n.t("printcenter.jobs.casl_authorization"),
description: "CASL Authorization",
subject: `${i18n.t("printcenter.jobs.casl_authorization")} - ${
- context.job.ro_number
+ context && context.job && context.job.ro_number
}`,
key: "casl_authorization",
disabled: false,
@@ -35,7 +35,7 @@ export const TemplateList = (type, context) => {
description: "Diagnostic Authorization",
subject: `${i18n.t(
"printcenter.jobs.diagnostic_authorization"
- )} - ${context.job.ro_number}`,
+ )} - ${context && context.job && context.job.ro_number}`,
key: "diagnostic_authorization",
disabled: false,
},
@@ -43,7 +43,7 @@ export const TemplateList = (type, context) => {
title: i18n.t("printcenter.jobs.job_notes"),
description: "All Jobs Notes",
subject: `${i18n.t("printcenter.jobs.job_notes")} - ${
- context.job.ro_number
+ context && context.job && context.job.ro_number
}`,
key: "job_notes",
disabled: false,
@@ -57,7 +57,7 @@ export const TemplateList = (type, context) => {
description: "Appointment Confirmation",
subject: `${i18n.t(
"printcenter.appointments.appointment_confirmation"
- )} - ${context.job.ro_number}`,
+ )} - ${context && context.job && context.job.ro_number}`,
key: "appointment_confirmation",
disabled: false,
},
@@ -70,7 +70,14 @@ export const TemplateList = (type, context) => {
description: "Parts Order",
key: "parts_order_confirmation",
subject: `${bodyshop.shopname} Parts Order ${
- (context && context.job && context.job.ro_number) || ""
+ (context &&
+ context &&
+ context.job &&
+ context.job &&
+ context &&
+ context.job &&
+ context.job.ro_number) ||
+ ""
}`,
disabled: false,
},
diff --git a/hasura/migrations/1611941041657_alter_table_public_bodyshops_add_column_workingdays/down.yaml b/hasura/migrations/1611941041657_alter_table_public_bodyshops_add_column_workingdays/down.yaml
new file mode 100644
index 000000000..fe9cc76ca
--- /dev/null
+++ b/hasura/migrations/1611941041657_alter_table_public_bodyshops_add_column_workingdays/down.yaml
@@ -0,0 +1,5 @@
+- args:
+ cascade: false
+ read_only: false
+ sql: ALTER TABLE "public"."bodyshops" DROP COLUMN "workingdays";
+ type: run_sql
diff --git a/hasura/migrations/1611941041657_alter_table_public_bodyshops_add_column_workingdays/up.yaml b/hasura/migrations/1611941041657_alter_table_public_bodyshops_add_column_workingdays/up.yaml
new file mode 100644
index 000000000..8e2eb5a32
--- /dev/null
+++ b/hasura/migrations/1611941041657_alter_table_public_bodyshops_add_column_workingdays/up.yaml
@@ -0,0 +1,6 @@
+- args:
+ cascade: false
+ read_only: false
+ sql: ALTER TABLE "public"."bodyshops" ADD COLUMN "workingdays" jsonb NOT NULL
+ DEFAULT jsonb_build_object();
+ type: run_sql
diff --git a/hasura/migrations/1611941052239_update_permission_user_public_table_bodyshops/down.yaml b/hasura/migrations/1611941052239_update_permission_user_public_table_bodyshops/down.yaml
new file mode 100644
index 000000000..c49b55fed
--- /dev/null
+++ b/hasura/migrations/1611941052239_update_permission_user_public_table_bodyshops/down.yaml
@@ -0,0 +1,76 @@
+- args:
+ role: user
+ table:
+ name: bodyshops
+ schema: public
+ type: drop_select_permission
+- args:
+ permission:
+ allow_aggregations: false
+ columns:
+ - accountingconfig
+ - address1
+ - address2
+ - appt_alt_transport
+ - appt_colors
+ - appt_length
+ - bill_tax_rates
+ - city
+ - country
+ - created_at
+ - default_adjustment_rate
+ - deliverchecklist
+ - email
+ - enforce_class
+ - federal_tax_id
+ - id
+ - imexshopid
+ - inhousevendorid
+ - insurance_vendor_id
+ - intakechecklist
+ - logo_img_path
+ - md_categories
+ - md_classes
+ - md_ins_cos
+ - md_labor_rates
+ - md_messaging_presets
+ - md_notes_presets
+ - md_order_statuses
+ - md_parts_locations
+ - md_rbac
+ - md_referral_sources
+ - md_responsibility_centers
+ - md_ro_statuses
+ - messagingservicesid
+ - phone
+ - prodtargethrs
+ - production_config
+ - region_config
+ - schedule_end_time
+ - schedule_start_time
+ - scoreboard_target
+ - shopname
+ - shoprates
+ - speedprint
+ - ssbuckets
+ - state
+ - state_tax_id
+ - stripe_acct_id
+ - target_touchtime
+ - template_header
+ - textid
+ - updated_at
+ - zip_post
+ computed_fields: []
+ filter:
+ associations:
+ bodyshop:
+ associations:
+ user:
+ authid:
+ _eq: X-Hasura-User-Id
+ role: user
+ table:
+ name: bodyshops
+ schema: public
+ type: create_select_permission
diff --git a/hasura/migrations/1611941052239_update_permission_user_public_table_bodyshops/up.yaml b/hasura/migrations/1611941052239_update_permission_user_public_table_bodyshops/up.yaml
new file mode 100644
index 000000000..c80b7fd81
--- /dev/null
+++ b/hasura/migrations/1611941052239_update_permission_user_public_table_bodyshops/up.yaml
@@ -0,0 +1,77 @@
+- args:
+ role: user
+ table:
+ name: bodyshops
+ schema: public
+ type: drop_select_permission
+- args:
+ permission:
+ allow_aggregations: false
+ columns:
+ - accountingconfig
+ - address1
+ - address2
+ - appt_alt_transport
+ - appt_colors
+ - appt_length
+ - bill_tax_rates
+ - city
+ - country
+ - created_at
+ - default_adjustment_rate
+ - deliverchecklist
+ - email
+ - enforce_class
+ - federal_tax_id
+ - id
+ - imexshopid
+ - inhousevendorid
+ - insurance_vendor_id
+ - intakechecklist
+ - logo_img_path
+ - md_categories
+ - md_classes
+ - md_ins_cos
+ - md_labor_rates
+ - md_messaging_presets
+ - md_notes_presets
+ - md_order_statuses
+ - md_parts_locations
+ - md_rbac
+ - md_referral_sources
+ - md_responsibility_centers
+ - md_ro_statuses
+ - messagingservicesid
+ - phone
+ - prodtargethrs
+ - production_config
+ - region_config
+ - schedule_end_time
+ - schedule_start_time
+ - scoreboard_target
+ - shopname
+ - shoprates
+ - speedprint
+ - ssbuckets
+ - state
+ - state_tax_id
+ - stripe_acct_id
+ - target_touchtime
+ - template_header
+ - textid
+ - updated_at
+ - workingdays
+ - zip_post
+ computed_fields: []
+ filter:
+ associations:
+ bodyshop:
+ associations:
+ user:
+ authid:
+ _eq: X-Hasura-User-Id
+ role: user
+ table:
+ name: bodyshops
+ schema: public
+ type: create_select_permission
diff --git a/hasura/migrations/1611941063164_update_permission_user_public_table_bodyshops/down.yaml b/hasura/migrations/1611941063164_update_permission_user_public_table_bodyshops/down.yaml
new file mode 100644
index 000000000..ef19e6f61
--- /dev/null
+++ b/hasura/migrations/1611941063164_update_permission_user_public_table_bodyshops/down.yaml
@@ -0,0 +1,69 @@
+- args:
+ role: user
+ table:
+ name: bodyshops
+ schema: public
+ type: drop_update_permission
+- args:
+ permission:
+ columns:
+ - accountingconfig
+ - address1
+ - address2
+ - appt_alt_transport
+ - appt_colors
+ - appt_length
+ - bill_tax_rates
+ - city
+ - country
+ - created_at
+ - default_adjustment_rate
+ - deliverchecklist
+ - email
+ - enforce_class
+ - federal_tax_id
+ - id
+ - inhousevendorid
+ - insurance_vendor_id
+ - intakechecklist
+ - logo_img_path
+ - md_categories
+ - md_classes
+ - md_ins_cos
+ - md_labor_rates
+ - md_messaging_presets
+ - md_notes_presets
+ - md_order_statuses
+ - md_parts_locations
+ - md_rbac
+ - md_referral_sources
+ - md_responsibility_centers
+ - md_ro_statuses
+ - phone
+ - prodtargethrs
+ - production_config
+ - schedule_end_time
+ - schedule_start_time
+ - scoreboard_target
+ - shopname
+ - shoprates
+ - speedprint
+ - ssbuckets
+ - state
+ - state_tax_id
+ - target_touchtime
+ - updated_at
+ - zip_post
+ filter:
+ associations:
+ bodyshop:
+ associations:
+ user:
+ authid:
+ _eq: X-Hasura-User-Id
+ set: {}
+ role: user
+ table:
+ name: bodyshops
+ schema: public
+ type: create_update_permission
diff --git a/hasura/migrations/1611941063164_update_permission_user_public_table_bodyshops/up.yaml b/hasura/migrations/1611941063164_update_permission_user_public_table_bodyshops/up.yaml
new file mode 100644
index 000000000..f8bd313df
--- /dev/null
+++ b/hasura/migrations/1611941063164_update_permission_user_public_table_bodyshops/up.yaml
@@ -0,0 +1,70 @@
+- args:
+ role: user
+ table:
+ name: bodyshops
+ schema: public
+ type: drop_update_permission
+- args:
+ permission:
+ columns:
+ - accountingconfig
+ - address1
+ - address2
+ - appt_alt_transport
+ - appt_colors
+ - appt_length
+ - bill_tax_rates
+ - city
+ - country
+ - created_at
+ - default_adjustment_rate
+ - deliverchecklist
+ - email
+ - enforce_class
+ - federal_tax_id
+ - id
+ - inhousevendorid
+ - insurance_vendor_id
+ - intakechecklist
+ - logo_img_path
+ - md_categories
+ - md_classes
+ - md_ins_cos
+ - md_labor_rates
+ - md_messaging_presets
+ - md_notes_presets
+ - md_order_statuses
+ - md_parts_locations
+ - md_rbac
+ - md_referral_sources
+ - md_responsibility_centers
+ - md_ro_statuses
+ - phone
+ - prodtargethrs
+ - production_config
+ - schedule_end_time
+ - schedule_start_time
+ - scoreboard_target
+ - shopname
+ - shoprates
+ - speedprint
+ - ssbuckets
+ - state
+ - state_tax_id
+ - target_touchtime
+ - updated_at
+ - workingdays
+ - zip_post
+ filter:
+ associations:
+ bodyshop:
+ associations:
+ user:
+ authid:
+ _eq: X-Hasura-User-Id
+ set: {}
+ role: user
+ table:
+ name: bodyshops
+ schema: public
+ type: create_update_permission
diff --git a/hasura/migrations/metadata.yaml b/hasura/migrations/metadata.yaml
index 687bcfc13..94d4e2e97 100644
--- a/hasura/migrations/metadata.yaml
+++ b/hasura/migrations/metadata.yaml
@@ -768,6 +768,7 @@ tables:
- template_header
- textid
- updated_at
+ - workingdays
- zip_post
filter:
associations:
@@ -826,6 +827,7 @@ tables:
- state_tax_id
- target_touchtime
- updated_at
+ - workingdays
- zip_post
filter:
associations:
diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js
index 2c827858b..79eb13924 100644
--- a/server/graphql-client/queries.js
+++ b/server/graphql-client/queries.js
@@ -186,6 +186,7 @@ query QUERY_UPCOMING_APPOINTMENTS($now: timestamptz!, $jobId: uuid!) {
bodyshop {
ssbuckets
target_touchtime
+ workingdays
}
jobhrs: joblines_aggregate {
aggregate {
diff --git a/server/scheduling/scheduling-job.js b/server/scheduling/scheduling-job.js
index 490884ac4..1bb8e9461 100644
--- a/server/scheduling/scheduling-job.js
+++ b/server/scheduling/scheduling-job.js
@@ -31,7 +31,7 @@ exports.job = async (req, res) => {
});
const { appointments, jobs } = result;
- const { ssbuckets } = result.jobs_by_pk.bodyshop;
+ const { ssbuckets, workingdays } = result.jobs_by_pk.bodyshop;
const jobHrs = result.jobs_by_pk.jobhrs.aggregate.sum.mod_lb_hrs;
const JobBucket = ssbuckets.filter(
@@ -40,14 +40,14 @@ exports.job = async (req, res) => {
)[0];
const bucketMatrix = {};
-
+ const yesterday = moment().subtract(1, "day");
//Get latest date + add 5 days to allow for back end adding..
const totalMatrixDays = moment
.max([
...appointments.map((a) => moment(a.start)),
...jobs
.map((p) => moment(p.scheduled_completion))
- .filter((p) => p.isValid()),
+ .filter((p) => p.isValid() && p.isAfter(yesterday)),
])
.add("5", "days")
.diff(moment(), "days");
@@ -102,6 +102,7 @@ exports.job = async (req, res) => {
(bucket) =>
bucket.gte <= jobHrs && (!!bucket.lt ? bucket.lt > jobHrs : true)
)[0];
+ console.log(pjobBucket.id, JobBucket.id, pjobBucket.id === JobBucket.id);
if (pjobBucket.id === JobBucket.id) {
//Theyre the same classification. Add it to the matrix.
const compDate = moment(pjob.scheduled_completion);
@@ -112,7 +113,6 @@ exports.job = async (req, res) => {
? compDate.format("yyyy-MM-DD")
: todayIsoString
: todayIsoString;
- console.log("bucketMatrix", bucketMatrix);
bucketMatrix[dateToUse] = {
...bucketMatrix[dateToUse],
out: (bucketMatrix[dateToUse].out || 0) + 1,
@@ -125,13 +125,37 @@ exports.job = async (req, res) => {
const possibleDates = [];
const bucketMatrixKeys = Object.keys(bucketMatrix);
bucketMatrixKeys.forEach((bmkey) => {
- if (JobBucket.target > bucketMatrix[bmkey].in - bucketMatrix[bmkey].out)
+ const isShopOpen = workingdays[dayOfWeekMapper(moment(bmkey).day())];
+
+ if (
+ JobBucket.target > bucketMatrix[bmkey].in - bucketMatrix[bmkey].out &&
+ isShopOpen
+ )
possibleDates.push(new Date(bmkey).toISOString().substr(0, 10));
});
-
+ console.log("possibleDates", possibleDates, "bucketMatrix", bucketMatrix);
res.json(possibleDates);
} catch (error) {
console.log("error", error);
res.status(400).send(error);
}
};
+
+const dayOfWeekMapper = (numberOfDay) => {
+ switch (numberOfDay) {
+ case 0:
+ return "sunday";
+ case 1:
+ return "monday";
+ case 2:
+ return "tuesday";
+ case 3:
+ return "wednesday";
+ case 4:
+ return "thursday";
+ case 5:
+ return "friday";
+ case 6:
+ return "saturday";
+ }
+};