Skip to content

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.

feat: rename state to stateProvince

Rob Carringtonb0dc9728de0d
diff --git a/apps/carbon/app/components/Form/Location.tsx b/apps/carbon/app/components/Form/Location.tsx
index a1887ce7dd..57ee45f854 100644
--- a/apps/carbon/app/components/Form/Location.tsx
+++ b/apps/carbon/app/components/Form/Location.tsx
@@ -43,7 +43,7 @@ const Location = (props: LocationSelectProps) => {
addressLine1: "",
addressLine2: "",
city: "",
- state: "",
+ stateProvince: "",
postalCode: "",
countryCode: "",
}}
diff --git a/apps/carbon/app/components/Layout/Topbar/Breadcrumbs.tsx b/apps/carbon/app/components/Layout/Topbar/Breadcrumbs.tsx
index ef19f2f5f4..6bdd5eafb1 100644
--- a/apps/carbon/app/components/Layout/Topbar/Breadcrumbs.tsx
+++ b/apps/carbon/app/components/Layout/Topbar/Breadcrumbs.tsx
@@ -193,7 +193,7 @@ function CompanyBreadcrumb() {
<Input autoFocus name="name" label="Company Name" />
<Input name="addressLine1" label="Address" />
<Input name="city" label="City" />
- <Input name="state" label="State" />
+ <Input name="stateProvince" label="State / Province" />
<Input name="postalCode" label="Postal Code" />
</VStack>
</ModalBody>
diff --git a/apps/carbon/app/components/Location.tsx b/apps/carbon/app/components/Location.tsx
index 7d8bbe86a6..e523115591 100644
--- a/apps/carbon/app/components/Location.tsx
+++ b/apps/carbon/app/components/Location.tsx
@@ -15,7 +15,7 @@ type LocationProps = {
addressLine1: string | null;
addressLine2: string | null;
city: string | null;
- state: string | null;
+ stateProvince: string | null;
postalCode: string | null;
country: {
alpha2: string;
@@ -38,7 +38,7 @@ const Location = ({ location, actions }: LocationProps) => {
);
const cityStatePostalCode = formatCityStatePostalCode(
location.address.city,
- location.address.state,
+ location.address.stateProvince,
location.address.postalCode
);
return (
diff --git a/apps/carbon/app/modules/purchasing/purchasing.service.ts b/apps/carbon/app/modules/purchasing/purchasing.service.ts
index afa017304e..05da40806c 100644
--- a/apps/carbon/app/modules/purchasing/purchasing.service.ts
+++ b/apps/carbon/app/modules/purchasing/purchasing.service.ts
@@ -283,7 +283,7 @@ export async function getSupplierLocations(
return client
.from("supplierLocation")
.select(
- "*, address(id, addressLine1, addressLine2, city, state, country(alpha2, name), postalCode)"
+ "*, address(id, addressLine1, addressLine2, city, stateProvince, country(alpha2, name), postalCode)"
)
.eq("supplierId", supplierId);
}
@@ -295,7 +295,7 @@ export async function getSupplierLocation(
return client
.from("supplierLocation")
.select(
- "*, address(id, addressLine1, addressLine2, city, state, country(alpha2, name), postalCode)"
+ "*, address(id, addressLine1, addressLine2, city, stateProvince, country(alpha2, name), postalCode)"
)
.eq("id", supplierContactId)
.single();
@@ -540,9 +540,9 @@ export async function insertSupplierLocation(
addressLine1?: string;
addressLine2?: string;
city?: string;
- state?: string;
+ stateProvince?: string;
postalCode?: string;
- // countryId: string;
+ countryCode?: string;
};
customFields?: Json;
}
@@ -722,8 +722,8 @@ export async function updateSupplierLocation(
addressLine1?: string;
addressLine2?: string;
city?: string;
- state?: string;
- // countryId: string;
+ stateProvince?: string;
+ countryCode?: string;
postalCode?: string;
};
customFields?: Json;
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm.tsx
index ea86d68271..d7c3f6f60c 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm.tsx
@@ -94,7 +94,7 @@ const SupplierLocationForm = ({
<Input name="addressLine1" label="Address Line 1" />
<Input name="addressLine2" label="Address Line 2" />
<Input name="city" label="City" />
- <Input name="state" label="State" />
+ <Input name="stateProvince" label="State / Province" />
<Input name="postalCode" label="Postal Code" />
<Country />
<CustomFormFields table="supplierLocation" />
diff --git a/apps/carbon/app/modules/resources/resources.models.ts b/apps/carbon/app/modules/resources/resources.models.ts
index 8c953a7d67..832ada1f37 100644
--- a/apps/carbon/app/modules/resources/resources.models.ts
+++ b/apps/carbon/app/modules/resources/resources.models.ts
@@ -61,7 +61,9 @@ export const locationValidator = z
addressLine1: z.string().min(1, { message: "Address is required" }),
addressLine2: z.string().optional(),
city: z.string().min(1, { message: "City is required" }),
- state: z.string().min(1, { message: "State is required" }),
+ stateProvince: z
+ .string()
+ .min(1, { message: "State / Province is required" }),
postalCode: z.string().min(1, { message: "Postal Code is required" }),
countryCode: z.string().min(1, { message: "Country is required" }),
timezone: z.string().min(1, { message: "Timezone is required" }),
diff --git a/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx b/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx
index 6d9a310645..a98c443dc1 100644
--- a/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx
@@ -94,7 +94,7 @@ const LocationForm = ({
<Input name="addressLine1" label="Address Line 1" />
<Input name="addressLine2" label="Address Line 2" />
<Input name="city" label="City" />
- <Input name="state" label="State" />
+ <Input name="stateProvince" label="State / Province" />
<Input name="postalCode" label="Postal Code" />
<Country />
<Timezone name="timezone" label="Timezone" />
diff --git a/apps/carbon/app/modules/resources/ui/Locations/LocationsTable.tsx b/apps/carbon/app/modules/resources/ui/Locations/LocationsTable.tsx
index 9578d2fd60..c437216410 100644
--- a/apps/carbon/app/modules/resources/ui/Locations/LocationsTable.tsx
+++ b/apps/carbon/app/modules/resources/ui/Locations/LocationsTable.tsx
@@ -51,8 +51,8 @@ const LocationsTable = memo(({ data, count }: LocationsTableProps) => {
cell: (item) => item.getValue(),
},
{
- accessorKey: "state",
- header: "State",
+ accessorKey: "stateProvince",
+ header: "State / Province",
cell: (item) => item.getValue(),
},
{
diff --git a/apps/carbon/app/modules/sales/sales.service.ts b/apps/carbon/app/modules/sales/sales.service.ts
index 285ce04af4..155ee6fa31 100644
--- a/apps/carbon/app/modules/sales/sales.service.ts
+++ b/apps/carbon/app/modules/sales/sales.service.ts
@@ -224,7 +224,7 @@ export async function getCustomerLocation(
return client
.from("customerLocation")
.select(
- "*, address(id, addressLine1, addressLine2, city, state, country(alpha2, name), postalCode)"
+ "*, address(id, addressLine1, addressLine2, city, stateProvince, country(alpha2, name), postalCode)"
)
.eq("id", customerContactId)
.single();
@@ -237,7 +237,7 @@ export async function getCustomerLocations(
return client
.from("customerLocation")
.select(
- "*, address(id, addressLine1, addressLine2, city, state, country(alpha2, name), postalCode)"
+ "*, address(id, addressLine1, addressLine2, city, stateProvince, country(alpha2, name), postalCode)"
)
.eq("customerId", customerId);
}
@@ -981,8 +981,8 @@ export async function insertCustomerLocation(
addressLine1?: string;
addressLine2?: string;
city?: string;
- state?: string;
- // countryId: string;
+ stateProvince?: string;
+ countryCode?: string;
postalCode?: string;
};
customFields?: Json;
@@ -1198,8 +1198,8 @@ export async function updateCustomerLocation(
addressLine1?: string;
addressLine2?: string;
city?: string;
- state?: string;
- // countryId: string;
+ stateProvince?: string;
+ countryCode?: string;
postalCode?: string;
};
customFields?: Json;
diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm.tsx
index 03f83c6445..5fe540e6ab 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm.tsx
@@ -83,7 +83,7 @@ const CustomerLocationForm = ({
<Input name="addressLine1" label="Address Line 1" />
<Input name="addressLine2" label="Address Line 2" />
<Input name="city" label="City" />
- <Input name="state" label="State" />
+ <Input name="stateProvince" label="State / Province" />
<Input name="postalCode" label="Postal Code" />
<Country />
<CustomFormFields table="customerLocation" />
diff --git a/apps/carbon/app/modules/settings/settings.models.ts b/apps/carbon/app/modules/settings/settings.models.ts
index 7667cd0116..3e6f94f834 100644
--- a/apps/carbon/app/modules/settings/settings.models.ts
+++ b/apps/carbon/app/modules/settings/settings.models.ts
@@ -27,7 +27,7 @@ const company = {
addressLine1: z.string().min(1, { message: "Address is required" }),
addressLine2: zfd.text(z.string().optional()),
city: z.string().min(1, { message: "City is required" }),
- state: z.string().min(1, { message: "State is required" }),
+ stateProvince: z.string().min(1, { message: "State / Province is required" }),
postalCode: z.string().min(1, { message: "Postal Code is required" }),
countryCode: z.string().min(1, { message: "Country is required" }),
phone: zfd.text(z.string().optional()),
diff --git a/apps/carbon/app/modules/settings/ui/Company/CompanyForm.tsx b/apps/carbon/app/modules/settings/ui/Company/CompanyForm.tsx
index 2fd24abde4..c6f58310cf 100644
--- a/apps/carbon/app/modules/settings/ui/Company/CompanyForm.tsx
+++ b/apps/carbon/app/modules/settings/ui/Company/CompanyForm.tsx
@@ -27,7 +27,7 @@ const CompanyForm = ({ company }: CompanyFormProps) => {
<Input name="addressLine1" label="Address Line 1" />
<Input name="addressLine2" label="Address Line 2" />
<Input name="city" label="City" />
- <Input name="state" label="State" />
+ <Input name="stateProvince" label="State / Province" />
<Input name="postalCode" label="Postal Code" />
<Input name="countryCode" label="Country" />
<Input name="phone" label="Phone Number" />
diff --git a/apps/carbon/app/routes/onboarding+/company.tsx b/apps/carbon/app/routes/onboarding+/company.tsx
index 79872b231e..6915e7fbab 100644
--- a/apps/carbon/app/routes/onboarding+/company.tsx
+++ b/apps/carbon/app/routes/onboarding+/company.tsx
@@ -163,7 +163,7 @@ export default function OnboardingCompany() {
name: company?.name ?? "",
addressLine1: company?.addressLine1 ?? "",
city: company?.city ?? "",
- state: company?.state ?? "",
+ stateProvince: company?.stateProvince ?? "",
postalCode: company?.postalCode ?? "",
countryCode: company?.countryCode ?? "",
};
@@ -185,7 +185,7 @@ export default function OnboardingCompany() {
<Input autoFocus name="name" label="Company Name" />
<Input name="addressLine1" label="Address" />
<Input name="city" label="City" />
- <Input name="state" label="State" />
+ <Input name="stateProvince" label="State / Province" />
<Input name="postalCode" label="Postal Code" />
<Country />
</VStack>
diff --git a/apps/carbon/app/routes/x+/customer+/$customerId.locations.$customerLocationId.tsx b/apps/carbon/app/routes/x+/customer+/$customerId.locations.$customerLocationId.tsx
index 8aa7683f75..cdf630c40a 100644
--- a/apps/carbon/app/routes/x+/customer+/$customerId.locations.$customerLocationId.tsx
+++ b/apps/carbon/app/routes/x+/customer+/$customerId.locations.$customerLocationId.tsx
@@ -106,7 +106,7 @@ export default function EditCustomerLocationRoute() {
addressLine1: location?.address?.addressLine1 ?? "",
addressLine2: location?.address?.addressLine2 ?? "",
city: location?.address?.city ?? "",
- state: location?.address?.state ?? "",
+ stateProvince: location?.address?.stateProvince ?? "",
postalCode: location?.address?.postalCode ?? "",
countryCode: location?.address?.country?.alpha2 ?? "",
...getCustomFields(location?.customFields),
diff --git a/apps/carbon/app/routes/x+/resources+/locations.$locationId.tsx b/apps/carbon/app/routes/x+/resources+/locations.$locationId.tsx
index 6ce402b27a..5774ef75cc 100644
--- a/apps/carbon/app/routes/x+/resources+/locations.$locationId.tsx
+++ b/apps/carbon/app/routes/x+/resources+/locations.$locationId.tsx
@@ -87,7 +87,7 @@ export default function LocationRoute() {
addressLine1: location.addressLine1 ?? undefined,
addressLine2: location.addressLine2 ?? undefined,
city: location.city ?? undefined,
- state: location.state ?? undefined,
+ stateProvince: location.stateProvince ?? undefined,
postalCode: location.postalCode ?? undefined,
countryCode: location.countryCode ?? undefined,
timezone: location.timezone ?? getLocalTimeZone(),
diff --git a/apps/carbon/app/routes/x+/resources+/locations.new.tsx b/apps/carbon/app/routes/x+/resources+/locations.new.tsx
index c2fcc5173f..9ad66d1cac 100644
--- a/apps/carbon/app/routes/x+/resources+/locations.new.tsx
+++ b/apps/carbon/app/routes/x+/resources+/locations.new.tsx
@@ -68,7 +68,7 @@ export default function NewLocationRoute() {
addressLine1: "",
addressLine2: "",
city: "",
- state: "",
+ stateProvince: "",
postalCode: "",
};
diff --git a/apps/carbon/app/routes/x+/settings+/company.tsx b/apps/carbon/app/routes/x+/settings+/company.tsx
index 64db6c9c52..8cdc9e7885 100644
--- a/apps/carbon/app/routes/x+/settings+/company.tsx
+++ b/apps/carbon/app/routes/x+/settings+/company.tsx
@@ -104,9 +104,9 @@ export default function Company() {
addressLine1: company.addressLine1 ?? "",
addressLine2: company.addressLine2 ?? undefined,
city: company.city ?? "",
- state: company.state ?? "",
+ stateProvince: company.stateProvince ?? "",
postalCode: company.postalCode ?? "",
- countryCode: company.countryCode ?? undefined,
+ countryCode: company.countryCode ?? "",
phone: company.phone ?? undefined,
email: company.email ?? undefined,
website: company.website ?? undefined,
diff --git a/apps/carbon/app/routes/x+/supplier+/$supplierId.locations.$supplierLocationId.tsx b/apps/carbon/app/routes/x+/supplier+/$supplierId.locations.$supplierLocationId.tsx
index e3479f1c37..8af6b77cc9 100644
--- a/apps/carbon/app/routes/x+/supplier+/$supplierId.locations.$supplierLocationId.tsx
+++ b/apps/carbon/app/routes/x+/supplier+/$supplierId.locations.$supplierLocationId.tsx
@@ -106,7 +106,7 @@ export default function EditSupplierLocationRoute() {
addressLine1: location?.address?.addressLine1 ?? "",
addressLine2: location?.address?.addressLine2 ?? "",
city: location?.address?.city ?? "",
- state: location?.address?.state ?? "",
+ stateProvince: location?.address?.stateProvince ?? "",
postalCode: location?.address?.postalCode ?? "",
countryCode: location?.address?.country?.alpha2 ?? "",
...getCustomFields(location?.customFields),
diff --git a/apps/carbon/app/types/validators.ts b/apps/carbon/app/types/validators.ts
index 9f8e25bf3d..04dec703c0 100644
--- a/apps/carbon/app/types/validators.ts
+++ b/apps/carbon/app/types/validators.ts
@@ -15,7 +15,7 @@ export const address = {
addressLine1: zfd.text(z.string().optional()),
addressLine2: zfd.text(z.string().optional()),
city: zfd.text(z.string().optional()),
- state: zfd.text(z.string().optional()),
+ stateProvince: zfd.text(z.string().optional()),
postalCode: zfd.text(z.string().optional()),
countryCode: zfd.text(z.string().optional()),
phone: zfd.text(z.string().optional()),
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index c76552bffb..02d0318649 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -8704,7 +8704,7 @@ export default {
$ref: "#/parameters/rowFilter.company.city",
},
{
- $ref: "#/parameters/rowFilter.company.state",
+ $ref: "#/parameters/rowFilter.company.stateProvince",
},
{
$ref: "#/parameters/rowFilter.company.postalCode",
@@ -8808,7 +8808,7 @@ export default {
$ref: "#/parameters/rowFilter.company.city",
},
{
- $ref: "#/parameters/rowFilter.company.state",
+ $ref: "#/parameters/rowFilter.company.stateProvince",
},
{
$ref: "#/parameters/rowFilter.company.postalCode",
@@ -8866,7 +8866,7 @@ export default {
$ref: "#/parameters/rowFilter.company.city",
},
{
- $ref: "#/parameters/rowFilter.company.state",
+ $ref: "#/parameters/rowFilter.company.stateProvince",
},
{
$ref: "#/parameters/rowFilter.company.postalCode",
@@ -12898,7 +12898,7 @@ export default {
$ref: "#/parameters/rowFilter.purchaseOrderLocations.supplierCity",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLocations.supplierState",
+ $ref: "#/parameters/rowFilter.purchaseOrderLocations.supplierStateProvince",
},
{
$ref: "#/parameters/rowFilter.purchaseOrderLocations.supplierPostalCode",
@@ -12919,7 +12919,7 @@ export default {
$ref: "#/parameters/rowFilter.purchaseOrderLocations.deliveryCity",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLocations.deliveryState",
+ $ref: "#/parameters/rowFilter.purchaseOrderLocations.deliveryStateProvince",
},
{
$ref: "#/parameters/rowFilter.purchaseOrderLocations.deliveryPostalCode",
@@ -12943,7 +12943,7 @@ export default {
$ref: "#/parameters/rowFilter.purchaseOrderLocations.customerCity",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderLocations.customerState",
+ $ref: "#/parameters/rowFilter.purchaseOrderLocations.customerStateProvince",
},
{
$ref: "#/parameters/rowFilter.purchaseOrderLocations.customerPostalCode",
@@ -19453,7 +19453,7 @@ export default {
$ref: "#/parameters/rowFilter.quoteCustomerDetails.customerCity",
},
{
- $ref: "#/parameters/rowFilter.quoteCustomerDetails.customerState",
+ $ref: "#/parameters/rowFilter.quoteCustomerDetails.customerStateProvince",
},
{
$ref: "#/parameters/rowFilter.quoteCustomerDetails.customerPostalCode",
@@ -24223,7 +24223,7 @@ export default {
$ref: "#/parameters/rowFilter.location.city",
},
{
- $ref: "#/parameters/rowFilter.location.state",
+ $ref: "#/parameters/rowFilter.location.stateProvince",
},
{
$ref: "#/parameters/rowFilter.location.postalCode",
@@ -24333,7 +24333,7 @@ export default {
$ref: "#/parameters/rowFilter.location.city",
},
{
- $ref: "#/parameters/rowFilter.location.state",
+ $ref: "#/parameters/rowFilter.location.stateProvince",
},
{
$ref: "#/parameters/rowFilter.location.postalCode",
@@ -24397,7 +24397,7 @@ export default {
$ref: "#/parameters/rowFilter.location.city",
},
{
- $ref: "#/parameters/rowFilter.location.state",
+ $ref: "#/parameters/rowFilter.location.stateProvince",
},
{
$ref: "#/parameters/rowFilter.location.postalCode",
@@ -26884,7 +26884,7 @@ export default {
$ref: "#/parameters/rowFilter.address.city",
},
{
- $ref: "#/parameters/rowFilter.address.state",
+ $ref: "#/parameters/rowFilter.address.stateProvince",
},
{
$ref: "#/parameters/rowFilter.address.postalCode",
@@ -26973,7 +26973,7 @@ export default {
$ref: "#/parameters/rowFilter.address.city",
},
{
- $ref: "#/parameters/rowFilter.address.state",
+ $ref: "#/parameters/rowFilter.address.stateProvince",
},
{
$ref: "#/parameters/rowFilter.address.postalCode",
@@ -27016,7 +27016,7 @@ export default {
$ref: "#/parameters/rowFilter.address.city",
},
{
- $ref: "#/parameters/rowFilter.address.state",
+ $ref: "#/parameters/rowFilter.address.stateProvince",
},
{
$ref: "#/parameters/rowFilter.address.postalCode",
@@ -28702,7 +28702,7 @@ export default {
$ref: "#/parameters/rowFilter.salesOrderLocations.customerCity",
},
{
- $ref: "#/parameters/rowFilter.salesOrderLocations.customerState",
+ $ref: "#/parameters/rowFilter.salesOrderLocations.customerStateProvince",
},
{
$ref: "#/parameters/rowFilter.salesOrderLocations.customerPostalCode",
@@ -28723,7 +28723,7 @@ export default {
$ref: "#/parameters/rowFilter.salesOrderLocations.paymentCity",
},
{
- $ref: "#/parameters/rowFilter.salesOrderLocations.paymentState",
+ $ref: "#/parameters/rowFilter.salesOrderLocations.paymentStateProvince",
},
{
$ref: "#/parameters/rowFilter.salesOrderLocations.paymentPostalCode",
@@ -39699,7 +39699,7 @@ export default {
format: "text",
type: "string",
},
- state: {
+ stateProvince: {
format: "text",
type: "string",
},
@@ -41536,7 +41536,7 @@ export default {
format: "text",
type: "string",
},
- supplierState: {
+ supplierStateProvince: {
format: "text",
type: "string",
},
@@ -41566,7 +41566,7 @@ export default {
format: "text",
type: "string",
},
- deliveryState: {
+ deliveryStateProvince: {
format: "text",
type: "string",
},
@@ -41598,7 +41598,7 @@ export default {
format: "text",
type: "string",
},
- customerState: {
+ customerStateProvince: {
format: "text",
type: "string",
},
@@ -44555,7 +44555,7 @@ export default {
format: "text",
type: "string",
},
- customerState: {
+ customerStateProvince: {
format: "text",
type: "string",
},
@@ -46689,7 +46689,7 @@ export default {
"name",
"addressLine1",
"city",
- "state",
+ "stateProvince",
"postalCode",
"timezone",
"companyId",
@@ -46719,7 +46719,7 @@ export default {
format: "text",
type: "string",
},
- state: {
+ stateProvince: {
format: "text",
type: "string",
},
@@ -47791,7 +47791,7 @@ export default {
format: "text",
type: "string",
},
- state: {
+ stateProvince: {
format: "text",
type: "string",
},
@@ -48497,7 +48497,7 @@ export default {
format: "text",
type: "string",
},
- customerState: {
+ customerStateProvince: {
format: "text",
type: "string",
},
@@ -48527,7 +48527,7 @@ export default {
format: "text",
type: "string",
},
- paymentState: {
+ paymentStateProvince: {
format: "text",
type: "string",
},
@@ -56227,8 +56227,8 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.company.state": {
- name: "state",
+ "rowFilter.company.stateProvince": {
+ name: "stateProvince",
required: false,
format: "text",
in: "query",
@@ -58627,8 +58627,8 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLocations.supplierState": {
- name: "supplierState",
+ "rowFilter.purchaseOrderLocations.supplierStateProvince": {
+ name: "supplierStateProvince",
required: false,
format: "text",
in: "query",
@@ -58676,8 +58676,8 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLocations.deliveryState": {
- name: "deliveryState",
+ "rowFilter.purchaseOrderLocations.deliveryStateProvince": {
+ name: "deliveryStateProvince",
required: false,
format: "text",
in: "query",
@@ -58732,8 +58732,8 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.purchaseOrderLocations.customerState": {
- name: "customerState",
+ "rowFilter.purchaseOrderLocations.customerStateProvince": {
+ name: "customerStateProvince",
required: false,
format: "text",
in: "query",
@@ -62579,8 +62579,8 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.quoteCustomerDetails.customerState": {
- name: "customerState",
+ "rowFilter.quoteCustomerDetails.customerStateProvince": {
+ name: "customerStateProvince",
required: false,
format: "text",
in: "query",
@@ -65462,8 +65462,8 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.location.state": {
- name: "state",
+ "rowFilter.location.stateProvince": {
+ name: "stateProvince",
required: false,
format: "text",
in: "query",
@@ -66808,8 +66808,8 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.address.state": {
- name: "state",
+ "rowFilter.address.stateProvince": {
+ name: "stateProvince",
required: false,
format: "text",
in: "query",
@@ -67719,8 +67719,8 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.salesOrderLocations.customerState": {
- name: "customerState",
+ "rowFilter.salesOrderLocations.customerStateProvince": {
+ name: "customerStateProvince",
required: false,
format: "text",
in: "query",
@@ -67768,8 +67768,8 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.salesOrderLocations.paymentState": {
- name: "paymentState",
+ "rowFilter.salesOrderLocations.paymentStateProvince": {
+ name: "paymentStateProvince",
required: false,
format: "text",
in: "query",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 557713d467..4b77ab1486 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -1525,7 +1525,7 @@ export type Database = {
id: string
phone: string | null
postalCode: string | null
- state: string | null
+ stateProvince: string | null
}
Insert: {
addressLine1?: string | null
@@ -1537,7 +1537,7 @@ export type Database = {
id?: string
phone?: string | null
postalCode?: string | null
- state?: string | null
+ stateProvince?: string | null
}
Update: {
addressLine1?: string | null
@@ -1549,7 +1549,7 @@ export type Database = {
id?: string
phone?: string | null
postalCode?: string | null
- state?: string | null
+ stateProvince?: string | null
}
Relationships: [
{
@@ -1921,7 +1921,7 @@ export type Database = {
name: string
phone: string | null
postalCode: string | null
- state: string | null
+ stateProvince: string | null
taxId: string | null
updatedBy: string | null
website: string | null
@@ -1938,7 +1938,7 @@ export type Database = {
name: string
phone?: string | null
postalCode?: string | null
- state?: string | null
+ stateProvince?: string | null
taxId?: string | null
updatedBy?: string | null
website?: string | null
@@ -1955,7 +1955,7 @@ export type Database = {
name?: string
phone?: string | null
postalCode?: string | null
- state?: string | null
+ stateProvince?: string | null
taxId?: string | null
updatedBy?: string | null
website?: string | null
@@ -8179,7 +8179,7 @@ export type Database = {
longitude: number | null
name: string
postalCode: string
- state: string
+ stateProvince: string
timezone: string
updatedAt: string | null
updatedBy: string | null
@@ -8198,7 +8198,7 @@ export type Database = {
longitude?: number | null
name: string
postalCode: string
- state: string
+ stateProvince: string
timezone: string
updatedAt?: string | null
updatedBy?: string | null
@@ -8217,7 +8217,7 @@ export type Database = {
longitude?: number | null
name?: string
postalCode?: string
- state?: string
+ stateProvince?: string
timezone?: string
updatedAt?: string | null
updatedBy?: string | null
@@ -25250,14 +25250,14 @@ export type Database = {
customerCountryCode: string | null
customerName: string | null
customerPostalCode: string | null
- customerState: string | null
+ customerStateProvince: string | null
deliveryAddressLine1: string | null
deliveryAddressLine2: string | null
deliveryCity: string | null
deliveryCountryCode: string | null
deliveryName: string | null
deliveryPostalCode: string | null
- deliveryState: string | null
+ deliveryStateProvince: string | null
dropShipment: boolean | null
id: string | null
supplierAddressLine1: string | null
@@ -25266,7 +25266,7 @@ export type Database = {
supplierCountryCode: string | null
supplierName: string | null
supplierPostalCode: string | null
- supplierState: string | null
+ supplierStateProvince: string | null
}
Relationships: [
{
@@ -25582,7 +25582,7 @@ export type Database = {
customerCountryCode: string | null
customerName: string | null
customerPostalCode: string | null
- customerState: string | null
+ customerStateProvince: string | null
quoteId: string | null
}
Relationships: [
@@ -26992,7 +26992,7 @@ export type Database = {
customerCountryCode: string | null
customerName: string | null
customerPostalCode: string | null
- customerState: string | null
+ customerStateProvince: string | null
id: string | null
paymentAddressLine1: string | null
paymentAddressLine2: string | null
@@ -27000,7 +27000,7 @@ export type Database = {
paymentCountryCode: string | null
paymentCustomerName: string | null
paymentPostalCode: string | null
- paymentState: string | null
+ paymentStateProvince: string | null
}
Relationships: [
{
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 557713d467..4b77ab1486 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -1525,7 +1525,7 @@ export type Database = {
id: string
phone: string | null
postalCode: string | null
- state: string | null
+ stateProvince: string | null
}
Insert: {
addressLine1?: string | null
@@ -1537,7 +1537,7 @@ export type Database = {
id?: string
phone?: string | null
postalCode?: string | null
- state?: string | null
+ stateProvince?: string | null
}
Update: {
addressLine1?: string | null
@@ -1549,7 +1549,7 @@ export type Database = {
id?: string
phone?: string | null
postalCode?: string | null
- state?: string | null
+ stateProvince?: string | null
}
Relationships: [
{
@@ -1921,7 +1921,7 @@ export type Database = {
name: string
phone: string | null
postalCode: string | null
- state: string | null
+ stateProvince: string | null
taxId: string | null
updatedBy: string | null
website: string | null
@@ -1938,7 +1938,7 @@ export type Database = {
name: string
phone?: string | null
postalCode?: string | null
- state?: string | null
+ stateProvince?: string | null
taxId?: string | null
updatedBy?: string | null
website?: string | null
@@ -1955,7 +1955,7 @@ export type Database = {
name?: string
phone?: string | null
postalCode?: string | null
- state?: string | null
+ stateProvince?: string | null
taxId?: string | null
updatedBy?: string | null
website?: string | null
@@ -8179,7 +8179,7 @@ export type Database = {
longitude: number | null
name: string
postalCode: string
- state: string
+ stateProvince: string
timezone: string
updatedAt: string | null
updatedBy: string | null
@@ -8198,7 +8198,7 @@ export type Database = {
longitude?: number | null
name: string
postalCode: string
- state: string
+ stateProvince: string
timezone: string
updatedAt?: string | null
updatedBy?: string | null
@@ -8217,7 +8217,7 @@ export type Database = {
longitude?: number | null
name?: string
postalCode?: string
- state?: string
+ stateProvince?: string
timezone?: string
updatedAt?: string | null
updatedBy?: string | null
@@ -25250,14 +25250,14 @@ export type Database = {
customerCountryCode: string | null
customerName: string | null
customerPostalCode: string | null
- customerState: string | null
+ customerStateProvince: string | null
deliveryAddressLine1: string | null
deliveryAddressLine2: string | null
deliveryCity: string | null
deliveryCountryCode: string | null
deliveryName: string | null
deliveryPostalCode: string | null
- deliveryState: string | null
+ deliveryStateProvince: string | null
dropShipment: boolean | null
id: string | null
supplierAddressLine1: string | null
@@ -25266,7 +25266,7 @@ export type Database = {
supplierCountryCode: string | null
supplierName: string | null
supplierPostalCode: string | null
- supplierState: string | null
+ supplierStateProvince: string | null
}
Relationships: [
{
@@ -25582,7 +25582,7 @@ export type Database = {
customerCountryCode: string | null
customerName: string | null
customerPostalCode: string | null
- customerState: string | null
+ customerStateProvince: string | null
quoteId: string | null
}
Relationships: [
@@ -26992,7 +26992,7 @@ export type Database = {
customerCountryCode: string | null
customerName: string | null
customerPostalCode: string | null
- customerState: string | null
+ customerStateProvince: string | null
id: string | null
paymentAddressLine1: string | null
paymentAddressLine2: string | null
@@ -27000,7 +27000,7 @@ export type Database = {
paymentCountryCode: string | null
paymentCustomerName: string | null
paymentPostalCode: string | null
- paymentState: string | null
+ paymentStateProvince: string | null
}
Relationships: [
{
diff --git a/packages/database/supabase/migrations/20240928155702_country-codes.sql b/packages/database/supabase/migrations/20240928155702_country-codes.sql
index d6368fe302..2e9a526421 100644
--- a/packages/database/supabase/migrations/20240928155702_country-codes.sql
+++ b/packages/database/supabase/migrations/20240928155702_country-codes.sql
@@ -25,6 +25,11 @@ ALTER TABLE "address" ADD CONSTRAINT "address_countryCode_fkey" FOREIGN KEY ("co
ALTER TABLE "country" ALTER COLUMN "alpha3" SET NOT NULL;
ALTER TABLE "country" ADD CONSTRAINT "country_alpha3_unique" UNIQUE ("alpha3");
+-- Rename the 'state' column to 'stateProvince'
+ALTER TABLE "address" RENAME COLUMN "state" TO "stateProvince";
+ALTER TABLE "location" RENAME COLUMN "state" TO "stateProvince";
+ALTER TABLE "company" RENAME COLUMN "state" TO "stateProvince";
+
-- Recreate the purchaseOrderLocations view
CREATE OR REPLACE VIEW "purchaseOrderLocations" WITH(SECURITY_INVOKER=true) AS
SELECT
@@ -33,14 +38,14 @@ CREATE OR REPLACE VIEW "purchaseOrderLocations" WITH(SECURITY_INVOKER=true) AS
sa."addressLine1" AS "supplierAddressLine1",
sa."addressLine2" AS "supplierAddressLine2",
sa."city" AS "supplierCity",
- sa."state" AS "supplierState",
+ sa."stateProvince" AS "supplierStateProvince",
sa."postalCode" AS "supplierPostalCode",
sa."countryCode" AS "supplierCountryCode",
dl.name AS "deliveryName",
dl."addressLine1" AS "deliveryAddressLine1",
dl."addressLine2" AS "deliveryAddressLine2",
dl."city" AS "deliveryCity",
- dl."state" AS "deliveryState",
+ dl."stateProvince" AS "deliveryStateProvince",
dl."postalCode" AS "deliveryPostalCode",
dl."countryCode" AS "deliveryCountryCode",
pod."dropShipment",
@@ -48,7 +53,7 @@ CREATE OR REPLACE VIEW "purchaseOrderLocations" WITH(SECURITY_INVOKER=true) AS
ca."addressLine1" AS "customerAddressLine1",
ca."addressLine2" AS "customerAddressLine2",
ca."city" AS "customerCity",
- ca."state" AS "customerState",
+ ca."stateProvince" AS "customerStateProvince",
ca."postalCode" AS "customerPostalCode",
ca."countryCode" AS "customerCountryCode"
FROM "purchaseOrder" po
@@ -77,7 +82,7 @@ SELECT
ca."addressLine1" AS "customerAddressLine1",
ca."addressLine2" AS "customerAddressLine2",
ca."city" AS "customerCity",
- ca."state" AS "customerState",
+ ca."stateProvince" AS "customerStateProvince",
ca."postalCode" AS "customerPostalCode",
ca."countryCode" AS "customerCountryCode"
FROM
@@ -94,14 +99,14 @@ FROM
ca."addressLine1" AS "customerAddressLine1",
ca."addressLine2" AS "customerAddressLine2",
ca."city" AS "customerCity",
- ca."state" AS "customerState",
+ ca."stateProvince" AS "customerStateProvince",
ca."postalCode" AS "customerPostalCode",
ca."countryCode" AS "customerCountryCode",
pc.name AS "paymentCustomerName",
pa."addressLine1" AS "paymentAddressLine1",
pa."addressLine2" AS "paymentAddressLine2",
pa."city" AS "paymentCity",
- pa."state" AS "paymentState",
+ pa."stateProvince" AS "paymentStateProvince",
pa."postalCode" AS "paymentPostalCode",
pa."countryCode" AS "paymentCountryCode"
FROM "salesOrder" so
diff --git a/packages/documents/src/email/PurchaseOrderEmail.tsx b/packages/documents/src/email/PurchaseOrderEmail.tsx
index 9d077c0cf1..f55d2085c4 100644
--- a/packages/documents/src/email/PurchaseOrderEmail.tsx
+++ b/packages/documents/src/email/PurchaseOrderEmail.tsx
@@ -41,7 +41,7 @@ const PurchaseOrderEmail = ({
deliveryAddressLine1,
deliveryAddressLine2,
deliveryCity,
- deliveryState,
+ deliveryStateProvince,
deliveryPostalCode,
deliveryCountryCode,
dropShipment,
@@ -49,7 +49,7 @@ const PurchaseOrderEmail = ({
customerAddressLine1,
customerAddressLine2,
customerCity,
- customerState,
+ customerStateProvince,
customerPostalCode,
customerCountryCode,
} = purchaseOrderLocations;
@@ -149,7 +149,7 @@ const PurchaseOrderEmail = ({
<Text>
{formatCityStatePostalCode(
customerCity,
- customerState,
+ customerStateProvince,
customerPostalCode
)}
</Text>
@@ -168,7 +168,7 @@ const PurchaseOrderEmail = ({
<Text>
{formatCityStatePostalCode(
deliveryCity,
- deliveryState,
+ deliveryStateProvince,
deliveryPostalCode
)}
</Text>
diff --git a/packages/documents/src/email/SalesOrderEmail.tsx b/packages/documents/src/email/SalesOrderEmail.tsx
index 94ff4a7588..4083d2e442 100644
--- a/packages/documents/src/email/SalesOrderEmail.tsx
+++ b/packages/documents/src/email/SalesOrderEmail.tsx
@@ -47,14 +47,14 @@ const SalesOrderEmail = ({
customerAddressLine1,
customerAddressLine2,
customerCity,
- customerState,
+ customerStateProvince,
customerPostalCode,
customerCountryCode,
// paymentCustomerName,
// paymentAddressLine1,
// paymentAddressLine2,
// paymentCity,
- // paymentState,
+ // paymentStateProvince,
// paymentPostalCode,
// paymentCountryCode,
} = salesOrderLocations;
@@ -148,7 +148,7 @@ const SalesOrderEmail = ({
<Text>
{formatCityStatePostalCode(
customerCity,
- customerState,
+ customerStateProvince,
customerPostalCode
)}
</Text>
diff --git a/packages/documents/src/pdf/PurchaseOrderPDF.tsx b/packages/documents/src/pdf/PurchaseOrderPDF.tsx
index c08523e114..185fbb76b4 100644
--- a/packages/documents/src/pdf/PurchaseOrderPDF.tsx
+++ b/packages/documents/src/pdf/PurchaseOrderPDF.tsx
@@ -56,14 +56,14 @@ const PurchaseOrderPDF = ({
supplierAddressLine1,
supplierAddressLine2,
supplierCity,
- supplierState,
+ supplierStateProvince,
supplierPostalCode,
supplierCountryCode,
deliveryName,
deliveryAddressLine1,
deliveryAddressLine2,
deliveryCity,
- deliveryState,
+ deliveryStateProvince,
deliveryPostalCode,
deliveryCountryCode,
dropShipment,
@@ -71,7 +71,7 @@ const PurchaseOrderPDF = ({
customerAddressLine1,
customerAddressLine2,
customerCity,
- customerState,
+ customerStateProvince,
customerPostalCode,
customerCountryCode,
} = purchaseOrderLocations;
@@ -109,7 +109,7 @@ const PurchaseOrderPDF = ({
<Text>
{formatCityStatePostalCode(
supplierCity,
- supplierState,
+ supplierStateProvince,
supplierPostalCode
)}
</Text>
@@ -124,7 +124,7 @@ const PurchaseOrderPDF = ({
<Text>
{formatCityStatePostalCode(
customerCity,
- customerState,
+ customerStateProvince,
customerPostalCode
)}
</Text>
@@ -139,7 +139,7 @@ const PurchaseOrderPDF = ({
<Text>
{formatCityStatePostalCode(
deliveryCity,
- deliveryState,
+ deliveryStateProvince,
deliveryPostalCode
)}
</Text>
diff --git a/packages/documents/src/pdf/QuotePDF.tsx b/packages/documents/src/pdf/QuotePDF.tsx
index 524403ad31..ec4eb56602 100644
--- a/packages/documents/src/pdf/QuotePDF.tsx
+++ b/packages/documents/src/pdf/QuotePDF.tsx
@@ -63,7 +63,7 @@ const QuotePDF = ({
customerAddressLine1,
customerAddressLine2,
customerCity,
- customerState,
+ customerStateProvince,
customerPostalCode,
customerCountryCode,
} = quoteCustomerDetails;
@@ -148,7 +148,7 @@ const QuotePDF = ({
<Text>
{formatCityStatePostalCode(
customerCity,
- customerState,
+ customerStateProvince,
customerPostalCode
)}
</Text>
diff --git a/packages/documents/src/pdf/SalesOrderPDF.tsx b/packages/documents/src/pdf/SalesOrderPDF.tsx
index efda763989..d7d1c24b87 100644
--- a/packages/documents/src/pdf/SalesOrderPDF.tsx
+++ b/packages/documents/src/pdf/SalesOrderPDF.tsx
@@ -56,14 +56,14 @@ const SalesOrderPDF = ({
customerAddressLine1,
customerAddressLine2,
customerCity,
- customerState,
+ customerStateProvince,
customerPostalCode,
customerCountryCode,
paymentCustomerName,
paymentAddressLine1,
paymentAddressLine2,
paymentCity,
- paymentState,
+ paymentStateProvince,
paymentPostalCode,
paymentCountryCode,
} = salesOrderLocations;
@@ -105,7 +105,7 @@ const SalesOrderPDF = ({
<Text style={tw("text-sm")}>
{formatCityStatePostalCode(
customerCity,
- customerState,
+ customerStateProvince,
customerPostalCode
)}
</Text>
@@ -123,7 +123,7 @@ const SalesOrderPDF = ({
<Text style={tw("text-sm")}>
{formatCityStatePostalCode(
paymentCity,
- paymentState,
+ paymentStateProvince,
paymentPostalCode
)}
</Text>
diff --git a/packages/documents/src/pdf/components/Summary.tsx b/packages/documents/src/pdf/components/Summary.tsx
index a8a83a55b5..1fc4070c15 100644
--- a/packages/documents/src/pdf/components/Summary.tsx
+++ b/packages/documents/src/pdf/components/Summary.tsx
@@ -62,8 +62,8 @@ const Summary = ({ company, items }: SummaryProps) => {
<Text style={styles.companyName}>{company.name}</Text>
{company.addressLine1 && <Text>{company.addressLine1}</Text>}
{company.addressLine2 && <Text>{company.addressLine2}</Text>}
- {company.city && company.state && company.postalCode && (
- <Text>{`${company.city}, ${company.state}, ${company.postalCode}`}</Text>
+ {company.city && company.stateProvince && company.postalCode && (
+ <Text>{`${company.city}, ${company.stateProvince}, ${company.postalCode}`}</Text>
)}
{company.phone && <Text>Phone: {company.phone}</Text>}
{company.email && <Text>Email: {company.email}</Text>}
diff --git a/packages/utils/src/address.ts b/packages/utils/src/address.ts
index 03613934ad..3c982978f9 100644
--- a/packages/utils/src/address.ts
+++ b/packages/utils/src/address.ts
@@ -15,7 +15,7 @@ export function formatAddressLines(
export function formatCityStatePostalCode(
city?: string | null,
- state?: string | null,
+ stateProvince?: string | null,
postalCode?: string | null
): string {
// Create an array to hold the different parts of the address
@@ -25,9 +25,11 @@ export function formatCityStatePostalCode(
if (city) parts.push(city);
// Combine state and postalCode without a comma if both are provided
- if (state) {
- const statepostalCode = postalCode ? `${state} ${postalCode}` : state;
- parts.push(statepostalCode);
+ if (stateProvince) {
+ const stateProvincePostalCode = postalCode
+ ? `${stateProvince} ${postalCode}`
+ : stateProvince;
+ parts.push(stateProvincePostalCode);
} else if (postalCode) {
parts.push(postalCode);
}
@@ -40,7 +42,7 @@ export function formatAddress(
addressLine1?: string | null,
addressLine2?: string | null,
city?: string | null,
- state?: string | null,
+ stateProvince?: string | null,
postalCode?: string | null,
country?: string | null
): string {
@@ -52,7 +54,7 @@ export function formatAddress(
const formattedCityStatePostalCode = formatCityStatePostalCode(
city,
- state,
+ stateProvince,
postalCode
);
if (formattedCityStatePostalCode) parts.push(formattedCityStatePostalCode);