From a9bd0a5ccb501cea9baa82bc75b729cc9c1e6648 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Tue, 28 Apr 2020 17:19:37 -0700 Subject: [PATCH] Added error handling if job totals have not been calculated --- bodyshop_translations.babel | 21 ++++++ client/package.json | 1 + .../job-totals-table.component.jsx | 5 +- .../job-totals-table/job-totals.utility.js | 2 + .../jobs-detail-financial.component.jsx | 72 +++++++++---------- client/src/graphql/jobs.queries.js | 1 + client/src/translations/en_us/common.json | 1 + client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + client/yarn.lock | 5 ++ 10 files changed, 69 insertions(+), 41 deletions(-) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 736b186b1..9a26f65f5 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -6053,6 +6053,27 @@ + + nofinancial + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + nojobselected false diff --git a/client/package.json b/client/package.json index 144ccfb3e..ca531d8df 100644 --- a/client/package.json +++ b/client/package.json @@ -15,6 +15,7 @@ "apollo-link-retry": "^2.2.16", "apollo-link-ws": "^1.0.20", "axios": "^0.19.2", + "dinero.js": "^1.8.1", "dotenv": "^8.2.0", "firebase": "^7.14.1", "graphql": "^15.0.0", diff --git a/client/src/components/job-totals-table/job-totals-table.component.jsx b/client/src/components/job-totals-table/job-totals-table.component.jsx index 1c7177a3c..2c5eaf522 100644 --- a/client/src/components/job-totals-table/job-totals-table.component.jsx +++ b/client/src/components/job-totals-table/job-totals-table.component.jsx @@ -1,10 +1,11 @@ -import { Col, Descriptions, Row, Statistic } from "antd"; +import { Col, Descriptions, Row, Statistic, Result } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; export default function JobsTotalsTableComponent({ totals }) { const { t } = useTranslation(); - if (!!!totals) return null; + if (!!!totals) + return ; return (
diff --git a/client/src/components/job-totals-table/job-totals.utility.js b/client/src/components/job-totals-table/job-totals.utility.js index 3b31eb11c..bb3f87771 100644 --- a/client/src/components/job-totals-table/job-totals.utility.js +++ b/client/src/components/job-totals-table/job-totals.utility.js @@ -1,3 +1,5 @@ +import Dinero from "dinero.js"; + export function CalculateJob(job, shoprates) { let ret = { parts: CalculatePartsTotals(job.joblines), diff --git a/client/src/components/jobs-detail-financial/jobs-detail-financial.component.jsx b/client/src/components/jobs-detail-financial/jobs-detail-financial.component.jsx index 5534db165..28f1f82a6 100644 --- a/client/src/components/jobs-detail-financial/jobs-detail-financial.component.jsx +++ b/client/src/components/jobs-detail-financial/jobs-detail-financial.component.jsx @@ -9,130 +9,124 @@ export default function JobsDetailFinancials({ job }) { return ( - + - + + name='depreciation_taxes'> TODO This is equivalent of GST payable. + name='federal_tax_payable'> TODO equivalent of other customer amount + name='other_amount_payable'> + name='towing_payable'> + name='storage_payable'> + name='adjustment_bottom_line'> + name='labor_rate_desc'> - + - + - + - + - + - + - + - + Note //TODO Remove ATP rate? - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + {JSON.stringify(job.cieca_ttl, null, "\t")} ); diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index 0e4e83490..4a8354ef4 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -282,6 +282,7 @@ export const GET_JOB_BY_PK = gql` count } } + cieca_ttl } } `; diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index f04c2e04d..9465b5037 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -423,6 +423,7 @@ "noaccess": "This job does not exist or you do not have access to it.", "nodamage": "No damage points on estimate.", "nodates": "No dates specified for this job.", + "nofinancial": "No financial data has been calculated yet for this job. Please save it again.", "nojobselected": "No job is selected.", "noowner": "No owner associated.", "novehicle": "No vehicle associated.", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 4cfc21747..54cb5b3ec 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -423,6 +423,7 @@ "noaccess": "Este trabajo no existe o no tiene acceso a él.", "nodamage": "", "nodates": "No hay fechas especificadas para este trabajo.", + "nofinancial": "", "nojobselected": "No hay trabajo seleccionado.", "noowner": "Ningún propietario asociado.", "novehicle": "No hay vehículo asociado.", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 86909780d..803b2d42b 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -423,6 +423,7 @@ "noaccess": "Ce travail n'existe pas ou vous n'y avez pas accès.", "nodamage": "", "nodates": "Aucune date spécifiée pour ce travail.", + "nofinancial": "", "nojobselected": "Aucun travail n'est sélectionné.", "noowner": "Aucun propriétaire associé.", "novehicle": "Aucun véhicule associé.", diff --git a/client/yarn.lock b/client/yarn.lock index cf5a45fe4..b7c3bdc37 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -4885,6 +4885,11 @@ diffie-hellman@^5.0.0: miller-rabin "^4.0.0" randombytes "^2.0.0" +dinero.js@^1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/dinero.js/-/dinero.js-1.8.1.tgz#775a647629b4195af9d02f46e9b7fa1fd81e906d" + integrity sha512-AQ09MDKonkGUrhBZZFx4tPTVcVJuHJ0VEA73LvcBoBB2eQSi1DbapeXj4wnUUpx1hVnPdyev1xPNnNMGy/Au0g== + dir-glob@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-2.0.0.tgz#0b205d2b6aef98238ca286598a8204d29d0a0034"