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: migrations for multi-tenant - batch 16
Brad Barbin346f7aa80841
diff --git a/apps/carbon/app/modules/parts/parts.service.ts b/apps/carbon/app/modules/parts/parts.service.tsindex 10038188d6..4f9bc2e0c9 100644--- a/apps/carbon/app/modules/parts/parts.service.ts+++ b/apps/carbon/app/modules/parts/parts.service.ts@@ -353,6 +353,7 @@ export async function upsertPart(client: SupabaseClient<Database>,part:| (z.infer<typeof partValidator> & {+ companyId: number;createdBy: string;customFields?: Json;})@@ -437,7 +438,7 @@ export async function upsertPartPlanning(})) {if ("createdBy" in partPlanning) {- return client.from("partPlanning").insert({ ...partPlanning, companyId });+ return client.from("partPlanning").insert(partPlanning);}return client.from("partPlanning")diff --git a/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx b/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsxindex 50c6ef2563..3dfc8baa86 100644--- a/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx+++ b/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx@@ -1,5 +1,6 @@import idb from "localforage";import { useEffect } from "react";+import { useUser } from "~/hooks";import { useSupabase } from "~/lib/supabase";import { useCustomers, useParts, usePeople, useSuppliers } from "~/stores";import type { Part } from "~/stores/parts";@@ -10,6 +11,9 @@ let hydratedFromServer = false;const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {const { supabase, accessToken } = useSupabase();+ const {+ company: { id: companyId },+ } = useUser();const [, setParts] = useParts();const [, setSuppliers] = useSuppliers();@@ -41,12 +45,25 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {supabase.from("part").select("id, name, replenishmentSystem")+ .eq("companyId", companyId).eq("active", true).eq("blocked", false).order("name"),- supabase.from("supplier").select("id, name").order("name"),- supabase.from("customer").select("id, name").order("name"),- supabase.from("employees").select("id, name, avatarUrl").order("name"),+ supabase+ .from("supplier")+ .select("id, name")+ .eq("companyId", companyId)+ .order("name"),+ supabase+ .from("customer")+ .select("id, name")+ .eq("companyId", companyId)+ .order("name"),+ supabase+ .from("employees")+ .select("id, name, avatarUrl")+ .eq("companyId", companyId)+ .order("name"),]);if (parts.error || suppliers.error || customers.error || people.error) {@@ -63,6 +80,7 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {};useEffect(() => {+ if (!companyId) return;hydrate();if (!supabase || !accessToken) return;@@ -77,6 +95,8 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {table: "part",},(payload) => {+ if ("companyId" in payload.new && payload.new.companyId !== companyId)+ return;switch (payload.eventType) {case "INSERT":const { new: inserted } = payload;@@ -125,6 +145,8 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {table: "customer",},(payload) => {+ if ("companyId" in payload.new && payload.new.companyId !== companyId)+ return;switch (payload.eventType) {case "INSERT":const { new: inserted } = payload;@@ -173,9 +195,12 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {table: "supplier",},(payload) => {+ if ("companyId" in payload.new && payload.new.companyId !== companyId)+ return;switch (payload.eventType) {case "INSERT":const { new: inserted } = payload;+setSuppliers((suppliers) =>[...suppliers,@@ -221,12 +246,15 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {table: "employee",},async (payload) => {+ if ("companyId" in payload.new && payload.new.companyId !== companyId)+ return;// TODO: there's a cleaner way of doing this, but since customers and suppliers// are also in the users table, we can't automatically add/update/delete them// from our list of employees. So for now we just refetch.const { data } = await supabase.from("employees").select("id, name, avatarUrl")+ .eq("companyId", companyId).order("name");if (data) {// @ts-ignore@@ -240,7 +268,7 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {if (channel) supabase?.removeChannel(channel);};// eslint-disable-next-line react-hooks/exhaustive-deps- }, [supabase, accessToken]);+ }, [supabase, accessToken, companyId]);return <>{children}</>;};diff --git a/apps/carbon/app/routes/onboarding+/company.tsx b/apps/carbon/app/routes/onboarding+/company.tsxindex 30730299fe..762afd46fb 100644--- a/apps/carbon/app/routes/onboarding+/company.tsx+++ b/apps/carbon/app/routes/onboarding+/company.tsx@@ -119,13 +119,16 @@ export async function action({ request }: ActionFunctionArgs) {throw new Error("Fatal: failed to seed company");}- const locationInsert = await upsertLocation(supabaseClient, {- ...data,- name: "Headquarters",- companyId,- timezone: getLocalTimeZone(),- createdBy: userId,- });+ // TODO: move all of this to transaction+ const [locationInsert] = await Promise.all([+ upsertLocation(supabaseClient, {+ ...data,+ name: "Headquarters",+ companyId,+ timezone: getLocalTimeZone(),+ createdBy: userId,+ }),+ ]);if (locationInsert.error) {logger.error(locationInsert.error);diff --git a/apps/carbon/app/routes/x+/part+/new.tsx b/apps/carbon/app/routes/x+/part+/new.tsxindex 1e94ac8c24..fba346901c 100644--- a/apps/carbon/app/routes/x+/part+/new.tsx+++ b/apps/carbon/app/routes/x+/part+/new.tsx@@ -11,7 +11,7 @@ import { error } from "~/utils/result";export async function action({ request }: ActionFunctionArgs) {assertIsPost(request);- const { client, userId } = await requirePermissions(request, {+ const { client, companyId, userId } = await requirePermissions(request, {create: "parts",});@@ -27,6 +27,7 @@ export async function action({ request }: ActionFunctionArgs) {const createPart = await upsertPart(client, {...validation.data,active: true,+ companyId,customFields: setCustomFields(formData),createdBy: userId,});diff --git a/packages/database/src/seed.ts b/packages/database/src/seed.tsindex fb2369d612..867ad88d3f 100644--- a/packages/database/src/seed.ts+++ b/packages/database/src/seed.ts@@ -46,6 +46,7 @@ const getUserId = async (): Promise<string> => {};async function seed() {+ // TODO: this should all be moved to the migration or seed functionconst id = await getUserId();const upsertAdmin = await supabaseAdmin.from("user").upsert([diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex 32665fcdae..4e795e423c 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -3118,24 +3118,35 @@ export type Database = {}customFieldTable: {Row: {+ companyId: numberid: stringmodule: Database["public"]["Enums"]["module"]name: stringtable: string}Insert: {+ companyId: numberid?: stringmodule: Database["public"]["Enums"]["module"]name: stringtable: string}Update: {+ companyId?: numberid?: stringmodule?: Database["public"]["Enums"]["module"]name?: stringtable?: string}- Relationships: []+ Relationships: [+ {+ foreignKeyName: "customFieldTable_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "company"+ referencedColumns: ["id"]+ },+ ]}department: {Row: {@@ -11290,6 +11301,7 @@ export type Database = {companyId: numbercreatedAt: stringcreatedBy: string+ currencyCode: stringcustomerContactId: string | nullcustomerId: stringcustomerLocationId: string | null@@ -11312,6 +11324,7 @@ export type Database = {companyId: numbercreatedAt?: stringcreatedBy: string+ currencyCode?: stringcustomerContactId?: string | nullcustomerId: stringcustomerLocationId?: string | null@@ -11334,6 +11347,7 @@ export type Database = {companyId?: numbercreatedAt?: stringcreatedBy?: string+ currencyCode?: stringcustomerContactId?: string | nullcustomerId?: stringcustomerLocationId?: string | null@@ -11441,6 +11455,13 @@ export type Database = {referencedRelation: "userDefaults"referencedColumns: ["userId"]},+ {+ foreignKeyName: "salesOrder_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currency"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "salesOrder_customerContactId_fkey"columns: ["customerContactId"]@@ -15925,10 +15946,19 @@ export type Database = {employees: {Row: {avatarUrl: string | null+ companyId: number | nullid: string | nullname: string | null}- Relationships: []+ Relationships: [+ {+ foreignKeyName: "employee_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "company"+ referencedColumns: ["id"]+ },+ ]}employeeSummary: {Row: {@@ -17908,6 +17938,7 @@ export type Database = {createdBy: string | nullcreatedByAvatar: string | nullcreatedByFullName: string | null+ currencyCode: string | nullcustomerContactId: string | nullcustomerId: string | nullcustomerLocationId: string | null@@ -18027,6 +18058,13 @@ export type Database = {referencedRelation: "userDefaults"referencedColumns: ["userId"]},+ {+ foreignKeyName: "salesOrder_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currency"+ 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 fdd4719a86..2e16bb9207 100644--- a/packages/database/supabase/functions/lib/seed.ts+++ b/packages/database/supabase/functions/lib/seed.ts@@ -1,2067 +1,2311 @@-export const customerStatuses = [- "Active",- "Inactive",- "Lead",- "On Hold",- "Cancelled",-];--export const supplierStauses = ["Active", "Inactive", "Pending", "Rejected"];+import { Database } from "./types.ts";-export const paymentTerms = [+export const accountCategories: Omit<+ Database["public"]["Tables"]["accountCategory"]["Insert"],+ "companyId"+>[] = [{- name: "Net 15",- daysDue: 15,- calculationMethod: "Net",- daysDiscount: 0,- discountPercentage: 0,+ category: "Bank",+ class: "Asset",+ incomeBalance: "Balance Sheet",createdBy: "system",},{- name: "Net 30",- daysDue: 30,- calculationMethod: "Net",- daysDiscount: 0,- discountPercentage: 0,+ category: "Accounts Receivable",+ class: "Asset",+ incomeBalance: "Balance Sheet",createdBy: "system",},{- name: "Net 60",- daysDue: 60,- calculationMethod: "Net",- daysDiscount: 0,- discountPercentage: 0,+ category: "Inventory",+ class: "Asset",+ incomeBalance: "Balance Sheet",createdBy: "system",},{- name: "1% 10 Net 30",- daysDue: 30,- calculationMethod: "Net",- daysDiscount: 10,- discountPercentage: 1,+ category: "Other Current Asset",+ class: "Asset",+ incomeBalance: "Balance Sheet",createdBy: "system",},{- name: "2% 10 Net 30",- daysDue: 30,- calculationMethod: "Net",- daysDiscount: 10,- discountPercentage: 2,+ category: "Fixed Asset",+ class: "Asset",+ incomeBalance: "Balance Sheet",createdBy: "system",},{- name: "COD",- daysDue: 0,- calculationMethod: "Net",- daysDiscount: 0,- discountPercentage: 0,+ category: "Accumulated Depreciation",+ class: "Asset",+ incomeBalance: "Balance Sheet",createdBy: "system",},{- name: "Net EOM 10th",- daysDue: 10,- calculationMethod: "End of Month",- daysDiscount: 0,- discountPercentage: 0,+ category: "Other Asset",+ class: "Asset",+ incomeBalance: "Balance Sheet",createdBy: "system",},-];--export const unitOfMeasures = [{- name: "Each",- code: "EA",+ category: "Accounts Payable",+ class: "Liability",+ incomeBalance: "Balance Sheet",createdBy: "system",},{- name: "Case",- code: "CS",+ category: "Other Current Liability",+ class: "Liability",+ incomeBalance: "Balance Sheet",createdBy: "system",},{- name: "Pack",- code: "PK",+ category: "Long Term Liability",+ class: "Liability",+ incomeBalance: "Balance Sheet",createdBy: "system",},{- name: "Pallet",- code: "PL",+ category: "Equity - No Close",+ class: "Equity",+ incomeBalance: "Balance Sheet",createdBy: "system",},{- name: "Roll",- code: "RL",+ category: "Equity - Close",+ class: "Equity",+ incomeBalance: "Balance Sheet",createdBy: "system",},{- name: "Box",- code: "BX",+ category: "Retained Earnings",+ class: "Equity",+ incomeBalance: "Balance Sheet",createdBy: "system",},{- name: "Bag",- code: "BG",+ category: "Income",+ class: "Revenue",+ incomeBalance: "Income Statement",createdBy: "system",},{- name: "Drum",- code: "DR",+ category: "Cost of Goods Sold",+ class: "Expense",+ incomeBalance: "Income Statement",createdBy: "system",},{- name: "Gallon",- code: "GL",+ category: "Expense",+ class: "Expense",+ incomeBalance: "Income Statement",createdBy: "system",},{- name: "Liter",- code: "LT",+ category: "Other Income",+ class: "Expense",+ incomeBalance: "Income Statement",createdBy: "system",},{- name: "Ounce",- code: "OZ",+ category: "Other Expense",+ class: "Expense",+ incomeBalance: "Income Statement",createdBy: "system",},+];++export const accounts: (Omit<+ Database["public"]["Tables"]["account"]["Insert"],+ "companyId" | "accountCategoryId"+> & { accountCategory: string | null })[] = [{- name: "Pound",- code: "LB",+ number: "10000",+ name: "Income Statement",+ type: "Begin Total",+ accountCategory: "Income",+ incomeBalance: "Income Statement",+ class: null,+ directPosting: false,createdBy: "system",},{- name: "Ton",- code: "TN",+ number: "11000",+ name: "Revenue",+ type: "Begin Total",+ accountCategory: "Income",+ incomeBalance: "Income Statement",+ class: "Revenue",+ directPosting: false,createdBy: "system",},{- name: "Yard",- code: "YD",+ number: "11210",+ name: "Sales",+ type: "Posting",+ accountCategory: "Income",+ incomeBalance: "Income Statement",+ class: "Revenue",+ directPosting: true,createdBy: "system",},{- name: "Meter",- code: "MT",+ number: "11600",+ name: "Sales Discounts",+ type: "Posting",+ accountCategory: "Income",+ incomeBalance: "Income Statement",+ class: "Revenue",+ directPosting: true,createdBy: "system",},-];--export const sequences = [{- table: "purchaseOrder",- name: "Purchase Order",- prefix: "PO",- suffix: null,- next: 0,- size: 6,- step: 1,+ number: "19999",+ name: "Revenue, Total",+ type: "End Total",+ accountCategory: "Income",+ incomeBalance: "Income Statement",+ class: "Revenue",+ directPosting: false,+ createdBy: "system",},{- table: "purchaseInvoice",- name: "Purchase Invoice",- prefix: "AP",- suffix: null,- next: 0,- size: 6,- step: 1,+ number: "20000",+ name: "Costs of Goods Sold",+ type: "Begin Total",+ accountCategory: "Cost of Goods Sold",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: false,+ createdBy: "system",},{- table: "receipt",- name: "Receipt",- prefix: "RE",- suffix: null,- next: 0,- size: 6,- step: 1,+ number: "21210",+ name: "Cost of Goods Sold",+ type: "Posting",+ accountCategory: "Cost of Goods Sold",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,+ createdBy: "system",},{- table: "salesOrder",- name: "Sales Order",- prefix: "SO",- suffix: null,- next: 0,- size: 6,- step: 1,+ number: "21410",+ name: "Purchases",+ type: "Posting",+ accountCategory: "Cost of Goods Sold",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,+ createdBy: "system",},{- table: "salesInvoice",- name: "Sales Invoice",- prefix: "AR",- suffix: null,- next: 0,- size: 6,- step: 1,+ number: "21590",+ name: "Direct Cost Applied",+ type: "Posting",+ accountCategory: "Cost of Goods Sold",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,+ createdBy: "system",},{- table: "requestForQuote",- name: "Request For Quote",- prefix: "RFQ",- suffix: null,- next: 0,- size: 6,- step: 1,+ number: "21600",+ name: "Overhead Applied",+ type: "Posting",+ accountCategory: "Cost of Goods Sold",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,+ createdBy: "system",},-];--export const currencies = [{- name: "US Dollar",- code: "USD",- symbol: "$",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "21610",+ name: "Purchase Variance",+ type: "Posting",+ accountCategory: "Cost of Goods Sold",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,createdBy: "system",},{- name: "Canadian Dollar",- code: "CAD",- symbol: "CA$",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "21700",+ name: "Inventory Adjustment",+ type: "Posting",+ accountCategory: "Cost of Goods Sold",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,createdBy: "system",},{- name: "Euro",- code: "EUR",- symbol: "€",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "24999",+ name: "Costs of Goods Sold, Total",+ type: "End Total",+ accountCategory: "Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: false,createdBy: "system",},{- name: "United Arab Emirates Dirham",- code: "AED",- symbol: "AED",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "25000",+ name: "Direct Capacity Cost",+ type: "Begin Total",+ accountCategory: "Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: false,createdBy: "system",},{- name: "Afghan Afghani",- code: "AFN",- symbol: "Af",- exchangeRate: 1,- decimalPlaces: 0,- isBaseCurrency: false,+ number: "25705",+ name: "Material Variance",+ type: "Posting",+ accountCategory: "Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,createdBy: "system",},{- name: "Albanian Lek",- code: "ALL",- symbol: "ALL",- exchangeRate: 1,- decimalPlaces: 0,- isBaseCurrency: false,+ number: "25710",+ name: "Capacity Variance",+ type: "Posting",+ accountCategory: "Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,createdBy: "system",},{- name: "Armenian Dram",- code: "AMD",- symbol: "AMD",- exchangeRate: 1,- decimalPlaces: 0,- isBaseCurrency: false,+ number: "25720",+ name: "Overhead Accounts",+ type: "Posting",+ accountCategory: "Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,createdBy: "system",},{- name: "Argentine Peso",- code: "ARS",- symbol: "AR$",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "47045",+ name: "Maintenance Expense",+ type: "Posting",+ accountCategory: "Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,createdBy: "system",},{- name: "Australian Dollar",- code: "AUD",- symbol: "AU$",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "49999",+ name: "Direct Capacity Cost, Total",+ type: "End Total",+ accountCategory: "Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,createdBy: "system",},{- name: "Azerbaijani Manat",- code: "AZN",- symbol: "man.",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "50000",+ name: "Depreciation of Fixed Assets",+ type: "Begin Total",+ accountCategory: "Other Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: false,createdBy: "system",},{- name: "Bosnia-Herzegovina Convertible Mark",- code: "BAM",- symbol: "KM",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "50015",+ name: "Depreciation Expense",+ type: "Posting",+ accountCategory: "Other Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,createdBy: "system",},{- name: "Bangladeshi Taka",- code: "BDT",- symbol: "Tk",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "50040",+ name: "Gains and Losses on Disposal",+ type: "Posting",+ accountCategory: "Other Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,createdBy: "system",},{- name: "Bulgarian Lev",- code: "BGN",- symbol: "BGN",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "50045",+ name: "Service Charge Account",+ type: "Posting",+ accountCategory: "Other Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,createdBy: "system",},{- name: "Bahraini Dinar",- code: "BHD",- symbol: "BD",- exchangeRate: 1,- decimalPlaces: 3,- isBaseCurrency: false,+ number: "50999",+ name: "Depreciation of Fixed Assets, Total",+ type: "End Total",+ accountCategory: "Other Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: false,createdBy: "system",},{- name: "Burundian Franc",- code: "BIF",- symbol: "FBu",- exchangeRate: 1,- decimalPlaces: 0,- isBaseCurrency: false,+ number: "51000",+ name: "Interest",+ type: "Begin Total",+ accountCategory: "Other Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: false,createdBy: "system",},{- name: "Brunei Dollar",- code: "BND",- symbol: "BN$",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "51110",+ name: "Interest Account",+ type: "Posting",+ accountCategory: "Other Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,createdBy: "system",},{- name: "Bolivian Boliviano",- code: "BOB",- symbol: "Bs",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "51115",+ name: "Supplier Payment Discounts",+ type: "Posting",+ accountCategory: "Other Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,createdBy: "system",},{- name: "Brazilian Real",- code: "BRL",- symbol: "R$",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "51120",+ name: "Customer Payment Discounts",+ type: "Posting",+ accountCategory: "Other Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,createdBy: "system",},{- name: "Botswanan Pula",- code: "BWP",- symbol: "BWP",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "51235",+ name: "Rounding Account",+ type: "Posting",+ accountCategory: "Other Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: true,createdBy: "system",},{- name: "Belarusian Ruble",- code: "BYN",- symbol: "Br",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,- createdBy: "system",- },+ number: "51999",+ name: "Interest, Total",+ type: "End Total",+ accountCategory: "Other Expense",+ incomeBalance: "Income Statement",+ class: "Expense",+ directPosting: false,+ createdBy: "system",+ },{- name: "Belize Dollar",- code: "BZD",- symbol: "BZ$",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "79999",+ name: "Income Statement, Total",+ type: "Total",+ accountCategory: "Income",+ incomeBalance: "Income Statement",+ class: null,+ directPosting: false,createdBy: "system",},{- name: "Congolese Franc",- code: "CDF",- symbol: "CDF",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "80000",+ name: "Balance Sheet",+ type: "Begin Total",+ incomeBalance: "Balance Sheet",+ accountCategory: null,+ directPosting: false,createdBy: "system",},{- name: "Swiss Franc",- code: "CHF",- symbol: "CHF",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "80001",+ name: "Assets",+ type: "Begin Total",+ accountCategory: null,+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: false,createdBy: "system",},{- name: "Chilean Peso",- code: "CLP",- symbol: "CL$",- exchangeRate: 1,- decimalPlaces: 0,- isBaseCurrency: false,+ number: "81000",+ name: "Fixed Assets",+ type: "Begin Total",+ accountCategory: null,+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: false,createdBy: "system",},{- name: "Chinese Yuan",- code: "CNY",- symbol: "CN¥",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "81010",+ name: "Fixed Asset Acquisition Cost",+ type: "Posting",+ accountCategory: "Fixed Asset",+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: true,createdBy: "system",},{- name: "Colombian Peso",- code: "COP",- symbol: "CO$",- exchangeRate: 1,- decimalPlaces: 0,- isBaseCurrency: false,+ number: "81015",+ name: "Fixed Asset Acquisition Cost on Disposal",+ type: "Posting",+ accountCategory: "Fixed Asset",+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: true,createdBy: "system",},{- name: "Costa Rican Colón",- code: "CRC",- symbol: "₡",- exchangeRate: 1,- decimalPlaces: 0,- isBaseCurrency: false,+ number: "81020",+ name: "Accumulated Depreciation",+ type: "Posting",+ accountCategory: "Accumulated Depreciation",+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: true,createdBy: "system",},{- name: "Cape Verdean Escudo",- code: "CVE",- symbol: "CV$",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "81030",+ name: "Fixed Asset Acquisition Depreciation on Disposal",+ type: "Posting",+ accountCategory: "Accumulated Depreciation",+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: true,createdBy: "system",},{- name: "Czech Republic Koruna",- code: "CZK",- symbol: "Kč",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "81999",+ name: "Fixed Assets, Total",+ type: "End Total",+ accountCategory: null,+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: false,createdBy: "system",},{- name: "Djiboutian Franc",- code: "DJF",- symbol: "Fdj",- exchangeRate: 1,- decimalPlaces: 0,- isBaseCurrency: false,+ number: "83000",+ name: "Current Assets",+ type: "Begin Total",+ accountCategory: null,+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: false,createdBy: "system",},{- name: "Danish Krone",- code: "DKK",- symbol: "Dkr",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "83105",+ name: "Inventory",+ type: "Posting",+ accountCategory: "Inventory",+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: true,createdBy: "system",},{- name: "Dominican Peso",- code: "DOP",- symbol: "RD$",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "83120",+ name: "Inventory Interim",+ type: "Posting",+ accountCategory: "Inventory",+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: true,createdBy: "system",},{- name: "Algerian Dinar",- code: "DZD",- symbol: "DA",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "83125",+ name: "Work In Progress (WIP)",+ type: "Posting",+ accountCategory: "Inventory",+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: true,createdBy: "system",},{- name: "Egyptian Pound",- code: "EGP",- symbol: "EGP",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "85005",+ name: "Receivables",+ type: "Posting",+ accountCategory: "Accounts Receivable",+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: true,createdBy: "system",},{- name: "Eritrean Nakfa",- code: "ERN",- symbol: "Nfk",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "85020",+ name: "Inventory Invoiced Not Received",+ type: "Posting",+ accountCategory: "Accounts Receivable",+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: true,createdBy: "system",},{- name: "Ethiopian Birr",- code: "ETB",- symbol: "Br",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "86005",+ name: "Bank - Cash",+ type: "Posting",+ accountCategory: "Bank",+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: true,createdBy: "system",},{- name: "British Pound Sterling",- code: "GBP",- symbol: "£",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "86010",+ name: "Bank - Local Currency",+ type: "Posting",+ accountCategory: "Bank",+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: false,createdBy: "system",},{- name: "Georgian Lari",- code: "GEL",- symbol: "GEL",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "86015",+ name: "Bank - Foreign Currency",+ type: "Posting",+ accountCategory: "Bank",+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: false,createdBy: "system",},{- name: "Ghanaian Cedi",- code: "GHS",- symbol: "GH₵",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "87999",+ name: "Current Assets, Total",+ type: "End Total",+ accountCategory: null,+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: false,createdBy: "system",},{- name: "Guinean Franc",- code: "GNF",- symbol: "FG",- exchangeRate: 1,- decimalPlaces: 0,- isBaseCurrency: false,+ number: "89999",+ name: "Assets, Total",+ type: "End Total",+ accountCategory: null,+ incomeBalance: "Balance Sheet",+ class: "Asset",+ directPosting: false,createdBy: "system",},{- name: "Guatemalan Quetzal",- code: "GTQ",- symbol: "GTQ",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "90000",+ name: "Liabilities",+ type: "Begin Total",+ accountCategory: null,+ incomeBalance: "Balance Sheet",+ class: "Liability",+ directPosting: false,createdBy: "system",},{- name: "Hong Kong Dollar",- code: "HKD",- symbol: "HK$",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "92210",+ name: "Customer Prepayments",+ type: "Posting",+ accountCategory: "Other Current Liability",+ incomeBalance: "Balance Sheet",+ class: "Liability",+ directPosting: true,createdBy: "system",},{- name: "Honduran Lempira",- code: "HNL",- symbol: "HNL",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "93005",+ name: "Payables",+ type: "Posting",+ accountCategory: "Accounts Payable",+ incomeBalance: "Balance Sheet",+ class: "Liability",+ directPosting: true,createdBy: "system",},{- name: "Croatian Kuna",- code: "HRK",- symbol: "kn",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "93010",+ name: "Inventory Received Not Invoiced",+ type: "Posting",+ accountCategory: "Other Current Liability",+ incomeBalance: "Balance Sheet",+ class: "Liability",+ directPosting: true,createdBy: "system",},{- name: "Hungarian Forint",- code: "HUF",- symbol: "Ft",- exchangeRate: 1,- decimalPlaces: 0,- isBaseCurrency: false,+ number: "93110",+ name: "Inventory Shipped Not Invoiced",+ type: "Posting",+ accountCategory: "Other Current Liability",+ incomeBalance: "Balance Sheet",+ class: "Liability",+ directPosting: true,createdBy: "system",},{- name: "Indonesian Rupiah",- code: "IDR",- symbol: "Rp",- exchangeRate: 1,- decimalPlaces: 0,- isBaseCurrency: false,+ number: "94100",+ name: "Sales Tax Payable",+ type: "Posting",+ accountCategory: "Other Current Liability",+ incomeBalance: "Balance Sheet",+ class: "Liability",+ directPosting: true,createdBy: "system",},{- name: "Israeli New Sheqel",- code: "ILS",- symbol: "₪",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "94110",+ name: "Purchase Tax Payable",+ type: "Posting",+ accountCategory: "Other Current Liability",+ incomeBalance: "Balance Sheet",+ class: "Liability",+ directPosting: true,createdBy: "system",},{- name: "Indian Rupee",- code: "INR",- symbol: "Rs",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "94115",+ name: "Reverse Charge Tax Payable",+ type: "Posting",+ accountCategory: "Other Current Liability",+ incomeBalance: "Balance Sheet",+ class: "Liability",+ directPosting: true,createdBy: "system",},{- name: "Iraqi Dinar",- code: "IQD",- symbol: "IQD",- exchangeRate: 1,- decimalPlaces: 0,- isBaseCurrency: false,+ number: "94999",+ name: "Liabilities, Total",+ type: "End Total",+ accountCategory: null,+ incomeBalance: "Balance Sheet",+ class: "Liability",+ directPosting: false,createdBy: "system",},{- name: "Iranian Rial",- code: "IRR",- symbol: "IRR",- exchangeRate: 1,- decimalPlaces: 0,- isBaseCurrency: false,+ number: "95000",+ name: "Equity",+ type: "Begin Total",+ accountCategory: null,+ incomeBalance: "Balance Sheet",+ class: "Equity",+ directPosting: false,createdBy: "system",},{- name: "Icelandic Króna",- code: "ISK",- symbol: "Ikr",- exchangeRate: 1,- decimalPlaces: 0,- isBaseCurrency: false,+ number: "95010",+ name: "Retained Earnings",+ type: "Posting",+ accountCategory: "Retained Earnings",+ incomeBalance: "Balance Sheet",+ class: "Equity",+ directPosting: false,createdBy: "system",},{- name: "Jamaican Dollar",- code: "JMD",- symbol: "J$",- exchangeRate: 1,- decimalPlaces: 2,- isBaseCurrency: false,+ number: "96010",+ name: "Owner Equity",+ type: "Posting",+ accountCategory: "Equity - No Close",+ incomeBalance: "Balance Sheet",+ class: "Equity",+ directPosting: true,createdBy: "system",},{- name: "Jordanian Dinar",- code: "JOD",- symbol: "JD",- exchangeRate: 1,- decimalPlaces: 3,- isBaseCurrency: false,+ number: "96999",+ name: "Equity, Total",+ type: "End Total",+ accountCategory: null,+ incomeBalance: "Balance Sheet",+ class: "Equity",+ directPosting: false,createdBy: "system",},{- name: "Japanese Yen",- code: "JPY",- symbol: "¥",+ number: "99999",+ name: "Balance Sheet, Total",+ type: "Total",+ accountCategory: null,+ incomeBalance: "Balance Sheet",+ class: null,+ directPosting: false,+ createdBy: "system",+ },+];++export const accountDefaults = {+ salesAccount: "11210",+ salesDiscountAccount: "11600",+ costOfGoodsSoldAccount: "21210",+ purchaseAccount: "21410",+ directCostAppliedAccount: "21590",+ overheadCostAppliedAccount: "21600",+ purchaseVarianceAccount: "21610",+ inventoryAdjustmentVarianceAccount: "21700",+ materialVarianceAccount: "25705",+ capacityVarianceAccount: "25710",+ overheadAccount: "25720",+ maintenanceAccount: "47045",+ assetDepreciationExpenseAccount: "50015",+ assetGainsAndLossesAccount: "50040",+ serviceChargeAccount: "50045",+ interestAccount: "51110",+ supplierPaymentDiscountAccount: "51115",+ customerPaymentDiscountAccount: "51120",+ roundingAccount: "51235",+ assetAquisitionCostAccount: "81010",+ assetAquisitionCostOnDisposalAccount: "81015",+ accumulatedDepreciationAccount: "81020",+ accumulatedDepreciationOnDisposalAccount: "81030",+ inventoryAccount: "83105",+ inventoryInterimAccrualAccount: "83120",+ workInProgressAccount: "83125",+ receivablesAccount: "85005",+ inventoryInvoicedNotReceivedAccount: "85020",+ bankCashAccount: "86005",+ bankLocalCurrencyAccount: "86010",+ bankForeignCurrencyAccount: "86015",+ prepaymentAccount: "92210",+ payablesAccount: "93005",+ inventoryReceivedNotInvoicedAccount: "93010",+ inventoryShippedNotInvoicedAccount: "93110",+ salesTaxPayableAccount: "94100",+ purchaseTaxPayableAccount: "94110",+ reverseChargeSalesTaxPayableAccount: "94115",+ retainedEarningsAccount: "95010",+};++export const currencies = [+ {+ name: "US Dollar",+ code: "USD",+ symbol: "$",exchangeRate: 1,- decimalPlaces: 0,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Kenyan Shilling",- code: "KES",- symbol: "Ksh",+ name: "Canadian Dollar",+ code: "CAD",+ symbol: "CA$",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Cambodian Riel",- code: "KHR",- symbol: "KHR",+ name: "Euro",+ code: "EUR",+ symbol: "€",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Comorian Franc",- code: "KMF",- symbol: "CF",+ name: "United Arab Emirates Dirham",+ code: "AED",+ symbol: "AED",exchangeRate: 1,- decimalPlaces: 0,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "South Korean Won",- code: "KRW",- symbol: "₩",+ name: "Afghan Afghani",+ code: "AFN",+ symbol: "Af",exchangeRate: 1,decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Kuwaiti Dinar",- code: "KWD",- symbol: "KD",+ name: "Albanian Lek",+ code: "ALL",+ symbol: "ALL",exchangeRate: 1,- decimalPlaces: 3,+ decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Kazakhstani Tenge",- code: "KZT",- symbol: "KZT",+ name: "Armenian Dram",+ code: "AMD",+ symbol: "AMD",exchangeRate: 1,- decimalPlaces: 2,+ decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Lebanese Pound",- code: "LBP",- symbol: "L.L",+ name: "Argentine Peso",+ code: "ARS",+ symbol: "AR$",exchangeRate: 1,- decimalPlaces: 0,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Sri Lankan Rupee",- code: "LKR",- symbol: "SLRs",+ name: "Australian Dollar",+ code: "AUD",+ symbol: "AU$",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Lithuanian Litas",- code: "LTL",- symbol: "Lt",+ name: "Azerbaijani Manat",+ code: "AZN",+ symbol: "man.",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Latvian Lats",- code: "LVL",- symbol: "Ls",+ name: "Bosnia-Herzegovina Convertible Mark",+ code: "BAM",+ symbol: "KM",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Libyan Dinar",- code: "LYD",- symbol: "LD",+ name: "Bangladeshi Taka",+ code: "BDT",+ symbol: "Tk",exchangeRate: 1,- decimalPlaces: 3,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Moroccan Dirham",- code: "MAD",- symbol: "MAD",+ name: "Bulgarian Lev",+ code: "BGN",+ symbol: "BGN",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Moldovan Leu",- code: "MDL",- symbol: "MDL",+ name: "Bahraini Dinar",+ code: "BHD",+ symbol: "BD",exchangeRate: 1,- decimalPlaces: 2,+ decimalPlaces: 3,isBaseCurrency: false,createdBy: "system",},{- name: "Malagasy Ariary",- code: "MGA",- symbol: "MGA",+ name: "Burundian Franc",+ code: "BIF",+ symbol: "FBu",exchangeRate: 1,decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Macedonian Denar",- code: "MKD",- symbol: "MKD",+ name: "Brunei Dollar",+ code: "BND",+ symbol: "BN$",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Myanma Kyat",- code: "MMK",- symbol: "MMK",+ name: "Bolivian Boliviano",+ code: "BOB",+ symbol: "Bs",exchangeRate: 1,- decimalPlaces: 0,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Macanese Pataca",- code: "MOP",- symbol: "MOP$",+ name: "Brazilian Real",+ code: "BRL",+ symbol: "R$",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Mauritian Rupee",- code: "MUR",- symbol: "MURs",+ name: "Botswanan Pula",+ code: "BWP",+ symbol: "BWP",exchangeRate: 1,- decimalPlaces: 0,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Mexican Peso",- code: "MXN",- symbol: "MX$",+ name: "Belarusian Ruble",+ code: "BYN",+ symbol: "Br",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Malaysian Ringgit",- code: "MYR",- symbol: "RM",+ name: "Belize Dollar",+ code: "BZD",+ symbol: "BZ$",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Mozambican Metical",- code: "MZN",- symbol: "MTn",+ name: "Congolese Franc",+ code: "CDF",+ symbol: "CDF",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Namibian Dollar",- code: "NAD",- symbol: "N$",+ name: "Swiss Franc",+ code: "CHF",+ symbol: "CHF",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Nigerian Naira",- code: "NGN",- symbol: "₦",+ name: "Chilean Peso",+ code: "CLP",+ symbol: "CL$",exchangeRate: 1,- decimalPlaces: 2,+ decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Nicaraguan Córdoba",- code: "NIO",- symbol: "C$",+ name: "Chinese Yuan",+ code: "CNY",+ symbol: "CN¥",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Norwegian Krone",- code: "NOK",- symbol: "Nkr",+ name: "Colombian Peso",+ code: "COP",+ symbol: "CO$",exchangeRate: 1,- decimalPlaces: 2,+ decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Nepalese Rupee",- code: "NPR",- symbol: "NPRs",+ name: "Costa Rican Colón",+ code: "CRC",+ symbol: "₡",exchangeRate: 1,- decimalPlaces: 2,+ decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "New Zealand Dollar",- code: "NZD",- symbol: "NZ$",+ name: "Cape Verdean Escudo",+ code: "CVE",+ symbol: "CV$",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Omani Rial",- code: "OMR",- symbol: "OMR",+ name: "Czech Republic Koruna",+ code: "CZK",+ symbol: "Kč",exchangeRate: 1,- decimalPlaces: 3,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Panamanian Balboa",- code: "PAB",- symbol: "B/.",+ name: "Djiboutian Franc",+ code: "DJF",+ symbol: "Fdj",exchangeRate: 1,- decimalPlaces: 2,+ decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Peruvian Nuevo Sol",- code: "PEN",- symbol: "S/.",+ name: "Danish Krone",+ code: "DKK",+ symbol: "Dkr",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Philippine Peso",- code: "PHP",- symbol: "₱",+ name: "Dominican Peso",+ code: "DOP",+ symbol: "RD$",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Pakistani Rupee",- code: "PKR",- symbol: "PKRs",+ name: "Algerian Dinar",+ code: "DZD",+ symbol: "DA",exchangeRate: 1,- decimalPlaces: 0,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Polish Zloty",- code: "PLN",- symbol: "zł",+ name: "Egyptian Pound",+ code: "EGP",+ symbol: "EGP",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Paraguayan Guarani",- code: "PYG",- symbol: "₲",+ name: "Eritrean Nakfa",+ code: "ERN",+ symbol: "Nfk",exchangeRate: 1,- decimalPlaces: 0,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Qatari Rial",- code: "QAR",- symbol: "QR",+ name: "Ethiopian Birr",+ code: "ETB",+ symbol: "Br",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Romanian Leu",- code: "RON",- symbol: "RON",+ name: "British Pound Sterling",+ code: "GBP",+ symbol: "£",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Serbian Dinar",- code: "RSD",- symbol: "din.",+ name: "Georgian Lari",+ code: "GEL",+ symbol: "GEL",exchangeRate: 1,- decimalPlaces: 0,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Russian Ruble",- code: "RUB",- symbol: "RUB",+ name: "Ghanaian Cedi",+ code: "GHS",+ symbol: "GH₵",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Rwandan Franc",- code: "RWF",- symbol: "RWF",+ name: "Guinean Franc",+ code: "GNF",+ symbol: "FG",exchangeRate: 1,decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Saudi Riyal",- code: "SAR",- symbol: "SR",+ name: "Guatemalan Quetzal",+ code: "GTQ",+ symbol: "GTQ",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Sudanese Pound",- code: "SDG",- symbol: "SDG",+ name: "Hong Kong Dollar",+ code: "HKD",+ symbol: "HK$",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Swedish Krona",- code: "SEK",- symbol: "Skr",+ name: "Honduran Lempira",+ code: "HNL",+ symbol: "HNL",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Singapore Dollar",- code: "SGD",- symbol: "S$",+ name: "Croatian Kuna",+ code: "HRK",+ symbol: "kn",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Somali Shilling",- code: "SOS",- symbol: "Ssh",+ name: "Hungarian Forint",+ code: "HUF",+ symbol: "Ft",exchangeRate: 1,decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Syrian Pound",- code: "SYP",- symbol: "SY£",+ name: "Indonesian Rupiah",+ code: "IDR",+ symbol: "Rp",exchangeRate: 1,decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Thai Baht",- code: "THB",- symbol: "฿",+ name: "Israeli New Sheqel",+ code: "ILS",+ symbol: "₪",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Tunisian Dinar",- code: "TND",- symbol: "DT",+ name: "Indian Rupee",+ code: "INR",+ symbol: "Rs",exchangeRate: 1,- decimalPlaces: 3,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Tongan Paʻanga",- code: "TOP",- symbol: "T$",+ name: "Iraqi Dinar",+ code: "IQD",+ symbol: "IQD",exchangeRate: 1,- decimalPlaces: 2,+ decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Turkish Lira",- code: "TRY",- symbol: "TL",+ name: "Iranian Rial",+ code: "IRR",+ symbol: "IRR",exchangeRate: 1,- decimalPlaces: 2,+ decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Trinidad and Tobago Dollar",- code: "TTD",- symbol: "TT$",+ name: "Icelandic Króna",+ code: "ISK",+ symbol: "Ikr",exchangeRate: 1,- decimalPlaces: 2,+ decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "New Taiwan Dollar",- code: "TWD",- symbol: "NT$",+ name: "Jamaican Dollar",+ code: "JMD",+ symbol: "J$",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Tanzanian Shilling",- code: "TZS",- symbol: "TSh",+ name: "Jordanian Dinar",+ code: "JOD",+ symbol: "JD",+ exchangeRate: 1,+ decimalPlaces: 3,+ isBaseCurrency: false,+ createdBy: "system",+ },+ {+ name: "Japanese Yen",+ code: "JPY",+ symbol: "¥",exchangeRate: 1,decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Ukrainian Hryvnia",- code: "UAH",- symbol: "₴",+ name: "Kenyan Shilling",+ code: "KES",+ symbol: "Ksh",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Ugandan Shilling",- code: "UGX",- symbol: "USh",+ name: "Cambodian Riel",+ code: "KHR",+ symbol: "KHR",exchangeRate: 1,- decimalPlaces: 0,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Uruguayan Peso",- code: "UYU",- symbol: "$U",+ name: "Comorian Franc",+ code: "KMF",+ symbol: "CF",exchangeRate: 1,- decimalPlaces: 2,+ decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Uzbekistan Som",- code: "UZS",- symbol: "UZS",+ name: "South Korean Won",+ code: "KRW",+ symbol: "₩",exchangeRate: 1,decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "Venezuelan Bolívar",- code: "VEF",- symbol: "Bs.F",+ name: "Kuwaiti Dinar",+ code: "KWD",+ symbol: "KD",exchangeRate: 1,- decimalPlaces: 2,+ decimalPlaces: 3,isBaseCurrency: false,createdBy: "system",},{- name: "Vietnamese Dong",- code: "VND",- symbol: "₫",+ name: "Kazakhstani Tenge",+ code: "KZT",+ symbol: "KZT",exchangeRate: 1,- decimalPlaces: 0,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "CFA Franc BEAC",- code: "XAF",- symbol: "FCFA",+ name: "Lebanese Pound",+ code: "LBP",+ symbol: "L.L",exchangeRate: 1,decimalPlaces: 0,isBaseCurrency: false,createdBy: "system",},{- name: "CFA Franc BCEAO",- code: "XOF",- symbol: "CFA",+ name: "Sri Lankan Rupee",+ code: "LKR",+ symbol: "SLRs",exchangeRate: 1,- decimalPlaces: 0,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Yemeni Rial",- code: "YER",- symbol: "YR",+ name: "Lithuanian Litas",+ code: "LTL",+ symbol: "Lt",exchangeRate: 1,- decimalPlaces: 0,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "South African Rand",- code: "ZAR",- symbol: "R",+ name: "Latvian Lats",+ code: "LVL",+ symbol: "Ls",exchangeRate: 1,decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},{- name: "Zambian Kwacha",- code: "ZMK",- symbol: "ZK",+ name: "Libyan Dinar",+ code: "LYD",+ symbol: "LD",exchangeRate: 1,- decimalPlaces: 0,+ decimalPlaces: 3,isBaseCurrency: false,createdBy: "system",},{- name: "Zimbabwean Dollar",- code: "ZWL",- symbol: "ZWL$",+ name: "Moroccan Dirham",+ code: "MAD",+ symbol: "MAD",exchangeRate: 1,- decimalPlaces: 0,+ decimalPlaces: 2,isBaseCurrency: false,createdBy: "system",},-];--export const accountCategories = [{- category: "Bank",- class: "Asset",- incomeBalance: "Balance Sheet",+ name: "Moldovan Leu",+ code: "MDL",+ symbol: "MDL",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- category: "Accounts Receivable",- class: "Asset",- incomeBalance: "Balance Sheet",+ name: "Malagasy Ariary",+ code: "MGA",+ symbol: "MGA",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- category: "Inventory",- class: "Asset",- incomeBalance: "Balance Sheet",+ name: "Macedonian Denar",+ code: "MKD",+ symbol: "MKD",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- category: "Other Current Asset",- class: "Asset",- incomeBalance: "Balance Sheet",+ name: "Myanma Kyat",+ code: "MMK",+ symbol: "MMK",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- category: "Fixed Asset",- class: "Asset",- incomeBalance: "Balance Sheet",+ name: "Macanese Pataca",+ code: "MOP",+ symbol: "MOP$",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- category: "Accumulated Depreciation",- class: "Asset",- incomeBalance: "Balance Sheet",+ name: "Mauritian Rupee",+ code: "MUR",+ symbol: "MURs",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- category: "Other Asset",- class: "Asset",- incomeBalance: "Balance Sheet",+ name: "Mexican Peso",+ code: "MXN",+ symbol: "MX$",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- category: "Accounts Payable",- class: "Liability",- incomeBalance: "Balance Sheet",+ name: "Malaysian Ringgit",+ code: "MYR",+ symbol: "RM",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- category: "Other Current Liability",- class: "Liability",- incomeBalance: "Balance Sheet",+ name: "Mozambican Metical",+ code: "MZN",+ symbol: "MTn",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- category: "Long Term Liability",- class: "Liability",- incomeBalance: "Balance Sheet",+ name: "Namibian Dollar",+ code: "NAD",+ symbol: "N$",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- category: "Equity - No Close",- class: "Equity",- incomeBalance: "Balance Sheet",+ name: "Nigerian Naira",+ code: "NGN",+ symbol: "₦",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- category: "Equity - Close",- class: "Equity",- incomeBalance: "Balance Sheet",+ name: "Nicaraguan Córdoba",+ code: "NIO",+ symbol: "C$",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- category: "Retained Earnings",- class: "Equity",- incomeBalance: "Balance Sheet",+ name: "Norwegian Krone",+ code: "NOK",+ symbol: "Nkr",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- category: "Income",- class: "Revenue",- incomeBalance: "Income Statement",+ name: "Nepalese Rupee",+ code: "NPR",+ symbol: "NPRs",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- category: "Cost of Goods Sold",- class: "Expense",- incomeBalance: "Income Statement",+ name: "New Zealand Dollar",+ code: "NZD",+ symbol: "NZ$",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- category: "Expense",- class: "Expense",- incomeBalance: "Income Statement",+ name: "Omani Rial",+ code: "OMR",+ symbol: "OMR",+ exchangeRate: 1,+ decimalPlaces: 3,+ isBaseCurrency: false,createdBy: "system",},{- category: "Other Income",- class: "Expense",- incomeBalance: "Income Statement",+ name: "Panamanian Balboa",+ code: "PAB",+ symbol: "B/.",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- category: "Other Expense",- class: "Expense",- incomeBalance: "Income Statement",+ name: "Peruvian Nuevo Sol",+ code: "PEN",+ symbol: "S/.",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},-];--export const accounts = [{- number: "10000",- name: "Income Statement",- type: "Begin Total",- accountCategory: "Income",- incomeBalance: "Income Statement",- class: null,- directPosting: false,+ name: "Philippine Peso",+ code: "PHP",+ symbol: "₱",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "11000",- name: "Revenue",- type: "Begin Total",- accountCategory: "Income",- incomeBalance: "Income Statement",- class: "Revenue",- directPosting: false,+ name: "Pakistani Rupee",+ code: "PKR",+ symbol: "PKRs",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- number: "11210",- name: "Sales",- type: "Posting",- accountCategory: "Income",- incomeBalance: "Income Statement",- class: "Revenue",- directPosting: true,+ name: "Polish Zloty",+ code: "PLN",+ symbol: "zł",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "11600",- name: "Sales Discounts",- type: "Posting",- accountCategory: "Income",- incomeBalance: "Income Statement",- class: "Revenue",- directPosting: true,+ name: "Paraguayan Guarani",+ code: "PYG",+ symbol: "₲",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- number: "19999",- name: "Revenue, Total",- type: "End Total",- accountCategory: "Income",- incomeBalance: "Income Statement",- class: "Revenue",- directPosting: false,+ name: "Qatari Rial",+ code: "QAR",+ symbol: "QR",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "20000",- name: "Costs of Goods Sold",- type: "Begin Total",- accountCategory: "Cost of Goods Sold",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: false,+ name: "Romanian Leu",+ code: "RON",+ symbol: "RON",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "21210",- name: "Cost of Goods Sold",- type: "Posting",- accountCategory: "Cost of Goods Sold",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Serbian Dinar",+ code: "RSD",+ symbol: "din.",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- number: "21410",- name: "Purchases",- type: "Posting",- accountCategory: "Cost of Goods Sold",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Russian Ruble",+ code: "RUB",+ symbol: "RUB",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "21590",- name: "Direct Cost Applied",- type: "Posting",- accountCategory: "Cost of Goods Sold",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Rwandan Franc",+ code: "RWF",+ symbol: "RWF",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- number: "21600",- name: "Overhead Applied",- type: "Posting",- accountCategory: "Cost of Goods Sold",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Saudi Riyal",+ code: "SAR",+ symbol: "SR",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "21610",- name: "Purchase Variance",- type: "Posting",- accountCategory: "Cost of Goods Sold",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Sudanese Pound",+ code: "SDG",+ symbol: "SDG",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "21700",- name: "Inventory Adjustment",- type: "Posting",- accountCategory: "Cost of Goods Sold",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Swedish Krona",+ code: "SEK",+ symbol: "Skr",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "24999",- name: "Costs of Goods Sold, Total",- type: "End Total",- accountCategory: "Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: false,- createdBy: "system",- },+ name: "Singapore Dollar",+ code: "SGD",+ symbol: "S$",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,+ createdBy: "system",+ },{- number: "25000",- name: "Direct Capacity Cost",- type: "Begin Total",- accountCategory: "Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: false,+ name: "Somali Shilling",+ code: "SOS",+ symbol: "Ssh",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- number: "25705",- name: "Material Variance",- type: "Posting",- accountCategory: "Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Syrian Pound",+ code: "SYP",+ symbol: "SY£",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- number: "25710",- name: "Capacity Variance",- type: "Posting",- accountCategory: "Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Thai Baht",+ code: "THB",+ symbol: "฿",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "25720",- name: "Overhead Accounts",- type: "Posting",- accountCategory: "Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Tunisian Dinar",+ code: "TND",+ symbol: "DT",+ exchangeRate: 1,+ decimalPlaces: 3,+ isBaseCurrency: false,createdBy: "system",},{- number: "47045",- name: "Maintenance Expense",- type: "Posting",- accountCategory: "Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Tongan Paʻanga",+ code: "TOP",+ symbol: "T$",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "49999",- name: "Direct Capacity Cost, Total",- type: "End Total",- accountCategory: "Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Turkish Lira",+ code: "TRY",+ symbol: "TL",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "50000",- name: "Depreciation of Fixed Assets",- type: "Begin Total",- accountCategory: "Other Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: false,+ name: "Trinidad and Tobago Dollar",+ code: "TTD",+ symbol: "TT$",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "50015",- name: "Depreciation Expense",- type: "Posting",- accountCategory: "Other Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "New Taiwan Dollar",+ code: "TWD",+ symbol: "NT$",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "50040",- name: "Gains and Losses on Disposal",- type: "Posting",- accountCategory: "Other Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Tanzanian Shilling",+ code: "TZS",+ symbol: "TSh",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- number: "50045",- name: "Service Charge Account",- type: "Posting",- accountCategory: "Other Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Ukrainian Hryvnia",+ code: "UAH",+ symbol: "₴",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "50999",- name: "Depreciation of Fixed Assets, Total",- type: "End Total",- accountCategory: "Other Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: false,+ name: "Ugandan Shilling",+ code: "UGX",+ symbol: "USh",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- number: "51000",- name: "Interest",- type: "Begin Total",- accountCategory: "Other Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: false,+ name: "Uruguayan Peso",+ code: "UYU",+ symbol: "$U",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "51110",- name: "Interest Account",- type: "Posting",- accountCategory: "Other Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Uzbekistan Som",+ code: "UZS",+ symbol: "UZS",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- number: "51115",- name: "Supplier Payment Discounts",- type: "Posting",- accountCategory: "Other Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Venezuelan Bolívar",+ code: "VEF",+ symbol: "Bs.F",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "51120",- name: "Customer Payment Discounts",- type: "Posting",- accountCategory: "Other Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "Vietnamese Dong",+ code: "VND",+ symbol: "₫",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- number: "51235",- name: "Rounding Account",- type: "Posting",- accountCategory: "Other Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: true,+ name: "CFA Franc BEAC",+ code: "XAF",+ symbol: "FCFA",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- number: "51999",- name: "Interest, Total",- type: "End Total",- accountCategory: "Other Expense",- incomeBalance: "Income Statement",- class: "Expense",- directPosting: false,+ name: "CFA Franc BCEAO",+ code: "XOF",+ symbol: "CFA",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- number: "79999",- name: "Income Statement, Total",- type: "Total",- accountCategory: "Income",- incomeBalance: "Income Statement",- class: null,- directPosting: false,+ name: "Yemeni Rial",+ code: "YER",+ symbol: "YR",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- number: "80000",- name: "Balance Sheet",- type: "Begin Total",- incomeBalance: "Balance Sheet",- accountCategory: null,- directPosting: false,+ name: "South African Rand",+ code: "ZAR",+ symbol: "R",+ exchangeRate: 1,+ decimalPlaces: 2,+ isBaseCurrency: false,createdBy: "system",},{- number: "80001",- name: "Assets",- type: "Begin Total",- accountCategory: null,- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: false,+ name: "Zambian Kwacha",+ code: "ZMK",+ symbol: "ZK",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},{- number: "81000",- name: "Fixed Assets",- type: "Begin Total",- accountCategory: null,- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: false,+ name: "Zimbabwean Dollar",+ code: "ZWL",+ symbol: "ZWL$",+ exchangeRate: 1,+ decimalPlaces: 0,+ isBaseCurrency: false,createdBy: "system",},+];++export const customFields: Omit<+ Database["public"]["Tables"]["customFieldTable"]["Insert"],+ "companyId"+>[] = [{- number: "81010",- name: "Fixed Asset Acquisition Cost",- type: "Posting",- accountCategory: "Fixed Asset",- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: true,- createdBy: "system",+ table: "account",+ name: "Account",+ module: "Accounting",},{- number: "81015",- name: "Fixed Asset Acquisition Cost on Disposal",- type: "Posting",- accountCategory: "Fixed Asset",- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: true,- createdBy: "system",+ table: "accountCategory",+ name: "Account Category",+ module: "Accounting",},{- number: "81020",- name: "Accumulated Depreciation",- type: "Posting",- accountCategory: "Accumulated Depreciation",- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: true,- createdBy: "system",+ table: "accountSubcategory",+ name: "Account Subcategory",+ module: "Accounting",},{- number: "81030",- name: "Fixed Asset Acquisition Depreciation on Disposal",- type: "Posting",- accountCategory: "Accumulated Depreciation",- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: true,- createdBy: "system",+ table: "contractor",+ name: "Contractor",+ module: "Resources",},{- number: "81999",- name: "Fixed Assets, Total",- type: "End Total",- accountCategory: null,- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: false,- createdBy: "system",+ table: "currency",+ name: "Currency",+ module: "Accounting",},{- number: "83000",- name: "Current Assets",- type: "Begin Total",- accountCategory: null,- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: false,- createdBy: "system",+ table: "customer",+ name: "Customer",+ module: "Sales",},{- number: "83105",- name: "Inventory",- type: "Posting",- accountCategory: "Inventory",- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: true,- createdBy: "system",+ table: "customerContact",+ name: "Customer Contact",+ module: "Sales",},{- number: "83120",- name: "Inventory Interim",- type: "Posting",- accountCategory: "Inventory",- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: true,- createdBy: "system",+ table: "customerLocation",+ name: "Customer Location",+ module: "Sales",},{- number: "83125",- name: "Work In Progress (WIP)",- type: "Posting",- accountCategory: "Inventory",- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: true,- createdBy: "system",+ table: "customerStatus",+ name: "Customer Status",+ module: "Sales",},{- number: "85005",- name: "Receivables",- type: "Posting",- accountCategory: "Accounts Receivable",- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: true,- createdBy: "system",+ table: "customerType",+ name: "Customer Type",+ module: "Sales",},{- number: "85020",- name: "Inventory Invoiced Not Received",- type: "Posting",- accountCategory: "Accounts Receivable",- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: true,- createdBy: "system",+ table: "department",+ name: "Department",+ module: "Resources",},{- number: "86005",- name: "Bank - Cash",- type: "Posting",- accountCategory: "Bank",- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: true,- createdBy: "system",+ table: "employeeJob",+ name: "Employee Job",+ module: "Resources",},{- number: "86010",- name: "Bank - Local Currency",- type: "Posting",- accountCategory: "Bank",- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: false,- createdBy: "system",+ table: "equipment",+ name: "Equipment",+ module: "Resources",},{- number: "86015",- name: "Bank - Foreign Currency",- type: "Posting",- accountCategory: "Bank",- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: false,- createdBy: "system",+ table: "equipmentType",+ name: "Equipment Type",+ module: "Resources",},{- number: "87999",- name: "Current Assets, Total",- type: "End Total",- accountCategory: null,- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: false,- createdBy: "system",+ table: "holiday",+ name: "Holiday",+ module: "Resources",},{- number: "89999",- name: "Assets, Total",- type: "End Total",- accountCategory: null,- incomeBalance: "Balance Sheet",- class: "Asset",- directPosting: false,- createdBy: "system",+ table: "journal",+ name: "Journal",+ module: "Accounting",},{- number: "90000",- name: "Liabilities",- type: "Begin Total",- accountCategory: null,- incomeBalance: "Balance Sheet",- class: "Liability",- directPosting: false,- createdBy: "system",+ table: "journalLine",+ name: "Journal Line",+ module: "Accounting",},{- number: "92210",- name: "Customer Prepayments",- type: "Posting",- accountCategory: "Other Current Liability",- incomeBalance: "Balance Sheet",- class: "Liability",- directPosting: true,- createdBy: "system",+ table: "location",+ name: "Location",+ module: "Resources",},{- number: "93005",- name: "Payables",- type: "Posting",- accountCategory: "Accounts Payable",- incomeBalance: "Balance Sheet",- class: "Liability",- directPosting: true,- createdBy: "system",+ table: "part",+ name: "Part",+ module: "Parts",},{- number: "93010",- name: "Inventory Received Not Invoiced",- type: "Posting",- accountCategory: "Other Current Liability",- incomeBalance: "Balance Sheet",- class: "Liability",- directPosting: true,- createdBy: "system",+ table: "partCost",+ name: "Part Cost",+ module: "Parts",},{- number: "93110",- name: "Inventory Shipped Not Invoiced",- type: "Posting",- accountCategory: "Other Current Liability",- incomeBalance: "Balance Sheet",- class: "Liability",- directPosting: true,- createdBy: "system",+ table: "partGroup",+ name: "Part Group",+ module: "Parts",},{- number: "94100",- name: "Sales Tax Payable",- type: "Posting",- accountCategory: "Other Current Liability",- incomeBalance: "Balance Sheet",- class: "Liability",- directPosting: true,- createdBy: "system",+ table: "partInventory",+ name: "Part Inventory",+ module: "Parts",},{- number: "94110",- name: "Purchase Tax Payable",- type: "Posting",- accountCategory: "Other Current Liability",- incomeBalance: "Balance Sheet",- class: "Liability",- directPosting: true,- createdBy: "system",+ table: "partPlanning",+ name: "Part Planning",+ module: "Parts",},{- number: "94115",- name: "Reverse Charge Tax Payable",- type: "Posting",- accountCategory: "Other Current Liability",- incomeBalance: "Balance Sheet",- class: "Liability",- directPosting: true,+ table: "partReplenishment",+ name: "Part Replenishment",+ module: "Parts",+ },+ {+ table: "partSupplier",+ name: "Part Supplier",+ module: "Parts",+ },+ {+ table: "partUnitSalePrice",+ name: "Part Unit Sale Price",+ module: "Parts",+ },+ {+ table: "partner",+ name: "Partner",+ module: "Resources",+ },+ {+ table: "paymentTerm",+ name: "Payment Term",+ module: "Accounting",+ },+ {+ table: "purchaseInvoice",+ name: "Purchase Invoice",+ module: "Invoicing",+ },+ {+ table: "purchaseInvoiceLine",+ name: "Purchase Invoice Line",+ module: "Invoicing",+ },+ {+ table: "purchasePayment",+ name: "Purchase Invoice Payment",+ module: "Invoicing",+ },+ {+ table: "purchaseOrder",+ name: "Purchase Order",+ module: "Purchasing",+ },+ {+ table: "purchaseOrderDelivery",+ name: "Purchase Order Delivery",+ module: "Purchasing",+ },+ {+ table: "purchaseOrderLine",+ name: "Purchase Order Line",+ module: "Purchasing",+ },+ {+ table: "purchaseOrderPayment",+ name: "Purchase Order Payment",+ module: "Purchasing",+ },+ {+ table: "quote",+ name: "Quote",+ module: "Sales",+ },+ {+ table: "quoteAssembly",+ name: "Quote Assembly",+ module: "Sales",+ },+ {+ table: "quoteLine",+ name: "Quote Line",+ module: "Sales",+ },+ {+ table: "quoteMaterial",+ name: "Quote Material",+ module: "Sales",+ },+ {+ table: "quoteOperation",+ name: "Quote Operation",+ module: "Sales",+ },+ {+ table: "receipt",+ name: "Receipt",+ module: "Inventory",+ },+ {+ table: "requestForQuote",+ name: "RFQ",+ module: "Purchasing",+ },+ {+ table: "requestForQuoteLine",+ name: "RFQ Line",+ module: "Purchasing",+ },+ {+ table: "requestForQuoteSupplier",+ name: "RFQ Supplier",+ module: "Purchasing",+ },+ {+ table: "service",+ name: "Service",+ module: "Parts",+ },+ {+ table: "serviceSupplier",+ name: "Service Supplier",+ module: "Parts",+ },+ {+ table: "shelf",+ name: "Shelf",+ module: "Inventory",+ },+ {+ table: "shift",+ name: "Shift",+ module: "Resources",+ },+ {+ table: "shippingMethod",+ name: "Shipping Method",+ module: "Inventory",+ },+ {+ table: "shippingTerm",+ name: "Shipping Term",+ module: "Accounting",+ },+ {+ table: "supplier",+ name: "Supplier",+ module: "Purchasing",+ },+ {+ table: "supplierContact",+ name: "Supplier Contact",+ module: "Purchasing",+ },+ {+ table: "supplierLocation",+ name: "Supplier Location",+ module: "Purchasing",+ },+ {+ table: "supplierPayment",+ name: "Supplier Payment",+ module: "Purchasing",+ },+ {+ table: "supplierShipping",+ name: "Supplier Shipping",+ module: "Purchasing",+ },+ {+ table: "supplierStatus",+ name: "Supplier Status",+ module: "Purchasing",+ },+ {+ table: "supplierType",+ name: "Supplier Type",+ module: "Purchasing",+ },+ {+ table: "unitOfMeasure",+ name: "Unit of Measure",+ module: "Inventory",+ },+ {+ table: "workCell",+ name: "Work Cell",+ module: "Resources",+ },+ {+ table: "workCellType",+ name: "Work Cell Type",+ module: "Resources",+ },+];++export const customerStatuses = [+ "Active",+ "Inactive",+ "Lead",+ "On Hold",+ "Cancelled",+];++export const fiscalYearSettings: Omit<+ Database["public"]["Tables"]["fiscalYearSettings"]["Insert"],+ "companyId"+> = {+ startMonth: "January",+ taxStartMonth: "January",+ updatedBy: "system",+};++function getDefaultAccount(key: string) {+ if (!(key in accountDefaults))+ throw new Error(`Account default not found for ${key}`);+ // @ts-ignore: we check above+ return accountDefaults[key];+}++export const integrations = [+ {+ id: "exchange-rates-v1",+ title: "Exchange Rates",+ description: "Pulls currency rates from exchange rates API",+ logoPath: "/integrations/exchange-rates.png",+ jsonschema: {+ type: "object",+ properties: {+ apiKey: {+ type: "string",+ },+ },+ required: ["apiKey"],+ },+ },+ {+ id: "resend",+ title: "Resend Emails",+ description: "Sends Transactional Emails with Resend API",+ logoPath: "/integrations/resend.png",+ jsonschema: {+ type: "object",+ properties: {+ apiKey: {+ type: "string",+ },+ },+ required: ["apiKey"],+ },+ },+ // {+ // id: 'google-places-v2',+ // title: 'Google Places',+ // description: 'Autocomplete addresses with Google Places API',+ // logoPath: '/integrations/google-places.png',+ // jsonschema: {+ // type: 'object',+ // properties: {+ // apiKey: {+ // type: 'string',+ // },+ // },+ // required: ['apiKey'],+ // },+ // },+];++export const paymentTerms: Omit<+ Database["public"]["Tables"]["paymentTerm"]["Insert"],+ "companyId"+>[] = [+ {+ name: "Net 15",+ daysDue: 15,+ calculationMethod: "Net",+ daysDiscount: 0,+ discountPercentage: 0,createdBy: "system",},{- number: "94999",- name: "Liabilities, Total",- type: "End Total",- accountCategory: null,- incomeBalance: "Balance Sheet",- class: "Liability",- directPosting: false,+ name: "Net 30",+ daysDue: 30,+ calculationMethod: "Net",+ daysDiscount: 0,+ discountPercentage: 0,createdBy: "system",},{- number: "95000",- name: "Equity",- type: "Begin Total",- accountCategory: null,- incomeBalance: "Balance Sheet",- class: "Equity",- directPosting: false,+ name: "Net 60",+ daysDue: 60,+ calculationMethod: "Net",+ daysDiscount: 0,+ discountPercentage: 0,createdBy: "system",},{- number: "95010",- name: "Retained Earnings",- type: "Posting",- accountCategory: "Retained Earnings",- incomeBalance: "Balance Sheet",- class: "Equity",- directPosting: false,+ name: "1% 10 Net 30",+ daysDue: 30,+ calculationMethod: "Net",+ daysDiscount: 10,+ discountPercentage: 1,createdBy: "system",},{- number: "96010",- name: "Owner Equity",- type: "Posting",- accountCategory: "Equity - No Close",- incomeBalance: "Balance Sheet",- class: "Equity",- directPosting: true,+ name: "2% 10 Net 30",+ daysDue: 30,+ calculationMethod: "Net",+ daysDiscount: 10,+ discountPercentage: 2,createdBy: "system",},{- number: "96999",- name: "Equity, Total",- type: "End Total",- accountCategory: null,- incomeBalance: "Balance Sheet",- class: "Equity",- directPosting: false,+ name: "COD",+ daysDue: 0,+ calculationMethod: "Net",+ daysDiscount: 0,+ discountPercentage: 0,createdBy: "system",},{- number: "99999",- name: "Balance Sheet, Total",- type: "Total",- accountCategory: null,- incomeBalance: "Balance Sheet",- class: null,- directPosting: false,+ name: "Net EOM 10th",+ daysDue: 10,+ calculationMethod: "End of Month",+ daysDiscount: 0,+ discountPercentage: 0,createdBy: "system",},];-export const accountDefaults = {- salesAccount: "11210",- salesDiscountAccount: "11600",- costOfGoodsSoldAccount: "21210",- purchaseAccount: "21410",- directCostAppliedAccount: "21590",- overheadCostAppliedAccount: "21600",- purchaseVarianceAccount: "21610",- inventoryAdjustmentVarianceAccount: "21700",- materialVarianceAccount: "25705",- capacityVarianceAccount: "25710",- overheadAccount: "25720",- maintenanceAccount: "47045",- assetDepreciationExpenseAccount: "50015",- assetGainsAndLossesAccount: "50040",- serviceChargeAccount: "50045",- interestAccount: "51110",- supplierPaymentDiscountAccount: "51115",- customerPaymentDiscountAccount: "51120",- roundingAccount: "51235",- assetAquisitionCostAccount: "81010",- assetAquisitionCostOnDisposalAccount: "81015",- accumulatedDepreciationAccount: "81020",- accumulatedDepreciationOnDisposalAccount: "81030",- inventoryAccount: "83105",- inventoryInterimAccrualAccount: "83120",- workInProgressAccount: "83125",- receivablesAccount: "85005",- inventoryInvoicedNotReceivedAccount: "85020",- bankCashAccount: "86005",- bankLocalCurrencyAccount: "86010",- bankForeignCurrencyAccount: "86015",- prepaymentAccount: "92210",- payablesAccount: "93005",- inventoryReceivedNotInvoicedAccount: "93010",- inventoryShippedNotInvoicedAccount: "93110",- salesTaxPayableAccount: "94100",- purchaseTaxPayableAccount: "94110",- reverseChargeSalesTaxPayableAccount: "94115",- retainedEarningsAccount: "95010",-};-export const postingGroupInventory = {partGroupId: null,locationId: null,@@ -2116,60 +2360,139 @@ export const postingGroupSales = {updatedBy: "system",};-function getDefaultAccount(key: string) {- return accountDefaults[key];-}+export const sequences = [+ {+ table: "purchaseOrder",+ name: "Purchase Order",+ prefix: "PO",+ suffix: null,+ next: 0,+ size: 6,+ step: 1,+ },+ {+ table: "purchaseInvoice",+ name: "Purchase Invoice",+ prefix: "AP",+ suffix: null,+ next: 0,+ size: 6,+ step: 1,+ },+ {+ table: "receipt",+ name: "Receipt",+ prefix: "RE",+ suffix: null,+ next: 0,+ size: 6,+ step: 1,+ },+ {+ table: "salesOrder",+ name: "Sales Order",+ prefix: "SO",+ suffix: null,+ next: 0,+ size: 6,+ step: 1,+ },+ {+ table: "salesInvoice",+ name: "Sales Invoice",+ prefix: "AR",+ suffix: null,+ next: 0,+ size: 6,+ step: 1,+ },+ {+ table: "requestForQuote",+ name: "Request For Quote",+ prefix: "RFQ",+ suffix: null,+ next: 0,+ size: 6,+ step: 1,+ },+];-export const fiscalYearSettings = {- startMonth: "January",- taxStartMonth: "January",- updatedBy: "system",-};+export const supplierStauses = ["Active", "Inactive", "Pending", "Rejected"];-export const integrations = [+export const unitOfMeasures = [{- id: "exchange-rates-v1",- title: "Exchange Rates",- description: "Pulls currency rates from exchange rates API",- logoPath: "/integrations/exchange-rates.png",- jsonschema: {- type: "object",- properties: {- apiKey: {- type: "string",- },- },- required: ["apiKey"],- },+ name: "Each",+ code: "EA",+ createdBy: "system",},{- id: "resend",- title: "Resend Emails",- description: "Sends Transactional Emails with Resend API",- logoPath: "/integrations/resend.png",- jsonschema: {- type: "object",- properties: {- apiKey: {- type: "string",- },- },- required: ["apiKey"],- },+ name: "Case",+ code: "CS",+ createdBy: "system",+ },+ {+ name: "Pack",+ code: "PK",+ createdBy: "system",+ },+ {+ name: "Pallet",+ code: "PL",+ createdBy: "system",+ },+ {+ name: "Roll",+ code: "RL",+ createdBy: "system",+ },+ {+ name: "Box",+ code: "BX",+ createdBy: "system",+ },+ {+ name: "Bag",+ code: "BG",+ createdBy: "system",+ },+ {+ name: "Drum",+ code: "DR",+ createdBy: "system",+ },+ {+ name: "Gallon",+ code: "GL",+ createdBy: "system",+ },+ {+ name: "Liter",+ code: "LT",+ createdBy: "system",+ },+ {+ name: "Ounce",+ code: "OZ",+ createdBy: "system",+ },+ {+ name: "Pound",+ code: "LB",+ createdBy: "system",+ },+ {+ name: "Ton",+ code: "TN",+ createdBy: "system",+ },+ {+ name: "Yard",+ code: "YD",+ createdBy: "system",+ },+ {+ name: "Meter",+ code: "MT",+ createdBy: "system",},- // {- // id: 'google-places-v2',- // title: 'Google Places',- // description: 'Autocomplete addresses with Google Places API',- // logoPath: '/integrations/google-places.png',- // jsonschema: {- // type: 'object',- // properties: {- // apiKey: {- // type: 'string',- // },- // },- // required: ['apiKey'],- // },- // },];diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.tsindex 32665fcdae..4e795e423c 100644--- a/packages/database/supabase/functions/lib/types.ts+++ b/packages/database/supabase/functions/lib/types.ts@@ -3118,24 +3118,35 @@ export type Database = {}customFieldTable: {Row: {+ companyId: numberid: stringmodule: Database["public"]["Enums"]["module"]name: stringtable: string}Insert: {+ companyId: numberid?: stringmodule: Database["public"]["Enums"]["module"]name: stringtable: string}Update: {+ companyId?: numberid?: stringmodule?: Database["public"]["Enums"]["module"]name?: stringtable?: string}- Relationships: []+ Relationships: [+ {+ foreignKeyName: "customFieldTable_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "company"+ referencedColumns: ["id"]+ },+ ]}department: {Row: {@@ -11290,6 +11301,7 @@ export type Database = {companyId: numbercreatedAt: stringcreatedBy: string+ currencyCode: stringcustomerContactId: string | nullcustomerId: stringcustomerLocationId: string | null@@ -11312,6 +11324,7 @@ export type Database = {companyId: numbercreatedAt?: stringcreatedBy: string+ currencyCode?: stringcustomerContactId?: string | nullcustomerId: stringcustomerLocationId?: string | null@@ -11334,6 +11347,7 @@ export type Database = {companyId?: numbercreatedAt?: stringcreatedBy?: string+ currencyCode?: stringcustomerContactId?: string | nullcustomerId?: stringcustomerLocationId?: string | null@@ -11441,6 +11455,13 @@ export type Database = {referencedRelation: "userDefaults"referencedColumns: ["userId"]},+ {+ foreignKeyName: "salesOrder_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currency"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "salesOrder_customerContactId_fkey"columns: ["customerContactId"]@@ -15925,10 +15946,19 @@ export type Database = {employees: {Row: {avatarUrl: string | null+ companyId: number | nullid: string | nullname: string | null}- Relationships: []+ Relationships: [+ {+ foreignKeyName: "employee_companyId_fkey"+ columns: ["companyId"]+ isOneToOne: false+ referencedRelation: "company"+ referencedColumns: ["id"]+ },+ ]}employeeSummary: {Row: {@@ -17908,6 +17938,7 @@ export type Database = {createdBy: string | nullcreatedByAvatar: string | nullcreatedByFullName: string | null+ currencyCode: string | nullcustomerContactId: string | nullcustomerId: string | nullcustomerLocationId: string | null@@ -18027,6 +18058,13 @@ export type Database = {referencedRelation: "userDefaults"referencedColumns: ["userId"]},+ {+ foreignKeyName: "salesOrder_currencyCode_fkey"+ columns: ["currencyCode", "companyId"]+ isOneToOne: false+ referencedRelation: "currency"+ referencedColumns: ["code", "companyId"]+ },{foreignKeyName: "salesOrder_customerContactId_fkey"columns: ["customerContactId"]diff --git a/packages/database/supabase/functions/seed-company/index.ts b/packages/database/supabase/functions/seed-company/index.tsindex c2c8020bf2..3fbd03c34b 100644--- a/packages/database/supabase/functions/seed-company/index.ts+++ b/packages/database/supabase/functions/seed-company/index.ts@@ -7,6 +7,7 @@ import {accountDefaults,accounts,currencies,+ customFields,customerStatuses,fiscalYearSettings,integrations,@@ -18,7 +19,6 @@ import {supplierStauses,unitOfMeasures,} from "../lib/seed.ts";-import { getSupabaseServiceRole } from "../lib/supabase.ts";const pool = getConnectionPool(1);const db = getDatabaseClient<DB>(pool);@@ -27,12 +27,12 @@ serve(async (req: Request) => {if (req.method === "OPTIONS") {return new Response("ok", { headers: corsHeaders });}- const { id: companyId } = await req.json();+ const { id } = await req.json();try {- if (!companyId) throw new Error("Payload is missing id");+ if (!id) throw new Error("Payload is missing id");+ const companyId = Number(id);- const client = getSupabaseServiceRole(req.headers.get("Authorization"));await db.transaction().execute(async (trx) => {// supplier statusawait trx@@ -88,12 +88,16 @@ serve(async (req: Request) => {const accountCategoriesByName = accountCategoriesWithIds.reduce<Record<string, string>>((acc, { id, category }) => {- acc[category] = id;+ if (id && category) {+ acc[category] = id;+ }return acc;}, {});- const getCategoryId = (category: string) =>- accountCategoriesByName[category];+ const getCategoryId = (category: string | null) => {+ if (!category) return null;+ return accountCategoriesByName[category];+ };await trx.insertInto("account")@@ -101,7 +105,7 @@ serve(async (req: Request) => {accounts.map(({ accountCategory, ...a }) => ({...a,companyId,- accountCategoryId: getCategoryId(a.category),+ accountCategoryId: getCategoryId(accountCategory),}))).execute();@@ -140,6 +144,11 @@ serve(async (req: Request) => {.insertInto("integration").values(integrations.map((i) => ({ ...i, companyId }))).execute();++ await trx+ .insertInto("customFieldTable")+ .values(customFields.map((cf) => ({ ...cf, companyId })))+ .execute();});return new Response(diff --git a/packages/database/supabase/migrations/20230123004612_suppliers-and-customers.sql b/packages/database/supabase/migrations/20230123004612_suppliers-and-customers.sqlindex 5f97976475..dc83e9c2c5 100644--- a/packages/database/supabase/migrations/20230123004612_suppliers-and-customers.sql+++ b/packages/database/supabase/migrations/20230123004612_suppliers-and-customers.sql@@ -98,6 +98,7 @@ CREATE TABLE "supplier" ("taxId" TEXT,"accountManagerId" TEXT,"logo" TEXT,+ "assignee" TEXT,"companyId" INTEGER,"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,"createdBy" TEXT,@@ -109,6 +110,7 @@ CREATE TABLE "supplier" (CONSTRAINT "supplier_supplierTypeId_fkey" FOREIGN KEY ("supplierTypeId") REFERENCES "supplierType"("id") ON UPDATE CASCADE ON DELETE SET NULL,CONSTRAINT "supplier_supplierStatusId_fkey" FOREIGN KEY ("supplierStatusId") REFERENCES "supplierStatus"("id") ON UPDATE CASCADE ON DELETE SET NULL,CONSTRAINT "supplier_accountManagerId_fkey" FOREIGN KEY ("accountManagerId") REFERENCES "user"("id") ON UPDATE CASCADE ON DELETE SET NULL,+ CONSTRAINT "supplier_assignee_fkey" FOREIGN KEY ("assignee") REFERENCES "user"("id") ON UPDATE CASCADE ON DELETE SET NULL,CONSTRAINT "supplier_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON UPDATE CASCADE ON DELETE CASCADE,CONSTRAINT "supplier_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON UPDATE CASCADE,CONSTRAINT "supplier_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON UPDATE CASCADE,@@ -208,6 +210,7 @@ CREATE TABLE "customer" ("taxId" TEXT,"accountManagerId" TEXT,"logo" TEXT,+ "assignee" TEXT,"companyId" INTEGER,"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,"createdBy" TEXT,@@ -218,6 +221,7 @@ CREATE TABLE "customer" (CONSTRAINT "customer_pkey" PRIMARY KEY ("id"),CONSTRAINT "customer_customerTypeId_fkey" FOREIGN KEY ("customerTypeId") REFERENCES "customerType"("id") ON UPDATE CASCADE ON DELETE SET NULL,CONSTRAINT "customer_customerStatusId_fkey" FOREIGN KEY ("customerStatusId") REFERENCES "customerStatus"("id") ON UPDATE CASCADE ON DELETE SET NULL,+ CONSTRAINT "customer_assignee_fkey" FOREIGN KEY ("assignee") REFERENCES "user"("id") ON UPDATE CASCADE ON DELETE SET NULL,CONSTRAINT "customer_accountManagerId_fkey" FOREIGN KEY ("accountManagerId") REFERENCES "user"("id") ON UPDATE CASCADE ON DELETE SET NULL,CONSTRAINT "customer_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON UPDATE CASCADE ON DELETE CASCADE,CONSTRAINT "customer_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON UPDATE CASCADE ON DELETE SET NULL,diff --git a/packages/database/supabase/migrations/20230224035103_shifts.sql b/packages/database/supabase/migrations/20230224035103_shifts.sqlindex 2d0c514676..c79cb11114 100644--- a/packages/database/supabase/migrations/20230224035103_shifts.sql+++ b/packages/database/supabase/migrations/20230224035103_shifts.sql@@ -18,7 +18,8 @@ CREATE TABLE "location" ("customFields" JSONB,CONSTRAINT "location_pkey" PRIMARY KEY ("id"),- CONSTRAINT "location_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE+ CONSTRAINT "location_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "location_name_unique" UNIQUE ("name", "companyId"));CREATE INDEX "location_name_idx" ON "location" ("name");diff --git a/packages/database/supabase/migrations/20230315222231_holidays.sql b/packages/database/supabase/migrations/20230315222231_holidays.sqlindex f8f1286cb3..105ab676bc 100644--- a/packages/database/supabase/migrations/20230315222231_holidays.sql+++ b/packages/database/supabase/migrations/20230315222231_holidays.sql@@ -11,7 +11,7 @@ CREATE TABLE "holiday" ("customFields" JSONB,CONSTRAINT "holiday_pkey" PRIMARY KEY ("id"),- CONSTRAINT "uq_holiday_date" UNIQUE ("date"),+ CONSTRAINT "uq_holiday_date" UNIQUE ("date", "companyId"),CONSTRAINT "holiday_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "holiday_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "holiday_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADEdiff --git a/packages/database/supabase/migrations/20230330024715_accounts.sql b/packages/database/supabase/migrations/20230330024715_accounts.sqlindex eb94dbb077..eba8e0d8e1 100644--- a/packages/database/supabase/migrations/20230330024715_accounts.sql+++ b/packages/database/supabase/migrations/20230330024715_accounts.sql@@ -107,7 +107,7 @@ CREATE TABLE "accountCategory" ("customFields" JSONB,CONSTRAINT "accountCategory_pkey" PRIMARY KEY ("id"),- CONSTRAINT "accountCategory_unique_category" UNIQUE ("category"),+ CONSTRAINT "accountCategory_unique_category" UNIQUE ("category", "companyId"),CONSTRAINT "accountCategory_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id"),CONSTRAINT "accountCategory_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),CONSTRAINT "accountCategory_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")@@ -164,7 +164,7 @@ CREATE TABLE "accountSubcategory" ("customFields" JSONB,CONSTRAINT "accountSubcategory_pkey" PRIMARY KEY ("id"),- CONSTRAINT "accountSubcategory_name_key" UNIQUE ("name"),+ CONSTRAINT "accountSubcategory_name_key" UNIQUE ("name", "accountCategoryId"),CONSTRAINT "accountSubcategory_accountCategoryId_fkey" FOREIGN KEY ("accountCategoryId") REFERENCES "accountCategory"("id"),CONSTRAINT "accountSubcategory_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),CONSTRAINT "accountSubcategory_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")diff --git a/packages/database/supabase/migrations/20230330024716_parts.sql b/packages/database/supabase/migrations/20230330024716_parts.sqlindex f605cb4ed5..f0bbfacc95 100644--- a/packages/database/supabase/migrations/20230330024716_parts.sql+++ b/packages/database/supabase/migrations/20230330024716_parts.sql@@ -152,6 +152,7 @@ CREATE TABLE "part" ("approvedBy" TEXT,"fromDate" DATE,"toDate" DATE,+ "assignee" TEXT,"companyId" INTEGER NOT NULL,"createdBy" TEXT NOT NULL,"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),@@ -161,8 +162,9 @@ CREATE TABLE "part" (CONSTRAINT "part_pkey" PRIMARY KEY ("id"),CONSTRAINT "part_unitOfMeasureCode_fkey" FOREIGN KEY ("unitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure"("code", "companyId") ON DELETE SET NULL ON UPDATE CASCADE,- CONSTRAINT "part_partGroupId_fkey" FOREIGN KEY ("partGroupId") REFERENCES "partGroup"("id"),+ CONSTRAINT "part_partGroupId_fkey" FOREIGN KEY ("partGroupId") REFERENCES "partGroup"("id") ON DELETE SET NULL ON UPDATE CASCADE,CONSTRAINT "part_approvedBy_fkey" FOREIGN KEY ("approvedBy") REFERENCES "user"("id"),+ CONSTRAINT "part_assignee_fkey" FOREIGN KEY ("assignee") REFERENCES "user"("id") ON UPDATE CASCADE ON DELETE SET NULL,CONSTRAINT "part_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "part_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),CONSTRAINT "part_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")@@ -208,11 +210,11 @@ CREATE POLICY "Employees with parts_delete can delete parts" ON "part"has_company_permission('parts_delete', "companyId"));-CREATE FUNCTION public.create_part_search_result()+CREATE OR REPLACE FUNCTION public.create_part_search_result()RETURNS TRIGGER AS $$BEGININSERT INTO public.search(name, description, entity, uuid, link, "companyId")- VALUES (new.id, new.id || ' ' || new.name || ' ' || COALESCE(new.description, ''), 'Part', new.id, '/x/part/' || new.id, new."companyId");+ VALUES (new.id, new.name || ' ' || COALESCE(new.description, ''), 'Part', new.id, '/x/part/' || new.id, new."companyId");RETURN new;END;$$ LANGUAGE plpgsql SECURITY DEFINER;@@ -225,28 +227,29 @@ CREATE FUNCTION public.create_part_related_records()RETURNS TRIGGER AS $$BEGININSERT INTO public."partCost"("partId", "costingMethod", "createdBy", "companyId")- VALUES (new.id, 'Standard', new."createdBy", new."companyId");+ VALUES (new.id, 'FIFO', new."createdBy", new."companyId");- INSERT INTO public."partReplenishment"("partId", "companyId", "createdBy", "companyId")- VALUES (new.id, new."companyId", new."createdBy", new."companyId");+ INSERT INTO public."partReplenishment"("partId", "createdBy", "companyId")+ VALUES (new.id, new."createdBy", new."companyId");- INSERT INTO public."partUnitSalePrice"("partId", "companyId", "currencyCode", "createdBy", "companyId")+ INSERT INTO public."partUnitSalePrice"("partId", "currencyCode", "createdBy", "companyId")-- TODO: get default currency- VALUES (new.id, new."companyId", 'USD', new."createdBy", new."companyId");+ VALUES (new.id, 'USD', new."createdBy", new."companyId");RETURN new;END;$$ LANGUAGE plpgsql SECURITY DEFINER;+CREATE TRIGGER create_part_related_recordsAFTER INSERT on public.partFOR EACH ROW EXECUTE PROCEDURE public.create_part_related_records();-CREATE FUNCTION public.update_part_search_result()+CREATE OR REPLACE FUNCTION public.update_part_search_result()RETURNS TRIGGER AS $$BEGINIF (old.name <> new.name OR old.description <> new.description) THEN- UPDATE public.search SET name = new.name, description = new.id || ' ' || new.name || ' ' || COALESCE(new.description, '')+ UPDATE public.search SET name = new.id, description = new.name || ' ' || COALESCE(new.description, '')WHERE entity = 'Part' AND uuid = new.id;END IF;RETURN new;@@ -368,7 +371,7 @@ CREATE TABLE "partSupplier" (CONSTRAINT "partSupplier_id_pkey" PRIMARY KEY ("id"),CONSTRAINT "partSupplier_partId_fkey" FOREIGN KEY ("partId") REFERENCES "part"("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "partSupplier_supplierId_fkey" FOREIGN KEY ("supplierId") REFERENCES "supplier"("id") ON DELETE CASCADE,- CONSTRAINT "partSupplier_part_supplier_unique" UNIQUE ("partId", "supplierId"),+ CONSTRAINT "partSupplier_part_supplier_unique" UNIQUE ("partId", "supplierId", "companyId"),CONSTRAINT "partSupplier_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "partSupplier_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),CONSTRAINT "partSupplier_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")@@ -611,7 +614,7 @@ CREATE TABLE "warehouse" ("updatedAt" TIMESTAMP WITH TIME ZONE,CONSTRAINT "warehouse_pkey" PRIMARY KEY ("id"),- CONSTRAINT "warehouse_name_key" UNIQUE ("name"),+ CONSTRAINT "warehouse_name_key" UNIQUE ("name", "companyId"),CONSTRAINT "warehouse_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location"("id"),CONSTRAINT "warehouse_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id"),CONSTRAINT "warehouse_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),diff --git a/packages/database/supabase/migrations/20230412120726_services.sql b/packages/database/supabase/migrations/20230412120726_services.sqlindex 2a6e1cd3c4..d78c444867 100644--- a/packages/database/supabase/migrations/20230412120726_services.sql+++ b/packages/database/supabase/migrations/20230412120726_services.sql@@ -15,6 +15,7 @@ CREATE TABLE "service" ("approvedBy" TEXT,"fromDate" DATE,"toDate" DATE,+ "assignee" TEXT,"customFields" JSONB,"companyId" INTEGER NOT NULL,"createdBy" TEXT NOT NULL,@@ -23,7 +24,8 @@ CREATE TABLE "service" ("updatedAt" TIMESTAMP WITH TIME ZONE,CONSTRAINT "service_pkey" PRIMARY KEY ("id"),- CONSTRAINT "service_partGroupId_fkey" FOREIGN KEY ("partGroupId") REFERENCES "partGroup"("id"),+ CONSTRAINT "service_partGroupId_fkey" FOREIGN KEY ("partGroupId") REFERENCES "partGroup"("id") ON DELETE SET NULL ON UPDATE CASCADE,+ CONSTRAINT "service_assignee_fkey" FOREIGN KEY ("assignee") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE,CONSTRAINT "service_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id"),CONSTRAINT "service_approvedBy_fkey" FOREIGN KEY ("approvedBy") REFERENCES "user"("id"),CONSTRAINT "service_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),diff --git a/packages/database/supabase/migrations/20230510035345_purchasing.sql b/packages/database/supabase/migrations/20230510035345_purchasing.sqlindex c9317cae2d..5126a8e5f3 100644--- a/packages/database/supabase/migrations/20230510035345_purchasing.sql+++ b/packages/database/supabase/migrations/20230510035345_purchasing.sql@@ -89,7 +89,7 @@ CREATE TABLE "shippingMethod" ("customFields" JSONB,CONSTRAINT "shippingMethod_pkey" PRIMARY KEY ("id"),- CONSTRAINT "shippingMethod_name_key" UNIQUE ("name"),+ CONSTRAINT "shippingMethod_name_key" UNIQUE ("name", "companyId"),CONSTRAINT "shippingMethod_carrierAccountId_fkey" FOREIGN KEY ("carrierAccountId", "companyId") REFERENCES "account" ("number", "companyId") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "shippingMethod_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "shippingMethod_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT,@@ -145,7 +145,7 @@ CREATE TABLE "shippingTerm" ("updatedBy" TEXT,CONSTRAINT "shippingTerm_pkey" PRIMARY KEY ("id"),- CONSTRAINT "shippingTerm_name_key" UNIQUE ("name"),+ CONSTRAINT "shippingTerm_name_key" UNIQUE ("name", "companyId"),CONSTRAINT "shippingTerm_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "shippingTerm_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT,CONSTRAINT "shippingTerm_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT@@ -216,6 +216,7 @@ CREATE TABLE "purchaseOrder" ("supplierLocationId" TEXT,"supplierContactId" TEXT,"supplierReference" TEXT,+ "assignee" TEXT,"companyId" INTEGER NOT NULL,"closedAt" DATE,"closedBy" TEXT,@@ -226,10 +227,11 @@ CREATE TABLE "purchaseOrder" ("updatedBy" TEXT,CONSTRAINT "purchaseOrder_pkey" PRIMARY KEY ("id"),- CONSTRAINT "purchaseOrder_purchaseOrderId_key" UNIQUE ("purchaseOrderId"),+ CONSTRAINT "purchaseOrder_purchaseOrderId_key" UNIQUE ("purchaseOrderId", "companyId"),CONSTRAINT "purchaseOrder_supplierId_fkey" FOREIGN KEY ("supplierId") REFERENCES "supplier" ("id") ON DELETE CASCADE,CONSTRAINT "purchaseOrder_supplierLocationId_fkey" FOREIGN KEY ("supplierLocationId") REFERENCES "supplierLocation" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,CONSTRAINT "purchaseOrder_supplierContactId_fkey" FOREIGN KEY ("supplierContactId") REFERENCES "supplierContact" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,+ CONSTRAINT "purchaseOrder_assignee_fkey" FOREIGN KEY ("assignee") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE,CONSTRAINT "purchaseOrder_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON UPDATE CASCADE ON DELETE CASCADE,CONSTRAINT "purchaseOrder_closedBy_fkey" FOREIGN KEY ("closedBy") REFERENCES "user" ("id") ON DELETE RESTRICT,CONSTRAINT "purchaseOrder_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT,diff --git a/packages/database/supabase/migrations/20230705033432_ledgers.sql b/packages/database/supabase/migrations/20230705033432_ledgers.sqlindex 41b48abe35..40e74a2328 100644--- a/packages/database/supabase/migrations/20230705033432_ledgers.sql+++ b/packages/database/supabase/migrations/20230705033432_ledgers.sql@@ -206,6 +206,9 @@ CREATE TABLE "costLedger" (CONSTRAINT "costLedger_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE CASCADE ON UPDATE CASCADE);+CREATE INDEX "costLedger_partId_idx" ON "costLedger" ("partId");+CREATE INDEX "costLedger_companyId_idx" ON "costLedger" ("companyId");+ALTER TABLE "costLedger" ENABLE ROW LEVEL SECURITY;CREATE POLICY "Employees with accounting_view can view the value ledger" ON "costLedger"diff --git a/packages/database/supabase/migrations/20230728025201_receipts.sql b/packages/database/supabase/migrations/20230728025201_receipts.sqlindex f04e87310a..16541bcd4e 100644--- a/packages/database/supabase/migrations/20230728025201_receipts.sql+++ b/packages/database/supabase/migrations/20230728025201_receipts.sql@@ -29,6 +29,7 @@ CREATE TABLE "receipt" ("status" "receiptStatus" NOT NULL DEFAULT 'Draft',"postingDate" DATE,"invoiced" BOOLEAN DEFAULT FALSE,+ "assignee" TEXT,"companyId" INTEGER NOT NULL,"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),"createdBy" TEXT NOT NULL,@@ -37,9 +38,10 @@ CREATE TABLE "receipt" ("customFields" JSONB,CONSTRAINT "receipt_pkey" PRIMARY KEY ("id"),- CONSTRAINT "receipt_receiptId_key" UNIQUE ("receiptId"),+ CONSTRAINT "receipt_receiptId_key" UNIQUE ("receiptId", "companyId"),CONSTRAINT "receipt_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location" ("id") ON DELETE SET NULL ON UPDATE CASCADE,CONSTRAINT "receipt_supplierId_fkey" FOREIGN KEY ("supplierId") REFERENCES "supplier" ("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "receipt_assignee_fkey" FOREIGN KEY ("assignee") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE,CONSTRAINT "receipt_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "receipt_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,CONSTRAINT "receipt_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADEdiff --git a/packages/database/supabase/migrations/20230924004608_accounts-payable.sql b/packages/database/supabase/migrations/20230924004608_accounts-payable.sqlindex 80a8ca0766..306113f0fb 100644--- a/packages/database/supabase/migrations/20230924004608_accounts-payable.sql+++ b/packages/database/supabase/migrations/20230924004608_accounts-payable.sql@@ -31,6 +31,7 @@ CREATE TABLE "purchaseInvoice" ("totalAmount" NUMERIC(10, 2) NOT NULL DEFAULT 0,"totalTax" NUMERIC(10, 2) NOT NULL DEFAULT 0,"balance" NUMERIC(10, 2) NOT NULL DEFAULT 0,+ "assignee" TEXT,"companyId" INTEGER NOT NULL,"customFields" JSONB,"createdBy" TEXT NOT NULL,@@ -45,6 +46,7 @@ CREATE TABLE "purchaseInvoice" (CONSTRAINT "purchaseInvoice_invoiceSupplierContactId_fkey" FOREIGN KEY ("invoiceSupplierContactId") REFERENCES "supplierContact" ("id"),CONSTRAINT "purchaseInvoice_paymentTermId_fkey" FOREIGN KEY ("paymentTermId") REFERENCES "paymentTerm" ("id"),CONSTRAINT "purchaseInvoice_currencyCode_fkey" FOREIGN KEY ("currencyCode", "companyId") REFERENCES "currency" ("code", "companyId"),+ CONSTRAINT "purchaseInvoice_assignee_fkey" FOREIGN KEY ("assignee") REFERENCES "user" ("id") ON UPDATE CASCADE ON DELETE SET NULL,CONSTRAINT "purchaseInvoice_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "purchaseInvoice_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id"),CONSTRAINT "purchaseInvoice_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id")diff --git a/packages/database/supabase/migrations/20240204025905_rfq.sql b/packages/database/supabase/migrations/20240204025905_rfq.sqlindex 7ed7cc9c20..81c9345a41 100644--- a/packages/database/supabase/migrations/20240204025905_rfq.sql+++ b/packages/database/supabase/migrations/20240204025905_rfq.sql@@ -10,6 +10,7 @@ CREATE TABLE "requestForQuote" ("receiptDate" DATE NOT NULL,"expirationDate" DATE,"locationId" TEXT,+ "assignee" TEXT,"customFields" JSONB,"companyId" INTEGER NOT NULL,"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT now(),@@ -19,6 +20,7 @@ CREATE TABLE "requestForQuote" (CONSTRAINT "requestForQuote_pkey" PRIMARY KEY ("id"),CONSTRAINT "requestForQuote_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location"("id"),+ CONSTRAINT "requestForQuote_assignee_fkey" FOREIGN KEY ("assignee") REFERENCES "user"("id"),CONSTRAINT "requestForQuote_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE RESTRICT ON UPDATE CASCADE,CONSTRAINT "requestForQuote_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON DELETE RESTRICT ON UPDATE CASCADE,CONSTRAINT "requestForQuote_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON DELETE RESTRICT ON UPDATE CASCADEdiff --git a/packages/database/supabase/migrations/20240206224405_quotes.sql b/packages/database/supabase/migrations/20240206224405_quotes.sqlindex 5a7e8767a3..d6d1f0e896 100644--- a/packages/database/supabase/migrations/20240206224405_quotes.sql+++ b/packages/database/supabase/migrations/20240206224405_quotes.sql@@ -26,6 +26,7 @@ CREATE TABLE "quote" ("customerContactId" TEXT,"customerReference" TEXT,"locationId" TEXT,+ "assignee" TEXT,"customFields" JSONB,"companyId" INTEGER NOT NULL,"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),@@ -34,12 +35,13 @@ CREATE TABLE "quote" ("updatedBy" TEXT,CONSTRAINT "quote_pkey" PRIMARY KEY ("id"),- CONSTRAINT "quote_quoteId_key" UNIQUE ("quoteId"),+ CONSTRAINT "quote_quoteId_key" UNIQUE ("quoteId", "companyId"),CONSTRAINT "quote_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,CONSTRAINT "quote_customerId_fkey" FOREIGN KEY ("customerId") REFERENCES "customer" ("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "quote_customerLocationId_fkey" FOREIGN KEY ("customerLocationId") REFERENCES "customerLocation" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,CONSTRAINT "quote_customerContactId_fkey" FOREIGN KEY ("customerContactId") REFERENCES "customerContact" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,CONSTRAINT "quote_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,+ CONSTRAINT "quote_assignee_fkey" FOREIGN KEY ("assignee") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE,CONSTRAINT "quote_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,CONSTRAINT "quote_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,CONSTRAINT "quote_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADEdiff --git a/packages/database/supabase/migrations/20240213043906_quote-rls.sql b/packages/database/supabase/migrations/20240213043906_quote-rls.sqlindex 4dec270d20..ef0fd45b30 100644--- a/packages/database/supabase/migrations/20240213043906_quote-rls.sql+++ b/packages/database/supabase/migrations/20240213043906_quote-rls.sql@@ -302,11 +302,11 @@ CREATE TRIGGER create_quotation_search_resultAFTER INSERT on public."quote"FOR EACH ROW EXECUTE PROCEDURE public.create_quotation_search_result();-CREATE FUNCTION public.update_quotation_search_result()+CREATE OR REPLACE FUNCTION public.update_quotation_search_result()RETURNS TRIGGER AS $$BEGINIF (old."quoteId" <> new."quoteId" OR old."name" <> new."name") THEN- UPDATE public.search SET name = new."quoteId", description = new.description+ UPDATE public.search SET name = new."quoteId", description = new.nameWHERE entity = 'Quotation' AND uuid = new.id;END IF;RETURN new;diff --git a/packages/database/supabase/migrations/20240311021818_custom-fields.sql b/packages/database/supabase/migrations/20240311021818_custom-fields.sqlindex 0c06733c72..bd356340a6 100644--- a/packages/database/supabase/migrations/20240311021818_custom-fields.sql+++ b/packages/database/supabase/migrations/20240311021818_custom-fields.sql@@ -20,9 +20,11 @@ CREATE TABLE "customFieldTable" ("module" module NOT NULL,"table" TEXT NOT NULL,"name" TEXT NOT NULL,+ "companyId" INTEGER NOT NULL,CONSTRAINT "customFieldTable_pkey" PRIMARY KEY ("id"),- CONSTRAINT "customFieldTable_module_table_name_key" UNIQUE ("module", "table", "name")+ CONSTRAINT "customFieldTable_module_table_name_key" UNIQUE ("module", "table", "name", "companyId"),+ CONSTRAINT "customFieldTable_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE);CREATE INDEX "customFieldTable_module_idx" ON "customFieldTable" ("module");diff --git a/packages/database/supabase/migrations/20240323161015_employees-view.sql b/packages/database/supabase/migrations/20240323161015_employees-view.sqlindex 6e4c3b65a5..d889bdd4ca 100644--- a/packages/database/supabase/migrations/20240323161015_employees-view.sql+++ b/packages/database/supabase/migrations/20240323161015_employees-view.sql@@ -2,7 +2,8 @@ CREATE OR REPLACE VIEW "employees" WITH(SECURITY_INVOKER=true) ASSELECTu.id,u."fullName" AS "name",- u."avatarUrl"+ u."avatarUrl",+ e."companyId"FROM "user" uINNER JOIN "employee" eON e.id = u.iddiff --git a/packages/database/supabase/migrations/20240324175747_assignee.sql b/packages/database/supabase/migrations/20240324175747_assignee.sqlindex 4679bdd1ee..501f95a30f 100644--- a/packages/database/supabase/migrations/20240324175747_assignee.sql+++ b/packages/database/supabase/migrations/20240324175747_assignee.sql@@ -1,13 +1,3 @@-ALTER TABLE "customer" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;-ALTER TABLE "part" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;-ALTER TABLE "purchaseOrder" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;-ALTER TABLE "purchaseInvoice" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;-ALTER TABLE "quote" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;-ALTER TABLE "receipt" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;-ALTER TABLE "requestForQuote" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;-ALTER TABLE "service" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;-ALTER TABLE "supplier" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;-DROP VIEW "customers";CREATE OR REPLACE VIEW "customers" WITH(SECURITY_INVOKER=true) ASSELECTdiff --git a/packages/database/supabase/migrations/20240329034816_quote-pricing.sql b/packages/database/supabase/migrations/20240329034816_quote-pricing.sqlindex b0a49a7164..ca8065d32b 100644--- a/packages/database/supabase/migrations/20240329034816_quote-pricing.sql+++ b/packages/database/supabase/migrations/20240329034816_quote-pricing.sql@@ -20,6 +20,8 @@ CREATE TABLE "quoteLinePrice" (CONSTRAINT "quoteLinePrice_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE);+CREATE INDEX "quoteLinePrice_quoteId_idx" ON "quoteLinePrice" ("quoteId");+CREATE OR REPLACE VIEW "quoteLines" WITH(SECURITY_INVOKER=true) AS (SELECTql.*,@@ -31,4 +33,34 @@ CREATE OR REPLACE VIEW "quoteLines" WITH(SECURITY_INVOKER=true) AS (qlp."extendedPrice" AS "pricingExtendedPrice"FROM "quoteLine" qlLEFT JOIN "quoteLinePrice" qlp ON ql."id" = qlp."quoteLineId"-);\ No newline at end of file+);++ALTER TABLE "quoteLinePrice" ENABLE ROW LEVEL SECURITY;++CREATE POLICY "Employees with sales_view can view quote line pricing" ON "quoteLinePrice"+ FOR SELECT+ USING (+ has_role('employee') AND+ has_company_permission('sales_view', (SELECT "companyId" FROM "quote" WHERE "id" = "quoteId"))+ );++CREATE POLICY "Employees with sales_create can insert quote line pricing" ON "quoteLinePrice"+ FOR INSERT+ WITH CHECK (+ has_role('employee') AND+ has_company_permission('sales_create', (SELECT "companyId" FROM "quote" WHERE "id" = "quoteId"))+ );++CREATE POLICY "Employees with sales_update can update quote line pricing" ON "quoteLinePrice"+ FOR UPDATE+ USING (+ has_role('employee') AND+ has_company_permission('sales_update', (SELECT "companyId" FROM "quote" WHERE "id" = "quoteId"))+ );++CREATE POLICY "Employees with sales_delete can delete quote line pricing" ON "quoteLinePrice"+ FOR DELETE+ USING (+ has_role('employee') AND+ has_company_permission('sales_delete', (SELECT "companyId" FROM "quote" WHERE "id" = "quoteId"))+ );diff --git a/packages/database/supabase/migrations/20240411035639_purchased-prices.sql b/packages/database/supabase/migrations/20240411035639_purchased-prices.sqldeleted file mode 100644index a0873d8f5f..0000000000--- a/packages/database/supabase/migrations/20240411035639_purchased-prices.sql+++ /dev/null@@ -1,19 +0,0 @@-CREATE OR REPLACE FUNCTION public.create_part_related_records()-RETURNS TRIGGER AS $$-BEGIN- INSERT INTO public."partCost"("partId", "costingMethod", "createdBy")- VALUES (new.id, 'FIFO', new."createdBy");-- INSERT INTO public."partReplenishment"("partId", "createdBy")- VALUES (new.id, new."createdBy");-- INSERT INTO public."partUnitSalePrice"("partId", "currencyCode", "createdBy")- -- TODO: get default currency- VALUES (new.id, 'USD', new."createdBy");-- RETURN new;-END;-$$ LANGUAGE plpgsql SECURITY DEFINER;---CREATE INDEX "costLedger_partId_idx" ON "costLedger" ("partId");\ No newline at end of filediff --git a/packages/database/supabase/migrations/20240412224648_sales-orders.sql b/packages/database/supabase/migrations/20240412224648_sales-orders.sqlindex 26c4c22d8e..80a153eb95 100644--- a/packages/database/supabase/migrations/20240412224648_sales-orders.sql+++ b/packages/database/supabase/migrations/20240412224648_sales-orders.sql@@ -15,10 +15,13 @@ CREATE TABLE "salesOrder" ("status" "salesOrderStatus" NOT NULL DEFAULT 'Draft',"orderDate" DATE NOT NULL DEFAULT CURRENT_DATE,"notes" TEXT,+ "currencyCode" TEXT NOT NULL DEFAULT 'USD',"customerId" TEXT NOT NULL,"customerLocationId" TEXT,"customerContactId" TEXT,"customerReference" TEXT,+ "quoteId" TEXT,+ "assignee" TEXT,"companyId" INTEGER NOT NULL,"closedAt" DATE,"closedBy" TEXT,@@ -27,21 +30,20 @@ CREATE TABLE "salesOrder" ("createdBy" TEXT NOT NULL,"updatedAt" TIMESTAMP WITH TIME ZONE,"updatedBy" TEXT,- "quoteId" TEXT,- "assignee" TEXT,CONSTRAINT "salesOrder_pkey" PRIMARY KEY ("id"),- CONSTRAINT "salesOrder_salesOrderId_key" UNIQUE ("salesOrderId"),+ CONSTRAINT "salesOrder_salesOrderId_key" UNIQUE ("salesOrderId", "companyId"),CONSTRAINT "salesOrder_customerId_fkey" FOREIGN KEY ("customerId") REFERENCES "customer" ("id") ON DELETE CASCADE,+ CONSTRAINT "salesOrder_currencyCode_fkey" FOREIGN KEY ("currencyCode", "companyId") REFERENCES "currency" ("code", "companyId") ON DELETE RESTRICT,CONSTRAINT "salesOrder_customerLocationId_fkey" FOREIGN KEY ("customerLocationId") REFERENCES "customerLocation" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,CONSTRAINT "salesOrder_customerContactId_fkey" FOREIGN KEY ("customerContactId") REFERENCES "customerContact" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,CONSTRAINT "salesOrder_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote"("id") ON UPDATE CASCADE ON DELETE RESTRICT,+ CONSTRAINT "salesOrder_assignee_fkey" FOREIGN KEY ("assignee") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE,CONSTRAINT "salesOrder_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "salesOrder_closedBy_fkey" FOREIGN KEY ("closedBy") REFERENCES "user" ("id") ON DELETE RESTRICT,CONSTRAINT "salesOrder_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT,- CONSTRAINT "salesOrder_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT,- CONSTRAINT "salesOrder_assignee_fkey" FOREIGN KEY ("assignee") REFERENCES "user" ("id") ON DELETE SET NULL+ CONSTRAINT "salesOrder_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT);CREATE INDEX "salesOrder_salesOrderId_idx" ON "salesOrder" ("salesOrderId", "companyId");@@ -300,35 +302,39 @@ CREATE POLICY "Employees with sales_view, inventory_view, or invoicing_view canFOR SELECTUSING ((- coalesce(get_my_claim('sales_view')::boolean, false) = true OR- coalesce(get_my_claim('inventory_view')::boolean, false) = true OR- coalesce(get_my_claim('invoicing_view')::boolean, false) = true- ) AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ has_company_permission('sales_view', "companyId") OR+ has_company_permission('invoicing_view', "companyId")+ ) AND has_role('employee')+ );CREATE POLICY "Customers with sales_view can their own sales orders" ON "salesOrder"FOR SELECTUSING (- coalesce(get_my_claim('sales_view')::boolean, false) = true- AND (get_my_claim('role'::text)) = '"customer"'::jsonb- AND "customerId" IN (+ has_role('customer') AND+ has_company_permission('sales_view', "companyId") AND+ "customerId" IN (SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()));CREATE POLICY "Employees with sales_create can create sales orders" ON "salesOrder"FOR INSERT- WITH CHECK (coalesce(get_my_claim('sales_create')::boolean,false) AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ WITH CHECK (+ has_company_permission('sales_create', "companyId") AND has_role('employee')+ );CREATE POLICY "Employees with sales_update can update sales orders" ON "salesOrder"FOR UPDATE- USING (coalesce(get_my_claim('sales_update')::boolean,false) AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ USING (+ has_company_permission('sales_update', "companyId") AND has_role('employee')+ );CREATE POLICY "Customers with sales_update can update their own sales orders" ON "salesOrder"FOR UPDATEUSING (- coalesce(get_my_claim('sales_update')::boolean, false) = true- AND (get_my_claim('role'::text)) = '"customer"'::jsonb+ has_role('customer') AND+ has_company_permission('sales_update', "companyId")AND "customerId" IN (SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid())@@ -336,16 +342,18 @@ CREATE POLICY "Customers with sales_update can update their own sales orders" ONCREATE POLICY "Employees with sales_delete can delete sales orders" ON "salesOrder"FOR DELETE- USING (coalesce(get_my_claim('sales_delete')::boolean, false) = true AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ USING (+ has_company_permission('sales_delete', "companyId") AND has_role('employee')+ );CREATE POLICY "Customers with sales_view can search for their own sales orders" ON "search"FOR SELECTUSING (- coalesce(get_my_claim('sales_view')::boolean, false) = true- AND (get_my_claim('role'::text)) = '"customer"'::jsonb- AND entity = 'Sales Order'- AND uuid IN (+ has_role('customer') AND+ has_company_permission('sales_view', "companyId") AND+ entity = 'Sales Order' AND+ uuid IN (SELECT id FROM "salesOrder" WHERE "customerId" IN (SELECT "customerId" FROM "salesOrder" WHERE "customerId" IN (SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()@@ -359,8 +367,8 @@ CREATE POLICY "Customers with sales_view can search for their own sales orders"CREATE FUNCTION public.create_sales_order_search_result()RETURNS TRIGGER AS $$BEGIN- INSERT INTO public.search(name, entity, uuid, link)- VALUES (new."salesOrderId", 'Sales Order', new.id, '/x/sales-order/' || new.id);+ INSERT INTO public.search(name, entity, uuid, link, "companyId")+ VALUES (new."salesOrderId", 'Sales Order', new.id, '/x/sales-order/' || new.id, new."companyId");RETURN new;END;$$ LANGUAGE plpgsql SECURITY DEFINER;@@ -403,7 +411,9 @@ ALTER TABLE "salesOrderStatusHistory" ENABLE ROW LEVEL SECURITY;CREATE POLICY "Anyone with sales_view can view sales order status history" ON "salesOrderStatusHistory"FOR SELECT- USING (coalesce(get_my_claim('sales_view')::boolean, false) = true);+ USING (+ has_company_permission('sales_view', (SELECT "companyId" FROM "salesOrder" WHERE id = "salesOrderId")) AND has_role('employee')+ );-- Sales Order Lines@@ -411,14 +421,17 @@ ALTER TABLE "salesOrderLine" ENABLE ROW LEVEL SECURITY;CREATE POLICY "Employees with sales_view can view sales order lines" ON "salesOrderLine"FOR SELECT- USING (coalesce(get_my_claim('sales_view')::boolean, false) = true AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ USING (+ has_role('employee') AND+ has_company_permission('sales_view', "companyId")+ );CREATE POLICY "Customers with sales_view can their own sales order lines" ON "salesOrderLine"FOR SELECTUSING (- coalesce(get_my_claim('sales_view')::boolean, false) = true- AND (get_my_claim('role'::text)) = '"customer"'::jsonb- AND "salesOrderId" IN (+ has_role('customer') AND+ has_company_permission('sales_view', "companyId") AND+ "salesOrderId" IN (SELECT id FROM "salesOrder" WHERE "customerId" IN (SELECT "customerId" FROM "salesOrder" WHERE "customerId" IN (SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()@@ -429,14 +442,17 @@ CREATE POLICY "Customers with sales_view can their own sales order lines" ON "saCREATE POLICY "Employees with sales_create can create sales order lines" ON "salesOrderLine"FOR INSERT- WITH CHECK (coalesce(get_my_claim('sales_create')::boolean,false) AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ WITH CHECK (+ has_role('employee') AND+ has_company_permission('sales_create', "companyId")+ );CREATE POLICY "Customers with sales_create can create lines on their own sales order" ON "salesOrderLine"FOR INSERTWITH CHECK (- coalesce(get_my_claim('sales_create')::boolean, false) = true- AND (get_my_claim('role'::text)) = '"customer"'::jsonb- AND "salesOrderId" IN (+ has_role('customer') AND+ has_company_permission('sales_create', "companyId") AND+ "salesOrderId" IN (SELECT id FROM "salesOrder" WHERE "customerId" IN (SELECT "customerId" FROM "salesOrder" WHERE "customerId" IN (SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()@@ -447,14 +463,17 @@ CREATE POLICY "Customers with sales_create can create lines on their own sales oCREATE POLICY "Employees with sales_update can update sales order lines" ON "salesOrderLine"FOR UPDATE- USING (coalesce(get_my_claim('sales_update')::boolean,false) AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ USING (+ has_role('employee') AND+ has_company_permission('sales_update', "companyId")+ );CREATE POLICY "Customers with sales_update can update their own sales order lines" ON "salesOrderLine"FOR UPDATEUSING (- coalesce(get_my_claim('sales_update')::boolean, false) = true- AND (get_my_claim('role'::text)) = '"customer"'::jsonb- AND "salesOrderId" IN (+ has_role('customer') AND+ has_company_permission('sales_update', "companyId") AND+ "salesOrderId" IN (SELECT id FROM "salesOrder" WHERE "customerId" IN (SELECT "customerId" FROM "salesOrder" WHERE "customerId" IN (SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()@@ -465,14 +484,17 @@ CREATE POLICY "Customers with sales_update can update their own sales order lineCREATE POLICY "Employees with sales_delete can delete sales order lines" ON "salesOrderLine"FOR DELETE- USING (coalesce(get_my_claim('sales_delete')::boolean, false) = true AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ USING (+ has_role('employee') AND+ has_company_permission('sales_delete', "companyId")+ );CREATE POLICY "Customers with sales_delete can delete lines on their own sales order" ON "salesOrderLine"FOR DELETEUSING (- coalesce(get_my_claim('sales_delete')::boolean, false) = true- AND (get_my_claim('role'::text)) = '"customer"'::jsonb- AND "salesOrderId" IN (+ has_role('customer') AND+ has_company_permission('sales_delete', "companyId") AND+ "salesOrderId" IN (SELECT id FROM "salesOrder" WHERE "customerId" IN (SELECT "customerId" FROM "salesOrder" WHERE "customerId" IN (SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()@@ -488,14 +510,17 @@ ALTER TABLE "salesOrderShipment" ENABLE ROW LEVEL SECURITY;CREATE POLICY "Employees with sales_view can view sales order shipments" ON "salesOrderShipment"FOR SELECT- USING (coalesce(get_my_claim('sales_view')::boolean, false) = true AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ USING (+ has_role('employee') AND+ has_company_permission('sales_view', "companyId")+ );CREATE POLICY "Customers with sales_view can their own sales order shipments" ON "salesOrderShipment"FOR SELECTUSING (- coalesce(get_my_claim('sales_view')::boolean, false) = true- AND (get_my_claim('role'::text)) = '"customer"'::jsonb- AND id IN (+ has_role('customer') AND+ has_company_permission('sales_view', "companyId") AND+ id IN (SELECT id FROM "salesOrder" WHERE "customerId" IN (SELECT "customerId" FROM "salesOrder" WHERE "customerId" IN (SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()@@ -506,18 +531,24 @@ CREATE POLICY "Customers with sales_view can their own sales order shipments" ONCREATE POLICY "Employees with sales_create can create sales order shipments" ON "salesOrderShipment"FOR INSERT- WITH CHECK (coalesce(get_my_claim('sales_create')::boolean,false) AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ WITH CHECK (+ has_role('employee') AND+ has_company_permission('sales_create', "companyId")+ );CREATE POLICY "Employees with sales_update can update sales order shipments" ON "salesOrderShipment"FOR UPDATE- USING (coalesce(get_my_claim('sales_update')::boolean,false) AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ USING (+ has_role('employee') AND+ has_company_permission('sales_update', "companyId")+ );CREATE POLICY "Customers with sales_update can their own sales order shipments" ON "salesOrderShipment"FOR UPDATEUSING (- coalesce(get_my_claim('sales_update')::boolean, false) = true- AND (get_my_claim('role'::text)) = '"customer"'::jsonb- AND id IN (+ has_role('customer') AND+ has_company_permission('sales_update', "companyId") AND+ id IN (SELECT id FROM "salesOrder" WHERE "customerId" IN (SELECT "customerId" FROM "salesOrder" WHERE "customerId" IN (SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()@@ -528,7 +559,10 @@ CREATE POLICY "Customers with sales_update can their own sales order shipments"CREATE POLICY "Employees with sales_delete can delete sales order shipments" ON "salesOrderShipment"FOR DELETE- USING (coalesce(get_my_claim('sales_delete')::boolean, false) = true AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ USING (+ has_role('employee') AND+ has_company_permission('sales_delete', "companyId")+ );-- Sales Order Payments@@ -537,19 +571,31 @@ ALTER TABLE "salesOrderPayment" ENABLE ROW LEVEL SECURITY;CREATE POLICY "Employees with sales_view can view sales order payments" ON "salesOrderPayment"FOR SELECT- USING (coalesce(get_my_claim('sales_view')::boolean, false) = true AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ USING (+ has_role('employee') AND+ has_company_permission('sales_view', "companyId")+ );CREATE POLICY "Employees with sales_create can create sales order payments" ON "salesOrderPayment"FOR INSERT- WITH CHECK (coalesce(get_my_claim('sales_create')::boolean,false) AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ WITH CHECK (+ has_role('employee') AND+ has_company_permission('sales_create', "companyId")+ );CREATE POLICY "Employees with sales_update can update sales order payments" ON "salesOrderPayment"FOR UPDATE- USING (coalesce(get_my_claim('sales_update')::boolean,false) AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ USING (+ has_role('employee') AND+ has_company_permission('sales_update', "companyId")+ );CREATE POLICY "Employees with sales_delete can delete sales order payments" ON "salesOrderPayment"FOR DELETE- USING (coalesce(get_my_claim('sales_delete')::boolean, false) = true AND (get_my_claim('role'::text)) = '"employee"'::jsonb);+ USING (+ has_role('employee') AND+ has_company_permission('sales_delete', "companyId")+ );ALTER VIEW "salesOrders" SET (security_invoker = on);ALTER VIEW "salesOrderCustomers" SET (security_invoker = on);diff --git a/packages/database/supabase/migrations/20240416212554_part-search.sql b/packages/database/supabase/migrations/20240416212554_part-search.sqldeleted file mode 100644index b2060058b2..0000000000--- a/packages/database/supabase/migrations/20240416212554_part-search.sql+++ /dev/null@@ -1,42 +0,0 @@-CREATE OR REPLACE FUNCTION public.update_quotation_search_result()-RETURNS TRIGGER AS $$-BEGIN- IF (old."quoteId" <> new."quoteId" OR old."name" <> new."name") THEN- UPDATE public.search SET name = new."quoteId", description = new.name- WHERE entity = 'Quotation' AND uuid = new.id;- END IF;- RETURN new;-END;-$$ LANGUAGE plpgsql SECURITY DEFINER;--CREATE OR REPLACE TRIGGER update_quotation_search_result- AFTER UPDATE on public."quote"- FOR EACH ROW EXECUTE PROCEDURE public.update_quotation_search_result();--CREATE OR REPLACE FUNCTION public.update_part_search_result()-RETURNS TRIGGER AS $$-BEGIN- IF (old.name <> new.name OR old.description <> new.description) THEN- UPDATE public.search SET name = new.id, description = new.name || ' ' || COALESCE(new.description, '')- WHERE entity = 'Part' AND uuid = new.id;- END IF;- RETURN new;-END;-$$ LANGUAGE plpgsql SECURITY DEFINER;--CREATE OR REPLACE TRIGGER update_part_search_result- AFTER UPDATE on public.part- FOR EACH ROW EXECUTE PROCEDURE public.update_part_search_result();--CREATE OR REPLACE FUNCTION public.create_part_search_result()-RETURNS TRIGGER AS $$-BEGIN- INSERT INTO public.search(name, description, entity, uuid, link)- VALUES (new.id, new.name || ' ' || COALESCE(new.description, ''), 'Part', new.id, '/x/part/' || new.id);- RETURN new;-END;-$$ LANGUAGE plpgsql SECURITY DEFINER;--CREATE OR REPLACE TRIGGER create_part_search_result- AFTER INSERT on public.part- FOR EACH ROW EXECUTE PROCEDURE public.create_part_search_result();\ No newline at end of filediff --git a/packages/database/supabase/seed.sql b/packages/database/supabase/seed.sqlindex 09721d228b..e69de29bb2 100644--- a/packages/database/supabase/seed.sql+++ b/packages/database/supabase/seed.sql@@ -1,525 +0,0 @@--- users---- INSERT INTO "user" ("id", "email", "firstName", "lastName")--- VALUES ('system', '[email protected]', 'System', 'Operation');---- theme---- INSERT INTO "theme" (--- "theme",--- "updatedBy"--- ) VALUES (--- 'zinc',--- 'system'--- );---- currencies---- INSERT INTO "currency" ("name", "code", "symbol", "exchangeRate", "decimalPlaces", "isBaseCurrency", "createdBy")--- VALUES--- ('US Dollar', 'USD', '$', 1, 2, TRUE, 'system'),--- ('Canadian Dollar', 'CAD', 'CA$', 1, 2, FALSE, 'system'),--- ('Euro', 'EUR', '€', 1, 2, FALSE, 'system'),--- ('United Arab Emirates Dirham', 'AED', 'AED', 1, 2, FALSE, 'system'),--- ('Afghan Afghani', 'AFN', 'Af', 1, 0, FALSE, 'system'),--- ('Albanian Lek', 'ALL', 'ALL', 1, 0, FALSE, 'system'),--- ('Armenian Dram', 'AMD', 'AMD', 1, 0, FALSE, 'system'),--- ('Argentine Peso', 'ARS', 'AR$', 1, 2, FALSE, 'system'),--- ('Australian Dollar', 'AUD', 'AU$', 1, 2, FALSE, 'system'),--- ('Azerbaijani Manat', 'AZN', 'man.', 1, 2, FALSE, 'system'),--- ('Bosnia-Herzegovina Convertible Mark', 'BAM', 'KM', 1, 2, FALSE, 'system'),--- ('Bangladeshi Taka', 'BDT', 'Tk', 1, 2, FALSE, 'system'),--- ('Bulgarian Lev', 'BGN', 'BGN', 1, 2, FALSE, 'system'),--- ('Bahraini Dinar', 'BHD', 'BD', 1, 3, FALSE, 'system'),--- ('Burundian Franc', 'BIF', 'FBu', 1, 0, FALSE, 'system'),--- ('Brunei Dollar', 'BND', 'BN$', 1, 2, FALSE, 'system'),--- ('Bolivian Boliviano', 'BOB', 'Bs', 1, 2, FALSE, 'system'),--- ('Brazilian Real', 'BRL', 'R$', 1, 2, FALSE, 'system'),--- ('Botswanan Pula', 'BWP', 'BWP', 1, 2, FALSE, 'system'),--- ('Belarusian Ruble', 'BYN', 'Br', 1, 2, FALSE, 'system'),--- ('Belize Dollar', 'BZD', 'BZ$', 1, 2, FALSE, 'system'),--- ('Congolese Franc', 'CDF', 'CDF', 1, 2, FALSE, 'system'),--- ('Swiss Franc', 'CHF', 'CHF', 1, 2, FALSE, 'system'),--- ('Chilean Peso', 'CLP', 'CL$', 1, 0, FALSE, 'system'),--- ('Chinese Yuan', 'CNY', 'CN¥', 1, 2, FALSE, 'system'),--- ('Colombian Peso', 'COP', 'CO$', 1, 0, FALSE, 'system'),--- ('Costa Rican Colón', 'CRC', '₡', 1, 0, FALSE, 'system'),--- ('Cape Verdean Escudo', 'CVE', 'CV$', 1, 2, FALSE, 'system'),--- ('Czech Republic Koruna', 'CZK', 'Kč', 1, 2, FALSE, 'system'),--- ('Djiboutian Franc', 'DJF', 'Fdj', 1, 0, FALSE, 'system'),--- ('Danish Krone', 'DKK', 'Dkr', 1, 2, FALSE, 'system'),--- ('Dominican Peso', 'DOP', 'RD$', 1, 2, FALSE, 'system'),--- ('Algerian Dinar', 'DZD', 'DA', 1, 2, FALSE, 'system'),--- ('Egyptian Pound', 'EGP', 'EGP', 1, 2, FALSE, 'system'),--- ('Eritrean Nakfa', 'ERN', 'Nfk', 1, 2, FALSE, 'system'),--- ('Ethiopian Birr', 'ETB', 'Br', 1, 2, FALSE, 'system'),--- ('British Pound Sterling', 'GBP', '£', 1, 2, FALSE, 'system'),--- ('Georgian Lari', 'GEL', 'GEL', 1, 2, FALSE, 'system'),--- ('Ghanaian Cedi', 'GHS', 'GH₵', 1, 2, FALSE, 'system'),--- ('Guinean Franc', 'GNF', 'FG', 1, 0, FALSE, 'system'),--- ('Guatemalan Quetzal', 'GTQ', 'GTQ', 1, 2, FALSE, 'system'),--- ('Hong Kong Dollar', 'HKD', 'HK$', 1, 2, FALSE, 'system'),--- ('Honduran Lempira', 'HNL', 'HNL', 1, 2, FALSE, 'system'),--- ('Croatian Kuna', 'HRK', 'kn', 1, 2, FALSE, 'system'),--- ('Hungarian Forint', 'HUF', 'Ft', 1, 0, FALSE, 'system'),--- ('Indonesian Rupiah', 'IDR', 'Rp', 1, 0, FALSE, 'system'),--- ('Israeli New Sheqel', 'ILS', '₪', 1, 2, FALSE, 'system'),--- ('Indian Rupee', 'INR', 'Rs', 1, 2, FALSE, 'system'),--- ('Iraqi Dinar', 'IQD', 'IQD', 1, 0, FALSE, 'system'),--- ('Iranian Rial', 'IRR', 'IRR', 1, 0, FALSE, 'system'),--- ('Icelandic Króna', 'ISK', 'Ikr', 1, 0, FALSE, 'system'),--- ('Jamaican Dollar', 'JMD', 'J$', 1, 2, FALSE, 'system'),--- ('Jordanian Dinar', 'JOD', 'JD', 1, 3, FALSE, 'system'),--- ('Japanese Yen', 'JPY', '¥', 1, 0, FALSE, 'system'),--- ('Kenyan Shilling', 'KES', 'Ksh', 1, 2, FALSE, 'system'),--- ('Cambodian Riel', 'KHR', 'KHR', 1, 2, FALSE, 'system'),--- ('Comorian Franc', 'KMF', 'CF', 1, 0, FALSE, 'system'),--- ('South Korean Won', 'KRW', '₩', 1, 0, FALSE, 'system'),--- ('Kuwaiti Dinar', 'KWD', 'KD', 1, 3, FALSE, 'system'),--- ('Kazakhstani Tenge', 'KZT', 'KZT', 1, 2, FALSE, 'system'),--- ('Lebanese Pound', 'LBP', 'L.L.', 1, 0, FALSE, 'system'),--- ('Sri Lankan Rupee', 'LKR', 'SLRs', 1, 2, FALSE, 'system'),--- ('Lithuanian Litas', 'LTL', 'Lt', 1, 2, FALSE, 'system'),--- ('Latvian Lats', 'LVL', 'Ls', 1, 2, FALSE, 'system'),--- ('Libyan Dinar', 'LYD', 'LD', 1, 3, FALSE, 'system'),--- ('Moroccan Dirham', 'MAD', 'MAD', 1, 2, FALSE, 'system'),--- ('Moldovan Leu', 'MDL', 'MDL', 1, 2, FALSE, 'system'),--- ('Malagasy Ariary', 'MGA', 'MGA', 1, 0, FALSE, 'system'),--- ('Macedonian Denar', 'MKD', 'MKD', 1, 2, FALSE, 'system'),--- ('Myanma Kyat', 'MMK', 'MMK', 1, 0, FALSE, 'system'),--- ('Macanese Pataca', 'MOP', 'MOP$', 1, 2, FALSE, 'system'),--- ('Mauritian Rupee', 'MUR', 'MURs', 1, 0, FALSE, 'system'),--- ('Mexican Peso', 'MXN', 'MX$', 1, 2, FALSE, 'system'),--- ('Malaysian Ringgit', 'MYR', 'RM', 1, 2, FALSE, 'system'),--- ('Mozambican Metical', 'MZN', 'MTn', 1, 2, FALSE, 'system'),--- ('Namibian Dollar', 'NAD', 'N$', 1, 2, FALSE, 'system'),--- ('Nigerian Naira', 'NGN', '₦', 1, 2, FALSE, 'system'),--- ('Nicaraguan Córdoba', 'NIO', 'C$', 1, 2, FALSE, 'system'),--- ('Norwegian Krone', 'NOK', 'Nkr', 1, 2, FALSE, 'system'),--- ('Nepalese Rupee', 'NPR', 'NPRs', 1, 2, FALSE, 'system'),--- ('New Zealand Dollar', 'NZD', 'NZ$', 1, 2, FALSE, 'system'),--- ('Omani Rial', 'OMR', 'OMR', 1, 3, FALSE, 'system'),--- ('Panamanian Balboa', 'PAB', 'B/.', 1, 2, FALSE, 'system'),--- ('Peruvian Nuevo Sol', 'PEN', 'S/.', 1, 2, FALSE, 'system'),--- ('Philippine Peso', 'PHP', '₱', 1, 2, FALSE, 'system'),--- ('Pakistani Rupee', 'PKR', 'PKRs', 1, 0, FALSE, 'system'),--- ('Polish Zloty', 'PLN', 'zł', 1, 2, FALSE, 'system'),--- ('Paraguayan Guarani', 'PYG', '₲', 1, 0, FALSE, 'system'),--- ('Qatari Rial', 'QAR', 'QR', 1, 2, FALSE, 'system'),--- ('Romanian Leu', 'RON', 'RON', 1, 2, FALSE, 'system'),--- ('Serbian Dinar', 'RSD', 'din.', 1, 0, FALSE, 'system'),--- ('Russian Ruble', 'RUB', 'RUB', 1, 2, FALSE, 'system'),--- ('Rwandan Franc', 'RWF', 'RWF', 1, 0, FALSE, 'system'),--- ('Saudi Riyal', 'SAR', 'SR', 1, 2, FALSE, 'system'),--- ('Sudanese Pound', 'SDG', 'SDG', 1, 2, FALSE, 'system'),--- ('Swedish Krona', 'SEK', 'Skr', 1, 2, FALSE, 'system'),--- ('Singapore Dollar', 'SGD', 'S$', 1, 2, FALSE, 'system'),--- ('Somali Shilling', 'SOS', 'Ssh', 1, 0, FALSE, 'system'),--- ('Syrian Pound', 'SYP', 'SY£', 1, 0, FALSE, 'system'),--- ('Thai Baht', 'THB', '฿', 1, 2, FALSE, 'system'),--- ('Tunisian Dinar', 'TND', 'DT', 1, 3, FALSE, 'system'),--- ('Tongan Paʻanga', 'TOP', 'T$', 1, 2, FALSE, 'system'),--- ('Turkish Lira', 'TRY', 'TL', 1, 2, FALSE, 'system'),--- ('Trinidad and Tobago Dollar', 'TTD', 'TT$', 1, 2, FALSE, 'system'),--- ('New Taiwan Dollar', 'TWD', 'NT$', 1, 2, FALSE, 'system'),--- ('Tanzanian Shilling', 'TZS', 'TSh', 1, 0, FALSE, 'system'),--- ('Ukrainian Hryvnia', 'UAH', '₴', 1, 2, FALSE, 'system'),--- ('Ugandan Shilling', 'UGX', 'USh', 1, 0, FALSE, 'system'),--- ('Uruguayan Peso', 'UYU', '$U', 1, 2, FALSE, 'system'),--- ('Uzbekistan Som', 'UZS', 'UZS', 1, 0, FALSE, 'system'),--- ('Venezuelan Bolívar', 'VEF', 'Bs.F.', 1, 2, FALSE, 'system'),--- ('Vietnamese Dong', 'VND', '₫', 1, 0, FALSE, 'system'),--- ('CFA Franc BEAC', 'XAF', 'FCFA', 1, 0, FALSE, 'system'),--- ('CFA Franc BCEAO', 'XOF', 'CFA', 1, 0, FALSE, 'system'),--- ('Yemeni Rial', 'YER', 'YR', 1, 0, FALSE, 'system'),--- ('South African Rand', 'ZAR', 'R', 1, 2, FALSE, 'system'),--- ('Zambian Kwacha', 'ZMK', 'ZK', 1, 0, FALSE, 'system'),--- ('Zimbabwean Dollar', 'ZWL', 'ZWL$', 1, 0, FALSE, 'system');---- attribute types---INSERT INTO "attributeDataType" ("label", "isBoolean", "isDate", "isList", "isNumeric", "isText", "isUser")-VALUES- ('Yes/No', true, false, false, false, false, false),- ('Date', false, true, false, false, false, false),- ('List', false, false, true, false, false, false),- ('Numeric', false, false, false, true, false, false),- ('Text', false, false, false, false, true, false),- ('User', false, false, false, false, false, true);----- -- supplier status--- INSERT INTO "supplierStatus" ("name", "createdBy") VALUES ('Active', 'system'), ('Inactive', 'system'), ('Pending', 'system'), ('Rejected', 'system');---- -- customer status--- INSERT INTO "customerStatus" ("name", "createdBy") VALUES ('Active', 'system'), ('Inactive', 'system'), ('Lead', 'system'), ('On Hold', 'system'), ('Cancelled', 'system'), ('Archived', 'system');---- -- unit of measure---- INSERT INTO "unitOfMeasure" ("code", "name", "createdBy")--- VALUES--- ( 'EA', 'Each', 'system'),--- ( 'PCS', 'Pieces', 'system');---- -- payment terms---- INSERT INTO "paymentTerm" ("name", "daysDue", "calculationMethod", "daysDiscount", "discountPercentage", "createdBy")--- VALUES--- ('Net 15', 15, 'Net', 0, 0, 'system'),--- ('Net 30', 30, 'Net', 0, 0, 'system'),--- ('Net 50', 50, 'Net', 0, 0, 'system'),--- ('Net 60', 60, 'Net', 0, 0, 'system'),--- ('Net 90', 90, 'Net', 0, 0, 'system'),--- ('1% 10 Net 30', 30, 'Net', 10, 1, 'system'),--- ('2% 10 Net 30', 30, 'Net', 10, 2, 'system'),--- ('Due on Receipt', 0, 'Net', 0, 0, 'system'),--- ('Net EOM 10', 10, 'End of Month', 0, 0, 'system');---- -- sequences---- INSERT INTO "sequence" ("table", "name", "prefix", "suffix", "next", "size", "step")--- VALUES--- ('purchaseOrder', 'Purchase Order', 'PO', NULL, 0, 6, 1),--- ('purchaseInvoice', 'Purchase Invoice', 'AP', NULL, 0, 6, 1),--- ('receipt', 'Receipt', 'RE', NULL, 0, 6, 1),--- ('requestForQuote', 'Request For Quote', 'RFQ', NULL, 0, 6, 1),--- ('quote', 'Quote', 'QUO', NULL, 0, 6, 1),--- ('salesOrder', 'Sales Order', 'SO', NULL, 0, 6, 1);---- account categories---- INSERT INTO public."accountCategory" (id, category, class, "incomeBalance", "createdBy")--- VALUES--- ('Bank', 'Bank', 'Asset', 'Balance Sheet', 'system'),--- ('Accounts Receivable', 'Accounts Receivable', 'Asset', 'Balance Sheet', 'system'),--- ('Inventory', 'Inventory', 'Asset', 'Balance Sheet', 'system'),--- ('Other Current Asset', 'Other Current Asset', 'Asset', 'Balance Sheet', 'system'),--- ('Fixed Asset', 'Fixed Asset', 'Asset', 'Balance Sheet', 'system'),--- ('Accumulated Depreciation', 'Accumulated Depreciation', 'Asset', 'Balance Sheet', 'system'),--- ('Other Asset', 'Other Asset', 'Asset', 'Balance Sheet', 'system'),--- ('Accounts Payable', 'Accounts Payable', 'Liability', 'Balance Sheet', 'system'),--- ('Other Current Liability', 'Other Current Liability', 'Liability', 'Balance Sheet', 'system'),--- ('Long Term Liability', 'Long Term Liability', 'Liability', 'Balance Sheet', 'system'),--- ('Equity - No Close', 'Equity - No Close', 'Equity', 'Balance Sheet', 'system'),--- ('Equity - Close', 'Equity - Close', 'Equity', 'Balance Sheet', 'system'),--- ('Retained Earnings', 'Retained Earnings', 'Equity', 'Balance Sheet', 'system'),--- ('Income', 'Income', 'Revenue', 'Income Statement', 'system'),--- ('Cost of Goods Sold', 'Cost of Goods Sold', 'Expense', 'Income Statement', 'system'),--- ('Expense', 'Expense', 'Expense', 'Income Statement', 'system'),--- ('Other Income', 'Other Income', 'Expense', 'Income Statement', 'system'),--- ('Other Expense', 'Other Expense', 'Expense', 'Income Statement', 'system');---- accounts----- INSERT INTO public.account--- (number, name, type, "accountCategoryId", "accountSubcategoryId", "incomeBalance", "class", "consolidatedRate", "directPosting", active, "createdBy")--- VALUES- -- ('10000', 'Income Statement', 'Begin Total', 'Income', NULL, 'Income Statement', null, 'Average', false, true, 'system'),- -- ('11000', 'Revenue', 'Begin Total', 'Income', NULL, 'Income Statement', 'Revenue', 'Average', false, true, 'system'),- -- ('11210', 'Sales', 'Posting', 'Income', NULL, 'Income Statement', 'Revenue', 'Average', true, true, 'system'),- -- ('11600', 'Sales Discounts', 'Posting', 'Income', NULL, 'Income Statement', 'Revenue', 'Average', true, true, 'system'),- -- ('19999', 'Revenue, Total', 'End Total', 'Income', NULL, 'Income Statement', 'Revenue', 'Average', false, true, 'system'),- -- ('20000', 'Costs of Goods Sold', 'Begin Total', 'Cost of Goods Sold', NULL, 'Income Statement', 'Expense', 'Average', false, true, 'system'),- -- ('21210', 'Cost of Goods Sold', 'Posting', 'Cost of Goods Sold', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('21410', 'Purchases', 'Posting', 'Cost of Goods Sold', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('21590', 'Direct Cost Applied', 'Posting', 'Cost of Goods Sold', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('21600', 'Overhead Applied', 'Posting', 'Cost of Goods Sold', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('21610', 'Purchase Variance', 'Posting', 'Cost of Goods Sold', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('21700', 'Inventory Adjustment', 'Posting', 'Cost of Goods Sold', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('24999', 'Costs of Goods Sold, Total', 'End Total', 'Expense', NULL, 'Income Statement', 'Expense', 'Average', false, true, 'system'),- -- ('25000', 'Direct Capacity Cost', 'Begin Total', 'Expense', NULL, 'Income Statement', 'Expense', 'Average', false, true, 'system'),- -- ('25705', 'Material Variance', 'Posting', 'Expense', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('25710', 'Capacity Variance', 'Posting', 'Expense', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('25720', 'Overhead Accounts', 'Posting', 'Expense', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('47045', 'Maintenance Expense', 'Posting', 'Expense', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('49999', 'Direct Capacity Cost, Total', 'End Total', 'Expense', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('50000', 'Depreciation of Fixed Assets', 'Begin Total', 'Other Expense', NULL, 'Income Statement', 'Expense', 'Average', false, true, 'system'),- -- ('50015', 'Depreciation Expense', 'Posting', 'Other Expense', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('50040', 'Gains and Losses on Disposal', 'Posting', 'Other Expense', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('50045', 'Service Charge Account', 'Posting', 'Other Expense', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('50999', 'Depreciation of Fixed Assets, Total', 'End Total', 'Other Expense', NULL, 'Income Statement', 'Expense', 'Average', false, true, 'system'),- -- ('51000', 'Interest', 'Begin Total', 'Other Expense', NULL, 'Income Statement', 'Expense', 'Average', false, true, 'system'),- -- ('51110', 'Interest Account', 'Posting', 'Other Expense', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('51115', 'Supplier Payment Discounts', 'Posting', 'Other Expense', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('51120', 'Customer Payment Discounts', 'Posting', 'Other Expense', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('51235', 'Rounding Account', 'Posting', 'Other Expense', NULL, 'Income Statement', 'Expense', 'Average', true, true, 'system'),- -- ('51999', 'Interest, Total', 'End Total', 'Other Expense', NULL, 'Income Statement', 'Expense', 'Average', false, true, 'system'),- -- ('79999', 'Income Statement, Total', 'Total', 'Income', NULL, 'Income Statement', null, 'Average', false, true, 'system'),- -- ('80000', 'Balance Sheet', 'Begin Total', NULL, NULL, 'Balance Sheet', null, 'Average', false, true, 'system'),- -- ('80001', 'Assets', 'Begin Total', NULL, NULL, 'Balance Sheet', 'Asset', 'Average', false, true, 'system'),- -- ('81000', 'Fixed Assets', 'Begin Total', NULL, NULL, 'Balance Sheet', 'Asset', 'Average', false, true, 'system'),- -- ('81010', 'Fixed Asset Acquisition Cost', 'Posting', 'Fixed Asset', NULL, 'Balance Sheet', 'Asset', 'Average', true, true, 'system'),- -- ('81015', 'Fixed Asset Acquisition Cost on Disposal', 'Posting', 'Fixed Asset', NULL, 'Balance Sheet', 'Asset','Average', true, true, 'system'),- -- ('81020', 'Accumulated Depreciation', 'Posting', 'Accumulated Depreciation', NULL, 'Balance Sheet', 'Asset', 'Average', true, true, 'system'),- -- ('81030', 'Fixed Asset Acquisition Depreciation on Disposal', 'Posting', 'Accumulated Depreciation', NULL, 'Balance Sheet', 'Asset', 'Average', true, true, 'system'),- -- ('81999', 'Fixed Assets, Total', 'End Total', NULL, NULL, 'Balance Sheet', 'Asset', 'Average', false, true, 'system'),- -- ('83000', 'Current Assets', 'Begin Total', NULL, NULL, 'Balance Sheet', 'Asset', 'Average', false, true, 'system'),- -- ('83105', 'Inventory', 'Posting', 'Inventory', NULL, 'Balance Sheet', 'Asset', 'Average', true, true, 'system'),- -- ('83120', 'Inventory Interim', 'Posting', 'Inventory', NULL, 'Balance Sheet', 'Asset', 'Average', true, true, 'system'),- -- ('83125', 'Work In Progress (WIP)', 'Posting', 'Inventory', NULL, 'Balance Sheet', 'Asset', 'Average', true, true, 'system'),- -- ('85005', 'Receivables', 'Posting', 'Accounts Receivable', NULL, 'Balance Sheet', 'Asset', 'Average', true, true, 'system'),- -- ('85020', 'Inventory Invoiced Not Received', 'Posting', 'Accounts Receivable', NULL, 'Balance Sheet', 'Asset', 'Average', true, true, 'system'),- -- ('86005', 'Bank - Cash', 'Posting', 'Bank', NULL, 'Balance Sheet', 'Asset', 'Average', true, true, 'system'),- -- ('86010', 'Bank - Local Currency', 'Posting', 'Bank', NULL, 'Balance Sheet', 'Asset', 'Average', false, true, 'system'),- -- ('86015', 'Bank - Foreign Currency', 'Posting', 'Bank', NULL, 'Balance Sheet', 'Asset', 'Average', false, true, 'system'),- -- ('87999', 'Current Assets, Total', 'End Total', NULL, NULL, 'Balance Sheet', 'Asset', 'Average', false, true, 'system'),- -- ('89999', 'Assets, Total', 'End Total', NULL, NULL, 'Balance Sheet', 'Asset', 'Average', false, true, 'system'),- -- ('90000', 'Liabilities', 'Begin Total', NULL, NULL, 'Balance Sheet', 'Liability', 'Average', false, true, 'system'),- -- ('92210', 'Customer Prepayments', 'Posting', 'Other Current Liability', NULL, 'Balance Sheet', 'Liability', 'Average', true, true, 'system'),- -- ('93005', 'Payables', 'Posting', 'Accounts Payable', NULL, 'Balance Sheet', 'Liability', 'Average', true, true, 'system'),- -- ('93010', 'Inventory Received Not Invoiced', 'Posting', 'Other Current Liability', NULL, 'Balance Sheet', 'Liability', 'Average', true, true, 'system'),- -- ('93110', 'Inventory Shipped Not Invoiced', 'Posting', 'Other Current Liability', NULL, 'Balance Sheet', 'Liability', 'Average', true, true, 'system'),- -- ('94100', 'Sales Tax Payable', 'Posting', 'Other Current Liability', NULL, 'Balance Sheet', 'Liability', 'Average', true, true, 'system'),- -- ('94110', 'Purchase Tax Payable', 'Posting', 'Other Current Liability', NULL, 'Balance Sheet', 'Liability', 'Average', true, true, 'system'),- -- ('94115', 'Reverse Charge Tax Payable', 'Posting', 'Other Current Liability', NULL, 'Balance Sheet', 'Liability', 'Average', true, true, 'system'),- -- ('94999', 'Liabilities, Total', 'End Total', NULL, NULL, 'Balance Sheet', 'Liability', 'Average', false, true, 'system'),- -- ('95000', 'Equity', 'Begin Total', NULL, NULL, 'Balance Sheet', 'Equity', 'Average', false, true, 'system'),- -- ('95010', 'Retained Earnings', 'Posting', 'Retained Earnings', NULL, 'Balance Sheet', 'Equity', 'Average', false, true, 'system'),- -- ('96010', 'Owner Equity', 'Posting', 'Equity - No Close', NULL, 'Balance Sheet', 'Equity', 'Average', true, true, 'system'),- -- ('96999', 'Equity, Total', 'End Total', NULL, NULL, 'Balance Sheet', 'Equity', 'Average', false, true, 'system'),- -- ('99999', 'Balance Sheet, Total', 'Total', NULL, NULL, 'Balance Sheet', null, 'Average', false, true, 'system');---- INSERT INTO public."accountDefault" (--- "id",--- "salesAccount",--- "salesDiscountAccount",--- "costOfGoodsSoldAccount",--- "purchaseAccount",--- "directCostAppliedAccount",--- "overheadCostAppliedAccount",--- "purchaseVarianceAccount",--- "inventoryAdjustmentVarianceAccount",--- "materialVarianceAccount",--- "capacityVarianceAccount",--- "overheadAccount",--- "maintenanceAccount",--- "assetDepreciationExpenseAccount",--- "assetGainsAndLossesAccount",--- "serviceChargeAccount",--- "interestAccount",--- "supplierPaymentDiscountAccount",--- "customerPaymentDiscountAccount",--- "roundingAccount",--- "assetAquisitionCostAccount",--- "assetAquisitionCostOnDisposalAccount",--- "accumulatedDepreciationAccount",--- "accumulatedDepreciationOnDisposalAccount",--- "inventoryAccount",--- "inventoryInterimAccrualAccount",--- "workInProgressAccount",--- "receivablesAccount",--- "inventoryInvoicedNotReceivedAccount",--- "bankCashAccount",--- "bankLocalCurrencyAccount",--- "bankForeignCurrencyAccount",--- "prepaymentAccount",--- "payablesAccount",--- "inventoryReceivedNotInvoicedAccount",--- "inventoryShippedNotInvoicedAccount",--- "salesTaxPayableAccount",--- "purchaseTaxPayableAccount",--- "reverseChargeSalesTaxPayableAccount",--- "retainedEarningsAccount",--- -- "updatedBy"--- -- ) VALUES (--- true,--- '11210',--- '11600',--- '21210',--- '21410',--- '21590',--- '21600',--- '21610',--- '21700',--- '25705',--- '25710',--- '25720',--- '47045',--- '50015',--- '50040',--- '50045',--- '51110',--- '51115',--- '51120',--- '51235',--- '81010',--- '81015',--- '81020',--- '81030',--- '83105',--- '83120',--- '83125',--- '85005',--- '85020',--- '86005',--- '86010',--- '86015',--- '92210',--- '93005',--- '93010',--- '93110',--- '94100',--- '94110',--- '94115',--- '95010',--- 'system'--- );----- INSERT INTO "postingGroupInventory" (- -- "partGroupId",- -- "costOfGoodsSoldAccount",- -- "inventoryAccount",- -- "inventoryInterimAccrualAccount",- -- "inventoryReceivedNotInvoicedAccount",- -- "inventoryInvoicedNotReceivedAccount",- -- "inventoryShippedNotInvoicedAccount",- -- "workInProgressAccount",- -- "directCostAppliedAccount",- -- "overheadCostAppliedAccount",- -- "purchaseVarianceAccount",- -- "inventoryAdjustmentVarianceAccount",- -- "materialVarianceAccount",- -- "capacityVarianceAccount",- -- "overheadAccount"--- ) SELECT- -- NULL,- -- "costOfGoodsSoldAccount",- -- "inventoryAccount",- -- "inventoryInterimAccrualAccount",- -- "inventoryReceivedNotInvoicedAccount",- -- "inventoryInvoicedNotReceivedAccount",- -- "inventoryShippedNotInvoicedAccount",- -- "workInProgressAccount",- -- "directCostAppliedAccount",- -- "overheadCostAppliedAccount",- -- "purchaseVarianceAccount",- -- "inventoryAdjustmentVarianceAccount",- -- "materialVarianceAccount",- -- "capacityVarianceAccount",- -- "overheadAccount",--- FROM "accountDefault" WHERE "id" = true;---- INSERT INTO "postingGroupPurchasing" (- -- "partGroupId",- -- "supplierTypeId",- -- "payablesAccount",- -- "purchaseAccount",- -- "purchaseDiscountAccount",- -- "purchaseCreditAccount",- -- "purchasePrepaymentAccount",- -- "purchaseTaxPayableAccount",- -- "updatedBy"--- ) SELECT--- NULL,--- NULL,- -- "payablesAccount",- -- "purchaseAccount",- -- "purchaseAccount",- -- "purchaseAccount",- -- "prepaymentAccount",- -- "purchaseTaxPayableAccount",--- 'system'--- FROM "accountDefault" WHERE "id" = true;---- INSERT INTO "postingGroupSales" (--- "partGroupId",--- "customerTypeId",- -- "receivablesAccount",- -- "salesAccount",- -- "salesDiscountAccount",- -- "salesCreditAccount",- -- "salesPrepaymentAccount",- -- "salesTaxPayableAccount",--- "updatedBy"--- ) SELECT--- NULL,--- NULL,- -- "receivablesAccount",- -- "salesAccount",- -- "salesDiscountAccount",- -- "salesAccount",- -- "prepaymentAccount",- -- "salesTaxPayableAccount",--- 'system'--- FROM "accountDefault" WHERE "id" = true;---- INSERT INTO "fiscalYearSettings" (--- "startMonth",--- "taxStartMonth",--- "updatedBy"--- ) VALUES (--- 'January',--- 'January',--- 'system'--- );----- TODO: resume seed here---- -- custom fields---- INSERT INTO "customFieldTable" ("table", "name", "module")--- VALUES--- ('account', 'Account', 'Accounting'),--- ('accountCategory', 'Account Category', 'Accounting'),--- ('accountSubcategory', 'Account Subcategory', 'Accounting'),--- ('contractor', 'Contractor', 'Resources'),--- ('currency', 'Currency', 'Accounting'),--- ('customer', 'Customer', 'Sales'),--- ('customerContact', 'Customer Contact', 'Sales'),--- ('customerLocation', 'Customer Location', 'Sales'),--- ('customerStatus', 'Customer Status', 'Sales'),--- ('customerType', 'Customer Type', 'Sales'),--- ('department', 'Department', 'Resources'),--- ('employeeJob', 'Employee Job', 'Resources'),--- ('equipment', 'Equipment', 'Resources'),--- ('equipmentType', 'Equipment Type', 'Resources'),--- ('holiday', 'Holiday', 'Resources'),--- ('journal', 'Journal', 'Accounting'),--- ('journalLine', 'Journal Line', 'Accounting'),--- ('location', 'Location', 'Resources'),--- ('part', 'Part', 'Parts'),--- ('partCost', 'Part Cost', 'Parts'),--- ('partGroup', 'Part Group', 'Parts'),--- ('partInventory', 'Part Inventory', 'Parts'),--- ('partPlanning', 'Part Planning', 'Parts'),--- ('partReplenishment', 'Part Replenishment', 'Parts'),--- ('partSupplier', 'Part Supplier', 'Parts'),--- ('partUnitSalePrice', 'Part Unit Sale Price', 'Parts'),--- ('partner', 'Partner', 'Resources'),--- ('paymentTerm', 'Payment Term', 'Accounting'),--- ('purchaseInvoice', 'Purchase Invoice', 'Invoicing'),--- ('purchaseInvoiceLine', 'Purchase Invoice Line', 'Invoicing'),--- ('purchasePayment', 'Purchase Invoice Payment', 'Invoicing'),--- ('purchaseOrder', 'Purchase Order', 'Purchasing'),--- ('purchaseOrderDelivery', 'Purchase Order Delivery', 'Purchasing'),--- ('purchaseOrderLine', 'Purchase Order Line', 'Purchasing'),--- ('purchaseOrderPayment', 'Purchase Order Payment', 'Purchasing'),--- ('quote', 'Quote', 'Sales'),--- ('quoteAssembly', 'Quote Assembly', 'Sales'),--- ('quoteLine', 'Quote Line', 'Sales'),--- ('quoteMaterial', 'Quote Material', 'Sales'),--- ('quoteOperation', 'Quote Operation', 'Sales'),--- ('receipt', 'Receipt', 'Inventory'),--- ('requestForQuote', 'RFQ', 'Purchasing'),--- ('requestForQuoteLine', 'RFQ Line', 'Purchasing'),--- ('requestForQuoteSupplier', 'RFQ Supplier', 'Purchasing'),--- ('service', 'Service', 'Parts'),--- ('serviceSupplier', 'Service Supplier', 'Parts'),--- ('shelf', 'Shelf', 'Inventory'),--- ('shift', 'Shift', 'Resources'),--- ('shippingMethod', 'Shipping Method', 'Inventory'),--- ('shippingTerm', 'Shipping Term', 'Accounting'),--- ('supplier', 'Supplier', 'Purchasing'),--- ('supplierContact', 'Supplier Contact', 'Purchasing'),--- ('supplierLocation', 'Supplier Location', 'Purchasing'),--- ('supplierPayment', 'Supplier Payment', 'Purchasing'),--- ('supplierShipping', 'Supplier Shipping', 'Purchasing'),--- ('supplierStatus', 'Supplier Status', 'Purchasing'),--- ('supplierType', 'Supplier Type', 'Purchasing'),--- ('unitOfMeasure', 'Unit of Measure', 'Inventory'),--- ('workCell', 'Work Cell', 'Resources'),--- ('workCellType', 'Work Cell Type', 'Resources');diff --git a/turbo.json b/turbo.jsonindex 55894971a3..43b3f849b6 100644--- a/turbo.json+++ b/turbo.json@@ -26,9 +26,6 @@},"dev": {"dependsOn": ["^build"],- "cache": false- },- "carbon#dev": {"cache": false,"persistent": true},