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
refactor: remove isBaseCurrency from currency table
Rob Carringtonbf300873f810
diff --git a/apps/carbon/app/hooks/useUser.tsx b/apps/carbon/app/hooks/useUser.tsxindex f952153942..04427569d5 100644--- a/apps/carbon/app/hooks/useUser.tsx+++ b/apps/carbon/app/hooks/useUser.tsx@@ -15,6 +15,7 @@ type Company = {name: string;logo: string | null;countryCode: string | null;+ baseCurrencyCode: string;};type Groups = string[];@@ -64,7 +65,8 @@ function isCompany(value: any): value is Company {typeof value.id === "string" &&typeof value.name === "string" &&(typeof value.logo === "string" || value.logo === null) &&- (typeof value.countryCode === "string" || value.countryCode === null)+ (typeof value.countryCode === "string" || value.countryCode === null) &&+ typeof value.baseCurrencyCode === "string");}diff --git a/apps/carbon/app/modules/accounting/accounting.models.ts b/apps/carbon/app/modules/accounting/accounting.models.tsindex a2d8235533..846ce76359 100644--- a/apps/carbon/app/modules/accounting/accounting.models.ts+++ b/apps/carbon/app/modules/accounting/accounting.models.ts@@ -185,7 +185,6 @@ export const currencyValidator = z.object({symbol: z.string().min(1, { message: "Symbol is required" }),decimalPlaces: zfd.numeric(z.number().min(0).max(4)),exchangeRate: zfd.numeric(z.number().min(0, { message: "Rate is required" })),- isBaseCurrency: zfd.checkbox(),});export const defaultBalanceSheetAccountValidator = z.object({diff --git a/apps/carbon/app/modules/accounting/accounting.service.ts b/apps/carbon/app/modules/accounting/accounting.service.tsindex 53f33c6b16..4f0682af6d 100644--- a/apps/carbon/app/modules/accounting/accounting.service.ts+++ b/apps/carbon/app/modules/accounting/accounting.service.ts@@ -305,11 +305,24 @@ export async function getBaseCurrency(client: SupabaseClient<Database>,companyId: string) {+ const { data: company, error } = await client+ .from("company")+ .select("baseCurrencyCode")+ .eq("id", companyId)+ .single();++ if (error) {+ throw new Error(`Failed to get company: ${error.message}`);+ }++ if (!company || !company.baseCurrencyCode) {+ throw new Error("Company or base currency code not found");+ }+return client.from("currency").select("*")- .eq("companyId", companyId)- .eq("isBaseCurrency", true)+ .eq("code", company.baseCurrencyCode).single();}@@ -393,7 +406,7 @@ export async function getCurrency(client: SupabaseClient<Database>,currencyId: string) {- return client.from("currency").select("*").eq("id", currencyId).single();+ return client.from("currencies").select("*").eq("id", currencyId).single();}export async function getCurrencies(@@ -404,7 +417,7 @@ export async function getCurrencies(}) {let query = client- .from("currency")+ .from("currencies").select("*", {count: "exact",})@@ -415,16 +428,10 @@ export async function getCurrencies(query = query.ilike("name", `%${args.search}%`);}- query = setGenericQueryFilters(query, args, [- { column: "isBaseCurrency", ascending: false },- ]);return query;}-export async function getCurrenciesList(- client: SupabaseClient<Database>,- companyId: string-) {+export async function getCurrenciesList(client: SupabaseClient<Database>) {return client.from("currencyCode").select("code, name")@@ -785,14 +792,6 @@ export async function upsertCurrency(customFields?: Json;})) {- if (currency.isBaseCurrency) {- await client- .from("currency")- .update({ isBaseCurrency: false })- .eq("isBaseCurrency", true)- .eq("companyId", currency.companyId);- }-if ("createdBy" in currency) {return client.from("currency").insert([currency]).select("*").single();}diff --git a/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTable.tsx b/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTable.tsxindex 3f31dcdf89..b46e678e9b 100644--- a/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTable.tsx+++ b/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTable.tsx@@ -1,4 +1,4 @@-import { Checkbox, MenuIcon, MenuItem } from "@carbon/react";+import { MenuIcon, MenuItem } from "@carbon/react";import { useNavigate } from "@remix-run/react";import type { ColumnDef } from "@tanstack/react-table";import { memo, useCallback, useMemo } from "react";@@ -45,11 +45,6 @@ const CurrenciesTable = memo(({ data, count }: CurrenciesTableProps) => {header: "Exchange Rate",cell: (item) => item.getValue(),},- {- accessorKey: "isBaseCurrency",- header: "Default Currency",- cell: ({ row }) => <Checkbox isChecked={row.original.isBaseCurrency} />,- },];return [...defaultColumns, ...customColumns];}, [customColumns]);@@ -61,7 +56,9 @@ const CurrenciesTable = memo(({ data, count }: CurrenciesTableProps) => {<MenuItemdisabled={!permissions.can("update", "accounting")}onClick={() => {- navigate(`${path.to.currency(row.id)}?${params.toString()}`);+ navigate(+ `${path.to.currency(row.id as string)}?${params.toString()}`+ );}}><MenuIcon icon={<LuPencil />} />@@ -71,7 +68,9 @@ const CurrenciesTable = memo(({ data, count }: CurrenciesTableProps) => {disabled={!permissions.can("delete", "accounting")}onClick={() => {navigate(- `${path.to.deleteCurrency(row.id)}?${params.toString()}`+ `${path.to.deleteCurrency(+ row.id as string+ )}?${params.toString()}`);}}>diff --git a/apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm.tsx b/apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm.tsxindex 4c270fa8c0..5e19b92ef9 100644--- a/apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm.tsx+++ b/apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm.tsx@@ -14,15 +14,13 @@ import { useNavigate } from "@remix-run/react";import { useState } from "react";import type { z } from "zod";import {- Boolean,CustomFormFields,Hidden,Input,Number,Submit,} from "~/components/Form";-import { usePermissions, useRouteData } from "~/hooks";-import type { Currency } from "~/modules/accounting";+import { usePermissions, useUser } from "~/hooks";import { currencyValidator } from "~/modules/accounting";import { path } from "~/utils/path";@@ -38,15 +36,12 @@ const CurrencyForm = ({ initialValues }: CurrencyFormProps) => {initialValues.decimalPlaces ?? 2);- const routeData = useRouteData<{ baseCurrency?: Currency }>(- path.to.accountingRoot- );- const [name, setName] = useState(initialValues.name);+ const { company } = useUser();- const isBaseCurrency = routeData?.baseCurrency?.id === initialValues.id;- const exchnageRateHelperText = isBaseCurrency+ const isBaseCurrency = company?.baseCurrencyCode === initialValues.code;+ const exchangeRateHelperText = isBaseCurrency? "This is the base currency. Exchange rate is always 1."- : `One ${name} is equal to how many ${routeData?.baseCurrency?.name}?`;+ : `One ${initialValues.code} is equal to how many ${company?.baseCurrencyCode}?`;const isEditing = initialValues.id !== undefined;const isDisabled = isEditing@@ -77,13 +72,9 @@ const CurrencyForm = ({ initialValues }: CurrencyFormProps) => {<DrawerBody><Hidden name="id" /><VStack spacing={4}>- <Input- name="name"- label="Name"- onChange={(e) => setName(e.target.value)}- />- <Input name="code" label="Code" isReadOnly={isEditing} />- <Input name="symbol" label="Symbol" />+ <Input name="name" label="Name" isReadOnly />+ <Input name="code" label="Code" isReadOnly />+ <Input name="symbol" label="Symbol" isReadOnly /><Numbername="decimalPlaces"label="Decimal Places"@@ -99,9 +90,9 @@ const CurrencyForm = ({ initialValues }: CurrencyFormProps) => {formatOptions={{minimumFractionDigits: decimalPlaces ?? 0,}}- helperText={exchnageRateHelperText}+ helperText={exchangeRateHelperText}/>- <Boolean name="isBaseCurrency" label="Base Currency" />+<CustomFormFields table="currency" /></VStack></DrawerBody>diff --git a/apps/carbon/app/routes/api+/accounting.currencies.ts b/apps/carbon/app/routes/api+/accounting.currencies.tsindex e440ff3b5a..c8b2857403 100644--- a/apps/carbon/app/routes/api+/accounting.currencies.ts+++ b/apps/carbon/app/routes/api+/accounting.currencies.ts@@ -4,7 +4,7 @@ import { json } from "@vercel/remix";import { getCurrenciesList } from "~/modules/accounting";export async function loader({ request }: LoaderFunctionArgs) {- const { client, companyId } = await requirePermissions(request, {});+ const { client } = await requirePermissions(request, {});- return json(await getCurrenciesList(client, companyId));+ return json(await getCurrenciesList(client));}diff --git a/apps/carbon/app/routes/x+/accounting+/currencies.$currencyId.tsx b/apps/carbon/app/routes/x+/accounting+/currencies.$currencyId.tsxindex 34f95c0691..e8c706eda1 100644--- a/apps/carbon/app/routes/x+/accounting+/currencies.$currencyId.tsx+++ b/apps/carbon/app/routes/x+/accounting+/currencies.$currencyId.tsx@@ -81,7 +81,6 @@ export default function EditCurrencysRoute() {symbol: currency?.symbol ?? "",exchangeRate: currency?.exchangeRate ?? 1,decimalPlaces: currency?.decimalPlaces ?? 2,- isBaseCurrency: currency?.isBaseCurrency ?? false,...getCustomFields(currency?.customFields),};diff --git a/apps/carbon/app/routes/x+/accounting+/currencies.new.tsx b/apps/carbon/app/routes/x+/accounting+/currencies.new.tsxindex b588f7c63d..b32736f66a 100644--- a/apps/carbon/app/routes/x+/accounting+/currencies.new.tsx+++ b/apps/carbon/app/routes/x+/accounting+/currencies.new.tsx@@ -71,7 +71,6 @@ export default function NewCurrencyRoute() {code: "",symbol: "",exchangeRate: 1,- isBaseCurrency: false,decimalPlaces: 2,};diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.tsindex 8f95ce00ee..6a101f6a7a 100644--- a/packages/database/src/swagger-docs-schema.ts+++ b/packages/database/src/swagger-docs-schema.ts@@ -7740,6 +7740,87 @@ export default {tags: ["purchaseInvoicePriceChange"],},},+ "/currencies": {+ get: {+ parameters: [+ {+ $ref: "#/parameters/rowFilter.currencies.id",+ },+ {+ $ref: "#/parameters/rowFilter.currencies.code",+ },+ {+ $ref: "#/parameters/rowFilter.currencies.exchangeRate",+ },+ {+ $ref: "#/parameters/rowFilter.currencies.decimalPlaces",+ },+ {+ $ref: "#/parameters/rowFilter.currencies.active",+ },+ {+ $ref: "#/parameters/rowFilter.currencies.companyId",+ },+ {+ $ref: "#/parameters/rowFilter.currencies.createdBy",+ },+ {+ $ref: "#/parameters/rowFilter.currencies.createdAt",+ },+ {+ $ref: "#/parameters/rowFilter.currencies.updatedBy",+ },+ {+ $ref: "#/parameters/rowFilter.currencies.updatedAt",+ },+ {+ $ref: "#/parameters/rowFilter.currencies.customFields",+ },+ {+ $ref: "#/parameters/rowFilter.currencies.name",+ },+ {+ $ref: "#/parameters/rowFilter.currencies.symbol",+ },+ {+ $ref: "#/parameters/select",+ },+ {+ $ref: "#/parameters/order",+ },+ {+ $ref: "#/parameters/range",+ },+ {+ $ref: "#/parameters/rangeUnit",+ },+ {+ $ref: "#/parameters/offset",+ },+ {+ $ref: "#/parameters/limit",+ },+ {+ $ref: "#/parameters/preferCount",+ },+ ],+ responses: {+ "200": {+ description: "OK",+ schema: {+ items: {+ $ref: "#/definitions/currencies",+ },+ type: "array",+ },+ },+ "206": {+ description: "Partial Content",+ },+ },+ tags: ["currencies"],+ },+ },"/shift": {get: {parameters: [@@ -31254,9 +31335,6 @@ export default {{$ref: "#/parameters/rowFilter.currency.decimalPlaces",},- {- $ref: "#/parameters/rowFilter.currency.isBaseCurrency",- },{$ref: "#/parameters/rowFilter.currency.active",},@@ -31349,9 +31427,6 @@ export default {{$ref: "#/parameters/rowFilter.currency.decimalPlaces",},- {- $ref: "#/parameters/rowFilter.currency.isBaseCurrency",- },{$ref: "#/parameters/rowFilter.currency.active",},@@ -31398,9 +31473,6 @@ export default {{$ref: "#/parameters/rowFilter.currency.decimalPlaces",},- {- $ref: "#/parameters/rowFilter.currency.isBaseCurrency",- },{$ref: "#/parameters/rowFilter.currency.active",},@@ -39364,6 +39436,69 @@ export default {},type: "object",},+ currencies: {+ properties: {+ id: {+ description: "Note:\nThis is a Primary Key.<pk/>",+ format: "text",+ type: "string",+ },+ code: {+ description:+ "Note:\nThis is a Foreign Key to `currencyCode.code`.<fk table='currencyCode' column='code'/>",+ format: "text",+ type: "string",+ },+ exchangeRate: {+ format: "numeric",+ type: "number",+ },+ decimalPlaces: {+ format: "integer",+ type: "integer",+ },+ active: {+ format: "boolean",+ type: "boolean",+ },+ companyId: {+ description:+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",+ format: "text",+ type: "string",+ },+ createdBy: {+ format: "text",+ type: "string",+ },+ createdAt: {+ format: "timestamp with time zone",+ type: "string",+ },+ updatedBy: {+ description:+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",+ format: "text",+ type: "string",+ },+ updatedAt: {+ format: "timestamp with time zone",+ type: "string",+ },+ customFields: {+ format: "jsonb",+ },+ name: {+ format: "text",+ type: "string",+ },+ symbol: {+ format: "text",+ type: "string",+ },+ },+ type: "object",+ },shift: {required: ["id",@@ -50334,7 +50469,6 @@ export default {"code","exchangeRate","decimalPlaces",- "isBaseCurrency","active","companyId","createdBy",@@ -50363,11 +50497,6 @@ export default {format: "integer",type: "integer",},- isBaseCurrency: {- default: false,- format: "boolean",- type: "boolean",- },active: {default: true,format: "boolean",@@ -55817,6 +55946,106 @@ export default {in: "query",type: "string",},+ "body.currencies": {+ name: "currencies",+ description: "currencies",+ required: false,+ in: "body",+ schema: {+ $ref: "#/definitions/currencies",+ },+ },+ "rowFilter.currencies.id": {+ name: "id",+ required: false,+ format: "text",+ in: "query",+ type: "string",+ },+ "rowFilter.currencies.code": {+ name: "code",+ required: false,+ format: "text",+ in: "query",+ type: "string",+ },+ "rowFilter.currencies.exchangeRate": {+ name: "exchangeRate",+ required: false,+ format: "numeric",+ in: "query",+ type: "string",+ },+ "rowFilter.currencies.decimalPlaces": {+ name: "decimalPlaces",+ required: false,+ format: "integer",+ in: "query",+ type: "string",+ },+ "rowFilter.currencies.active": {+ name: "active",+ required: false,+ format: "boolean",+ in: "query",+ type: "string",+ },+ "rowFilter.currencies.companyId": {+ name: "companyId",+ required: false,+ format: "text",+ in: "query",+ type: "string",+ },+ "rowFilter.currencies.createdBy": {+ name: "createdBy",+ required: false,+ format: "text",+ in: "query",+ type: "string",+ },+ "rowFilter.currencies.createdAt": {+ name: "createdAt",+ required: false,+ format: "timestamp with time zone",+ in: "query",+ type: "string",+ },+ "rowFilter.currencies.updatedBy": {+ name: "updatedBy",+ required: false,+ format: "text",+ in: "query",+ type: "string",+ },+ "rowFilter.currencies.updatedAt": {+ name: "updatedAt",+ required: false,+ format: "timestamp with time zone",+ in: "query",+ type: "string",+ },+ "rowFilter.currencies.customFields": {+ name: "customFields",+ required: false,+ format: "jsonb",+ in: "query",+ type: "string",+ },+ "rowFilter.currencies.name": {+ name: "name",+ required: false,+ format: "text",+ in: "query",+ type: "string",+ },+ "rowFilter.currencies.symbol": {+ name: "symbol",+ required: false,+ format: "text",+ in: "query",+ type: "string",+ },"body.shift": {name: "shift",description: "shift",@@ -70248,13 +70477,6 @@ export default {in: "query",type: "string",},- "rowFilter.currency.isBaseCurrency": {- name: "isBaseCurrency",- required: false,- format: "boolean",- in: "query",- type: "string",- },"rowFilter.currency.active": {name: "active",required: false,diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex 8bade8aa15..1fb7fe0b07 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -2673,7 +2673,6 @@ export type Database = {decimalPlaces: numberexchangeRate: numberid: string- isBaseCurrency: booleanupdatedAt: string | nullupdatedBy: string | null}@@ -2687,7 +2686,6 @@ export type Database = {decimalPlaces?: numberexchangeRate?: numberid?: string- isBaseCurrency?: booleanupdatedAt?: string | nullupdatedBy?: string | null}@@ -2701,7 +2699,6 @@ export type Database = {decimalPlaces?: numberexchangeRate?: numberid?: string- isBaseCurrency?: booleanupdatedAt?: string | nullupdatedBy?: string | null}@@ -3431,6 +3428,13 @@ export type Database = {referencedRelation: "integrations"referencedColumns: ["companyId"]},+ {+ foreignKeyName: "customerPayment_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "customerPayment_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -6879,6 +6883,13 @@ export type Database = {referencedRelation: "userDefaults"referencedColumns: ["userId"]},+ {+ foreignKeyName: "itemUnitSalePrice_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "itemUnitSalePrice_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -12028,6 +12039,13 @@ export type Database = {referencedRelation: "userDefaults"referencedColumns: ["userId"]},+ {+ foreignKeyName: "purchaseInvoice_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "purchaseInvoice_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -12329,6 +12347,13 @@ export type Database = {referencedRelation: "userDefaults"referencedColumns: ["userId"]},+ {+ foreignKeyName: "purchaseInvoiceLines_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "purchaseInvoiceLines_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -13444,6 +13469,13 @@ export type Database = {updatedBy?: string | null}Relationships: [+ {+ foreignKeyName: "purchaseOrderPayment_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "purchaseOrderPayment_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -13802,6 +13834,13 @@ export type Database = {referencedRelation: "userDefaults"referencedColumns: ["userId"]},+ {+ foreignKeyName: "purchasePayment_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "purchasePayment_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -15510,6 +15549,13 @@ export type Database = {referencedRelation: "integrations"referencedColumns: ["companyId"]},+ {+ foreignKeyName: "quotePayment_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "quotePayment_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -16381,6 +16427,13 @@ export type Database = {referencedRelation: "userDefaults"referencedColumns: ["userId"]},+ {+ foreignKeyName: "salesOrder_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "salesOrder_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -16854,6 +16907,13 @@ export type Database = {referencedRelation: "integrations"referencedColumns: ["companyId"]},+ {+ foreignKeyName: "salesOrderPayment_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "salesOrderPayment_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -19596,6 +19656,13 @@ export type Database = {referencedRelation: "integrations"referencedColumns: ["companyId"]},+ {+ foreignKeyName: "supplierPayment_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "supplierPayment_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -22665,6 +22732,95 @@ export type Database = {},]}+ currencies: {+ Row: {+ active: boolean | null+ code: string | null+ companyId: string | null+ createdAt: string | null+ createdBy: string | null+ customFields: Json | null+ decimalPlaces: number | null+ exchangeRate: number | null+ id: string | null+ name: string | null+ symbol: string | null+ updatedAt: string | null+ updatedBy: string | null+ }+ Relationships: [+ {+ foreignKeyName: "currency_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "company"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "currency_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "companies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "currency_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "customFieldTables"+ referencedColumns: ["companyId"]+ },+ {+ foreignKeyName: "currency_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "integrations"+ referencedColumns: ["companyId"]+ },+ {+ foreignKeyName: "currency_currencyCode_fkey"+ columns: ["code"]+ isOneToOne: false+ referencedRelation: "currencyCode"+ referencedColumns: ["code"]+ },+ {+ foreignKeyName: "currency_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "user"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "currency_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employeeSummary"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "currency_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employees"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "currency_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employeesAcrossCompanies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "currency_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "userDefaults"+ referencedColumns: ["userId"]+ },+ ]+ }customers: {Row: {accountManagerId: string | null@@ -25071,6 +25227,13 @@ export type Database = {referencedRelation: "currency"referencedColumns: ["code", "companyId"]},+ {+ foreignKeyName: "purchaseInvoice_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "purchaseInvoice_invoiceSupplierId_fkey"columns: ["invoiceSupplierId"]@@ -27186,14 +27349,14 @@ export type Database = {Relationships: [{foreignKeyName: "address_countryCode_fkey"- columns: ["paymentCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]},{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["paymentCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]@@ -27380,6 +27543,13 @@ export type Database = {referencedRelation: "currency"referencedColumns: ["code", "companyId"]},+ {+ foreignKeyName: "salesOrder_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "salesOrder_customerContactId_fkey"columns: ["customerContactId"]diff --git a/packages/database/supabase/functions/lib/seed.ts b/packages/database/supabase/functions/lib/seed.tsindex 31b460da45..33c727b35f 100644--- a/packages/database/supabase/functions/lib/seed.ts+++ b/packages/database/supabase/functions/lib/seed.ts@@ -806,826 +806,708 @@ export const currencies = [code: "USD",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "CAD",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "EUR",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "AED",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "AFN",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "ALL",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "AMD",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "ARS",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "AUD",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "AZN",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "BAM",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "BDT",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "BGN",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "BHD",exchangeRate: 1,decimalPlaces: 3,- isBaseCurrency: false,createdBy: "system",},{code: "BIF",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "BND",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "BOB",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "BRL",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "BWP",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "BYN",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "BZD",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "CDF",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "CHF",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "CLP",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "CNY",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "COP",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "CRC",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "CVE",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "CZK",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "DJF",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "DKK",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "DOP",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "DZD",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "EGP",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "ERN",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "ETB",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "GBP",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "GEL",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "GHS",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "GNF",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "GTQ",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "HKD",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "HNL",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "HRK",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "HUF",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "IDR",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "ILS",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "INR",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "IQD",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "IRR",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "ISK",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "JMD",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "JOD",exchangeRate: 1,decimalPlaces: 3,- isBaseCurrency: false,createdBy: "system",},{code: "JPY",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "KES",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "KHR",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "KMF",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "KRW",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "KWD",exchangeRate: 1,decimalPlaces: 3,- isBaseCurrency: false,createdBy: "system",},{code: "KZT",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "LBP",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "LKR",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "LTL",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "LVL",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "LYD",exchangeRate: 1,decimalPlaces: 3,- isBaseCurrency: false,createdBy: "system",},{code: "MAD",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "MDL",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "MGA",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "MKD",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "MMK",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "MOP",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "MUR",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "MXN",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "MYR",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "MZN",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "NAD",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "NGN",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "NIO",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "NOK",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "NPR",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "NZD",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "OMR",exchangeRate: 1,decimalPlaces: 3,- isBaseCurrency: false,createdBy: "system",},{code: "PAB",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "PEN",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "PHP",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "PKR",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "PLN",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "PYG",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "QAR",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "RON",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "RSD",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "RUB",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "RWF",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "SAR",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "SDG",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "SEK",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "SGD",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "SOS",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "SYP",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "THB",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "TND",exchangeRate: 1,decimalPlaces: 3,- isBaseCurrency: false,createdBy: "system",},{code: "TOP",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "TRY",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "TTD",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "TWD",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "TZS",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "UAH",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "UGX",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "UYU",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "UZS",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "VEF",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "VND",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "XAF",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "XOF",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "YER",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "ZAR",exchangeRate: 1,decimalPlaces: 2,- isBaseCurrency: false,createdBy: "system",},{code: "ZMK",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},{code: "ZWL",exchangeRate: 1,decimalPlaces: 0,- isBaseCurrency: false,createdBy: "system",},];diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.tsindex 8bade8aa15..1fb7fe0b07 100644--- a/packages/database/supabase/functions/lib/types.ts+++ b/packages/database/supabase/functions/lib/types.ts@@ -2673,7 +2673,6 @@ export type Database = {decimalPlaces: numberexchangeRate: numberid: string- isBaseCurrency: booleanupdatedAt: string | nullupdatedBy: string | null}@@ -2687,7 +2686,6 @@ export type Database = {decimalPlaces?: numberexchangeRate?: numberid?: string- isBaseCurrency?: booleanupdatedAt?: string | nullupdatedBy?: string | null}@@ -2701,7 +2699,6 @@ export type Database = {decimalPlaces?: numberexchangeRate?: numberid?: string- isBaseCurrency?: booleanupdatedAt?: string | nullupdatedBy?: string | null}@@ -3431,6 +3428,13 @@ export type Database = {referencedRelation: "integrations"referencedColumns: ["companyId"]},+ {+ foreignKeyName: "customerPayment_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "customerPayment_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -6879,6 +6883,13 @@ export type Database = {referencedRelation: "userDefaults"referencedColumns: ["userId"]},+ {+ foreignKeyName: "itemUnitSalePrice_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "itemUnitSalePrice_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -12028,6 +12039,13 @@ export type Database = {referencedRelation: "userDefaults"referencedColumns: ["userId"]},+ {+ foreignKeyName: "purchaseInvoice_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "purchaseInvoice_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -12329,6 +12347,13 @@ export type Database = {referencedRelation: "userDefaults"referencedColumns: ["userId"]},+ {+ foreignKeyName: "purchaseInvoiceLines_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "purchaseInvoiceLines_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -13444,6 +13469,13 @@ export type Database = {updatedBy?: string | null}Relationships: [+ {+ foreignKeyName: "purchaseOrderPayment_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "purchaseOrderPayment_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -13802,6 +13834,13 @@ export type Database = {referencedRelation: "userDefaults"referencedColumns: ["userId"]},+ {+ foreignKeyName: "purchasePayment_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "purchasePayment_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -15510,6 +15549,13 @@ export type Database = {referencedRelation: "integrations"referencedColumns: ["companyId"]},+ {+ foreignKeyName: "quotePayment_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "quotePayment_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -16381,6 +16427,13 @@ export type Database = {referencedRelation: "userDefaults"referencedColumns: ["userId"]},+ {+ foreignKeyName: "salesOrder_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "salesOrder_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -16854,6 +16907,13 @@ export type Database = {referencedRelation: "integrations"referencedColumns: ["companyId"]},+ {+ foreignKeyName: "salesOrderPayment_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "salesOrderPayment_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -19596,6 +19656,13 @@ export type Database = {referencedRelation: "integrations"referencedColumns: ["companyId"]},+ {+ foreignKeyName: "supplierPayment_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "supplierPayment_currencyCode_fkey"columns: ["currencyCode", "companyId"]@@ -22665,6 +22732,95 @@ export type Database = {},]}+ currencies: {+ Row: {+ active: boolean | null+ code: string | null+ companyId: string | null+ createdAt: string | null+ createdBy: string | null+ customFields: Json | null+ decimalPlaces: number | null+ exchangeRate: number | null+ id: string | null+ name: string | null+ symbol: string | null+ updatedAt: string | null+ updatedBy: string | null+ }+ Relationships: [+ {+ foreignKeyName: "currency_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "company"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "currency_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "companies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "currency_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "customFieldTables"+ referencedColumns: ["companyId"]+ },+ {+ foreignKeyName: "currency_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "integrations"+ referencedColumns: ["companyId"]+ },+ {+ foreignKeyName: "currency_currencyCode_fkey"+ columns: ["code"]+ isOneToOne: false+ referencedRelation: "currencyCode"+ referencedColumns: ["code"]+ },+ {+ foreignKeyName: "currency_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "user"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "currency_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employeeSummary"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "currency_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employees"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "currency_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "employeesAcrossCompanies"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "currency_updatedBy_fkey"+ columns: ["updatedBy"]+ isOneToOne: false+ referencedRelation: "userDefaults"+ referencedColumns: ["userId"]+ },+ ]+ }customers: {Row: {accountManagerId: string | null@@ -25071,6 +25227,13 @@ export type Database = {referencedRelation: "currency"referencedColumns: ["code", "companyId"]},+ {+ foreignKeyName: "purchaseInvoice_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "purchaseInvoice_invoiceSupplierId_fkey"columns: ["invoiceSupplierId"]@@ -27186,14 +27349,14 @@ export type Database = {Relationships: [{foreignKeyName: "address_countryCode_fkey"- columns: ["paymentCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]},{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["paymentCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]@@ -27380,6 +27543,13 @@ export type Database = {referencedRelation: "currency"referencedColumns: ["code", "companyId"]},+ {+ foreignKeyName: "salesOrder_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currencies"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "salesOrder_customerContactId_fkey"columns: ["customerContactId"]diff --git a/packages/database/supabase/migrations/20240930183906_currency-codes.sql b/packages/database/supabase/migrations/20240930183906_currency-codes.sqlindex c704449a4a..317be73068 100644--- a/packages/database/supabase/migrations/20240930183906_currency-codes.sql+++ b/packages/database/supabase/migrations/20240930183906_currency-codes.sql@@ -133,9 +133,10 @@ ALTER TABLE "currency" ADD CONSTRAINT "currency_currencyCode_fkey"FOREIGN KEY ("code") REFERENCES "currencyCode"("code")ON DELETE SET NULL ON UPDATE CASCADE;--- Drop the name and symbol columns from the currency table+-- Drop the name, symbol, and isBaseCurrency columns from the currency tableALTER TABLE "currency" DROP COLUMN "name";ALTER TABLE "currency" DROP COLUMN "symbol";+ALTER TABLE "currency" DROP COLUMN "isBaseCurrency";-- Base currency code-- Add a baseCurrencyCode column to the company table@@ -165,4 +166,11 @@ CREATE OR REPLACE VIEW "companies" WITH(SECURITY_INVOKER=true) ASLEFT JOIN "employee" eON e.id = uc."userId" AND e."companyId" = uc."companyId"LEFT JOIN "employeeType" et- ON et.id = e."employeeTypeId";\ No newline at end of file+ ON et.id = e."employeeTypeId";++-- Create a currencies view with all of the columns from the currency table, joined with the currencyCode table+CREATE OR REPLACE VIEW "currencies" WITH(SECURITY_INVOKER=true) AS+ SELECT c.*, cc."name", cc."symbol"+ FROM "currency" c+ INNER JOIN "currencyCode" cc+ ON cc."code" = c."code";