From fddf75b40bcc86db64f3fb5f95e47f147fd552bd Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Wed, 19 May 2021 17:52:24 -0700 Subject: [PATCH 1/9] IOS-7 Added takenat to documents and uploads. --- client/package.json | 1 + .../documents-upload.utility.js | 10 ++++ client/src/graphql/documents.queries.js | 9 ++-- client/yarn.lock | 5 ++ .../down.yaml | 5 ++ .../up.yaml | 5 ++ .../down.yaml | 46 ++++++++++++++++++ .../up.yaml | 47 ++++++++++++++++++ .../down.yaml | 47 ++++++++++++++++++ .../up.yaml | 48 +++++++++++++++++++ hasura/migrations/metadata.yaml | 2 + 11 files changed, 221 insertions(+), 4 deletions(-) create mode 100644 hasura/migrations/1621469433708_alter_table_public_documents_add_column_takenat/down.yaml create mode 100644 hasura/migrations/1621469433708_alter_table_public_documents_add_column_takenat/up.yaml create mode 100644 hasura/migrations/1621469445403_update_permission_user_public_table_documents/down.yaml create mode 100644 hasura/migrations/1621469445403_update_permission_user_public_table_documents/up.yaml create mode 100644 hasura/migrations/1621469452694_update_permission_user_public_table_documents/down.yaml create mode 100644 hasura/migrations/1621469452694_update_permission_user_public_table_documents/up.yaml diff --git a/client/package.json b/client/package.json index ac2eec8c5..57f1b5afd 100644 --- a/client/package.json +++ b/client/package.json @@ -20,6 +20,7 @@ "dinero.js": "^1.8.1", "dotenv": "^9.0.2", "env-cmd": "^10.1.0", + "exifr": "^7.0.0", "firebase": "^8.6.0", "graphql": "^15.5.0", "i18next": "^20.2.2", diff --git a/client/src/components/documents-upload/documents-upload.utility.js b/client/src/components/documents-upload/documents-upload.utility.js index d074619e3..ad5083e95 100644 --- a/client/src/components/documents-upload/documents-upload.utility.js +++ b/client/src/components/documents-upload/documents-upload.utility.js @@ -5,6 +5,8 @@ import { logImEXEvent } from "../../firebase/firebase.utils"; import { INSERT_NEW_DOCUMENT } from "../../graphql/documents.queries"; import { axiosAuthInterceptorId } from "../../utils/CleanAxios"; import client from "../../utils/GraphQLClient"; +import exifr from "exifr"; + //Context: currentUserEmail, bodyshop, jobid, invoiceid //Required to prevent headers from getting set and rejected from Cloudinary. @@ -85,6 +87,7 @@ export const uploadToCloudinary = async ( if (!!onProgress) onProgress({ percent: (e.loaded / e.total) * 100 }); }, }; + const formData = new FormData(); formData.append("file", file); @@ -122,6 +125,12 @@ export const uploadToCloudinary = async ( } //Insert the document with the matching key. + let takenat; + if (fileType.includes("image")) { + const exif = await exifr.parse(file); + console.log(`exif`, exif); + takenat = exif && exif.DateTimeOriginal; + } const documentInsert = await client.mutate({ mutation: INSERT_NEW_DOCUMENT, variables: { @@ -135,6 +144,7 @@ export const uploadToCloudinary = async ( extension: extension, bodyshopid: bodyshop.id, size: cloudinaryUploadResponse.data.bytes || file.size, + takenat, }, ], }, diff --git a/client/src/graphql/documents.queries.js b/client/src/graphql/documents.queries.js index a01a44b0d..837e6e091 100644 --- a/client/src/graphql/documents.queries.js +++ b/client/src/graphql/documents.queries.js @@ -9,15 +9,13 @@ export const GET_DOCUMENTS_BY_JOB = gql` } } } - documents( - order_by: { updated_at: desc } - where: { jobid: { _eq: $jobId } } - ) { + documents(order_by: { takenat: desc }, where: { jobid: { _eq: $jobId } }) { id name key type size + takenat bill { id invoice_number @@ -51,6 +49,7 @@ export const INSERT_NEW_DOCUMENT = gql` name key size + takenat } } } @@ -78,6 +77,7 @@ export const QUERY_TEMPORARY_DOCS = gql` type extension size + takenat } } `; @@ -94,6 +94,7 @@ export const UPDATE_DOCUMENT = gql` type key size + takenat } } `; diff --git a/client/yarn.lock b/client/yarn.lock index 09ce4065f..e6fdbac30 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -5696,6 +5696,11 @@ exenv@^1.2.2: resolved "https://registry.npmjs.org/exenv/-/exenv-1.2.2.tgz" integrity sha1-KueOhdmJQVhnCwPUe+wfA72Ru50= +exifr@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/exifr/-/exifr-7.0.0.tgz#065d54639f2999ac901dd8475db99b4d3f31f11e" + integrity sha512-5JRtopcolAfsX4YGcvTkldXyFDC+VPV40DxhSdRvrDr4OJQHtyccNoYl4aRzYBnVVpNueMmenS0KhzLiyNSfEQ== + exit@^0.1.2: version "0.1.2" resolved "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz" diff --git a/hasura/migrations/1621469433708_alter_table_public_documents_add_column_takenat/down.yaml b/hasura/migrations/1621469433708_alter_table_public_documents_add_column_takenat/down.yaml new file mode 100644 index 000000000..7b0215a38 --- /dev/null +++ b/hasura/migrations/1621469433708_alter_table_public_documents_add_column_takenat/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."documents" DROP COLUMN "takenat"; + type: run_sql diff --git a/hasura/migrations/1621469433708_alter_table_public_documents_add_column_takenat/up.yaml b/hasura/migrations/1621469433708_alter_table_public_documents_add_column_takenat/up.yaml new file mode 100644 index 000000000..9aa3ee8cd --- /dev/null +++ b/hasura/migrations/1621469433708_alter_table_public_documents_add_column_takenat/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."documents" ADD COLUMN "takenat" timestamptz NULL; + type: run_sql diff --git a/hasura/migrations/1621469445403_update_permission_user_public_table_documents/down.yaml b/hasura/migrations/1621469445403_update_permission_user_public_table_documents/down.yaml new file mode 100644 index 000000000..0754a089a --- /dev/null +++ b/hasura/migrations/1621469445403_update_permission_user_public_table_documents/down.yaml @@ -0,0 +1,46 @@ +- args: + role: user + table: + name: documents + schema: public + type: drop_insert_permission +- args: + permission: + check: + _or: + - job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + - bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - billid + - bodyshopid + - created_at + - extension + - id + - jobid + - key + - name + - size + - type + - updated_at + - uploaded_by + set: {} + role: user + table: + name: documents + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1621469445403_update_permission_user_public_table_documents/up.yaml b/hasura/migrations/1621469445403_update_permission_user_public_table_documents/up.yaml new file mode 100644 index 000000000..487da0fa8 --- /dev/null +++ b/hasura/migrations/1621469445403_update_permission_user_public_table_documents/up.yaml @@ -0,0 +1,47 @@ +- args: + role: user + table: + name: documents + schema: public + type: drop_insert_permission +- args: + permission: + check: + _or: + - job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + - bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - billid + - bodyshopid + - created_at + - extension + - id + - jobid + - key + - name + - size + - takenat + - type + - updated_at + - uploaded_by + set: {} + role: user + table: + name: documents + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1621469452694_update_permission_user_public_table_documents/down.yaml b/hasura/migrations/1621469452694_update_permission_user_public_table_documents/down.yaml new file mode 100644 index 000000000..2f87c23b2 --- /dev/null +++ b/hasura/migrations/1621469452694_update_permission_user_public_table_documents/down.yaml @@ -0,0 +1,47 @@ +- args: + role: user + table: + name: documents + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: true + columns: + - billid + - bodyshopid + - created_at + - extension + - id + - jobid + - key + - name + - size + - type + - updated_at + - uploaded_by + computed_fields: [] + filter: + _or: + - job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + - bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: documents + schema: public + type: create_select_permission diff --git a/hasura/migrations/1621469452694_update_permission_user_public_table_documents/up.yaml b/hasura/migrations/1621469452694_update_permission_user_public_table_documents/up.yaml new file mode 100644 index 000000000..95c75a40c --- /dev/null +++ b/hasura/migrations/1621469452694_update_permission_user_public_table_documents/up.yaml @@ -0,0 +1,48 @@ +- args: + role: user + table: + name: documents + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: true + columns: + - billid + - bodyshopid + - created_at + - extension + - id + - jobid + - key + - name + - size + - takenat + - type + - updated_at + - uploaded_by + computed_fields: [] + filter: + _or: + - job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + - bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: documents + schema: public + type: create_select_permission diff --git a/hasura/migrations/metadata.yaml b/hasura/migrations/metadata.yaml index de6e94e7f..3aef96e54 100644 --- a/hasura/migrations/metadata.yaml +++ b/hasura/migrations/metadata.yaml @@ -1520,6 +1520,7 @@ tables: - key - name - size + - takenat - type - updated_at - uploaded_by @@ -1536,6 +1537,7 @@ tables: - key - name - size + - takenat - type - updated_at - uploaded_by From 2d19c3517755dee329b1eadbc718b83b0fb1704c Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Fri, 21 May 2021 09:31:55 -0700 Subject: [PATCH 2/9] IO-1147 Default tax rates on parts for manual jobs. --- .../jobs-create-jobs-info.component.jsx | 12 +++---- .../jobs-create/jobs-create.container.jsx | 31 +++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/client/src/components/jobs-create-jobs-info/jobs-create-jobs-info.component.jsx b/client/src/components/jobs-create-jobs-info/jobs-create-jobs-info.component.jsx index e49f79d6f..8e9bb44b6 100644 --- a/client/src/components/jobs-create-jobs-info/jobs-create-jobs-info.component.jsx +++ b/client/src/components/jobs-create-jobs-info/jobs-create-jobs-info.component.jsx @@ -26,12 +26,6 @@ export function JobsCreateJobsInfo({ bodyshop, form, selected }) { const { getFieldValue } = form; return (
- +
); } diff --git a/client/src/pages/jobs-create/jobs-create.container.jsx b/client/src/pages/jobs-create/jobs-create.container.jsx index 2bf15463b..63aabf3c0 100644 --- a/client/src/pages/jobs-create/jobs-create.container.jsx +++ b/client/src/pages/jobs-create/jobs-create.container.jsx @@ -155,6 +155,13 @@ function JobsCreateContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) { layout="vertical" autoComplete={"off"} initialValues={{ + tax_tow_rt: bodyshop.bill_tax_rates.state_tax_rate / 100, + tax_str_rt: bodyshop.bill_tax_rates.state_tax_rate / 100, + tax_paint_mat_rt: bodyshop.bill_tax_rates.state_tax_rate / 100, + tax_shop_mat_rt: bodyshop.bill_tax_rates.state_tax_rate / 100, + tax_sub_rt: bodyshop.bill_tax_rates.state_tax_rate / 100, + tax_lbr_rt: bodyshop.bill_tax_rates.state_tax_rate / 100, + tax_levies_rt: bodyshop.bill_tax_rates.state_tax_rate / 100, parts_tax_rates: { PAA: { prt_type: "PAA", @@ -220,6 +227,30 @@ function JobsCreateContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) { prt_tax_in: true, prt_tax_rt: bodyshop.bill_tax_rates.state_tax_rate / 100, }, + PASL: { + prt_type: "PASL", + prt_discp: 0, + prt_mktyp: false, + prt_mkupp: 0, + prt_tax_in: true, + prt_tax_rt: bodyshop.bill_tax_rates.state_tax_rate / 100, + }, + PAP: { + prt_type: "PAP", + prt_discp: 0, + prt_mktyp: false, + prt_mkupp: 0, + prt_tax_in: true, + prt_tax_rt: bodyshop.bill_tax_rates.state_tax_rate / 100, + }, + PAO: { + prt_type: "PAO", + prt_discp: 0, + prt_mktyp: false, + prt_mkupp: 0, + prt_tax_in: true, + prt_tax_rt: bodyshop.bill_tax_rates.state_tax_rate / 100, + }, }, }} > From f2a4eb1b659cdcae4dfbca071513a996c5479a4f Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Fri, 21 May 2021 09:38:30 -0700 Subject: [PATCH 3/9] IO-1101 Fix PAP marking of lines. --- .../components/job-detail-lines/job-lines.component.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/src/components/job-detail-lines/job-lines.component.jsx b/client/src/components/job-detail-lines/job-lines.component.jsx index b6a179e52..02c73382a 100644 --- a/client/src/components/job-detail-lines/job-lines.component.jsx +++ b/client/src/components/job-detail-lines/job-lines.component.jsx @@ -313,9 +313,12 @@ export function JobLinesComponent({ if (e.key === "clear") { setSelectedLines([]); } else { + const markedTypes = [e.key]; + if (e.key === "PAN") markedTypes.push("PAP"); + if (e.key === "PAS") markedTypes.push("PASL"); setSelectedLines([ ...selectedLines, - ...jobLines.filter((item) => item.part_type === e.key), + ...jobLines.filter((item) => markedTypes.includes(item.part_type)), ]); } }; @@ -378,7 +381,7 @@ export function JobLinesComponent({ setState({ ...state, filteredInfo: { - part_type: ["PAN,PAL,PAA,PAS,PASL"], + part_type: ["PAN,PAL,PAA,PAP,PAS,PASL"], }, }); }} From f6378daa89c7c50a6bfbd39a29422281d77eb1fc Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Fri, 21 May 2021 12:37:54 -0700 Subject: [PATCH 4/9] IO-1151 IO-1159 Calculated Repair & Label Updates --- bodyshop_translations.babel | 44 ++++++++++++++++++- .../jobs-detail-dates.component.jsx | 17 ++++++- .../vehicle-detail-form.container.jsx | 2 +- client/src/translations/en_us/common.json | 2 + client/src/translations/es/common.json | 2 + client/src/translations/fr/common.json | 2 + 6 files changed, 66 insertions(+), 3 deletions(-) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 00805210e..446075c77 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -1,4 +1,4 @@ - +