diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel new file mode 100644 index 000000000..8bda8c2cf --- /dev/null +++ b/bodyshop_translations.babel @@ -0,0 +1,1476 @@ + + + + react-intl + bodyshop_translations.babel + + + + + + translation + + + general + + + labels + + + in + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + loading + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + na + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + out + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + save + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + unknown + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + languages + + + english + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + french + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + spanish + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + + + jobs + + + actions + + + addDocuments + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + addNote + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + postInvoices + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + printCenter + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + errors + + + noaccess + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + nojobselected + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + noowner + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + novehicle + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + saving + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + validation + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + validationtitle + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + fields + + + claim_total + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + clm_no + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + clm_total + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + deductible + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + est_number + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + owner + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + owner_owing + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + phone1 + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + ro_number + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + status + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + vehicle + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + labels + + + cards + + + appraiser + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + customer + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + damage + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + dates + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + documents + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + estimator + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + filehandler + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + insurance + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + notes + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + parts + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + totals + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + vehicle + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + convert + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + vehicle_info + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + successes + + + converted + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + save + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + savetitle + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + + + menus + + + currentuser + + + languageselector + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + profile + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + profilesidebar + + + profile + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + shops + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + + + notes + + + fields + + + critical + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + private + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + text + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + labels + + + newnoteplaceholder + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + + + profile + + + errors + + + state + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + + + titles + + + app + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + jobs + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + jobsdetail + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + profile + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + vehicles + + + fields + + + plate_no + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + + + + + + false + + + en-US + + client/src/translations/en_us/common.json + + + es-MX + + client/src/translations/es/common.json + + + fr-CA + + client/src/translations/fr/common.json + + + + + client/src/translations/en_us/common.json + + + client/src/translations/es/common.json + + + client/src/translations/fr/common.json + + + + true + + + + + + + en-US + + + tab + namespaced-json + true + + diff --git a/client/src/components/job-tombstone/job-tombstone.component.jsx b/client/src/components/job-tombstone/job-tombstone.component.jsx index 7e51e830c..0f56000e9 100644 --- a/client/src/components/job-tombstone/job-tombstone.component.jsx +++ b/client/src/components/job-tombstone/job-tombstone.component.jsx @@ -15,7 +15,7 @@ import { Avatar, Layout } from "antd"; -import { UPDATE_JOB } from "../../graphql/jobs.queries"; +import { UPDATE_JOB, CONVERT_JOB_TO_RO } from "../../graphql/jobs.queries"; import { useMutation } from "@apollo/react-hooks"; import FormItemPhone from "../form-items-formatted/phone-form-item.component"; import { useTranslation } from "react-i18next"; @@ -36,6 +36,7 @@ const formItemLayout = { function JobTombstone({ job, ...otherProps }) { const [jobContext, setJobContext] = useState(job); const [mutationUpdateJob] = useMutation(UPDATE_JOB); + const [mutationConvertJob] = useMutation(CONVERT_JOB_TO_RO); const { t } = useTranslation(); if (!job) { @@ -95,11 +96,31 @@ function JobTombstone({ job, ...otherProps }) { } tags={{jobContext?.job_status?.name}} extra={[ - - - + , + ]}> diff --git a/client/src/graphql/apollo-error-handling.js b/client/src/graphql/apollo-error-handling.js index 5ef59bdad..5ffb06e1c 100644 --- a/client/src/graphql/apollo-error-handling.js +++ b/client/src/graphql/apollo-error-handling.js @@ -9,55 +9,56 @@ const errorLink = onError( console.log("networkError", networkError); console.log("operation", operation); console.log("forward", forward); - //if (graphQLErrors) { - // User access token has expired - if (networkError.message.includes("JWTExpired")) { - console.log("Got to the error check."); - if (access_token && access_token !== "undefined") { - // Let's refresh token through async request - return new Observable(observer => { - auth.currentUser - .getIdToken(true) - .then(function(idToken) { - if (!idToken) { - window.localStorage.removeItem("token"); - return console.log("Refresh token has expired"); - } - console.log("Got a new token", idToken); - window.localStorage.setItem("token", idToken); - - // reset the headers - operation.setContext(({ headers = {} }) => ({ - headers: { - // Re-add old headers - ...headers, - // Switch out old access token for new one - authorization: idToken ? `Bearer ${idToken}` : "" - } - })); - - // const subscriber = { - // next: observer.next.bind(observer), - // error: observer.error.bind(observer), - // complete: observer.complete.bind(observer) - // }; - console.log("About to resend the request."); - // Retry last failed request - forward(operation); //.subscribe(subscriber); - }) - .catch(error => { - // No refresh or client token available, we force user to login - console.log("Hit an error."); - observer.error(error); - }); - }); - } + if (graphQLErrors) { + //User access token has expired + console.log("graphQLErrors", graphQLErrors); } - //} if (networkError) { console.log(`[Network error]: ${networkError}`); //props.history.push("/network-error"); + if (networkError.message.includes("JWTExpired")) { + console.log("Got to the error check."); + if (access_token && access_token !== "undefined") { + // Let's refresh token through async request + return new Observable(observer => { + auth.currentUser + .getIdToken(true) + .then(function(idToken) { + if (!idToken) { + window.localStorage.removeItem("token"); + return console.log("Refresh token has expired"); + } + console.log("Got a new token", idToken); + window.localStorage.setItem("token", idToken); + + // reset the headers + operation.setContext(({ headers = {} }) => ({ + headers: { + // Re-add old headers + ...headers, + // Switch out old access token for new one + authorization: idToken ? `Bearer ${idToken}` : "" + } + })); + + // const subscriber = { + // next: observer.next.bind(observer), + // error: observer.error.bind(observer), + // complete: observer.complete.bind(observer) + // }; + console.log("About to resend the request."); + // Retry last failed request + forward(operation); //.subscribe(subscriber); + }) + .catch(error => { + // No refresh or client token available, we force user to login + console.log("Hit an error."); + observer.error(error); + }); + }); + } + } } } ); diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index 8ee2824d0..86e10bda7 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -272,3 +272,15 @@ export const UPDATE_JOB = gql` } } `; + +export const CONVERT_JOB_TO_RO = gql` + mutation CONVERT_JOB_TO_RO($jobId: uuid!) { + update_jobs(where: { id: { _eq: $jobId } }, _set: { converted: true }) { + returning { + id + ro_number + converted + } + } + } +`; diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 713fe902a..e4865ddc7 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1,110 +1,108 @@ { - "translation": { - "general": { - "languages": { - "english": "English", - "french": "French", - "spanish": "Spanish" - }, - "labels": { - "in": "In", - "out": "Out", - "na": "N/A", - "unknown": "Unknown", - "save": "Save", - "loading": "Loading..." - } - }, - "menus": { - "currentuser": { - "profile": "Profile", - "languageselector": "Language" - }, - "profilesidebar": { - "profile": "My Profile", - "shops": "My Shops" - } - }, - - "titles": { - "app": "Bodyshop by ImEX Systems", - "jobs": "All Jobs | $t(titles.app)", - "jobsdetail": "Job {{ro_number}} | $t(titles.app)", - "profile": "My Profile | $t(titles.app)" - }, - - "profile": { - "errors": { - "state": "Error reading page state. Please refresh." - } - }, - - "vehicles": { - "fields": { - "plate_no": "License Plate" - } - }, - - "notes": { - "labels": { - "newnoteplaceholder": "Add a note..." - }, - "fields": { - "critical": "Critical", - "private": "Private", - "text": "Contents" - } - }, - - "jobs": { - "labels": { - "cards": { - "customer": "Customer Information", - "vehicle": "Vehicle", - "insurance": "Insurance Details", - "dates": "Dates", - "documents": "Documents", - "parts": "Parts", - "notes": "Notes", - "damage": "Area of Damage", - "totals": "Totals", - "filehandler": "File Handler", - "appraiser": "Appraiser", - "estimator": "Estimator" - }, - "vehicle_info": "Vehicle" - }, - "fields": { - "ro_number": "RO #", - "est_number": "Estimate Number", - "clm_total": "Claim Total", - "deductible": "Deductible", - "owner": "Owner", - "status": "Job Status", - "vehicle": "Vehicle", - "phone1": "Phone 1", - "clm_no": "Claim #", - "owner_owing": "Cust. Owes" - }, - "successes": { - "save": "Record Saved", - "savetitle": "Record saved succesfully." - }, - "errors": { - "noaccess": "This job does not exist or you do not have access to it.", - "validationtitle": "Validation Error", - "validation": "Please ensure all fields are entered correctly.", - "saving": "Error encountered while saving record.", - "nojobselected": "No job is selected.", - "noowner": "No owner associated.", - "novehicle": "No vehicle associated." - }, - "actions": { - "addDocuments": "Add Job Documents", - "printCenter": "Print Center", - "postInvoices": "Post Invoices", - "addNote": "Add Note" - } - } - } + "translation": { + "general": { + "labels": { + "in": "In", + "loading": "Loading...", + "na": "N/A", + "out": "Out", + "save": "Save", + "unknown": "Unknown" + }, + "languages": { + "english": "English", + "french": "French", + "spanish": "Spanish" + } + }, + "jobs": { + "actions": { + "addDocuments": "Add Job Documents", + "addNote": "Add Note", + "postInvoices": "Post Invoices", + "printCenter": "Print Center" + }, + "errors": { + "noaccess": "This job does not exist or you do not have access to it.", + "nojobselected": "No job is selected.", + "noowner": "No owner associated.", + "novehicle": "No vehicle associated.", + "saving": "Error encountered while saving record.", + "validation": "Please ensure all fields are entered correctly.", + "validationtitle": "Validation Error" + }, + "fields": { + "claim_total": "Claim Total", + "clm_no": "Claim #", + "clm_total": "Claim Total", + "deductible": "Deductible", + "est_number": "Estimate Number", + "owner": "Owner", + "owner_owing": "Cust. Owes", + "phone1": "Phone 1", + "ro_number": "RO #", + "status": "Job Status", + "vehicle": "Vehicle" + }, + "labels": { + "cards": { + "appraiser": "Appraiser", + "customer": "Customer Information", + "damage": "Area of Damage", + "dates": "Dates", + "documents": "Documents", + "estimator": "Estimator", + "filehandler": "File Handler", + "insurance": "Insurance Details", + "notes": "Notes", + "parts": "Parts", + "totals": "Totals", + "vehicle": "Vehicle" + }, + "convert": "Convert", + "vehicle_info": "Vehicle" + }, + "successes": { + "converted": "Job converted successfully.", + "save": "Record Saved", + "savetitle": "Record saved successfully." + } + }, + "menus": { + "currentuser": { + "languageselector": "Language", + "profile": "Profile" + }, + "profilesidebar": { + "profile": "My Profile", + "shops": "My Shops" + } + }, + "notes": { + "fields": { + "critical": "Critical", + "private": "Private", + "text": "Contents" + }, + "labels": { + "newnoteplaceholder": "Add a note..." + } + }, + "profile": { + "errors": { + "state": "Error reading page state. Please refresh." + } + }, + "titles": { + "app": "Bodyshop by ImEX Systems", + "jobs": "All Jobs | $t(titles.app)", + "jobsdetail": "Job {{ro_number}} | $t(titles.app)", + "profile": "My Profile | $t(titles.app)" + }, + "vehicles": { + "fields": { + "plate_no": "License Plate" + } + } + } } diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index d9900b975..49edea7be 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1,9 +1,108 @@ { - "translation": { - "general": { - "title": "Hola a {{framework}}", - "greetings": "Hola!", - "intro": "To get started, edit <1><0> and save to reload." - } - } + "translation": { + "general": { + "labels": { + "in": "en", + "loading": "Cargando...", + "na": "N / A", + "out": "Afuera", + "save": "Salvar", + "unknown": "Desconocido" + }, + "languages": { + "english": "Inglés", + "french": "francés", + "spanish": "español" + } + }, + "jobs": { + "actions": { + "addDocuments": "Agregar documentos de trabajo", + "addNote": "Añadir la nota", + "postInvoices": "Contabilizar facturas", + "printCenter": "Centro de impresión" + }, + "errors": { + "noaccess": "Este trabajo no existe o no tiene acceso a él.", + "nojobselected": "No hay trabajo seleccionado.", + "noowner": "Ningún propietario asociado.", + "novehicle": "No hay vehículo asociado.", + "saving": "Se encontró un error al guardar el registro.", + "validation": "Asegúrese de que todos los campos se ingresen correctamente.", + "validationtitle": "Error de validacion" + }, + "fields": { + "claim_total": "Reclamar total", + "clm_no": "Reclamación #", + "clm_total": "Reclamar total", + "deductible": "Deducible", + "est_number": "Numero Estimado", + "owner": "Propietario", + "owner_owing": "Cust. Debe", + "phone1": "Teléfono 1", + "ro_number": "RO #", + "status": "Estado del trabajo", + "vehicle": "Vehículo" + }, + "labels": { + "cards": { + "appraiser": "Tasador", + "customer": "Información al cliente", + "damage": "Área de Daño", + "dates": "fechas", + "documents": "documentos", + "estimator": "Estimador", + "filehandler": "File Handler", + "insurance": "detalles del seguro", + "notes": "Notas", + "parts": "Partes", + "totals": "Totales", + "vehicle": "Vehículo" + }, + "convert": "Convertir", + "vehicle_info": "Vehículo" + }, + "successes": { + "converted": "Trabajo convertido con éxito.", + "save": "Registro guardado", + "savetitle": "Registro guardado con éxito." + } + }, + "menus": { + "currentuser": { + "languageselector": "idioma", + "profile": "Perfil" + }, + "profilesidebar": { + "profile": "Mi perfil", + "shops": "Mis tiendas" + } + }, + "notes": { + "fields": { + "critical": "Crítico", + "private": "Privado", + "text": "Contenido" + }, + "labels": { + "newnoteplaceholder": "Agrega una nota..." + } + }, + "profile": { + "errors": { + "state": "Error al leer el estado de la página. Porfavor refresca." + } + }, + "titles": { + "app": "Carrocería de ImEX Systems", + "jobs": "Todos los trabajos | $t(titles.app)", + "jobsdetail": "Trabajo {{ro_number}} | $t(titles.app)", + "profile": "Mi perfil | $ t (títulos.app)" + }, + "vehicles": { + "fields": { + "plate_no": "Placa" + } + } + } } diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 015f13867..8a3b0ad0f 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1,22 +1,108 @@ { - "translation": { - "general": { - "languages": { - "english": "Anglais", - "french": "Francais", - "spanish": "Espanol" - }, - "title": "Welcome to {{framework}}", - "greetings": "Hello2!", - "intro": "To get started, edit <1><0> and save to reload." - }, - "whiteboard": { - "viewJobImages": "Viewez le Job Images", - "printCenter": "Printez Centre", - "postInvoices": "Postez le Invoices", - "notes": "Le Job Notes", - "partStatus": "Status de Parts", - "receiveParts": "Receive Parts" - } - } + "translation": { + "general": { + "labels": { + "in": "dans", + "loading": "Chargement...", + "na": "N / A", + "out": "En dehors", + "save": "sauvegarder", + "unknown": "Inconnu" + }, + "languages": { + "english": "Anglais", + "french": "Francais", + "spanish": "Espanol" + } + }, + "jobs": { + "actions": { + "addDocuments": "Ajouter des documents de travail", + "addNote": "Ajouter une note", + "postInvoices": "Poster des factures", + "printCenter": "Centre d'impression" + }, + "errors": { + "noaccess": "Ce travail n'existe pas ou vous n'y avez pas accès.", + "nojobselected": "Aucun travail n'est sélectionné.", + "noowner": "Aucun propriétaire associé.", + "novehicle": "Aucun véhicule associé.", + "saving": "Erreur rencontrée lors de la sauvegarde de l'enregistrement.", + "validation": "Veuillez vous assurer que tous les champs sont correctement entrés.", + "validationtitle": "Erreur de validation" + }, + "fields": { + "claim_total": "Total réclamation", + "clm_no": "Prétendre #", + "clm_total": "Total réclamation", + "deductible": "Déductible", + "est_number": "Numéro d'estimation", + "owner": "Propriétaire", + "owner_owing": "Cust. Owes", + "phone1": "Téléphone 1", + "ro_number": "RO #", + "status": "Statut de l'emploi", + "vehicle": "Véhicule" + }, + "labels": { + "cards": { + "appraiser": "Expert", + "customer": "Informations client", + "damage": "Zone de dommages", + "dates": "Rendez-vous", + "documents": "Les documents", + "estimator": "Estimateur", + "filehandler": "Gestionnaire de fichiers", + "insurance": "Détails de l'assurance", + "notes": "Remarques", + "parts": "les pièces", + "totals": "Totaux", + "vehicle": "Véhicule" + }, + "convert": "Convertir", + "vehicle_info": "Véhicule" + }, + "successes": { + "converted": "Travail converti avec succès.", + "save": "Enregistrement enregistré", + "savetitle": "Enregistrement enregistré avec succès." + } + }, + "menus": { + "currentuser": { + "languageselector": "La langue", + "profile": "Profil" + }, + "profilesidebar": { + "profile": "Mon profil", + "shops": "Mes boutiques" + } + }, + "notes": { + "fields": { + "critical": "Critique", + "private": "privé", + "text": "Contenu" + }, + "labels": { + "newnoteplaceholder": "Ajouter une note..." + } + }, + "profile": { + "errors": { + "state": "Erreur lors de la lecture de l'état de la page. Rafraichissez, s'il vous plait." + } + }, + "titles": { + "app": "Carrosserie par ImEX Systems", + "jobs": "Tous les emplois | $t(titles.app)", + "jobsdetail": "Travail {{ro_number}} | $t(titles.app)", + "profile": "Mon profil | $ t (titres.app)" + }, + "vehicles": { + "fields": { + "plate_no": "Plaque d'immatriculation" + } + } + } } diff --git a/hasura/migrations/1579026961016_create_table_public_counters/down.yaml b/hasura/migrations/1579026961016_create_table_public_counters/down.yaml new file mode 100644 index 000000000..a1dd6677c --- /dev/null +++ b/hasura/migrations/1579026961016_create_table_public_counters/down.yaml @@ -0,0 +1,3 @@ +- args: + sql: DROP TABLE "public"."counters" + type: run_sql diff --git a/hasura/migrations/1579026961016_create_table_public_counters/up.yaml b/hasura/migrations/1579026961016_create_table_public_counters/up.yaml new file mode 100644 index 000000000..b5290d84c --- /dev/null +++ b/hasura/migrations/1579026961016_create_table_public_counters/up.yaml @@ -0,0 +1,19 @@ +- args: + sql: CREATE EXTENSION IF NOT EXISTS pgcrypto; + type: run_sql +- args: + sql: "CREATE TABLE \"public\".\"counters\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(), + \"updated_at\" timestamptz NOT NULL DEFAULT now(), \"shopid\" uuid NOT NULL, + \"countertype\" text NOT NULL, \"prefix\" text, \"count\" integer NOT NULL DEFAULT + 1, PRIMARY KEY (\"id\") , FOREIGN KEY (\"shopid\") REFERENCES \"public\".\"bodyshops\"(\"id\") + ON UPDATE cascade ON DELETE cascade);\nCREATE OR REPLACE FUNCTION \"public\".\"set_current_timestamp_updated_at\"()\nRETURNS + TRIGGER AS $$\nDECLARE\n _new record;\nBEGIN\n _new := NEW;\n _new.\"updated_at\" + = NOW();\n RETURN _new;\nEND;\n$$ LANGUAGE plpgsql;\nCREATE TRIGGER \"set_public_counters_updated_at\"\nBEFORE + UPDATE ON \"public\".\"counters\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT + ON TRIGGER \"set_public_counters_updated_at\" ON \"public\".\"counters\" \nIS + 'trigger to set value of column \"updated_at\" to current timestamp on row update';\n" + type: run_sql +- args: + name: counters + schema: public + type: add_existing_table_or_view diff --git a/hasura/migrations/1579026971671_track_all_relationships/down.yaml b/hasura/migrations/1579026971671_track_all_relationships/down.yaml new file mode 100644 index 000000000..2dd45125d --- /dev/null +++ b/hasura/migrations/1579026971671_track_all_relationships/down.yaml @@ -0,0 +1,24 @@ +- args: + relationship: counters + table: + name: bodyshops + schema: public + type: drop_relationship +- args: + relationship: bodyshop + table: + name: counters + schema: public + type: drop_relationship +- args: + relationship: user + table: + name: notes + schema: public + type: drop_relationship +- args: + relationship: notes + table: + name: users + schema: public + type: drop_relationship diff --git a/hasura/migrations/1579026971671_track_all_relationships/up.yaml b/hasura/migrations/1579026971671_track_all_relationships/up.yaml new file mode 100644 index 000000000..700be44d3 --- /dev/null +++ b/hasura/migrations/1579026971671_track_all_relationships/up.yaml @@ -0,0 +1,40 @@ +- args: + name: counters + table: + name: bodyshops + schema: public + using: + foreign_key_constraint_on: + column: shopid + table: + name: counters + schema: public + type: create_array_relationship +- args: + name: bodyshop + table: + name: counters + schema: public + using: + foreign_key_constraint_on: shopid + type: create_object_relationship +- args: + name: user + table: + name: notes + schema: public + using: + foreign_key_constraint_on: created_by + type: create_object_relationship +- args: + name: notes + table: + name: users + schema: public + using: + foreign_key_constraint_on: + column: created_by + table: + name: notes + schema: public + type: create_array_relationship diff --git a/hasura/migrations/1579027296343_create_ronum_function/down.yaml b/hasura/migrations/1579027296343_create_ronum_function/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1579027296343_create_ronum_function/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1579027296343_create_ronum_function/up.yaml b/hasura/migrations/1579027296343_create_ronum_function/up.yaml new file mode 100644 index 000000000..c48f71c55 --- /dev/null +++ b/hasura/migrations/1579027296343_create_ronum_function/up.yaml @@ -0,0 +1,8 @@ +- args: + cascade: true + sql: "CREATE OR REPLACE FUNCTION assign_ro_number()\r\n RETURNS trigger\r\n LANGUAGE + plpgsql\r\nAS $function$\r\n begin\r\n IF NEW.converted = true and + new.ro_number is null THEN\r\n UPDATE counters\r\n\tSET count = count + + 1 where shopid=new.shopid\r\n\tRETURNING CONCAT(prefix,count) into new.ro_number;\r\n\r\n + \ END IF;\r\n RETURN NEW;\r\n END;\r\n $function$\r\n;\r\n" + type: run_sql diff --git a/hasura/migrations/1579027345149_assign_ro_trigger/down.yaml b/hasura/migrations/1579027345149_assign_ro_trigger/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1579027345149_assign_ro_trigger/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1579027345149_assign_ro_trigger/up.yaml b/hasura/migrations/1579027345149_assign_ro_trigger/up.yaml new file mode 100644 index 000000000..704f4a655 --- /dev/null +++ b/hasura/migrations/1579027345149_assign_ro_trigger/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: true + sql: "create trigger jobs_assign_RO before\r\nupdate\r\n on\r\n jobs for + each row execute function assign_ro_number();\r\n" + type: run_sql diff --git a/hasura/migrations/1579028145978_alter_table_public_jobs_add_column_converted/down.yaml b/hasura/migrations/1579028145978_alter_table_public_jobs_add_column_converted/down.yaml new file mode 100644 index 000000000..a22482f86 --- /dev/null +++ b/hasura/migrations/1579028145978_alter_table_public_jobs_add_column_converted/down.yaml @@ -0,0 +1,3 @@ +- args: + sql: ALTER TABLE "public"."jobs" DROP COLUMN "converted"; + type: run_sql diff --git a/hasura/migrations/1579028145978_alter_table_public_jobs_add_column_converted/up.yaml b/hasura/migrations/1579028145978_alter_table_public_jobs_add_column_converted/up.yaml new file mode 100644 index 000000000..e74c74992 --- /dev/null +++ b/hasura/migrations/1579028145978_alter_table_public_jobs_add_column_converted/up.yaml @@ -0,0 +1,4 @@ +- args: + sql: ALTER TABLE "public"."jobs" ADD COLUMN "converted" boolean NOT NULL DEFAULT + false; + type: run_sql diff --git a/hasura/migrations/1579028156646_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1579028156646_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 000000000..716de8355 --- /dev/null +++ b/hasura/migrations/1579028156646_update_permission_user_public_table_jobs/down.yaml @@ -0,0 +1,128 @@ +- args: + role: user + table: + name: jobs + schema: public + type: drop_insert_permission +- args: + permission: + check: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - id + - created_at + - updated_at + - shopid + - est_number + - ro_number + - ownerid + - vehicleid + - labor_rate_id + - labor_rate_desc + - rate_lab + - rate_lad + - rate_lae + - rate_lar + - rate_las + - rate_laf + - rate_lam + - rate_lag + - rate_atp + - rate_lau + - rate_la1 + - rate_la2 + - rate_la3 + - rate_la4 + - rate_mapa + - rate_mash + - rate_mahw + - rate_ma2s + - rate_ma3s + - rate_ma2t + - rate_mabl + - rate_macs + - rate_matd + - federal_tax_rate + - state_tax_rate + - local_tax_rate + - est_co_nm + - est_addr1 + - est_addr2 + - est_city + - est_st + - est_zip + - est_ctry + - est_ph1 + - est_ea + - est_ct_ln + - est_ct_fn + - scheduled_in + - actual_in + - scheduled_completion + - actual_completion + - scheduled_delivery + - actual_delivery + - regie_number + - invoice_date + - claim_total + - deductible + - inproduction + - statusid + - pit_owner_first_name + - pit_owner_last_name + - pit_owner_phone + - pit_owner_email + - pit_vehicle_plate_no + - ins_co_id + - ins_co_nm + - ins_addr1 + - ins_addr2 + - ins_city + - ins_st + - ins_zip + - ins_ctry + - ins_ph1 + - ins_ph1x + - ins_ph2 + - ins_ph2x + - ins_fax + - ins_faxx + - ins_ct_ln + - ins_ct_fn + - ins_title + - ins_ct_ph + - ins_ct_phx + - ins_ea + - ins_memo + - policy_no + - ded_amt + - ded_status + - asgn_no + - asgn_date + - asgn_type + - clm_no + - clm_ofc_id + - date_estimated + - date_open + - date_scheduled + - date_invoiced + - date_closed + - date_exported + - clm_total + - owner_owing + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: jobs + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1579028156646_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1579028156646_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 000000000..81bdff74e --- /dev/null +++ b/hasura/migrations/1579028156646_update_permission_user_public_table_jobs/up.yaml @@ -0,0 +1,129 @@ +- args: + role: user + table: + name: jobs + schema: public + type: drop_insert_permission +- args: + permission: + check: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - id + - created_at + - updated_at + - shopid + - est_number + - ro_number + - ownerid + - vehicleid + - labor_rate_id + - labor_rate_desc + - rate_lab + - rate_lad + - rate_lae + - rate_lar + - rate_las + - rate_laf + - rate_lam + - rate_lag + - rate_atp + - rate_lau + - rate_la1 + - rate_la2 + - rate_la3 + - rate_la4 + - rate_mapa + - rate_mash + - rate_mahw + - rate_ma2s + - rate_ma3s + - rate_ma2t + - rate_mabl + - rate_macs + - rate_matd + - federal_tax_rate + - state_tax_rate + - local_tax_rate + - est_co_nm + - est_addr1 + - est_addr2 + - est_city + - est_st + - est_zip + - est_ctry + - est_ph1 + - est_ea + - est_ct_ln + - est_ct_fn + - scheduled_in + - actual_in + - scheduled_completion + - actual_completion + - scheduled_delivery + - actual_delivery + - regie_number + - invoice_date + - claim_total + - deductible + - inproduction + - statusid + - pit_owner_first_name + - pit_owner_last_name + - pit_owner_phone + - pit_owner_email + - pit_vehicle_plate_no + - ins_co_id + - ins_co_nm + - ins_addr1 + - ins_addr2 + - ins_city + - ins_st + - ins_zip + - ins_ctry + - ins_ph1 + - ins_ph1x + - ins_ph2 + - ins_ph2x + - ins_fax + - ins_faxx + - ins_ct_ln + - ins_ct_fn + - ins_title + - ins_ct_ph + - ins_ct_phx + - ins_ea + - ins_memo + - policy_no + - ded_amt + - ded_status + - asgn_no + - asgn_date + - asgn_type + - clm_no + - clm_ofc_id + - date_estimated + - date_open + - date_scheduled + - date_invoiced + - date_closed + - date_exported + - clm_total + - owner_owing + - converted + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: jobs + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1579028161738_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1579028161738_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 000000000..ae63fa93d --- /dev/null +++ b/hasura/migrations/1579028161738_update_permission_user_public_table_jobs/down.yaml @@ -0,0 +1,126 @@ +- args: + role: user + table: + name: jobs + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - ded_status + - inproduction + - asgn_date + - invoice_date + - claim_total + - clm_total + - ded_amt + - deductible + - federal_tax_rate + - local_tax_rate + - owner_owing + - rate_atp + - rate_la1 + - rate_la2 + - rate_la3 + - rate_la4 + - rate_lab + - rate_lad + - rate_lae + - rate_laf + - rate_lag + - rate_lam + - rate_lar + - rate_las + - rate_lau + - rate_ma2s + - rate_ma2t + - rate_ma3s + - rate_mabl + - rate_macs + - rate_mahw + - rate_mapa + - rate_mash + - rate_matd + - state_tax_rate + - asgn_no + - asgn_type + - clm_no + - clm_ofc_id + - est_addr1 + - est_addr2 + - est_city + - est_co_nm + - est_ct_fn + - est_ct_ln + - est_ctry + - est_ea + - est_number + - est_ph1 + - est_st + - est_zip + - ins_addr1 + - ins_addr2 + - ins_city + - ins_co_id + - ins_co_nm + - ins_ct_fn + - ins_ct_ln + - ins_ct_ph + - ins_ct_phx + - ins_ctry + - ins_ea + - ins_fax + - ins_faxx + - ins_memo + - ins_ph1 + - ins_ph1x + - ins_ph2 + - ins_ph2x + - ins_st + - ins_title + - ins_zip + - labor_rate_desc + - labor_rate_id + - pit_owner_email + - pit_owner_first_name + - pit_owner_last_name + - pit_owner_phone + - pit_vehicle_plate_no + - policy_no + - regie_number + - ro_number + - actual_completion + - actual_delivery + - actual_in + - created_at + - date_closed + - date_estimated + - date_exported + - date_invoiced + - date_open + - date_scheduled + - scheduled_completion + - scheduled_delivery + - scheduled_in + - updated_at + - id + - ownerid + - shopid + - statusid + - vehicleid + computed_fields: [] + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: jobs + schema: public + type: create_select_permission diff --git a/hasura/migrations/1579028161738_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1579028161738_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 000000000..f98c35f13 --- /dev/null +++ b/hasura/migrations/1579028161738_update_permission_user_public_table_jobs/up.yaml @@ -0,0 +1,127 @@ +- args: + role: user + table: + name: jobs + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - converted + - ded_status + - inproduction + - asgn_date + - invoice_date + - claim_total + - clm_total + - ded_amt + - deductible + - federal_tax_rate + - local_tax_rate + - owner_owing + - rate_atp + - rate_la1 + - rate_la2 + - rate_la3 + - rate_la4 + - rate_lab + - rate_lad + - rate_lae + - rate_laf + - rate_lag + - rate_lam + - rate_lar + - rate_las + - rate_lau + - rate_ma2s + - rate_ma2t + - rate_ma3s + - rate_mabl + - rate_macs + - rate_mahw + - rate_mapa + - rate_mash + - rate_matd + - state_tax_rate + - asgn_no + - asgn_type + - clm_no + - clm_ofc_id + - est_addr1 + - est_addr2 + - est_city + - est_co_nm + - est_ct_fn + - est_ct_ln + - est_ctry + - est_ea + - est_number + - est_ph1 + - est_st + - est_zip + - ins_addr1 + - ins_addr2 + - ins_city + - ins_co_id + - ins_co_nm + - ins_ct_fn + - ins_ct_ln + - ins_ct_ph + - ins_ct_phx + - ins_ctry + - ins_ea + - ins_fax + - ins_faxx + - ins_memo + - ins_ph1 + - ins_ph1x + - ins_ph2 + - ins_ph2x + - ins_st + - ins_title + - ins_zip + - labor_rate_desc + - labor_rate_id + - pit_owner_email + - pit_owner_first_name + - pit_owner_last_name + - pit_owner_phone + - pit_vehicle_plate_no + - policy_no + - regie_number + - ro_number + - actual_completion + - actual_delivery + - actual_in + - created_at + - date_closed + - date_estimated + - date_exported + - date_invoiced + - date_open + - date_scheduled + - scheduled_completion + - scheduled_delivery + - scheduled_in + - updated_at + - id + - ownerid + - shopid + - statusid + - vehicleid + computed_fields: [] + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: jobs + schema: public + type: create_select_permission diff --git a/hasura/migrations/1579028166613_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1579028166613_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 000000000..578c534e8 --- /dev/null +++ b/hasura/migrations/1579028166613_update_permission_user_public_table_jobs/down.yaml @@ -0,0 +1,128 @@ +- args: + role: user + table: + name: jobs + schema: public + type: drop_update_permission +- args: + permission: + columns: + - ded_status + - inproduction + - asgn_date + - invoice_date + - claim_total + - clm_total + - ded_amt + - deductible + - federal_tax_rate + - local_tax_rate + - owner_owing + - rate_atp + - rate_la1 + - rate_la2 + - rate_la3 + - rate_la4 + - rate_lab + - rate_lad + - rate_lae + - rate_laf + - rate_lag + - rate_lam + - rate_lar + - rate_las + - rate_lau + - rate_ma2s + - rate_ma2t + - rate_ma3s + - rate_mabl + - rate_macs + - rate_mahw + - rate_mapa + - rate_mash + - rate_matd + - state_tax_rate + - asgn_no + - asgn_type + - clm_no + - clm_ofc_id + - est_addr1 + - est_addr2 + - est_city + - est_co_nm + - est_ct_fn + - est_ct_ln + - est_ctry + - est_ea + - est_number + - est_ph1 + - est_st + - est_zip + - ins_addr1 + - ins_addr2 + - ins_city + - ins_co_id + - ins_co_nm + - ins_ct_fn + - ins_ct_ln + - ins_ct_ph + - ins_ct_phx + - ins_ctry + - ins_ea + - ins_fax + - ins_faxx + - ins_memo + - ins_ph1 + - ins_ph1x + - ins_ph2 + - ins_ph2x + - ins_st + - ins_title + - ins_zip + - labor_rate_desc + - labor_rate_id + - pit_owner_email + - pit_owner_first_name + - pit_owner_last_name + - pit_owner_phone + - pit_vehicle_plate_no + - policy_no + - regie_number + - ro_number + - actual_completion + - actual_delivery + - actual_in + - created_at + - date_closed + - date_estimated + - date_exported + - date_invoiced + - date_open + - date_scheduled + - scheduled_completion + - scheduled_delivery + - scheduled_in + - updated_at + - id + - ownerid + - shopid + - statusid + - vehicleid + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: jobs + schema: public + type: create_update_permission diff --git a/hasura/migrations/1579028166613_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1579028166613_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 000000000..ee5d48718 --- /dev/null +++ b/hasura/migrations/1579028166613_update_permission_user_public_table_jobs/up.yaml @@ -0,0 +1,129 @@ +- args: + role: user + table: + name: jobs + schema: public + type: drop_update_permission +- args: + permission: + columns: + - converted + - ded_status + - inproduction + - asgn_date + - invoice_date + - claim_total + - clm_total + - ded_amt + - deductible + - federal_tax_rate + - local_tax_rate + - owner_owing + - rate_atp + - rate_la1 + - rate_la2 + - rate_la3 + - rate_la4 + - rate_lab + - rate_lad + - rate_lae + - rate_laf + - rate_lag + - rate_lam + - rate_lar + - rate_las + - rate_lau + - rate_ma2s + - rate_ma2t + - rate_ma3s + - rate_mabl + - rate_macs + - rate_mahw + - rate_mapa + - rate_mash + - rate_matd + - state_tax_rate + - asgn_no + - asgn_type + - clm_no + - clm_ofc_id + - est_addr1 + - est_addr2 + - est_city + - est_co_nm + - est_ct_fn + - est_ct_ln + - est_ctry + - est_ea + - est_number + - est_ph1 + - est_st + - est_zip + - ins_addr1 + - ins_addr2 + - ins_city + - ins_co_id + - ins_co_nm + - ins_ct_fn + - ins_ct_ln + - ins_ct_ph + - ins_ct_phx + - ins_ctry + - ins_ea + - ins_fax + - ins_faxx + - ins_memo + - ins_ph1 + - ins_ph1x + - ins_ph2 + - ins_ph2x + - ins_st + - ins_title + - ins_zip + - labor_rate_desc + - labor_rate_id + - pit_owner_email + - pit_owner_first_name + - pit_owner_last_name + - pit_owner_phone + - pit_vehicle_plate_no + - policy_no + - regie_number + - ro_number + - actual_completion + - actual_delivery + - actual_in + - created_at + - date_closed + - date_estimated + - date_exported + - date_invoiced + - date_open + - date_scheduled + - scheduled_completion + - scheduled_delivery + - scheduled_in + - updated_at + - id + - ownerid + - shopid + - statusid + - vehicleid + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: jobs + schema: public + type: create_update_permission diff --git a/hasura/migrations/1579030370307_fix_assign_ro_function/down.yaml b/hasura/migrations/1579030370307_fix_assign_ro_function/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1579030370307_fix_assign_ro_function/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1579030370307_fix_assign_ro_function/up.yaml b/hasura/migrations/1579030370307_fix_assign_ro_function/up.yaml new file mode 100644 index 000000000..21837bd0e --- /dev/null +++ b/hasura/migrations/1579030370307_fix_assign_ro_function/up.yaml @@ -0,0 +1,9 @@ +- args: + cascade: true + sql: "CREATE OR REPLACE FUNCTION public.assign_ro_number()\r\n RETURNS trigger\r\n + LANGUAGE plpgsql\r\nAS $function$\r\n begin\r\n IF NEW.converted + = true and new.ro_number is null THEN\r\n UPDATE counters\r\n\tSET + count = count + 1 where shopid=new.shopid AND countertype=\"ronum\"\r\n\tRETURNING + CONCAT(prefix,count) into new.ro_number;\r\n\r\n END IF;\r\n RETURN + NEW;\r\n END;\r\n $function$\r\n;\r\n" + type: run_sql diff --git a/hasura/migrations/1579031584079_fix_ro_assign_function2/down.yaml b/hasura/migrations/1579031584079_fix_ro_assign_function2/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1579031584079_fix_ro_assign_function2/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1579031584079_fix_ro_assign_function2/up.yaml b/hasura/migrations/1579031584079_fix_ro_assign_function2/up.yaml new file mode 100644 index 000000000..7d2cc120c --- /dev/null +++ b/hasura/migrations/1579031584079_fix_ro_assign_function2/up.yaml @@ -0,0 +1,9 @@ +- args: + cascade: true + sql: "CREATE OR REPLACE FUNCTION public.assign_ro_number()\r\n RETURNS trigger\r\n + LANGUAGE plpgsql\r\nAS $function$\r\n begin\r\n IF NEW.converted + = true and (new.ro_number is null or new.ro_number = '') THEN\r\n UPDATE + counters\r\n\tSET count = count + 1 where shopid=new.shopid AND countertype + = 'ronum'\r\n\tRETURNING count into new.ro_number;\r\n\r\n END IF;\r\n + \ RETURN NEW;\r\n END;\r\n $function$\r\n;\r\n" + type: run_sql diff --git a/hasura/migrations/1579031647010_fix_ro_assign_function3/down.yaml b/hasura/migrations/1579031647010_fix_ro_assign_function3/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1579031647010_fix_ro_assign_function3/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1579031647010_fix_ro_assign_function3/up.yaml b/hasura/migrations/1579031647010_fix_ro_assign_function3/up.yaml new file mode 100644 index 000000000..c6e32d164 --- /dev/null +++ b/hasura/migrations/1579031647010_fix_ro_assign_function3/up.yaml @@ -0,0 +1,9 @@ +- args: + cascade: true + sql: "CREATE OR REPLACE FUNCTION public.assign_ro_number()\r\n RETURNS trigger\r\n + LANGUAGE plpgsql\r\nAS $function$\r\n begin\r\n IF NEW.converted + = true and (new.ro_number is null or new.ro_number = '') THEN\r\n UPDATE + counters\r\n\tSET count = count + 1 where shopid=new.shopid AND countertype + = 'ronum'\r\n\tRETURNING concat(prefix,count) into new.ro_number;\r\n\r\n END + IF;\r\n RETURN NEW;\r\n END;\r\n $function$\r\n;\r\n" + type: run_sql