From d2bb7121cb73106dffe6d452008d9e12f89347fb Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Tue, 1 Jun 2021 11:52:09 -0700 Subject: [PATCH] IO-1178 Resolve line markup issues. --- .../admin-root/admin-root.component.jsx | 4 ++-- bodyshop_translations.babel | 21 +++++++++++++++++++ .../job-detail-lines/job-lines.component.jsx | 2 +- .../job-lines-upsert-modal.component.jsx | 7 +++++++ client/src/translations/en_us/common.json | 1 + client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + firebase/readme.md | 5 ++--- hasura/config.yaml | 2 +- .../down.yaml | 5 +++++ .../up.yaml | 6 ++++++ .../1622571551101_run_sql_migration/down.yaml | 1 + .../1622571551101_run_sql_migration/up.yaml | 5 +++++ server/job/job-costing.js | 4 ++-- server/job/job-totals.js | 6 +++--- 15 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 hasura/migrations/1622571272382_alter_table_public_joblines_alter_column_prt_dsmk_p/down.yaml create mode 100644 hasura/migrations/1622571272382_alter_table_public_joblines_alter_column_prt_dsmk_p/up.yaml create mode 100644 hasura/migrations/1622571551101_run_sql_migration/down.yaml create mode 100644 hasura/migrations/1622571551101_run_sql_migration/up.yaml diff --git a/admin/src/components/admin-root/admin-root.component.jsx b/admin/src/components/admin-root/admin-root.component.jsx index bb650ed88..7ef2edf01 100644 --- a/admin/src/components/admin-root/admin-root.component.jsx +++ b/admin/src/components/admin-root/admin-root.component.jsx @@ -28,7 +28,7 @@ import JobsShow from "../jobs/jobs.show"; const httpLink = new HttpLink({ uri: process.env.REACT_APP_GRAPHQL_ENDPOINT, headers: { - "x-hasura-admin-secret": `Dev-BodyShopAppBySnaptSoftware!`, + "x-hasura-admin-secret": `Dev-BodyShopApp!`, // 'Authorization': `Bearer xxxx`, }, }); @@ -67,7 +67,7 @@ const client = new ApolloClient({ // uri: process.env.REACT_APP_GRAPHQL_ENDPOINT, // cache: new InMemoryCache(), // headers: { -// "x-hasura-admin-secret": `Dev-BodyShopAppBySnaptSoftware!`, +// "x-hasura-admin-secret": `Dev-BodyShopApp!`, // // 'Authorization': `Bearer xxxx`, // }, // }); diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index abc4f8118..1e18e7b09 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -15232,6 +15232,27 @@ + + prt_dsmk_p + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + status false 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 cd88da672..8184eb331 100644 --- a/client/src/components/job-detail-lines/job-lines.component.jsx +++ b/client/src/components/job-detail-lines/job-lines.component.jsx @@ -157,7 +157,7 @@ export function JobLinesComponent({ render: (text, record) => ( <> {record.act_price} - {record.prt_dsmk_p !== 0 && ( + {record.prt_dsmk_p && record.prt_dsmk_p !== 0 && ( {`(${record.prt_dsmk_p}%)`} diff --git a/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx b/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx index 07e9cc009..a2fa6b8ac 100644 --- a/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx +++ b/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx @@ -210,6 +210,13 @@ export default function JobLinesUpsertModalComponent({ > + + + diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 164bdd128..0b1238c9b 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -957,6 +957,7 @@ }, "profitcenter_labor": "Profit Center: Labor", "profitcenter_part": "Profit Center: Part", + "prt_dsmk_p": "Line Markup %", "status": "Status", "total": "Total", "unq_seq": "Seq #" diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 4fae2a134..d19817847 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -957,6 +957,7 @@ }, "profitcenter_labor": "", "profitcenter_part": "", + "prt_dsmk_p": "", "status": "Estado", "total": "", "unq_seq": "Seq #" diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 63fde29b6..497e05f9a 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -957,6 +957,7 @@ }, "profitcenter_labor": "", "profitcenter_part": "", + "prt_dsmk_p": "", "status": "Statut", "total": "", "unq_seq": "Seq #" diff --git a/firebase/readme.md b/firebase/readme.md index fba8d7a35..a1b2e503b 100644 --- a/firebase/readme.md +++ b/firebase/readme.md @@ -1,4 +1,3 @@ +Must set the environment variables using: -Must set the environment variables using: - -firebase functions:config:set auth.graphql_endpoint="https://bodyshop-dev-db.herokuapp.com/v1/graphql" auth.hasura_secret_admin_key="Dev-BodyShopAppBySnaptSoftware!" \ No newline at end of file +firebase functions:config:set auth.graphql_endpoint="https://bodyshop-dev-db.herokuapp.com/v1/graphql" auth.hasura_secret_admin_key="Dev-BodyShopApp!" diff --git a/hasura/config.yaml b/hasura/config.yaml index 3dda55b42..b3b3d8636 100644 --- a/hasura/config.yaml +++ b/hasura/config.yaml @@ -1,2 +1,2 @@ endpoint: https://bodyshop-dev-db.herokuapp.com -admin_secret: Dev-BodyShopAppBySnaptSoftware! \ No newline at end of file +admin_secret: Dev-BodyShopApp! diff --git a/hasura/migrations/1622571272382_alter_table_public_joblines_alter_column_prt_dsmk_p/down.yaml b/hasura/migrations/1622571272382_alter_table_public_joblines_alter_column_prt_dsmk_p/down.yaml new file mode 100644 index 000000000..106fafc7e --- /dev/null +++ b/hasura/migrations/1622571272382_alter_table_public_joblines_alter_column_prt_dsmk_p/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE ONLY "public"."joblines" ALTER COLUMN "prt_dsmk_p" DROP DEFAULT; + type: run_sql diff --git a/hasura/migrations/1622571272382_alter_table_public_joblines_alter_column_prt_dsmk_p/up.yaml b/hasura/migrations/1622571272382_alter_table_public_joblines_alter_column_prt_dsmk_p/up.yaml new file mode 100644 index 000000000..1b845543f --- /dev/null +++ b/hasura/migrations/1622571272382_alter_table_public_joblines_alter_column_prt_dsmk_p/up.yaml @@ -0,0 +1,6 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE ONLY "public"."joblines" ALTER COLUMN "prt_dsmk_p" SET DEFAULT + 0; + type: run_sql diff --git a/hasura/migrations/1622571551101_run_sql_migration/down.yaml b/hasura/migrations/1622571551101_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1622571551101_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1622571551101_run_sql_migration/up.yaml b/hasura/migrations/1622571551101_run_sql_migration/up.yaml new file mode 100644 index 000000000..579fcb8c2 --- /dev/null +++ b/hasura/migrations/1622571551101_run_sql_migration/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: "update joblines \nset prt_dsmk_p = 0 where joblines.prt_dsmk_p is null;" + type: run_sql diff --git a/server/job/job-costing.js b/server/job/job-costing.js index 24d1d6382..7ee629959 100644 --- a/server/job/job-costing.js +++ b/server/job/job-costing.js @@ -281,7 +281,7 @@ function GenerateCostingData(job) { amount: Math.round((val.act_price || 0) * 100), }) .multiply(val.part_qty || 0) - .percentage(val.prt_dsmk_p) + .percentage(val.prt_dsmk_p || 0) ); if (!acc.parts[partsProfitCenter]) acc.parts[partsProfitCenter] = Dinero(); @@ -310,7 +310,7 @@ function GenerateCostingData(job) { amount: Math.round((val.act_price || 0) * 100), }) .multiply(val.part_qty || 0) - .percentage(val.prt_dsmk_p) + .percentage(val.prt_dsmk_p || 0) ); if (!acc.parts[partsProfitCenter]) diff --git a/server/job/job-totals.js b/server/job/job-totals.js index 45f6bb4e5..ee9d76aca 100644 --- a/server/job/job-totals.js +++ b/server/job/job-totals.js @@ -217,7 +217,7 @@ function CalculatePartsTotals(jobLines) { amount: Math.round((value.act_price || 0) * 100), }) .multiply(value.part_qty || 0) - .percentage(value.prt_dsmk_p) + .percentage(value.prt_dsmk_p || 0) ), list: { ...acc.parts.list, @@ -248,7 +248,7 @@ function CalculatePartsTotals(jobLines) { amount: Math.round((value.act_price || 0) * 100), }) .multiply(value.part_qty || 0) - .percentage(value.prt_dsmk_p) + .percentage(value.prt_dsmk_p || 0) ), }, }; @@ -382,7 +382,7 @@ function CalculateTaxesTotals(job, otherTotals) { amount: Math.round((val.act_price || 0) * 100), }) .multiply(val.part_qty || 0) - .percentage(val.prt_dsmk_p) + .percentage(val.prt_dsmk_p || 0) ) .percentage( ((job.parts_tax_rates &&