Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
feat: default the Country dropdown to the user's country
Rob Carrington295014e19fd8
diff --git a/apps/carbon/app/components/Form/Country.tsx b/apps/carbon/app/components/Form/Country.tsxindex 053a78d011..8600a62450 100644--- a/apps/carbon/app/components/Form/Country.tsx+++ b/apps/carbon/app/components/Form/Country.tsx@@ -1,17 +1,16 @@+import type { ComboboxProps } from "@carbon/form";import { useMount } from "@carbon/react";import { useFetcher } from "@remix-run/react";-import { Select } from "~/components/Form";+import { Combobox } from "~/components/Form";import type { getCountries } from "~/modules/shared";import { path } from "~/utils/path";-const Country = () => {+type CountrySelectProps = Omit<ComboboxProps, "options">;++const Country = (props: CountrySelectProps) => {const options = useCountry();- return (- <>- <Select name="countryCode" options={options} label="Country" />- </>- );+ return <Combobox options={options} label="Country" {...props} />;};Country.displayName = "Country";diff --git a/apps/carbon/app/components/Form/Location.tsx b/apps/carbon/app/components/Form/Location.tsxindex 57ee45f854..e6f4538cab 100644--- a/apps/carbon/app/components/Form/Location.tsx+++ b/apps/carbon/app/components/Form/Location.tsx@@ -4,6 +4,7 @@ import { useDisclosure, useMount } from "@carbon/react";import { getLocalTimeZone } from "@internationalized/date";import { useFetcher } from "@remix-run/react";import { useMemo, useRef, useState } from "react";+import { useUser } from "~/hooks";import type { getLocationsList } from "~/modules/resources";import { LocationForm } from "~/modules/resources";import { path } from "~/utils/path";@@ -17,6 +18,8 @@ const Location = (props: LocationSelectProps) => {const options = useLocations();+ const { company } = useUser();+return (<><CreatableCombobox@@ -45,7 +48,7 @@ const Location = (props: LocationSelectProps) => {city: "",stateProvince: "",postalCode: "",- countryCode: "",+ countryCode: company?.countryCode ?? "",}}/>)}diff --git a/apps/carbon/app/hooks/useUser.tsx b/apps/carbon/app/hooks/useUser.tsxindex 93a42f0b40..f952153942 100644--- a/apps/carbon/app/hooks/useUser.tsx+++ b/apps/carbon/app/hooks/useUser.tsx@@ -14,6 +14,7 @@ type Company = {id: string;name: string;logo: string | null;+ countryCode: string | null;};type Groups = string[];@@ -62,7 +63,8 @@ function isCompany(value: any): value is Company {return (typeof value.id === "string" &&typeof value.name === "string" &&- (typeof value.logo === "string" || value.logo === null)+ (typeof value.logo === "string" || value.logo === null) &&+ (typeof value.countryCode === "string" || value.countryCode === null));}diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm.tsxindex d7c3f6f60c..490efede61 100644--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm.tsx+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm.tsx@@ -96,7 +96,7 @@ const SupplierLocationForm = ({<Input name="city" label="City" /><Input name="stateProvince" label="State / Province" /><Input name="postalCode" label="Postal Code" />- <Country />+ <Country name="countryCode" /><CustomFormFields table="supplierLocation" /></VStack></ModalDrawerBody>diff --git a/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx b/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsxindex a98c443dc1..91c9720185 100644--- a/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx+++ b/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx@@ -96,7 +96,7 @@ const LocationForm = ({<Input name="city" label="City" /><Input name="stateProvince" label="State / Province" /><Input name="postalCode" label="Postal Code" />- <Country />+ <Country name="countryCode" /><Timezone name="timezone" label="Timezone" />{/* <Number name="latitude" label="Latitude" minValue={-90} maxValue={90} /><Number name="longitude" label="Longitude" minVale={-180} maxValue={180} /> */}diff --git a/apps/carbon/app/modules/resources/ui/Locations/LocationsTable.tsx b/apps/carbon/app/modules/resources/ui/Locations/LocationsTable.tsxindex c437216410..0c0727a753 100644--- a/apps/carbon/app/modules/resources/ui/Locations/LocationsTable.tsx+++ b/apps/carbon/app/modules/resources/ui/Locations/LocationsTable.tsx@@ -60,11 +60,11 @@ const LocationsTable = memo(({ data, count }: LocationsTableProps) => {header: "Country",cell: (item) => item.getValue(),},- {- accessorKey: "timezone",- header: "Timezone",- cell: (item) => item.getValue(),- },+ // {+ // accessorKey: "timezone",+ // header: "Timezone",+ // cell: (item) => item.getValue(),+ // },{id: "createdBy",header: "Created By",diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm.tsxindex 5fe540e6ab..37e22c4f49 100644--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm.tsx+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm.tsx@@ -85,7 +85,7 @@ const CustomerLocationForm = ({<Input name="city" label="City" /><Input name="stateProvince" label="State / Province" /><Input name="postalCode" label="Postal Code" />- <Country />+ <Country name="countryCode" /><CustomFormFields table="customerLocation" /></VStack></ModalDrawerBody>diff --git a/apps/carbon/app/routes/onboarding+/company.tsx b/apps/carbon/app/routes/onboarding+/company.tsxindex 6915e7fbab..0294743c77 100644--- a/apps/carbon/app/routes/onboarding+/company.tsx+++ b/apps/carbon/app/routes/onboarding+/company.tsx@@ -187,7 +187,7 @@ export default function OnboardingCompany() {<Input name="city" label="City" /><Input name="stateProvince" label="State / Province" /><Input name="postalCode" label="Postal Code" />- <Country />+ <Country name="countryCode" /></VStack></CardContent>diff --git a/apps/carbon/app/routes/x+/customer+/$customerId.locations.new.tsx b/apps/carbon/app/routes/x+/customer+/$customerId.locations.new.tsxindex 051f92ce75..7584a805d0 100644--- a/apps/carbon/app/routes/x+/customer+/$customerId.locations.new.tsx+++ b/apps/carbon/app/routes/x+/customer+/$customerId.locations.new.tsx@@ -5,6 +5,7 @@ import { validationError, validator } from "@carbon/form";import { useNavigate, useParams } from "@remix-run/react";import type { ActionFunctionArgs } from "@vercel/remix";import { json, redirect } from "@vercel/remix";+import { useUser } from "~/hooks";import {CustomerLocationForm,customerLocationValidator,@@ -67,12 +68,13 @@ export async function action({ request, params }: ActionFunctionArgs) {export default function CustomerLocationsNewRoute() {const navigate = useNavigate();-+ const { company } = useUser();const { customerId } = useParams();if (!customerId) throw new Error("customerId not found");const initialValues = {name: "",+ countryCode: company?.countryCode ?? "",};return (diff --git a/apps/carbon/app/routes/x+/resources+/locations.$locationId.tsx b/apps/carbon/app/routes/x+/resources+/locations.$locationId.tsxindex 5774ef75cc..32bae8cfe5 100644--- a/apps/carbon/app/routes/x+/resources+/locations.$locationId.tsx+++ b/apps/carbon/app/routes/x+/resources+/locations.$locationId.tsx@@ -89,7 +89,7 @@ export default function LocationRoute() {city: location.city ?? undefined,stateProvince: location.stateProvince ?? undefined,postalCode: location.postalCode ?? undefined,- countryCode: location.countryCode ?? undefined,+ countryCode: location.countryCode ?? "",timezone: location.timezone ?? getLocalTimeZone(),latitude: location.latitude ?? undefined,longitude: location.longitude ?? undefined,diff --git a/apps/carbon/app/routes/x+/resources+/locations.new.tsx b/apps/carbon/app/routes/x+/resources+/locations.new.tsxindex 9ad66d1cac..c8f8d7623b 100644--- a/apps/carbon/app/routes/x+/resources+/locations.new.tsx+++ b/apps/carbon/app/routes/x+/resources+/locations.new.tsx@@ -6,6 +6,7 @@ import { getLocalTimeZone } from "@internationalized/date";import { useNavigate } from "@remix-run/react";import type { ActionFunctionArgs } from "@vercel/remix";import { json, redirect } from "@vercel/remix";+import { useUser } from "~/hooks";import {LocationForm,locationValidator,@@ -60,6 +61,7 @@ export async function action({ request }: ActionFunctionArgs) {export default function NewLocationRoute() {const navigate = useNavigate();+ const { company } = useUser();const onClose = () => navigate(path.to.locations);const initialValues = {@@ -70,6 +72,7 @@ export default function NewLocationRoute() {city: "",stateProvince: "",postalCode: "",+ countryCode: company?.countryCode ?? "",};return <LocationForm initialValues={initialValues} onClose={onClose} />;diff --git a/apps/carbon/app/routes/x+/supplier+/$supplierId.locations.new.tsx b/apps/carbon/app/routes/x+/supplier+/$supplierId.locations.new.tsxindex de6a78ffda..23f9ca39f4 100644--- a/apps/carbon/app/routes/x+/supplier+/$supplierId.locations.new.tsx+++ b/apps/carbon/app/routes/x+/supplier+/$supplierId.locations.new.tsx@@ -5,6 +5,7 @@ import { validationError, validator } from "@carbon/form";import { useNavigate, useParams } from "@remix-run/react";import type { ActionFunctionArgs } from "@vercel/remix";import { json, redirect } from "@vercel/remix";+import { useUser } from "~/hooks";import {SupplierLocationForm,insertSupplierLocation,@@ -67,12 +68,13 @@ export async function action({ request, params }: ActionFunctionArgs) {export default function SupplierLocationsNewRoute() {const navigate = useNavigate();-+ const { company } = useUser();const { supplierId } = useParams();if (!supplierId) throw new Error("supplierId not found");const initialValues = {name: "",+ countryCode: company?.countryCode ?? "",};return (diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.tsindex 02d0318649..f1ea2a1ec1 100644--- a/packages/database/src/swagger-docs-schema.ts+++ b/packages/database/src/swagger-docs-schema.ts@@ -8212,7 +8212,7 @@ export default {$ref: "#/parameters/rowFilter.companies.city",},{- $ref: "#/parameters/rowFilter.companies.state",+ $ref: "#/parameters/rowFilter.companies.stateProvince",},{$ref: "#/parameters/rowFilter.companies.postalCode",@@ -12906,6 +12906,9 @@ export default {{$ref: "#/parameters/rowFilter.purchaseOrderLocations.supplierCountryCode",},+ {+ $ref: "#/parameters/rowFilter.purchaseOrderLocations.supplierCountryName",+ },{$ref: "#/parameters/rowFilter.purchaseOrderLocations.deliveryName",},@@ -12927,6 +12930,9 @@ export default {{$ref: "#/parameters/rowFilter.purchaseOrderLocations.deliveryCountryCode",},+ {+ $ref: "#/parameters/rowFilter.purchaseOrderLocations.deliveryCountryName",+ },{$ref: "#/parameters/rowFilter.purchaseOrderLocations.dropShipment",},@@ -12951,6 +12957,9 @@ export default {{$ref: "#/parameters/rowFilter.purchaseOrderLocations.customerCountryCode",},+ {+ $ref: "#/parameters/rowFilter.purchaseOrderLocations.customerCountryName",+ },{$ref: "#/parameters/select",},@@ -19461,6 +19470,9 @@ export default {{$ref: "#/parameters/rowFilter.quoteCustomerDetails.customerCountryCode",},+ {+ $ref: "#/parameters/rowFilter.quoteCustomerDetails.customerCountryName",+ },{$ref: "#/parameters/select",},@@ -28710,6 +28722,9 @@ export default {{$ref: "#/parameters/rowFilter.salesOrderLocations.customerCountryCode",},+ {+ $ref: "#/parameters/rowFilter.salesOrderLocations.customerCountryName",+ },{$ref: "#/parameters/rowFilter.salesOrderLocations.paymentCustomerName",},@@ -28731,6 +28746,9 @@ export default {{$ref: "#/parameters/rowFilter.salesOrderLocations.paymentCountryCode",},+ {+ $ref: "#/parameters/rowFilter.salesOrderLocations.paymentCountryName",+ },{$ref: "#/parameters/select",},@@ -39345,7 +39363,7 @@ export default {format: "text",type: "string",},- state: {+ stateProvince: {format: "text",type: "string",},@@ -41550,6 +41568,10 @@ export default {format: "text",type: "string",},+ supplierCountryName: {+ format: "text",+ type: "string",+ },deliveryName: {format: "text",type: "string",@@ -41578,6 +41600,10 @@ export default {format: "text",type: "string",},+ deliveryCountryName: {+ format: "text",+ type: "string",+ },dropShipment: {format: "boolean",type: "boolean",@@ -41612,6 +41638,10 @@ export default {format: "text",type: "string",},+ customerCountryName: {+ format: "text",+ type: "string",+ },},type: "object",},@@ -44569,6 +44599,10 @@ export default {format: "text",type: "string",},+ customerCountryName: {+ format: "text",+ type: "string",+ },},type: "object",},@@ -46548,7 +46582,7 @@ export default {properties: {id: {description:- "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",+ "Note:\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",format: "text",type: "string",},@@ -46597,7 +46631,7 @@ export default {},supplierLocationId: {description:- "Note:\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",format: "text",type: "string",},@@ -48511,6 +48545,10 @@ export default {format: "text",type: "string",},+ customerCountryName: {+ format: "text",+ type: "string",+ },paymentCustomerName: {format: "text",type: "string",@@ -48541,6 +48579,10 @@ export default {format: "text",type: "string",},+ paymentCountryName: {+ format: "text",+ type: "string",+ },},type: "object",},@@ -55738,8 +55780,8 @@ export default {in: "query",type: "string",},- "rowFilter.companies.state": {- name: "state",+ "rowFilter.companies.stateProvince": {+ name: "stateProvince",required: false,format: "text",in: "query",@@ -58648,6 +58690,13 @@ export default {in: "query",type: "string",},+ "rowFilter.purchaseOrderLocations.supplierCountryName": {+ name: "supplierCountryName",+ required: false,+ format: "text",+ in: "query",+ type: "string",+ },"rowFilter.purchaseOrderLocations.deliveryName": {name: "deliveryName",required: false,@@ -58697,6 +58746,13 @@ export default {in: "query",type: "string",},+ "rowFilter.purchaseOrderLocations.deliveryCountryName": {+ name: "deliveryCountryName",+ required: false,+ format: "text",+ in: "query",+ type: "string",+ },"rowFilter.purchaseOrderLocations.dropShipment": {name: "dropShipment",required: false,@@ -58753,6 +58809,13 @@ export default {in: "query",type: "string",},+ "rowFilter.purchaseOrderLocations.customerCountryName": {+ name: "customerCountryName",+ required: false,+ format: "text",+ in: "query",+ type: "string",+ },"body.quoteLines": {name: "quoteLines",description: "quoteLines",@@ -62600,6 +62663,13 @@ export default {in: "query",type: "string",},+ "rowFilter.quoteCustomerDetails.customerCountryName": {+ name: "customerCountryName",+ required: false,+ format: "text",+ in: "query",+ type: "string",+ },"body.pickMethod": {name: "pickMethod",description: "pickMethod",@@ -67740,6 +67810,13 @@ export default {in: "query",type: "string",},+ "rowFilter.salesOrderLocations.customerCountryName": {+ name: "customerCountryName",+ required: false,+ format: "text",+ in: "query",+ type: "string",+ },"rowFilter.salesOrderLocations.paymentCustomerName": {name: "paymentCustomerName",required: false,@@ -67789,6 +67866,13 @@ export default {in: "query",type: "string",},+ "rowFilter.salesOrderLocations.paymentCountryName": {+ name: "paymentCountryName",+ required: false,+ format: "text",+ in: "query",+ type: "string",+ },"body.oauthCode": {name: "oauthCode",description: "oauthCode",diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex 4b77ab1486..10a71f50a4 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -22149,7 +22149,7 @@ export type Database = {phone: string | nullpostalCode: string | nullrole: Database["public"]["Enums"]["role"] | null- state: string | null+ stateProvince: string | nulltaxId: string | nullupdatedBy: string | nulluserId: string | null@@ -25248,6 +25248,7 @@ export type Database = {customerAddressLine2: string | nullcustomerCity: string | nullcustomerCountryCode: string | null+ customerCountryName: string | nullcustomerName: string | nullcustomerPostalCode: string | nullcustomerStateProvince: string | null@@ -25255,6 +25256,7 @@ export type Database = {deliveryAddressLine2: string | nulldeliveryCity: string | nulldeliveryCountryCode: string | null+ deliveryCountryName: string | nulldeliveryName: string | nulldeliveryPostalCode: string | nulldeliveryStateProvince: string | null@@ -25264,6 +25266,7 @@ export type Database = {supplierAddressLine2: string | nullsupplierCity: string | nullsupplierCountryCode: string | null+ supplierCountryName: string | nullsupplierName: string | nullsupplierPostalCode: string | nullsupplierStateProvince: string | null@@ -25580,6 +25583,7 @@ export type Database = {customerAddressLine2: string | nullcustomerCity: string | nullcustomerCountryCode: string | null+ customerCountryName: string | nullcustomerName: string | nullcustomerPostalCode: string | nullcustomerStateProvince: string | null@@ -26990,6 +26994,7 @@ export type Database = {customerAddressLine2: string | nullcustomerCity: string | nullcustomerCountryCode: string | null+ customerCountryName: string | nullcustomerName: string | nullcustomerPostalCode: string | nullcustomerStateProvince: string | null@@ -26998,6 +27003,7 @@ export type Database = {paymentAddressLine2: string | nullpaymentCity: string | nullpaymentCountryCode: string | null+ paymentCountryName: string | nullpaymentCustomerName: string | nullpaymentPostalCode: string | nullpaymentStateProvince: string | null@@ -27005,14 +27011,14 @@ export type Database = {Relationships: [{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["paymentCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]},{foreignKeyName: "address_countryCode_fkey"- columns: ["paymentCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.tsindex 4b77ab1486..10a71f50a4 100644--- a/packages/database/supabase/functions/lib/types.ts+++ b/packages/database/supabase/functions/lib/types.ts@@ -22149,7 +22149,7 @@ export type Database = {phone: string | nullpostalCode: string | nullrole: Database["public"]["Enums"]["role"] | null- state: string | null+ stateProvince: string | nulltaxId: string | nullupdatedBy: string | nulluserId: string | null@@ -25248,6 +25248,7 @@ export type Database = {customerAddressLine2: string | nullcustomerCity: string | nullcustomerCountryCode: string | null+ customerCountryName: string | nullcustomerName: string | nullcustomerPostalCode: string | nullcustomerStateProvince: string | null@@ -25255,6 +25256,7 @@ export type Database = {deliveryAddressLine2: string | nulldeliveryCity: string | nulldeliveryCountryCode: string | null+ deliveryCountryName: string | nulldeliveryName: string | nulldeliveryPostalCode: string | nulldeliveryStateProvince: string | null@@ -25264,6 +25266,7 @@ export type Database = {supplierAddressLine2: string | nullsupplierCity: string | nullsupplierCountryCode: string | null+ supplierCountryName: string | nullsupplierName: string | nullsupplierPostalCode: string | nullsupplierStateProvince: string | null@@ -25580,6 +25583,7 @@ export type Database = {customerAddressLine2: string | nullcustomerCity: string | nullcustomerCountryCode: string | null+ customerCountryName: string | nullcustomerName: string | nullcustomerPostalCode: string | nullcustomerStateProvince: string | null@@ -26990,6 +26994,7 @@ export type Database = {customerAddressLine2: string | nullcustomerCity: string | nullcustomerCountryCode: string | null+ customerCountryName: string | nullcustomerName: string | nullcustomerPostalCode: string | nullcustomerStateProvince: string | null@@ -26998,6 +27003,7 @@ export type Database = {paymentAddressLine2: string | nullpaymentCity: string | nullpaymentCountryCode: string | null+ paymentCountryName: string | nullpaymentCustomerName: string | nullpaymentPostalCode: string | nullpaymentStateProvince: string | null@@ -27005,14 +27011,14 @@ export type Database = {Relationships: [{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["paymentCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]},{foreignKeyName: "address_countryCode_fkey"- columns: ["paymentCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]diff --git a/packages/database/supabase/migrations/20240928155702_country-codes.sql b/packages/database/supabase/migrations/20240928155702_country-codes.sqlindex 2e9a526421..5697a78a1d 100644--- a/packages/database/supabase/migrations/20240928155702_country-codes.sql+++ b/packages/database/supabase/migrations/20240928155702_country-codes.sql@@ -4,7 +4,7 @@DROP VIEW IF EXISTS "purchaseOrderLocations";DROP VIEW IF EXISTS "quoteCustomerDetails";DROP VIEW IF EXISTS "salesOrderLocations";-+DROP VIEW IF EXISTS "companies";-- Remove the 'code' columnALTER TABLE "country" DROP COLUMN IF EXISTS "code";@@ -41,6 +41,7 @@ CREATE OR REPLACE VIEW "purchaseOrderLocations" WITH(SECURITY_INVOKER=true) ASsa."stateProvince" AS "supplierStateProvince",sa."postalCode" AS "supplierPostalCode",sa."countryCode" AS "supplierCountryCode",+ sc."name" AS "supplierCountryName",dl.name AS "deliveryName",dl."addressLine1" AS "deliveryAddressLine1",dl."addressLine2" AS "deliveryAddressLine2",@@ -48,6 +49,7 @@ CREATE OR REPLACE VIEW "purchaseOrderLocations" WITH(SECURITY_INVOKER=true) ASdl."stateProvince" AS "deliveryStateProvince",dl."postalCode" AS "deliveryPostalCode",dl."countryCode" AS "deliveryCountryCode",+ dc."name" AS "deliveryCountryName",pod."dropShipment",c.name AS "customerName",ca."addressLine1" AS "customerAddressLine1",@@ -55,7 +57,8 @@ CREATE OR REPLACE VIEW "purchaseOrderLocations" WITH(SECURITY_INVOKER=true) ASca."city" AS "customerCity",ca."stateProvince" AS "customerStateProvince",ca."postalCode" AS "customerPostalCode",- ca."countryCode" AS "customerCountryCode"+ ca."countryCode" AS "customerCountryCode",+ cc."name" AS "customerCountryName"FROM "purchaseOrder" poLEFT OUTER JOIN "supplier" sON s.id = po."supplierId"@@ -63,16 +66,22 @@ CREATE OR REPLACE VIEW "purchaseOrderLocations" WITH(SECURITY_INVOKER=true) ASON sl.id = po."supplierLocationId"LEFT OUTER JOIN "address" saON sa.id = sl."addressId"+ LEFT OUTER JOIN "country" sc+ ON sc.alpha2 = sa."countryCode"INNER JOIN "purchaseOrderDelivery" podON pod.id = po.idLEFT OUTER JOIN "location" dlON dl.id = pod."locationId"+ LEFT OUTER JOIN "country" dc+ ON dc.alpha2 = dl."countryCode"LEFT OUTER JOIN "customer" cON c.id = pod."customerId"LEFT OUTER JOIN "customerLocation" clON cl.id = pod."customerLocationId"LEFT OUTER JOIN "address" ca- ON ca.id = cl."addressId";+ ON ca.id = cl."addressId"+ LEFT OUTER JOIN "country" cc+ ON cc.alpha2 = ca."countryCode";-- Recreate the quoteCustomerDetails viewCREATE OR REPLACE VIEW "quoteCustomerDetails" WITH(SECURITY_INVOKER=true) AS@@ -84,12 +93,14 @@ SELECTca."city" AS "customerCity",ca."stateProvince" AS "customerStateProvince",ca."postalCode" AS "customerPostalCode",- ca."countryCode" AS "customerCountryCode"+ ca."countryCode" AS "customerCountryCode",+ cc."name" AS "customerCountryName"FROM"quote" qLEFT OUTER JOIN "customer" c ON c.id = q."customerId"LEFT OUTER JOIN "customerLocation" cl on cl.id = q."customerLocationId"- LEFT OUTER JOIN "address" ca ON ca.id = cl."addressId";+ LEFT OUTER JOIN "address" ca ON ca.id = cl."addressId"+ LEFT OUTER JOIN "country" cc ON cc.alpha2 = ca."countryCode";-- Recreate the salesOrderLocations viewCREATE OR REPLACE VIEW "salesOrderLocations" WITH(SECURITY_INVOKER=true) AS@@ -102,13 +113,15 @@ FROMca."stateProvince" AS "customerStateProvince",ca."postalCode" AS "customerPostalCode",ca."countryCode" AS "customerCountryCode",+ cc."name" AS "customerCountryName",pc.name AS "paymentCustomerName",pa."addressLine1" AS "paymentAddressLine1",pa."addressLine2" AS "paymentAddressLine2",pa."city" AS "paymentCity",pa."stateProvince" AS "paymentStateProvince",pa."postalCode" AS "paymentPostalCode",- pa."countryCode" AS "paymentCountryCode"+ pa."countryCode" AS "paymentCountryCode",+ pn."name" AS "paymentCountryName"FROM "salesOrder" soINNER JOIN "customer" cON c.id = so."customerId"@@ -116,6 +129,8 @@ FROMON cl.id = so."customerLocationId"LEFT OUTER JOIN "address" caON ca.id = cl."addressId"+ LEFT OUTER JOIN "country" cc+ ON cc.alpha2 = ca."countryCode"LEFT OUTER JOIN "salesOrderPayment" sopON sop.id = so.idLEFT OUTER JOIN "customer" pc@@ -123,7 +138,22 @@ FROMLEFT OUTER JOIN "customerLocation" plON pl.id = sop."invoiceCustomerLocationId"LEFT OUTER JOIN "address" pa- ON pa.id = pl."addressId";+ ON pa.id = pl."addressId"+ LEFT OUTER JOIN "country" pn+ ON pn.alpha2 = pa."countryCode";++CREATE OR REPLACE VIEW "companies" WITH(SECURITY_INVOKER=true) AS+ SELECT DISTINCT+ c.*,+ uc.*,+ et.name AS "employeeType"+ FROM "userToCompany" uc+ INNER JOIN "company" c+ ON c.id = uc."companyId"+ LEFT JOIN "employee" e+ ON e.id = uc."userId" AND e."companyId" = uc."companyId"+ LEFT JOIN "employeeType" et+ ON et.id = e."employeeTypeId";-- Insert the country code dataINSERT INTO "country" ("name", "alpha2", "alpha3") VALUESdiff --git a/packages/documents/src/email/PurchaseOrderEmail.tsx b/packages/documents/src/email/PurchaseOrderEmail.tsxindex f55d2085c4..1d62700e8f 100644--- a/packages/documents/src/email/PurchaseOrderEmail.tsx+++ b/packages/documents/src/email/PurchaseOrderEmail.tsx@@ -43,7 +43,7 @@ const PurchaseOrderEmail = ({deliveryCity,deliveryStateProvince,deliveryPostalCode,- deliveryCountryCode,+ deliveryCountryName,dropShipment,customerName,customerAddressLine1,@@ -51,7 +51,7 @@ const PurchaseOrderEmail = ({customerCity,customerStateProvince,customerPostalCode,- customerCountryCode,+ customerCountryName,} = purchaseOrderLocations;const reSubject = `Re: ${purchaseOrder.purchaseOrderId} from ${company.name}`;@@ -153,7 +153,7 @@ const PurchaseOrderEmail = ({customerPostalCode)}</Text>- <Text>{customerCountryCode}</Text>+ <Text>{customerCountryName}</Text></>) : (<>@@ -172,7 +172,7 @@ const PurchaseOrderEmail = ({deliveryPostalCode)}</Text>- <Text>{deliveryCountryCode}</Text>+ <Text>{deliveryCountryName}</Text></>)}</Column>diff --git a/packages/documents/src/email/SalesOrderEmail.tsx b/packages/documents/src/email/SalesOrderEmail.tsxindex 4083d2e442..d75f57c19f 100644--- a/packages/documents/src/email/SalesOrderEmail.tsx+++ b/packages/documents/src/email/SalesOrderEmail.tsx@@ -49,14 +49,14 @@ const SalesOrderEmail = ({customerCity,customerStateProvince,customerPostalCode,- customerCountryCode,+ customerCountryName,// paymentCustomerName,// paymentAddressLine1,// paymentAddressLine2,// paymentCity,// paymentStateProvince,// paymentPostalCode,- // paymentCountryCode,+ // paymentCountryName,} = salesOrderLocations;const reSubject = `Re: ${salesOrder.salesOrderId} from ${company.name}`;@@ -152,7 +152,7 @@ const SalesOrderEmail = ({customerPostalCode)}</Text>- <Text>{customerCountryCode}</Text>+ <Text>{customerCountryName}</Text></Column></Row></Section>diff --git a/packages/documents/src/pdf/PurchaseOrderPDF.tsx b/packages/documents/src/pdf/PurchaseOrderPDF.tsxindex 185fbb76b4..578d40f0ef 100644--- a/packages/documents/src/pdf/PurchaseOrderPDF.tsx+++ b/packages/documents/src/pdf/PurchaseOrderPDF.tsx@@ -58,14 +58,14 @@ const PurchaseOrderPDF = ({supplierCity,supplierStateProvince,supplierPostalCode,- supplierCountryCode,+ supplierCountryName,deliveryName,deliveryAddressLine1,deliveryAddressLine2,deliveryCity,deliveryStateProvince,deliveryPostalCode,- deliveryCountryCode,+ deliveryCountryName,dropShipment,customerName,customerAddressLine1,@@ -73,7 +73,7 @@ const PurchaseOrderPDF = ({customerCity,customerStateProvince,customerPostalCode,- customerCountryCode,+ customerCountryName,} = purchaseOrderLocations;return (@@ -113,7 +113,7 @@ const PurchaseOrderPDF = ({supplierPostalCode)}</Text>- <Text>{supplierCountryCode}</Text>+ <Text>{supplierCountryName}</Text></View>{dropShipment ? (<View style={tw("flex flex-col text-sm gap-1 w-1/3")}>@@ -128,7 +128,7 @@ const PurchaseOrderPDF = ({customerPostalCode)}</Text>- <Text>{customerCountryCode}</Text>+ <Text>{customerCountryName}</Text></View>) : (<View style={tw("flex flex-col text-sm gap-1 w-1/3")}>@@ -143,7 +143,7 @@ const PurchaseOrderPDF = ({deliveryPostalCode)}</Text>- <Text>{deliveryCountryCode}</Text>+ <Text>{deliveryCountryName}</Text></View>)}</View>diff --git a/packages/documents/src/pdf/QuotePDF.tsx b/packages/documents/src/pdf/QuotePDF.tsxindex ec4eb56602..3714569832 100644--- a/packages/documents/src/pdf/QuotePDF.tsx+++ b/packages/documents/src/pdf/QuotePDF.tsx@@ -65,7 +65,7 @@ const QuotePDF = ({customerCity,customerStateProvince,customerPostalCode,- customerCountryCode,+ customerCountryName,} = quoteCustomerDetails;const pricesByLine = quoteLinePrices.reduce<@@ -152,7 +152,7 @@ const QuotePDF = ({customerPostalCode)}</Text>- <Text>{customerCountryCode}</Text>+ <Text>{customerCountryName}</Text></View></View>diff --git a/packages/documents/src/pdf/SalesOrderPDF.tsx b/packages/documents/src/pdf/SalesOrderPDF.tsxindex d7d1c24b87..024f6e8f78 100644--- a/packages/documents/src/pdf/SalesOrderPDF.tsx+++ b/packages/documents/src/pdf/SalesOrderPDF.tsx@@ -58,14 +58,14 @@ const SalesOrderPDF = ({customerCity,customerStateProvince,customerPostalCode,- customerCountryCode,+ customerCountryName,paymentCustomerName,paymentAddressLine1,paymentAddressLine2,paymentCity,paymentStateProvince,paymentPostalCode,- paymentCountryCode,+ paymentCountryName,} = salesOrderLocations;return (@@ -109,7 +109,7 @@ const SalesOrderPDF = ({customerPostalCode)}</Text>- <Text style={tw("text-sm")}>{customerCountryCode}</Text>+ <Text style={tw("text-sm")}>{customerCountryName}</Text></View><View style={tw("flex flex-col gap-1 w-1/3")}><Text style={tw("text-gray-500 text-xs")}>Bill To</Text>@@ -127,7 +127,7 @@ const SalesOrderPDF = ({paymentPostalCode)}</Text>- <Text style={tw("text-sm")}>{paymentCountryCode}</Text>+ <Text style={tw("text-sm")}>{paymentCountryName}</Text></View></View><View style={tw("flex flex-row justify-between mb-5")}>