Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

Add development DB seed script and seed data

Sidwebworks60f530e61a92
diff --git a/package.json b/package.json
index bf0ee975df..dabd535ece 100755
--- a/package.json
+++ b/package.json
@@ -44,6 +44,7 @@
"db:push": "turbo run db:push",
"db:restart": "run-s db:stop db:start",
"db:seed": "turbo run db:seed --no-cache",
+ "db:seed:dev": "npm run db:seed:dev -w @carbon/database --",
"db:start": "npm run db:start -w @carbon/database",
"db:start:redis": "npm run db:start -w @carbon/kv",
"db:stop": "npm run db:stop -w @carbon/database",
diff --git a/packages/database/package.json b/packages/database/package.json
index 1aca51fb13..c90cc74b8d 100644
--- a/packages/database/package.json
+++ b/packages/database/package.json
@@ -30,6 +30,7 @@
"db:migrate": "supabase migration up",
"db:migrate:new": "supabase migration new",
"db:seed": "tsx src/seed.ts",
+ "db:seed:dev": "tsx src/seed-dev.ts",
"db:setup": "supabase db reset",
"db:start": "supabase start",
"db:stop": "supabase stop",
diff --git a/packages/database/src/seed-dev.ts b/packages/database/src/seed-dev.ts
new file mode 100644
index 0000000000..33a9b07a38
--- /dev/null
+++ b/packages/database/src/seed-dev.ts
@@ -0,0 +1,628 @@
+/**
+ * Development seed script for Carbon
+ *
+ * This script creates a development user and company with all default seed data.
+ * Run after `npm run db:build` to set up a fully functional local environment.
+ *
+ * Usage:
+ * npm run db:seed:dev -- --email [email protected]
+ */
+
+import { parseArgs } from "node:util";
+import { createClient } from "@supabase/supabase-js";
+import * as dotenv from "dotenv";
+import { getPostgresConnectionPool } from "./client";
+import {
+ accountCategories,
+ accountDefaults,
+ accounts,
+ currencies,
+ customerStatuses,
+ defaultLocation,
+ failureModes,
+ fiscalYearSettings,
+ gaugeTypes,
+ getGroupId,
+ groups,
+ nonConformanceRequiredActions,
+ nonConformanceTypes,
+ paymentTerms,
+ postingGroupInventory,
+ postingGroupPurchasing,
+ postingGroupSales,
+ scrapReasons,
+ sequences,
+ supplierStatuses,
+ unitOfMeasures
+} from "./seed/seed.data";
+import type { Database } from "./types";
+
+// Load environment variables
+dotenv.config();
+
+const DEV_PASSWORD = "password";
+const DEV_COMPANY_NAME = "Carbon Development";
+
+// Parse CLI arguments
+const { values } = parseArgs({
+ options: {
+ email: {
+ type: "string",
+ short: "e"
+ }
+ },
+ strict: true
+});
+
+function printUsage() {
+ console.log(`
+Usage: npm run db:seed:dev -- --email <email>
+
+Arguments:
+ --email, -e Required. The email address for the dev user.
+
+Example:
+ npm run db:seed:dev -- --email [email protected]
+ `);
+}
+
+async function seedDev() {
+ const email = values.email;
+
+ if (!email) {
+ console.error("Error: --email is required\n");
+ printUsage();
+ process.exit(1);
+ }
+
+ // Validate email format
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
+ if (!emailRegex.test(email)) {
+ console.error("Error: Invalid email format\n");
+ process.exit(1);
+ }
+
+ console.log(`\nSeeding development environment for: ${email}\n`);
+
+ // Initialize Supabase admin client
+ const supabaseAdmin = createClient<Database>(
+ process.env.SUPABASE_URL!,
+ process.env.SUPABASE_SERVICE_ROLE_KEY!,
+ {
+ auth: {
+ autoRefreshToken: false,
+ persistSession: false
+ }
+ }
+ );
+
+ // Initialize PostgreSQL connection pool
+ const pgPool = getPostgresConnectionPool(1);
+ const client = await pgPool.connect();
+
+ try {
+ // Step 1: Check if user already exists (via Supabase Auth API - cannot be in transaction)
+ console.log("1. Checking for existing user...");
+ const { data: existingUsers } = await supabaseAdmin.auth.admin.listUsers();
+ const existingUser = existingUsers?.users?.find((u) => u.email === email);
+
+ let userId: string;
+
+ if (existingUser) {
+ console.log(` User ${email} already exists, using existing user.`);
+ userId = existingUser.id;
+
+ // Update password to known value
+ const { error: updateError } =
+ await supabaseAdmin.auth.admin.updateUserById(userId, {
+ password: DEV_PASSWORD
+ });
+ if (updateError) {
+ console.warn(
+ ` Warning: Could not update password: ${updateError.message}`
+ );
+ } else {
+ console.log(` Password updated to: ${DEV_PASSWORD}`);
+ }
+ } else {
+ // Create new user
+ console.log(" Creating new user...");
+ const { data: newUser, error: createError } =
+ await supabaseAdmin.auth.admin.createUser({
+ email,
+ password: DEV_PASSWORD,
+ email_confirm: true,
+ app_metadata: {
+ role: "employee",
+ provider: "email",
+ providers: ["email"]
+ }
+ });
+
+ if (createError) {
+ throw new Error(`Failed to create user: ${createError.message}`);
+ }
+
+ if (!newUser.user) {
+ throw new Error("Failed to create user: No user returned");
+ }
+
+ userId = newUser.user.id;
+ console.log(` User created with ID: ${userId}`);
+ }
+
+ // Step 2: Begin transaction for all database operations
+ console.log("2. Starting database transaction...");
+ await client.query("BEGIN");
+
+ try {
+ // Generate company ID using xid() function
+ console.log("3. Generating company ID...");
+ const xidResult = await client.query("SELECT xid() as id");
+ const companyId = xidResult.rows[0].id as string;
+ console.log(` Company ID: ${companyId}`);
+
+ // Create the company
+ console.log("4. Creating company...");
+ await client.query(
+ `INSERT INTO company (id, name, "baseCurrencyCode") VALUES ($1, $2, 'USD')`,
+ [companyId, DEV_COMPANY_NAME]
+ );
+ console.log(` Company "${DEV_COMPANY_NAME}" created.`);
+
+ // Seed the company with all default data
+ console.log("5. Seeding company with default data...");
+
+ // Create storage bucket
+ await client.query(
+ `INSERT INTO storage.buckets (id, name, public) VALUES ($1, $2, false)`,
+ [companyId, companyId]
+ );
+
+ // Link user to company
+ await client.query(
+ `INSERT INTO "userToCompany" ("userId", "companyId", "role") VALUES ($1, $2, 'employee')`,
+ [userId, companyId]
+ );
+
+ // Create groups
+ for (const group of groups) {
+ await client.query(
+ `INSERT INTO "group" (id, name, "isCustomerTypeGroup", "isEmployeeTypeGroup", "isSupplierTypeGroup", "companyId")
+ VALUES ($1, $2, $3, $4, $5, $6)`,
+ [
+ getGroupId(group.idPrefix, companyId),
+ group.name,
+ group.isCustomerTypeGroup,
+ group.isEmployeeTypeGroup,
+ group.isSupplierTypeGroup,
+ companyId
+ ]
+ );
+ }
+
+ // Create Admin employee type
+ const employeeTypeResult = await client.query(
+ `INSERT INTO "employeeType" (name, "companyId", protected) VALUES ('Admin', $1, true) RETURNING id`,
+ [companyId]
+ );
+ const employeeTypeId = employeeTypeResult.rows[0].id;
+
+ // Get available modules
+ const modulesResult = await client.query(`SELECT name FROM modules`);
+ const modules = modulesResult.rows as { name: string }[];
+
+ // Create employee type permissions
+ for (const module of modules) {
+ if (module.name) {
+ await client.query(
+ `INSERT INTO "employeeTypePermission" ("employeeTypeId", module, "create", "update", "delete", view)
+ VALUES ($1, $2, $3, $4, $5, $6)`,
+ [
+ employeeTypeId,
+ module.name,
+ [companyId],
+ [companyId],
+ [companyId],
+ [companyId]
+ ]
+ );
+ }
+ }
+
+ // Create employee record
+ await client.query(
+ `INSERT INTO employee (id, "employeeTypeId", "companyId", active) VALUES ($1, $2, $3, true)`,
+ [userId, employeeTypeId, companyId]
+ );
+
+ // Seed supplier statuses
+ for (const name of supplierStatuses) {
+ await client.query(
+ `INSERT INTO "supplierStatus" (name, "companyId", "createdBy") VALUES ($1, $2, 'system')`,
+ [name, companyId]
+ );
+ }
+
+ // Seed customer statuses
+ for (const name of customerStatuses) {
+ await client.query(
+ `INSERT INTO "customerStatus" (name, "companyId", "createdBy") VALUES ($1, $2, 'system')`,
+ [name, companyId]
+ );
+ }
+
+ // Seed scrap reasons
+ for (const name of scrapReasons) {
+ await client.query(
+ `INSERT INTO "scrapReason" (name, "companyId", "createdBy") VALUES ($1, $2, 'system')`,
+ [name, companyId]
+ );
+ }
+
+ // Seed payment terms
+ for (const pt of paymentTerms) {
+ await client.query(
+ `INSERT INTO "paymentTerm" (name, "daysDue", "calculationMethod", "daysDiscount", "discountPercentage", "companyId", "createdBy")
+ VALUES ($1, $2, $3, $4, $5, $6, 'system')`,
+ [
+ pt.name,
+ pt.daysDue,
+ pt.calculationMethod,
+ pt.daysDiscount,
+ pt.discountPercentage,
+ companyId
+ ]
+ );
+ }
+
+ // Seed units of measure
+ for (const uom of unitOfMeasures) {
+ await client.query(
+ `INSERT INTO "unitOfMeasure" (name, code, "companyId", "createdBy") VALUES ($1, $2, $3, 'system')`,
+ [uom.name, uom.code, companyId]
+ );
+ }
+
+ // Seed gauge types
+ for (const gt of gaugeTypes) {
+ await client.query(
+ `INSERT INTO "gaugeType" (name, "companyId", "createdBy") VALUES ($1, $2, 'system')`,
+ [gt, companyId]
+ );
+ }
+
+ // Seed maintenance failure modes
+ for (const fm of failureModes) {
+ await client.query(
+ `INSERT INTO "maintenanceFailureMode" (name, "companyId", "createdBy") VALUES ($1, $2, 'system')`,
+ [fm, companyId]
+ );
+ }
+
+ // Seed non-conformance types
+ for (const nct of nonConformanceTypes) {
+ await client.query(
+ `INSERT INTO "nonConformanceType" (name, "companyId", "createdBy") VALUES ($1, $2, 'system')`,
+ [nct, companyId]
+ );
+ }
+
+ // Seed non-conformance required actions
+ for (const nca of nonConformanceRequiredActions) {
+ await client.query(
+ `INSERT INTO "nonConformanceRequiredAction" (name, "companyId", "createdBy") VALUES ($1, $2, 'system')`,
+ [nca, companyId]
+ );
+ }
+
+ // Seed sequences
+ for (const seq of sequences) {
+ await client.query(
+ `INSERT INTO sequence ("table", name, prefix, suffix, next, size, step, "companyId")
+ VALUES ($1, $2, $3, NULL, $4, $5, $6, $7)`,
+ [
+ seq.table,
+ seq.name,
+ seq.prefix,
+ seq.next,
+ seq.size,
+ seq.step,
+ companyId
+ ]
+ );
+ }
+
+ // Seed currencies
+ for (const c of currencies) {
+ await client.query(
+ `INSERT INTO currency (code, "exchangeRate", "decimalPlaces", "companyId", "createdBy")
+ VALUES ($1, $2, $3, $4, 'system')`,
+ [c.code, c.exchangeRate, c.decimalPlaces, companyId]
+ );
+ }
+
+ // Seed account categories
+ const categoryIdMap: Record<string, string> = {};
+ for (const ac of accountCategories) {
+ const result = await client.query(
+ `INSERT INTO "accountCategory" (category, class, "incomeBalance", "companyId", "createdBy")
+ VALUES ($1, $2, $3, $4, 'system') RETURNING id`,
+ [ac.category, ac.class, ac.incomeBalance, companyId]
+ );
+ categoryIdMap[ac.category] = result.rows[0].id;
+ }
+
+ // Seed accounts (chart of accounts)
+ for (const acc of accounts) {
+ await client.query(
+ `INSERT INTO account (number, name, type, "accountCategoryId", "incomeBalance", class, "directPosting", "companyId", "createdBy")
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, 'system')`,
+ [
+ acc.number,
+ acc.name,
+ acc.type,
+ categoryIdMap[acc.accountCategory],
+ acc.incomeBalance,
+ acc.class,
+ acc.directPosting,
+ companyId
+ ]
+ );
+ }
+
+ // Seed account defaults
+ await client.query(
+ `INSERT INTO "accountDefault" (
+ "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", "companyId"
+ ) VALUES (
+ $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19,
+ $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40
+ )`,
+ [
+ accountDefaults.salesAccount,
+ accountDefaults.salesDiscountAccount,
+ accountDefaults.costOfGoodsSoldAccount,
+ accountDefaults.purchaseAccount,
+ accountDefaults.directCostAppliedAccount,
+ accountDefaults.overheadCostAppliedAccount,
+ accountDefaults.purchaseVarianceAccount,
+ accountDefaults.inventoryAdjustmentVarianceAccount,
+ accountDefaults.materialVarianceAccount,
+ accountDefaults.capacityVarianceAccount,
+ accountDefaults.overheadAccount,
+ accountDefaults.maintenanceAccount,
+ accountDefaults.assetDepreciationExpenseAccount,
+ accountDefaults.assetGainsAndLossesAccount,
+ accountDefaults.serviceChargeAccount,
+ accountDefaults.interestAccount,
+ accountDefaults.supplierPaymentDiscountAccount,
+ accountDefaults.customerPaymentDiscountAccount,
+ accountDefaults.roundingAccount,
+ accountDefaults.assetAquisitionCostAccount,
+ accountDefaults.assetAquisitionCostOnDisposalAccount,
+ accountDefaults.accumulatedDepreciationAccount,
+ accountDefaults.accumulatedDepreciationOnDisposalAccount,
+ accountDefaults.inventoryAccount,
+ accountDefaults.inventoryInterimAccrualAccount,
+ accountDefaults.workInProgressAccount,
+ accountDefaults.receivablesAccount,
+ accountDefaults.inventoryInvoicedNotReceivedAccount,
+ accountDefaults.bankCashAccount,
+ accountDefaults.bankLocalCurrencyAccount,
+ accountDefaults.bankForeignCurrencyAccount,
+ accountDefaults.prepaymentAccount,
+ accountDefaults.payablesAccount,
+ accountDefaults.inventoryReceivedNotInvoicedAccount,
+ accountDefaults.inventoryShippedNotInvoicedAccount,
+ accountDefaults.salesTaxPayableAccount,
+ accountDefaults.purchaseTaxPayableAccount,
+ accountDefaults.reverseChargeSalesTaxPayableAccount,
+ accountDefaults.retainedEarningsAccount,
+ companyId
+ ]
+ );
+
+ // Seed posting groups
+ await client.query(
+ `INSERT INTO "postingGroupInventory" (
+ "itemPostingGroupId", "locationId", "costOfGoodsSoldAccount", "inventoryAccount",
+ "inventoryInterimAccrualAccount", "inventoryReceivedNotInvoicedAccount",
+ "inventoryInvoicedNotReceivedAccount", "inventoryShippedNotInvoicedAccount",
+ "workInProgressAccount", "directCostAppliedAccount", "overheadCostAppliedAccount",
+ "purchaseVarianceAccount", "inventoryAdjustmentVarianceAccount", "materialVarianceAccount",
+ "capacityVarianceAccount", "overheadAccount", "companyId", "updatedBy"
+ ) VALUES (
+ NULL, NULL, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, 'system'
+ )`,
+ [
+ postingGroupInventory.costOfGoodsSoldAccount,
+ postingGroupInventory.inventoryAccount,
+ postingGroupInventory.inventoryInterimAccrualAccount,
+ postingGroupInventory.inventoryReceivedNotInvoicedAccount,
+ postingGroupInventory.inventoryInvoicedNotReceivedAccount,
+ postingGroupInventory.inventoryShippedNotInvoicedAccount,
+ postingGroupInventory.workInProgressAccount,
+ postingGroupInventory.directCostAppliedAccount,
+ postingGroupInventory.overheadCostAppliedAccount,
+ postingGroupInventory.purchaseVarianceAccount,
+ postingGroupInventory.inventoryAdjustmentVarianceAccount,
+ postingGroupInventory.materialVarianceAccount,
+ postingGroupInventory.capacityVarianceAccount,
+ postingGroupInventory.overheadAccount,
+ companyId
+ ]
+ );
+
+ await client.query(
+ `INSERT INTO "postingGroupPurchasing" (
+ "itemPostingGroupId", "supplierTypeId", "payablesAccount", "purchaseAccount",
+ "purchaseDiscountAccount", "purchaseCreditAccount", "purchasePrepaymentAccount",
+ "purchaseTaxPayableAccount", "companyId", "updatedBy"
+ ) VALUES (
+ NULL, NULL, $1, $2, $3, $4, $5, $6, $7, 'system'
+ )`,
+ [
+ postingGroupPurchasing.payablesAccount,
+ postingGroupPurchasing.purchaseAccount,
+ postingGroupPurchasing.purchaseDiscountAccount,
+ postingGroupPurchasing.purchaseCreditAccount,
+ postingGroupPurchasing.purchasePrepaymentAccount,
+ postingGroupPurchasing.purchaseTaxPayableAccount,
+ companyId
+ ]
+ );
+
+ await client.query(
+ `INSERT INTO "postingGroupSales" (
+ "itemPostingGroupId", "customerTypeId", "receivablesAccount", "salesAccount",
+ "salesDiscountAccount", "salesCreditAccount", "salesPrepaymentAccount",
+ "salesTaxPayableAccount", "companyId", "updatedBy"
+ ) VALUES (
+ NULL, NULL, $1, $2, $3, $4, $5, $6, $7, 'system'
+ )`,
+ [
+ postingGroupSales.receivablesAccount,
+ postingGroupSales.salesAccount,
+ postingGroupSales.salesDiscountAccount,
+ postingGroupSales.salesCreditAccount,
+ postingGroupSales.salesPrepaymentAccount,
+ postingGroupSales.salesTaxPayableAccount,
+ companyId
+ ]
+ );
+
+ // Seed fiscal year settings
+ await client.query(
+ `INSERT INTO "fiscalYearSettings" ("startMonth", "taxStartMonth", "companyId", "updatedBy")
+ VALUES ($1, $2, $3, 'system')`,
+ [
+ fiscalYearSettings.startMonth,
+ fiscalYearSettings.taxStartMonth,
+ companyId
+ ]
+ );
+
+ // Seed default location (required for inventory, jobs, etc.)
+ // Must be after accountDefaults since location trigger copies from accountDefaults
+ const locationResult = await client.query(
+ `INSERT INTO location (name, "addressLine1", city, "stateProvince", "postalCode", "countryCode", timezone, "companyId", "createdBy")
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, 'system') RETURNING id`,
+ [
+ defaultLocation.name,
+ defaultLocation.addressLine1,
+ defaultLocation.city,
+ defaultLocation.stateProvince,
+ defaultLocation.postalCode,
+ defaultLocation.countryCode,
+ defaultLocation.timezone,
+ companyId
+ ]
+ );
+ const locationId = locationResult.rows[0].id;
+
+ // Link employee to location (employeeJob)
+ await client.query(
+ `INSERT INTO "employeeJob" (id, "companyId", "locationId") VALUES ($1, $2, $3)`,
+ [userId, companyId, locationId]
+ );
+
+ // Update user permissions
+ console.log("6. Updating user permissions...");
+
+ // Build permissions object
+ const newPermissions: Record<string, string[]> = {};
+ for (const module of modules) {
+ const moduleName = module.name?.toLowerCase();
+ if (!moduleName) continue;
+
+ const permissionTypes = ["view", "create", "update", "delete"];
+ for (const type of permissionTypes) {
+ const key = `${moduleName}_${type}`;
+ newPermissions[key] = [companyId];
+ }
+ }
+
+ // Get current permissions and merge
+ const currentPermResult = await client.query(
+ `SELECT permissions FROM "userPermission" WHERE id = $1`,
+ [userId]
+ );
+
+ let finalPermissions = newPermissions;
+ if (
+ currentPermResult.rows.length > 0 &&
+ currentPermResult.rows[0].permissions
+ ) {
+ const currentPerms = currentPermResult.rows[0].permissions as Record<
+ string,
+ string[]
+ >;
+ finalPermissions = { ...currentPerms };
+ for (const [key, value] of Object.entries(newPermissions)) {
+ if (key in finalPermissions) {
+ if (!finalPermissions[key].includes(companyId)) {
+ finalPermissions[key].push(companyId);
+ }
+ } else {
+ finalPermissions[key] = value;
+ }
+ }
+ }
+
+ await client.query(
+ `UPDATE "userPermission" SET permissions = $1 WHERE id = $2`,
+ [JSON.stringify(finalPermissions), userId]
+ );
+
+ console.log(" User permissions updated.");
+
+ // Commit the transaction
+ await client.query("COMMIT");
+ console.log(" Transaction committed successfully.");
+
+ // Success!
+ console.log(`
+========================================
+Dev environment seeded successfully!
+========================================
+
+Login credentials:
+ Email: ${email}
+ Password: ${DEV_PASSWORD}
+
+Company: ${DEV_COMPANY_NAME}
+Company ID: ${companyId}
+
+You can now start the app and log in!
+`);
+ } catch (err) {
+ // Rollback on any error
+ await client.query("ROLLBACK");
+ console.error(" Transaction rolled back due to error.");
+ throw err;
+ }
+ } catch (error) {
+ console.error("\nError seeding development environment:");
+ console.error(error);
+ process.exit(1);
+ } finally {
+ client.release();
+ await pgPool.end();
+ }
+}
+
+seedDev();
diff --git a/packages/database/supabase/functions/lib/seed.ts b/packages/database/src/seed/seed.data.ts
similarity index 50%
rename from packages/database/supabase/functions/lib/seed.ts
rename to packages/database/src/seed/seed.data.ts
index cbbb20e760..d6e5d7f7e7 100644
--- a/packages/database/supabase/functions/lib/seed.ts
+++ b/packages/database/src/seed/seed.data.ts
@@ -1,123 +1,550 @@
-import { Database } from "./types.ts";
+/**
+ * Shared seed data for company initialization
+ * Used by both seed-dev.ts (Node.js) and seed-company edge function (Deno)
+ *
+ * This is the single source of truth for all seed data.
+ */
-export const accountCategories: Omit<
- Database["public"]["Tables"]["accountCategory"]["Insert"],
- "companyId"
->[] = [
+export const supplierStatuses = [
+ "Active",
+ "Inactive",
+ "Pending",
+ "Rejected"
+] as const;
+
+export const customerStatuses = [
+ "Active",
+ "Inactive",
+ "Lead",
+ "On Hold",
+ "Cancelled"
+] as const;
+
+export const scrapReasons = ["Defective", "Damaged", "Quality"] as const;
+
+export const paymentTerms = [
+ {
+ name: "Net 15",
+ daysDue: 15,
+ calculationMethod: "Net",
+ daysDiscount: 0,
+ discountPercentage: 0,
+ createdBy: "system"
+ },
+ {
+ name: "Net 30",
+ daysDue: 30,
+ calculationMethod: "Net",
+ daysDiscount: 0,
+ discountPercentage: 0,
+ createdBy: "system"
+ },
+ {
+ name: "Net 60",
+ daysDue: 60,
+ calculationMethod: "Net",
+ daysDiscount: 0,
+ discountPercentage: 0,
+ createdBy: "system"
+ },
+ {
+ name: "1% 10 Net 30",
+ daysDue: 30,
+ calculationMethod: "Net",
+ daysDiscount: 10,
+ discountPercentage: 1,
+ createdBy: "system"
+ },
+ {
+ name: "2% 10 Net 30",
+ daysDue: 30,
+ calculationMethod: "Net",
+ daysDiscount: 10,
+ discountPercentage: 2,
+ createdBy: "system"
+ },
+ {
+ name: "COD",
+ daysDue: 0,
+ calculationMethod: "Net",
+ daysDiscount: 0,
+ discountPercentage: 0,
+ createdBy: "system"
+ },
+ {
+ name: "Net EOM 10th",
+ daysDue: 10,
+ calculationMethod: "End of Month",
+ daysDiscount: 0,
+ discountPercentage: 0,
+ createdBy: "system"
+ }
+] as const;
+
+export const unitOfMeasures = [
+ { name: "Each", code: "EA", createdBy: "system" },
+ { 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" }
+] as const;
+
+export const gaugeTypes = [
+ "Gauge Block",
+ "Caliper - Inside",
+ "Caliper - Outside",
+ "Caliper - Depth",
+ "Micrometer - Outside",
+ "Micrometer - Inside",
+ "Micrometer - Depth",
+ "Dial Indicator",
+ "Height Gauge",
+ "Thread Gauge",
+ "Pin Gauge",
+ "Ring Gauge",
+ "Plug Gauge",
+ "Bore Gauge",
+ "Feeler Gauge",
+ "Surface Plate",
+ "Go/No-Go Gauge",
+ "Profile Gauge",
+ "Coordinate Measuring Machine (CMM)",
+ "Optical Comparator"
+] as const;
+
+export const failureModes = [
+ "Bearing Failure",
+ "Lubrication Failure",
+ "Electrical Fault",
+ "Leak",
+ "Excessive Wear",
+ "Misalignment",
+ "Overheating",
+ "Cracking/Fatigue",
+ "Blockage",
+ "Excessive Vibration"
+] as const;
+
+export const nonConformanceTypes = [
+ { name: "Design Error", createdBy: "system" },
+ { name: "Manufacturing Defect", createdBy: "system" },
+ { name: "Process Deviation", createdBy: "system" },
+ { name: "Material Issue", createdBy: "system" },
+ { name: "Testing Failure", createdBy: "system" },
+ { name: "Documentation Error", createdBy: "system" },
+ { name: "Training Issue", createdBy: "system" },
+ { name: "Equipment Malfunction", createdBy: "system" },
+ { name: "Supplier Issue", createdBy: "system" },
+ { name: "Customer Complaint", createdBy: "system" }
+] as const;
+
+export const nonConformanceRequiredActions = [
+ { name: "Corrective Action", createdBy: "system" },
+ { name: "Preventive Action", createdBy: "system" },
+ { name: "Containment Action", createdBy: "system" },
+ { name: "Verification", createdBy: "system" },
+ { name: "Customer Communication", createdBy: "system" },
+ { name: "Root Cause Analysis", createdBy: "system" },
+ { name: "Inventory", createdBy: "system" },
+ { name: "WIP", createdBy: "system" },
+ { name: "Finished Goods", createdBy: "system" },
+ { name: "Incoming Materials", createdBy: "system" },
+ { name: "Process", createdBy: "system" },
+ { name: "Documentation", createdBy: "system" }
+] as const;
+
+export const sequences = [
+ {
+ table: "job",
+ name: "Job",
+ prefix: "J",
+ suffix: null,
+ next: 0,
+ size: 6,
+ step: 1
+ },
+ {
+ table: "gauge",
+ name: "Gauge",
+ prefix: "G",
+ suffix: null,
+ next: 0,
+ size: 5,
+ step: 1
+ },
+ {
+ table: "maintenanceDispatch",
+ name: "Maintenance Dispatch",
+ prefix: "MAIN",
+ suffix: null,
+ next: 0,
+ size: 6,
+ step: 1
+ },
+ {
+ table: "nonConformance",
+ name: "Issue",
+ prefix: "NCR",
+ suffix: null,
+ next: 0,
+ size: 6,
+ step: 1
+ },
+ {
+ 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: "purchasingRfq",
+ name: "Purchasing RFQ",
+ prefix: "PRFQ",
+ suffix: null,
+ next: 0,
+ size: 6,
+ step: 1
+ },
+ {
+ table: "receipt",
+ name: "Receipt",
+ prefix: "RE",
+ suffix: null,
+ next: 0,
+ size: 6,
+ step: 1
+ },
+ {
+ table: "salesRfq",
+ name: "RFQ (Sales)",
+ prefix: "RFQ",
+ 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: "stockTransfer",
+ name: "Stock Transfer",
+ prefix: "ST",
+ suffix: null,
+ next: 0,
+ size: 6,
+ step: 1
+ },
+ {
+ table: "quote",
+ name: "Quote",
+ prefix: "Q",
+ suffix: null,
+ next: 0,
+ size: 6,
+ step: 1
+ },
+ {
+ table: "supplierQuote",
+ name: "Supplier Quote",
+ prefix: "SQ",
+ suffix: null,
+ next: 0,
+ size: 6,
+ step: 1
+ },
+ {
+ table: "shipment",
+ name: "Shipment",
+ prefix: "SHP",
+ suffix: null,
+ next: 0,
+ size: 6,
+ step: 1
+ },
+ {
+ table: "warehouseTransfer",
+ name: "Warehouse Transfer",
+ prefix: "WT",
+ suffix: null,
+ next: 0,
+ size: 6,
+ step: 1
+ }
+] as const;
+
+// All 118 currencies from the original seed
+export const currencies = [
+ { code: "USD", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "CAD", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "EUR", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "AED", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "AFN", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "ALL", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "AMD", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "ARS", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "AUD", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "AZN", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "BAM", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "BDT", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "BGN", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "BHD", exchangeRate: 1, decimalPlaces: 3, createdBy: "system" },
+ { code: "BIF", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "BND", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "BOB", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "BRL", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "BWP", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "BYN", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "BZD", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "CDF", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "CHF", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "CLP", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "CNY", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "COP", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "CRC", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "CVE", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "CZK", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "DJF", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "DKK", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "DOP", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "DZD", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "EGP", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "ERN", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "ETB", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "GBP", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "GEL", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "GHS", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "GNF", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "GTQ", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "HKD", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "HNL", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "HRK", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "HUF", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "IDR", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "ILS", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "INR", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "IQD", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "IRR", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "ISK", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "JMD", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "JOD", exchangeRate: 1, decimalPlaces: 3, createdBy: "system" },
+ { code: "JPY", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "KES", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "KHR", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "KMF", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "KRW", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "KWD", exchangeRate: 1, decimalPlaces: 3, createdBy: "system" },
+ { code: "KZT", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "LBP", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "LKR", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "LTL", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "LVL", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "LYD", exchangeRate: 1, decimalPlaces: 3, createdBy: "system" },
+ { code: "MAD", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "MDL", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "MGA", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "MKD", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "MMK", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "MOP", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "MUR", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "MXN", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "MYR", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "MZN", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "NAD", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "NGN", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "NIO", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "NOK", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "NPR", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "NZD", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "OMR", exchangeRate: 1, decimalPlaces: 3, createdBy: "system" },
+ { code: "PAB", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "PEN", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "PHP", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "PKR", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "PLN", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "PYG", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "QAR", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "RON", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "RSD", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "RUB", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "RWF", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "SAR", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "SDG", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "SEK", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "SGD", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "SOS", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "SYP", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "THB", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "TND", exchangeRate: 1, decimalPlaces: 3, createdBy: "system" },
+ { code: "TOP", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "TRY", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "TTD", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "TWD", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "TZS", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "UAH", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "UGX", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "UYU", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "UZS", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "VEF", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "VND", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "XAF", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "XOF", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "YER", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "ZAR", exchangeRate: 1, decimalPlaces: 2, createdBy: "system" },
+ { code: "ZMK", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" },
+ { code: "ZWL", exchangeRate: 1, decimalPlaces: 0, createdBy: "system" }
+] as const;
+
+export const accountCategories = [
{
category: "Bank",
class: "Asset",
incomeBalance: "Balance Sheet",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Accounts Receivable",
class: "Asset",
incomeBalance: "Balance Sheet",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Inventory",
class: "Asset",
incomeBalance: "Balance Sheet",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Other Current Asset",
class: "Asset",
incomeBalance: "Balance Sheet",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Fixed Asset",
class: "Asset",
incomeBalance: "Balance Sheet",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Accumulated Depreciation",
class: "Asset",
incomeBalance: "Balance Sheet",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Other Asset",
class: "Asset",
incomeBalance: "Balance Sheet",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Accounts Payable",
class: "Liability",
incomeBalance: "Balance Sheet",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Other Current Liability",
class: "Liability",
incomeBalance: "Balance Sheet",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Long Term Liability",
class: "Liability",
incomeBalance: "Balance Sheet",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Equity - No Close",
class: "Equity",
incomeBalance: "Balance Sheet",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Equity - Close",
class: "Equity",
incomeBalance: "Balance Sheet",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Retained Earnings",
class: "Equity",
incomeBalance: "Balance Sheet",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Income",
class: "Revenue",
incomeBalance: "Income Statement",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Cost of Goods Sold",
class: "Expense",
incomeBalance: "Income Statement",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Expense",
class: "Expense",
incomeBalance: "Income Statement",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Other Income",
class: "Expense",
incomeBalance: "Income Statement",
- createdBy: "system",
+ createdBy: "system"
},
{
category: "Other Expense",
class: "Expense",
incomeBalance: "Income Statement",
- createdBy: "system",
- },
-];
+ createdBy: "system"
+ }
+] as const;
-export const accounts: (Omit<
- Database["public"]["Tables"]["account"]["Insert"],
- "companyId" | "accountCategoryId"
-> & { accountCategory: string | null })[] = [
+// Complete chart of accounts (64 accounts)
+export const accounts = [
{
number: "10000",
name: "Income Statement",
@@ -126,7 +553,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: null,
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "11000",
@@ -136,7 +563,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Revenue",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "11210",
@@ -146,7 +573,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Revenue",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "11600",
@@ -156,7 +583,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Revenue",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "19999",
@@ -166,7 +593,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Revenue",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "20000",
@@ -176,7 +603,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "21210",
@@ -186,7 +613,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "21410",
@@ -196,7 +623,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "21590",
@@ -206,7 +633,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "21600",
@@ -216,7 +643,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "21610",
@@ -226,7 +653,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "21700",
@@ -236,7 +663,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "24999",
@@ -246,7 +673,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "25000",
@@ -256,7 +683,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "25705",
@@ -266,7 +693,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "25710",
@@ -276,7 +703,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "25720",
@@ -286,7 +713,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "47045",
@@ -296,7 +723,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "49999",
@@ -306,7 +733,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "50000",
@@ -316,7 +743,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "50015",
@@ -326,7 +753,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "50040",
@@ -336,7 +763,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "50045",
@@ -346,7 +773,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "50999",
@@ -356,7 +783,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "51000",
@@ -366,7 +793,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "51110",
@@ -376,7 +803,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "51115",
@@ -386,7 +813,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "51120",
@@ -396,7 +823,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "51235",
@@ -406,7 +833,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "51999",
@@ -416,7 +843,7 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: "Expense",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "79999",
@@ -426,16 +853,17 @@ export const accounts: (Omit<
incomeBalance: "Income Statement",
class: null,
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "80000",
name: "Balance Sheet",
type: "Begin Total",
- incomeBalance: "Balance Sheet",
accountCategory: null,
+ incomeBalance: "Balance Sheet",
+ class: null,
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "80001",
@@ -445,7 +873,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "81000",
@@ -455,7 +883,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "81010",
@@ -465,7 +893,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "81015",
@@ -475,7 +903,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "81020",
@@ -485,7 +913,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "81030",
@@ -495,7 +923,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "81999",
@@ -505,7 +933,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "83000",
@@ -515,7 +943,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "83105",
@@ -525,7 +953,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "83120",
@@ -535,7 +963,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "83125",
@@ -545,7 +973,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "85005",
@@ -555,7 +983,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "85020",
@@ -565,7 +993,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "86005",
@@ -575,7 +1003,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "86010",
@@ -585,7 +1013,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "86015",
@@ -595,7 +1023,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "87999",
@@ -605,7 +1033,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "89999",
@@ -615,7 +1043,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Asset",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "90000",
@@ -625,7 +1053,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Liability",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "92210",
@@ -635,7 +1063,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Liability",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "93005",
@@ -645,7 +1073,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Liability",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "93010",
@@ -655,7 +1083,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Liability",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "93110",
@@ -665,7 +1093,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Liability",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "94100",
@@ -675,7 +1103,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Liability",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "94110",
@@ -685,7 +1113,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Liability",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "94115",
@@ -695,7 +1123,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Liability",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "94999",
@@ -705,7 +1133,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Liability",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "95000",
@@ -715,7 +1143,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Equity",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "95010",
@@ -725,7 +1153,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Equity",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "96010",
@@ -735,7 +1163,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Equity",
directPosting: true,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "96999",
@@ -745,7 +1173,7 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: "Equity",
directPosting: false,
- createdBy: "system",
+ createdBy: "system"
},
{
number: "99999",
@@ -755,9 +1183,9 @@ export const accounts: (Omit<
incomeBalance: "Balance Sheet",
class: null,
directPosting: false,
- createdBy: "system",
- },
-];
+ createdBy: "system"
+ }
+] as const;
export const accountDefaults = {
salesAccount: "11210",
@@ -798,1245 +1226,105 @@ export const accountDefaults = {
salesTaxPayableAccount: "94100",
purchaseTaxPayableAccount: "94110",
reverseChargeSalesTaxPayableAccount: "94115",
- retainedEarningsAccount: "95010",
-};
+ retainedEarningsAccount: "95010"
+} as const;
-export const currencies = [
- {
- code: "USD",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "CAD",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "EUR",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "AED",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
+export const postingGroupInventory = {
+ costOfGoodsSoldAccount: accountDefaults.costOfGoodsSoldAccount,
+ inventoryAccount: accountDefaults.inventoryAccount,
+ inventoryInterimAccrualAccount:
+ accountDefaults.inventoryInterimAccrualAccount,
+ inventoryReceivedNotInvoicedAccount:
+ accountDefaults.inventoryReceivedNotInvoicedAccount,
+ inventoryInvoicedNotReceivedAccount:
+ accountDefaults.inventoryInvoicedNotReceivedAccount,
+ inventoryShippedNotInvoicedAccount:
+ accountDefaults.inventoryShippedNotInvoicedAccount,
+ workInProgressAccount: accountDefaults.workInProgressAccount,
+ directCostAppliedAccount: accountDefaults.directCostAppliedAccount,
+ overheadCostAppliedAccount: accountDefaults.overheadCostAppliedAccount,
+ purchaseVarianceAccount: accountDefaults.purchaseVarianceAccount,
+ inventoryAdjustmentVarianceAccount:
+ accountDefaults.inventoryAdjustmentVarianceAccount,
+ materialVarianceAccount: accountDefaults.materialVarianceAccount,
+ capacityVarianceAccount: accountDefaults.capacityVarianceAccount,
+ overheadAccount: accountDefaults.overheadAccount,
+ updatedBy: "system"
+} as const;
+
+export const postingGroupPurchasing = {
+ payablesAccount: accountDefaults.payablesAccount,
+ purchaseAccount: accountDefaults.purchaseAccount,
+ purchaseDiscountAccount: accountDefaults.purchaseAccount,
+ purchaseCreditAccount: accountDefaults.purchaseAccount,
+ purchasePrepaymentAccount: accountDefaults.prepaymentAccount,
+ purchaseTaxPayableAccount: accountDefaults.purchaseTaxPayableAccount,
+ updatedBy: "system"
+} as const;
+
+export const postingGroupSales = {
+ receivablesAccount: accountDefaults.receivablesAccount,
+ salesAccount: accountDefaults.salesAccount,
+ salesDiscountAccount: accountDefaults.salesDiscountAccount,
+ salesCreditAccount: accountDefaults.salesAccount,
+ salesPrepaymentAccount: accountDefaults.prepaymentAccount,
+ salesTaxPayableAccount: accountDefaults.salesTaxPayableAccount,
+ updatedBy: "system"
+} as const;
+
+export const fiscalYearSettings = {
+ startMonth: "January",
+ taxStartMonth: "January",
+ updatedBy: "system"
+} as const;
+
+/**
+ * Default location seeded for new companies
+ * Required for inventory quantities, jobs, and other location-dependent features
+ */
+export const defaultLocation = {
+ name: "Headquarters",
+ addressLine1: "123 Main Street",
+ city: "Austin",
+ stateProvince: "TX",
+ postalCode: "78701",
+ countryCode: "US",
+ timezone: "America/Chicago",
+ createdBy: "system"
+} as const;
+
+export const groups = [
{
- code: "AFN",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
+ idPrefix: "00000000-0000",
+ name: "All Employees",
+ isCustomerTypeGroup: false,
+ isEmployeeTypeGroup: true,
+ isSupplierTypeGroup: false
},
{
- code: "ALL",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
+ idPrefix: "11111111-1111",
+ name: "All Customers",
+ isCustomerTypeGroup: true,
+ isEmployeeTypeGroup: false,
+ isSupplierTypeGroup: false
},
{
- code: "AMD",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "ARS",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "AUD",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "AZN",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "BAM",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "BDT",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "BGN",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "BHD",
- exchangeRate: 1,
- decimalPlaces: 3,
- createdBy: "system",
- },
- {
- code: "BIF",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "BND",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "BOB",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "BRL",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "BWP",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "BYN",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "BZD",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "CDF",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "CHF",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "CLP",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "CNY",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "COP",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "CRC",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "CVE",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "CZK",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "DJF",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "DKK",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "DOP",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "DZD",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "EGP",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "ERN",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "ETB",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "GBP",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "GEL",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "GHS",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "GNF",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "GTQ",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "HKD",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "HNL",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "HRK",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "HUF",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "IDR",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "ILS",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "INR",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "IQD",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "IRR",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "ISK",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "JMD",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "JOD",
- exchangeRate: 1,
- decimalPlaces: 3,
- createdBy: "system",
- },
- {
- code: "JPY",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "KES",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "KHR",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "KMF",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "KRW",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "KWD",
- exchangeRate: 1,
- decimalPlaces: 3,
- createdBy: "system",
- },
- {
- code: "KZT",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "LBP",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "LKR",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "LTL",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "LVL",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "LYD",
- exchangeRate: 1,
- decimalPlaces: 3,
- createdBy: "system",
- },
- {
- code: "MAD",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "MDL",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "MGA",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "MKD",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "MMK",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "MOP",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "MUR",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "MXN",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "MYR",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "MZN",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "NAD",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "NGN",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "NIO",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "NOK",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "NPR",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "NZD",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "OMR",
- exchangeRate: 1,
- decimalPlaces: 3,
- createdBy: "system",
- },
- {
- code: "PAB",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "PEN",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "PHP",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "PKR",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "PLN",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "PYG",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "QAR",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "RON",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "RSD",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "RUB",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "RWF",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "SAR",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "SDG",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "SEK",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "SGD",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "SOS",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "SYP",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "THB",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "TND",
- exchangeRate: 1,
- decimalPlaces: 3,
- createdBy: "system",
- },
- {
- code: "TOP",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "TRY",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "TTD",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "TWD",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "TZS",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "UAH",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "UGX",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "UYU",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "UZS",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "VEF",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "VND",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "XAF",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "XOF",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "YER",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "ZAR",
- exchangeRate: 1,
- decimalPlaces: 2,
- createdBy: "system",
- },
- {
- code: "ZMK",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
- {
- code: "ZWL",
- exchangeRate: 1,
- decimalPlaces: 0,
- createdBy: "system",
- },
-];
-
-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",
-};
-
-export const gaugeTypes = [
- "Gauge Block",
- "Caliper - Inside",
- "Caliper - Outside",
- "Caliper - Depth",
- "Micrometer - Outside",
- "Micrometer - Inside",
- "Micrometer - Depth",
- "Dial Indicator",
- "Height Gauge",
- "Thread Gauge",
- "Pin Gauge",
- "Ring Gauge",
- "Plug Gauge",
- "Bore Gauge",
- "Feeler Gauge",
- "Surface Plate",
- "Go/No-Go Gauge",
- "Profile Gauge",
- "Coordinate Measuring Machine (CMM)",
- "Optical Comparator",
-];
+ idPrefix: "22222222-2222",
+ name: "All Suppliers",
+ isCustomerTypeGroup: false,
+ isEmployeeTypeGroup: false,
+ isSupplierTypeGroup: true
+ }
+] as const;
-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];
+/**
+ * Helper to generate group ID from idPrefix and company ID
+ * The resulting ID format: {idPrefix}-{companyId formatted as XXXX-YYYY-ZZZZZZZZZZZZ}
+ */
+export function getGroupId(idPrefix: string, companyId: string): string {
+ const companyIdPart = `${companyId.substring(0, 4)}-${companyId.substring(
+ 4,
+ 8
+ )}-${companyId.substring(8, 20)}`;
+ return `${idPrefix}-${companyIdPart}`;
}
-
-export const groupCompanyTemplate = "<%=XXXX-YYYY-ZZZZZZZZZZZZ=%>";
-export const groups = [
- {
- id: `00000000-0000-${groupCompanyTemplate}`,
- name: "All Employees",
- isCustomerTypeGroup: false,
- isEmployeeTypeGroup: true,
- isSupplierTypeGroup: false,
- },
- {
- id: `11111111-1111-${groupCompanyTemplate}`,
- name: "All Customers",
- isCustomerTypeGroup: true,
- isEmployeeTypeGroup: false,
- isSupplierTypeGroup: false,
- },
- {
- id: `22222222-2222-${groupCompanyTemplate}`,
- name: "All Suppliers",
- isCustomerTypeGroup: false,
- isEmployeeTypeGroup: false,
- isSupplierTypeGroup: true,
- },
-];
-
-export const failureModes: string[] = [
- "Bearing Failure",
- "Lubrication Failure",
- "Electrical Fault",
- "Leak",
- "Excessive Wear",
- "Misalignment",
- "Overheating",
- "Cracking/Fatigue",
- "Blockage",
- "Excessive Vibration"
-];
-
-export const nonConformanceTypes: Omit<
- Database["public"]["Tables"]["nonConformanceType"]["Insert"],
- "companyId"
->[] = [
- {
- name: "Design Error",
- createdBy: "system",
- },
- {
- name: "Manufacturing Defect",
- createdBy: "system",
- },
- {
- name: "Process Deviation",
- createdBy: "system",
- },
- {
- name: "Material Issue",
- createdBy: "system",
- },
- {
- name: "Testing Failure",
- createdBy: "system",
- },
- {
- name: "Documentation Error",
- createdBy: "system",
- },
- {
- name: "Training Issue",
- createdBy: "system",
- },
- {
- name: "Equipment Malfunction",
- createdBy: "system",
- },
- {
- name: "Supplier Issue",
- createdBy: "system",
- },
- {
- name: "Customer Complaint",
- createdBy: "system",
- },
-];
-
-
-export const nonConformanceRequiredActions: Omit<
- Database["public"]["Tables"]["nonConformanceRequiredAction"]["Insert"],
- "companyId"
->[] = [
- {
- name: "Corrective Action",
- createdBy: "system",
- },
- {
- name: "Preventive Action",
- createdBy: "system",
- },
- {
- name: "Containment Action",
- createdBy: "system",
- },
- {
- name: "Verification",
- createdBy: "system",
- },
- {
- name: "Customer Communication",
- createdBy: "system",
- },
- {
- name: "Root Cause Analysis",
- createdBy: "system",
- },
- {
- name: "Inventory",
- createdBy: "system",
- },
- {
- name: "WIP",
- createdBy: "system",
- },
- {
- name: "Finished Goods",
- createdBy: "system",
- },
- {
- name: "Incoming Materials",
- createdBy: "system",
- },
- {
- name: "Process",
- createdBy: "system",
- },
- {
- name: "Documentation",
- createdBy: "system",
- },
-];
-
-export const paymentTerms: Omit<
- Database["public"]["Tables"]["paymentTerm"]["Insert"],
- "companyId"
->[] = [
- {
- name: "Net 15",
- daysDue: 15,
- calculationMethod: "Net",
- daysDiscount: 0,
- discountPercentage: 0,
- createdBy: "system",
- },
- {
- name: "Net 30",
- daysDue: 30,
- calculationMethod: "Net",
- daysDiscount: 0,
- discountPercentage: 0,
- createdBy: "system",
- },
- {
- name: "Net 60",
- daysDue: 60,
- calculationMethod: "Net",
- daysDiscount: 0,
- discountPercentage: 0,
- createdBy: "system",
- },
- {
- name: "1% 10 Net 30",
- daysDue: 30,
- calculationMethod: "Net",
- daysDiscount: 10,
- discountPercentage: 1,
- createdBy: "system",
- },
- {
- name: "2% 10 Net 30",
- daysDue: 30,
- calculationMethod: "Net",
- daysDiscount: 10,
- discountPercentage: 2,
- createdBy: "system",
- },
- {
- name: "COD",
- daysDue: 0,
- calculationMethod: "Net",
- daysDiscount: 0,
- discountPercentage: 0,
- createdBy: "system",
- },
- {
- name: "Net EOM 10th",
- daysDue: 10,
- calculationMethod: "End of Month",
- daysDiscount: 0,
- discountPercentage: 0,
- createdBy: "system",
- },
-];
-
-export const postingGroupInventory = {
- itemPostingGroupId: null,
- locationId: null,
- costOfGoodsSoldAccount: getDefaultAccount("costOfGoodsSoldAccount"),
- inventoryAccount: getDefaultAccount("inventoryAccount"),
- inventoryInterimAccrualAccount: getDefaultAccount(
- "inventoryInterimAccrualAccount"
- ),
- inventoryReceivedNotInvoicedAccount: getDefaultAccount(
- "inventoryReceivedNotInvoicedAccount"
- ),
- inventoryInvoicedNotReceivedAccount: getDefaultAccount(
- "inventoryInvoicedNotReceivedAccount"
- ),
- inventoryShippedNotInvoicedAccount: getDefaultAccount(
- "inventoryShippedNotInvoicedAccount"
- ),
- workInProgressAccount: getDefaultAccount("workInProgressAccount"),
- directCostAppliedAccount: getDefaultAccount("directCostAppliedAccount"),
- overheadCostAppliedAccount: getDefaultAccount("overheadCostAppliedAccount"),
- purchaseVarianceAccount: getDefaultAccount("purchaseVarianceAccount"),
- inventoryAdjustmentVarianceAccount: getDefaultAccount(
- "inventoryAdjustmentVarianceAccount"
- ),
- materialVarianceAccount: getDefaultAccount("materialVarianceAccount"),
- capacityVarianceAccount: getDefaultAccount("capacityVarianceAccount"),
- overheadAccount: getDefaultAccount("overheadAccount"),
- updatedBy: "system",
-};
-
-export const postingGroupPurchasing = {
- itemPostingGroupId: null,
- supplierTypeId: null,
- payablesAccount: getDefaultAccount("payablesAccount"),
- purchaseAccount: getDefaultAccount("purchaseAccount"),
- purchaseDiscountAccount: getDefaultAccount("purchaseAccount"),
- purchaseCreditAccount: getDefaultAccount("purchaseAccount"),
- purchasePrepaymentAccount: getDefaultAccount("prepaymentAccount"),
- purchaseTaxPayableAccount: getDefaultAccount("purchaseTaxPayableAccount"),
- updatedBy: "system",
-};
-
-export const postingGroupSales = {
- itemPostingGroupId: null,
- customerTypeId: null,
- receivablesAccount: getDefaultAccount("receivablesAccount"),
- salesAccount: getDefaultAccount("salesAccount"),
- salesDiscountAccount: getDefaultAccount("salesDiscountAccount"),
- salesCreditAccount: getDefaultAccount("salesAccount"),
- salesPrepaymentAccount: getDefaultAccount("prepaymentAccount"),
- salesTaxPayableAccount: getDefaultAccount("salesTaxPayableAccount"),
- updatedBy: "system",
-};
-
-export const scrapReasons = ["Defective", "Damaged", "Quality"];
-
-export const sequences = [
- {
- table: "job",
- name: "Job",
- prefix: "J",
- suffix: null,
- next: 0,
- size: 6,
- step: 1,
- },
- {
- table: "gauge",
- name: "Gauge",
- prefix: "G",
- suffix: null,
- next: 0,
- },
- {
- table: "maintenanceDispatch",
- name: "Maintenance Dispatch",
- prefix: "MAIN",
- suffix: null,
- next: 0,
- size: 6,
- step: 1,
- },
- {
- table: "nonConformance",
- name: "Issue",
- prefix: "NCR",
- suffix: null,
- next: 0,
- size: 6,
- step: 1,
- },
- {
- 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: "purchasingRfq",
- name: "Purchasing RFQ",
- prefix: "PRFQ",
- suffix: null,
- next: 0,
- size: 6,
- step: 1,
- },
- {
- table: "receipt",
- name: "Receipt",
- prefix: "RE",
- suffix: null,
- next: 0,
- size: 6,
- step: 1,
- },
- {
- table: "salesRfq",
- name: "RFQ (Sales)",
- prefix: "RFQ",
- 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: "stockTransfer",
- name: "Stock Transfer",
- prefix: "ST",
- suffix: null,
- next: 0,
- size: 6,
- step: 1,
- },
- {
- table: "quote",
- name: "Quote",
- prefix: "Q",
- suffix: null,
- next: 0,
- size: 6,
- step: 1,
- },
- {
- table: "supplierQuote",
- name: "Supplier Quote",
- prefix: "SQ",
- suffix: null,
- next: 0,
- size: 6,
- step: 1,
- },
- {
- table: "shipment",
- name: "Shipment",
- prefix: "SHP",
- suffix: null,
- next: 0,
- size: 6,
- step: 1,
- },
- {
- table: "warehouseTransfer",
- name: "Warehouse Transfer",
- prefix: "WT",
- suffix: null,
- next: 0,
- size: 6,
- step: 1,
- },
-];
-
-export const supplierStauses = ["Active", "Inactive", "Pending", "Rejected"];
-
-export const unitOfMeasures = [
- {
- name: "Each",
- code: "EA",
- createdBy: "system",
- },
- {
- 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",
- },
-];
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index c52242bff5..21fd9baa0e 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -48677,14 +48677,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -51808,14 +51808,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
diff --git a/packages/database/supabase/seed.sql b/packages/database/supabase/seed.sql
index b33ce06d1f..31907d73da 100644
--- a/packages/database/supabase/seed.sql
+++ b/packages/database/supabase/seed.sql
@@ -1,70 +1,3 @@
--- Insert admin user into auth.users table and public.user table
-WITH new_auth_user AS (
- INSERT INTO auth.users (
- instance_id, id, aud, role, email, encrypted_password,
- email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at,
- recovery_token, recovery_sent_at, email_change_token_new, email_change,
- email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data,
- is_super_admin, created_at, updated_at, phone, phone_confirmed_at,
- phone_change, phone_change_token, phone_change_sent_at,
- email_change_token_current, email_change_confirm_status, banned_until,
- reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, is_anonymous
- ) VALUES (
- '00000000-0000-0000-0000-000000000000',
- uuid_generate_v4(),
- 'authenticated',
- 'authenticated',
- crypt(md5(random()::text), gen_salt('bf')),
- CURRENT_TIMESTAMP,
- NULL,
- '',
- NULL,
- '',
- NULL,
- '',
- '',
- NULL,
- NULL,
- '{"role": "employee", "provider": "email", "providers": ["email"]}',
- '{}',
- NULL,
- CURRENT_TIMESTAMP,
- CURRENT_TIMESTAMP,
- NULL,
- NULL,
- '',
- '',
- NULL,
- '',
- 0,
- NULL,
- '',
- NULL,
- false,
- NULL,
- false
- ) RETURNING id
-),
-new_user_identity AS (
- INSERT INTO auth.identities (
- user_id,
- provider_id,
- identity_data,
- provider,
- last_sign_in_at,
- created_at,
- updated_at
- )
- SELECT
- id,
- id,
- format('{"sub":"%s","email":"%s"}', id, '[email protected]')::jsonb,
- 'email',
- CURRENT_TIMESTAMP,
- CURRENT_TIMESTAMP,
- CURRENT_TIMESTAMP
- FROM new_auth_user
- RETURNING user_id
-)
-SELECT user_id FROM new_user_identity;
\ No newline at end of file
+-- This file is intentionally empty.
+-- User and company seeding is now handled by the seed-dev.ts script.
+-- Run: npm run db:seed:dev -- --email [email protected]