diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel
index e3e62a467..d82244e68 100644
--- a/bodyshop_translations.babel
+++ b/bodyshop_translations.babel
@@ -20581,6 +20581,27 @@
+
+ date_rentalresp
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
date_scheduled
false
@@ -20602,6 +20623,27 @@
+
+ date_towin
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
ded_amt
false
@@ -27371,6 +27413,27 @@
+
+ threshhold
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
total_cost
false
diff --git a/client/src/components/job-totals-table/job-totals.table.labor.component.jsx b/client/src/components/job-totals-table/job-totals.table.labor.component.jsx
index 76c897ea7..bbd8d7629 100644
--- a/client/src/components/job-totals-table/job-totals.table.labor.component.jsx
+++ b/client/src/components/job-totals-table/job-totals.table.labor.component.jsx
@@ -1,4 +1,4 @@
-import { Table } from "antd";
+import { Space, Table } from "antd";
import Dinero from "dinero.js";
import React, { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
@@ -119,7 +119,18 @@ export default function JobTotalsTableLabor({ job }) {
- {t("jobs.labels.mapa")}
+
+
+ {t("jobs.labels.mapa")}
+ {job.materials &&
+ job.materials.mapa &&
+ job.materials.mapa.cal_maxdlr &&
+ job.materials.mapa.cal_maxdlr > 0 &&
+ t("jobs.labels.threshhold", {
+ amount: job.materials.mapa.cal_maxdlr,
+ })}
+
+
{job.job_totals.rates.mapa.rate}
@@ -133,7 +144,18 @@ export default function JobTotalsTableLabor({ job }) {
- {t("jobs.labels.mash")}
+
+
+ {t("jobs.labels.mash")}
+ {job.materials &&
+ job.materials.mash &&
+ job.materials.mash.cal_maxdlr &&
+ job.materials.mash.cal_maxdlr > 0 &&
+ t("jobs.labels.threshhold", {
+ amount: job.materials.mash.cal_maxdlr,
+ })}
+
+
{job.job_totals.rates.mash.rate}
diff --git a/client/src/components/jobs-admin-dates/jobs-admin-dates.component.jsx b/client/src/components/jobs-admin-dates/jobs-admin-dates.component.jsx
index e708cb268..28cc4595e 100644
--- a/client/src/components/jobs-admin-dates/jobs-admin-dates.component.jsx
+++ b/client/src/components/jobs-admin-dates/jobs-admin-dates.component.jsx
@@ -58,6 +58,15 @@ export default function JobsAdminDatesChange({ job }) {
>
+
+
+
+
+
+
diff --git a/client/src/components/jobs-detail-dates/jobs-detail-dates.component.jsx b/client/src/components/jobs-detail-dates/jobs-detail-dates.component.jsx
index ec2c9bcef..d4b4848c3 100644
--- a/client/src/components/jobs-detail-dates/jobs-detail-dates.component.jsx
+++ b/client/src/components/jobs-detail-dates/jobs-detail-dates.component.jsx
@@ -39,6 +39,12 @@ export function JobsDetailDatesComponent({ jobRO, job, bodyshop }) {
+
+
+
+
+
+
diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx
index 015e0113c..5a9715a96 100644
--- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx
+++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx
@@ -401,6 +401,8 @@ export function JobsDetailHeaderActions({
job: {
status: bodyshop.md_ro_statuses.default_void,
voided: true,
+ scheduled_in: null,
+ inproduction: false,
},
note: [
{
diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js
index c2b60a88c..9f4c1664c 100644
--- a/client/src/graphql/jobs.queries.js
+++ b/client/src/graphql/jobs.queries.js
@@ -595,6 +595,7 @@ export const GET_JOB_BY_PK = gql`
ca_gst_registrant
ownerid
ded_note
+ materials
owner {
id
ownr_fn
@@ -649,6 +650,8 @@ export const GET_JOB_BY_PK = gql`
date_invoiced
date_last_contacted
date_next_contact
+ date_towin
+ date_rentalresp
date_exported
status
owner_owing
@@ -1097,6 +1100,15 @@ export const VOID_JOB = gql`
insert_notes(objects: $note) {
affected_rows
}
+ update_appointments(
+ where: { jobid: { _eq: $jobId } }
+ _set: { canceled: true }
+ ) {
+ returning {
+ id
+ canceled
+ }
+ }
}
`;
diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json
index 9cee773e8..e8cb5b900 100644
--- a/client/src/translations/en_us/common.json
+++ b/client/src/translations/en_us/common.json
@@ -1254,7 +1254,9 @@
"date_last_contacted": "Last Contacted Date",
"date_next_contact": "Next Contact Date",
"date_open": "Open",
+ "date_rentalresp": "Shop Rental Responsibility Start",
"date_scheduled": "Scheduled",
+ "date_towin": "Towed In",
"ded_amt": "Deductible",
"ded_note": "Deductible Note",
"ded_status": "Deductible Status",
@@ -1602,6 +1604,7 @@
"supplementnote": "The job had a supplement imported.",
"suspended": "SUSPENDED",
"suspense": "Suspense",
+ "threshhold": "Max Threshold: ${{amount}}",
"total_cost": "Total Cost",
"total_cust_payable": "Total Customer Amount Payable",
"total_repairs": "Total Repairs",
diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json
index fffc38b2b..e00010111 100644
--- a/client/src/translations/es/common.json
+++ b/client/src/translations/es/common.json
@@ -1254,7 +1254,9 @@
"date_last_contacted": "",
"date_next_contact": "",
"date_open": "Abierto",
+ "date_rentalresp": "",
"date_scheduled": "Programado",
+ "date_towin": "",
"ded_amt": "Deducible",
"ded_note": "",
"ded_status": "Estado deducible",
@@ -1602,6 +1604,7 @@
"supplementnote": "",
"suspended": "",
"suspense": "",
+ "threshhold": "",
"total_cost": "",
"total_cust_payable": "",
"total_repairs": "",
diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json
index faf9dfd0b..99306174b 100644
--- a/client/src/translations/fr/common.json
+++ b/client/src/translations/fr/common.json
@@ -1254,7 +1254,9 @@
"date_last_contacted": "",
"date_next_contact": "",
"date_open": "Ouvrir",
+ "date_rentalresp": "",
"date_scheduled": "Prévu",
+ "date_towin": "",
"ded_amt": "Déductible",
"ded_note": "",
"ded_status": "Statut de franchise",
@@ -1602,6 +1604,7 @@
"supplementnote": "",
"suspended": "",
"suspense": "",
+ "threshhold": "",
"total_cost": "",
"total_cust_payable": "",
"total_repairs": "",
diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml
index fbcd2db79..c91b048fc 100644
--- a/hasura/metadata/tables.yaml
+++ b/hasura/metadata/tables.yaml
@@ -2721,7 +2721,9 @@
- date_last_contacted
- date_next_contact
- date_open
+ - date_rentalresp
- date_scheduled
+ - date_towin
- ded_amt
- ded_note
- ded_status
@@ -2804,6 +2806,7 @@
- loss_desc
- loss_of_use
- loss_type
+ - materials
- other_amount_payable
- owner_owing
- ownerid
@@ -2978,7 +2981,9 @@
- date_last_contacted
- date_next_contact
- date_open
+ - date_rentalresp
- date_scheduled
+ - date_towin
- ded_amt
- ded_note
- ded_status
@@ -3061,6 +3066,7 @@
- loss_desc
- loss_of_use
- loss_type
+ - materials
- other_amount_payable
- owner_owing
- ownerid
@@ -3245,7 +3251,9 @@
- date_last_contacted
- date_next_contact
- date_open
+ - date_rentalresp
- date_scheduled
+ - date_towin
- ded_amt
- ded_note
- ded_status
@@ -3328,6 +3336,7 @@
- loss_desc
- loss_of_use
- loss_type
+ - materials
- other_amount_payable
- owner_owing
- ownerid
diff --git a/hasura/migrations/1647275416695_alter_table_public_jobs_add_column_materials/down.sql b/hasura/migrations/1647275416695_alter_table_public_jobs_add_column_materials/down.sql
new file mode 100644
index 000000000..11bd7aff7
--- /dev/null
+++ b/hasura/migrations/1647275416695_alter_table_public_jobs_add_column_materials/down.sql
@@ -0,0 +1,4 @@
+-- Could not auto-generate a down migration.
+-- Please write an appropriate down migration for the SQL below:
+-- alter table "public"."jobs" add column "materials" jsonb
+-- not null default jsonb_build_object();
diff --git a/hasura/migrations/1647275416695_alter_table_public_jobs_add_column_materials/up.sql b/hasura/migrations/1647275416695_alter_table_public_jobs_add_column_materials/up.sql
new file mode 100644
index 000000000..f3c72141b
--- /dev/null
+++ b/hasura/migrations/1647275416695_alter_table_public_jobs_add_column_materials/up.sql
@@ -0,0 +1,2 @@
+alter table "public"."jobs" add column "materials" jsonb
+ not null default jsonb_build_object();
diff --git a/hasura/migrations/1647288645478_alter_table_public_jobs_add_column_towin_date/down.sql b/hasura/migrations/1647288645478_alter_table_public_jobs_add_column_towin_date/down.sql
new file mode 100644
index 000000000..7c44f678f
--- /dev/null
+++ b/hasura/migrations/1647288645478_alter_table_public_jobs_add_column_towin_date/down.sql
@@ -0,0 +1,4 @@
+-- Could not auto-generate a down migration.
+-- Please write an appropriate down migration for the SQL below:
+-- alter table "public"."jobs" add column "towin_date" timestamptz
+-- null;
diff --git a/hasura/migrations/1647288645478_alter_table_public_jobs_add_column_towin_date/up.sql b/hasura/migrations/1647288645478_alter_table_public_jobs_add_column_towin_date/up.sql
new file mode 100644
index 000000000..12268c70f
--- /dev/null
+++ b/hasura/migrations/1647288645478_alter_table_public_jobs_add_column_towin_date/up.sql
@@ -0,0 +1,2 @@
+alter table "public"."jobs" add column "towin_date" timestamptz
+ null;
diff --git a/hasura/migrations/1647288669678_alter_table_public_jobs_alter_column_towin_date/down.sql b/hasura/migrations/1647288669678_alter_table_public_jobs_alter_column_towin_date/down.sql
new file mode 100644
index 000000000..fa9e05495
--- /dev/null
+++ b/hasura/migrations/1647288669678_alter_table_public_jobs_alter_column_towin_date/down.sql
@@ -0,0 +1 @@
+alter table "public"."jobs" rename column "date_towin" to "towin_date";
diff --git a/hasura/migrations/1647288669678_alter_table_public_jobs_alter_column_towin_date/up.sql b/hasura/migrations/1647288669678_alter_table_public_jobs_alter_column_towin_date/up.sql
new file mode 100644
index 000000000..74de863b3
--- /dev/null
+++ b/hasura/migrations/1647288669678_alter_table_public_jobs_alter_column_towin_date/up.sql
@@ -0,0 +1 @@
+alter table "public"."jobs" rename column "towin_date" to "date_towin";
diff --git a/hasura/migrations/1647288692067_alter_table_public_jobs_add_column_date_rentalresp/down.sql b/hasura/migrations/1647288692067_alter_table_public_jobs_add_column_date_rentalresp/down.sql
new file mode 100644
index 000000000..09117d3d4
--- /dev/null
+++ b/hasura/migrations/1647288692067_alter_table_public_jobs_add_column_date_rentalresp/down.sql
@@ -0,0 +1,4 @@
+-- Could not auto-generate a down migration.
+-- Please write an appropriate down migration for the SQL below:
+-- alter table "public"."jobs" add column "date_rentalresp" timestamptz
+-- null;
diff --git a/hasura/migrations/1647288692067_alter_table_public_jobs_add_column_date_rentalresp/up.sql b/hasura/migrations/1647288692067_alter_table_public_jobs_add_column_date_rentalresp/up.sql
new file mode 100644
index 000000000..0d6edf459
--- /dev/null
+++ b/hasura/migrations/1647288692067_alter_table_public_jobs_add_column_date_rentalresp/up.sql
@@ -0,0 +1,2 @@
+alter table "public"."jobs" add column "date_rentalresp" timestamptz
+ null;
diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js
index 74f4f3a15..306cb06cb 100644
--- a/server/graphql-client/queries.js
+++ b/server/graphql-client/queries.js
@@ -960,6 +960,7 @@ exports.GET_JOB_BY_PK = ` query GET_JOB_BY_PK($id: uuid!) {
voided
ca_bc_pvrt
ca_customer_gst
+ materials
joblines(where: { removed: { _eq: false } }){
id
line_no
diff --git a/server/job/job-totals.js b/server/job/job-totals.js
index f6ef1fda6..35f6d7849 100644
--- a/server/job/job-totals.js
+++ b/server/job/job-totals.js
@@ -234,11 +234,30 @@ function CalculateRatesTotals(ratesList) {
if (!ret[property].total) {
ret[property].total = Dinero();
}
- ret[property].total = ret[property].total.add(
- Dinero({
- amount: Math.round((ret[property].rate || 0) * 100),
- }).multiply(ret[property].hours)
- );
+ let threshold;
+ //Check if there is a max for this type.
+ if (ratesList.materials[property]) {
+ //
+ if (
+ ratesList.materials[property].cal_maxdlr &&
+ ratesList.materials[property].cal_maxdlr > 0
+ ) {
+ //It has an upper threshhold.
+ threshold = Dinero({
+ amount: Math.round(ratesList.materials[property].cal_maxdlr * 100),
+ });
+ }
+ }
+
+ const total = Dinero({
+ amount: Math.round((ret[property].rate || 0) * 100),
+ }).multiply(ret[property].hours);
+
+ if (threshold && total.greaterThanOrEqual(threshold)) {
+ ret[property].total = ret[property].total.add(threshold);
+ } else {
+ ret[property].total = ret[property].total.add(total);
+ }
}
subtotal = subtotal.add(ret[property].total);
@@ -252,6 +271,7 @@ function CalculateRatesTotals(ratesList) {
return ret;
}
+
function CalculatePartsTotals(jobLines) {
const ret = jobLines
.filter((jl) => !jl.removed)