From 6ea1a7a1160e74f131a9b2366e33fd45c8be9e5f Mon Sep 17 00:00:00 2001 From: Noor Fahim Date: Sat, 3 Oct 2026 18:49:20 +0600 Subject: [PATCH 1/2] Pay salaries month by month with proof; digital currency accounts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Payroll: clicking an employee shows their salary by month. Each month can be paid with a required payment screenshot (expense in Payroll on their project) or undone. Individual payments share the month's run, which skips them when posted and keeps them when un-posted. - Accounts: new "Digital currency (crypto)" account type with BTC, ETH, USDT, USDC, BNB and SOL, each with its own precision and symbol. Currency codes may be 3-5 letters (migration 0006 widens the columns). Crypto prices come from rates entered in Settings → Currency. Co-Authored-By: Claude Opus 5.5 --- apps/api/drizzle/0006_digital_currency.sql | 19 + apps/api/drizzle/meta/0006_snapshot.json | 9777 +++++++++++++++++ apps/api/drizzle/meta/_journal.json | 7 + apps/api/src/db/schema/_columns.ts | 2 +- .../modules/business/business.controller.ts | 15 + .../src/modules/business/payroll.service.ts | 191 +- .../src/modules/copilot/copilot.actions.ts | 4 +- apps/api/tests/integration/business.test.ts | 59 +- .../src/components/accounts/account-form.tsx | 6 +- .../src/components/accounts/accounts-view.tsx | 5 +- .../src/components/app/transaction-form.tsx | 4 +- apps/web/src/components/business/payroll.tsx | 284 +- .../src/components/settings/misc-settings.tsx | 4 +- apps/web/src/components/wealth/shared.tsx | 4 +- apps/web/src/lib/api/types/business.ts | 9 + packages/core/src/constants.ts | 37 +- packages/core/src/contracts/business-extra.ts | 17 + packages/core/src/contracts/common.ts | 2 +- packages/core/src/money.ts | 14 + packages/core/tests/money-dates.test.ts | 14 + 20 files changed, 10447 insertions(+), 27 deletions(-) create mode 100644 apps/api/drizzle/0006_digital_currency.sql create mode 100644 apps/api/drizzle/meta/0006_snapshot.json diff --git a/apps/api/drizzle/0006_digital_currency.sql b/apps/api/drizzle/0006_digital_currency.sql new file mode 100644 index 0000000..a88653d --- /dev/null +++ b/apps/api/drizzle/0006_digital_currency.sql @@ -0,0 +1,19 @@ +ALTER TYPE "public"."account_kind" ADD VALUE 'crypto_wallet';--> statement-breakpoint +ALTER TABLE "employee" ALTER COLUMN "currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "payroll_run" ALTER COLUMN "currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "workspace" ALTER COLUMN "base_currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "workspace" ALTER COLUMN "base_currency" SET DEFAULT 'BDT';--> statement-breakpoint +ALTER TABLE "exchange_rate" ALTER COLUMN "from_currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "exchange_rate" ALTER COLUMN "to_currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "financial_account" ALTER COLUMN "currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "ledger_entry" ALTER COLUMN "currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "transaction" ALTER COLUMN "currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "transaction" ALTER COLUMN "base_currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "commitment_occurrence" ALTER COLUMN "currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "commitment" ALTER COLUMN "currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "goal" ALTER COLUMN "currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "billing_payment" ALTER COLUMN "currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "asset" ALTER COLUMN "currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "investment" ALTER COLUMN "currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "liability" ALTER COLUMN "currency" SET DATA TYPE varchar(5);--> statement-breakpoint +ALTER TABLE "receivable" ALTER COLUMN "currency" SET DATA TYPE varchar(5); \ No newline at end of file diff --git a/apps/api/drizzle/meta/0006_snapshot.json b/apps/api/drizzle/meta/0006_snapshot.json new file mode 100644 index 0000000..0f10f64 --- /dev/null +++ b/apps/api/drizzle/meta/0006_snapshot.json @@ -0,0 +1,9777 @@ +{ + "id": "c192487d-554b-438c-aa8e-3745d7169b53", + "prevId": "a95a10ae-571e-4706-ac05-feb4daa52647", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.ai_usage": { + "name": "ai_usage", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "feature": { + "name": "feature", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "input_tokens": { + "name": "input_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "output_tokens": { + "name": "output_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cache_write_tokens": { + "name": "cache_write_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cost_usd": { + "name": "cost_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "latency_ms": { + "name": "latency_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_usage_workspace_idx": { + "name": "ai_usage_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_usage_workspace_id_workspace_id_fk": { + "name": "ai_usage_workspace_id_workspace_id_fk", + "tableFrom": "ai_usage", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_usage_user_id_auth_user_id_fk": { + "name": "ai_usage_user_id_auth_user_id_fk", + "tableFrom": "ai_usage", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.capture": { + "name": "capture", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "capture_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "stage": { + "name": "stage", + "type": "capture_stage", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'received'" + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "input_text": { + "name": "input_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "extraction": { + "name": "extraction", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "duration_ms": { + "name": "duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "cost_usd": { + "name": "cost_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false + }, + "is_subscription": { + "name": "is_subscription", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "draft_transaction_ids": { + "name": "draft_transaction_ids", + "type": "uuid[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::uuid[]" + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "processed_at": { + "name": "processed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "confirmed_at": { + "name": "confirmed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "capture_workspace_idx": { + "name": "capture_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "capture_workspace_id_workspace_id_fk": { + "name": "capture_workspace_id_workspace_id_fk", + "tableFrom": "capture", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "capture_file_id_file_id_fk": { + "name": "capture_file_id_file_id_fk", + "tableFrom": "capture", + "tableTo": "file", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "capture_created_by_auth_user_id_fk": { + "name": "capture_created_by_auth_user_id_fk", + "tableFrom": "capture", + "tableTo": "auth_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_message": { + "name": "copilot_message", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "thread_id": { + "name": "thread_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "copilot_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copilot_message_thread_idx": { + "name": "copilot_message_thread_idx", + "columns": [ + { + "expression": "thread_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_message_thread_id_copilot_thread_id_fk": { + "name": "copilot_message_thread_id_copilot_thread_id_fk", + "tableFrom": "copilot_message", + "tableTo": "copilot_thread", + "columnsFrom": [ + "thread_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_thread": { + "name": "copilot_thread", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copilot_thread_user_idx": { + "name": "copilot_thread_user_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_thread_workspace_id_workspace_id_fk": { + "name": "copilot_thread_workspace_id_workspace_id_fk", + "tableFrom": "copilot_thread", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_thread_user_id_auth_user_id_fk": { + "name": "copilot_thread_user_id_auth_user_id_fk", + "tableFrom": "copilot_thread", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.inbox_item": { + "name": "inbox_item", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "inbox_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "inbox_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "severity": { + "name": "severity", + "type": "severity", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'info'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dedupe_key": { + "name": "dedupe_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "snoozed_until": { + "name": "snoozed_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inbox_item_dedupe_idx": { + "name": "inbox_item_dedupe_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "dedupe_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inbox_item_workspace_status_idx": { + "name": "inbox_item_workspace_status_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "inbox_item_workspace_id_workspace_id_fk": { + "name": "inbox_item_workspace_id_workspace_id_fk", + "tableFrom": "inbox_item", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.report": { + "name": "report", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "report_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "period_start": { + "name": "period_start", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "period_end": { + "name": "period_end", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "narrative": { + "name": "narrative", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "narrative_source": { + "name": "narrative_source", + "type": "narrative_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'template'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "filters": { + "name": "filters", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "report_workspace_idx": { + "name": "report_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "report_workspace_id_workspace_id_fk": { + "name": "report_workspace_id_workspace_id_fk", + "tableFrom": "report", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "report_created_by_auth_user_id_fk": { + "name": "report_created_by_auth_user_id_fk", + "tableFrom": "report", + "tableTo": "auth_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_account": { + "name": "auth_account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "auth_account_user_idx": { + "name": "auth_account_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "auth_account_user_id_auth_user_id_fk": { + "name": "auth_account_user_id_auth_user_id_fk", + "tableFrom": "auth_account", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_rate_limit": { + "name": "auth_rate_limit", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_request": { + "name": "last_request", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "auth_rate_limit_key_unique": { + "name": "auth_rate_limit_key_unique", + "nullsNotDistinct": false, + "columns": [ + "key" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_session": { + "name": "auth_session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "impersonated_by": { + "name": "impersonated_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "auth_session_user_idx": { + "name": "auth_session_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "auth_session_user_id_auth_user_id_fk": { + "name": "auth_session_user_id_auth_user_id_fk", + "tableFrom": "auth_session", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "auth_session_token_unique": { + "name": "auth_session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_two_factor": { + "name": "auth_two_factor", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "backup_codes": { + "name": "backup_codes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "verified": { + "name": "verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "failed_verification_count": { + "name": "failed_verification_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "locked_until": { + "name": "locked_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "auth_two_factor_user_idx": { + "name": "auth_two_factor_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "auth_two_factor_secret_idx": { + "name": "auth_two_factor_secret_idx", + "columns": [ + { + "expression": "secret", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "auth_two_factor_user_id_auth_user_id_fk": { + "name": "auth_two_factor_user_id_auth_user_id_fk", + "tableFrom": "auth_two_factor", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_user": { + "name": "auth_user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'user'" + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ban_expires": { + "name": "ban_expires", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "two_factor_enabled": { + "name": "two_factor_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "auth_user_email_unique": { + "name": "auth_user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_verification": { + "name": "auth_verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "auth_verification_identifier_idx": { + "name": "auth_verification_identifier_idx", + "columns": [ + { + "expression": "identifier", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.employee": { + "name": "employee", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "counterparty_id": { + "name": "counterparty_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employment_type": { + "name": "employment_type", + "type": "employment_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'full_time'" + }, + "salary": { + "name": "salary", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "pay_day": { + "name": "pay_day", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "default_project_id": { + "name": "default_project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "employee_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_workspace_idx": { + "name": "employee_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_workspace_id_workspace_id_fk": { + "name": "employee_workspace_id_workspace_id_fk", + "tableFrom": "employee", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_counterparty_id_counterparty_id_fk": { + "name": "employee_counterparty_id_counterparty_id_fk", + "tableFrom": "employee", + "tableTo": "counterparty", + "columnsFrom": [ + "counterparty_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_default_project_id_project_id_fk": { + "name": "employee_default_project_id_project_id_fk", + "tableFrom": "employee", + "tableTo": "project", + "columnsFrom": [ + "default_project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_account_id_financial_account_id_fk": { + "name": "employee_account_id_financial_account_id_fk", + "tableFrom": "employee", + "tableTo": "financial_account", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.payroll_item": { + "name": "payroll_item", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "gross": { + "name": "gross", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "deductions": { + "name": "deductions", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "net": { + "name": "net", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "transaction_id": { + "name": "transaction_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "payroll_item_run_idx": { + "name": "payroll_item_run_idx", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "payroll_item_workspace_id_workspace_id_fk": { + "name": "payroll_item_workspace_id_workspace_id_fk", + "tableFrom": "payroll_item", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_item_run_id_payroll_run_id_fk": { + "name": "payroll_item_run_id_payroll_run_id_fk", + "tableFrom": "payroll_item", + "tableTo": "payroll_run", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_item_employee_id_employee_id_fk": { + "name": "payroll_item_employee_id_employee_id_fk", + "tableFrom": "payroll_item", + "tableTo": "employee", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "payroll_item_project_id_project_id_fk": { + "name": "payroll_item_project_id_project_id_fk", + "tableFrom": "payroll_item", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "payroll_item_account_id_financial_account_id_fk": { + "name": "payroll_item_account_id_financial_account_id_fk", + "tableFrom": "payroll_item", + "tableTo": "financial_account", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "payroll_item_transaction_id_transaction_id_fk": { + "name": "payroll_item_transaction_id_transaction_id_fk", + "tableFrom": "payroll_item", + "tableTo": "transaction", + "columnsFrom": [ + "transaction_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.payroll_run": { + "name": "payroll_run", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "period": { + "name": "period", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "payroll_run_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "pay_date": { + "name": "pay_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "total_net": { + "name": "total_net", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "currency": { + "name": "currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "posted_at": { + "name": "posted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "payroll_run_workspace_id_workspace_id_fk": { + "name": "payroll_run_workspace_id_workspace_id_fk", + "tableFrom": "payroll_run", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_run_created_by_auth_user_id_fk": { + "name": "payroll_run_created_by_auth_user_id_fk", + "tableFrom": "payroll_run", + "tableTo": "auth_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payroll_run_period_unique": { + "name": "payroll_run_period_unique", + "nullsNotDistinct": false, + "columns": [ + "workspace_id", + "period" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.api_key": { + "name": "api_key", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prefix": { + "name": "prefix", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key_hash": { + "name": "key_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scopes": { + "name": "scopes", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{read}'::text[]" + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "api_key_workspace_idx": { + "name": "api_key_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "api_key_workspace_id_workspace_id_fk": { + "name": "api_key_workspace_id_workspace_id_fk", + "tableFrom": "api_key", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_key_created_by_auth_user_id_fk": { + "name": "api_key_created_by_auth_user_id_fk", + "tableFrom": "api_key", + "tableTo": "auth_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "api_key_key_hash_unique": { + "name": "api_key_key_hash_unique", + "nullsNotDistinct": false, + "columns": [ + "key_hash" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_log": { + "name": "audit_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_type": { + "name": "actor_type", + "type": "actor_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'user'" + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "before": { + "name": "before", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "after": { + "name": "after", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "audit_log_workspace_created_idx": { + "name": "audit_log_workspace_created_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "audit_log_entity_idx": { + "name": "audit_log_entity_idx", + "columns": [ + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "audit_log_workspace_id_workspace_id_fk": { + "name": "audit_log_workspace_id_workspace_id_fk", + "tableFrom": "audit_log", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.domain_event": { + "name": "domain_event", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "processed_at": { + "name": "processed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "domain_event_pending_idx": { + "name": "domain_event_pending_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "processed_at is null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "domain_event_workspace_idx": { + "name": "domain_event_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "domain_event_workspace_id_workspace_id_fk": { + "name": "domain_event_workspace_id_workspace_id_fk", + "tableFrom": "domain_event", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.file": { + "name": "file", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "storage_backend": { + "name": "storage_backend", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "file_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'attachment'" + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "file_workspace_sha_idx": { + "name": "file_workspace_sha_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "file_workspace_id_workspace_id_fk": { + "name": "file_workspace_id_workspace_id_fk", + "tableFrom": "file", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "file_uploaded_by_auth_user_id_fk": { + "name": "file_uploaded_by_auth_user_id_fk", + "tableFrom": "file", + "tableTo": "auth_user", + "columnsFrom": [ + "uploaded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "file_storage_key_unique": { + "name": "file_storage_key_unique", + "nullsNotDistinct": false, + "columns": [ + "storage_key" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.job": { + "name": "job", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "status": { + "name": "status", + "type": "job_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'queued'" + }, + "run_at": { + "name": "run_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "max_attempts": { + "name": "max_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 5 + }, + "locked_at": { + "name": "locked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "locked_by": { + "name": "locked_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dedupe_key": { + "name": "dedupe_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result": { + "name": "result", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "job_status_run_at_idx": { + "name": "job_status_run_at_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "job_dedupe_active_idx": { + "name": "job_dedupe_active_idx", + "columns": [ + { + "expression": "dedupe_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "dedupe_key is not null and status in ('queued', 'running')", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "job_workspace_id_workspace_id_fk": { + "name": "job_workspace_id_workspace_id_fk", + "tableFrom": "job", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification": { + "name": "notification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "severity": { + "name": "severity", + "type": "severity", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'info'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link": { + "name": "link", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dedupe_key": { + "name": "dedupe_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "emailed_at": { + "name": "emailed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notification_dedupe_idx": { + "name": "notification_dedupe_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "dedupe_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_user_idx": { + "name": "notification_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_workspace_id_workspace_id_fk": { + "name": "notification_workspace_id_workspace_id_fk", + "tableFrom": "notification", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_user_id_auth_user_id_fk": { + "name": "notification_user_id_auth_user_id_fk", + "tableFrom": "notification", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.platform_setting": { + "name": "platform_setting", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "platform_setting_updated_by_auth_user_id_fk": { + "name": "platform_setting_updated_by_auth_user_id_fk", + "tableFrom": "platform_setting", + "tableTo": "auth_user", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rate_limit": { + "name": "rate_limit", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "window_start": { + "name": "window_start", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_settings": { + "name": "user_settings", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "active_workspace_id": { + "name": "active_workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "preferences": { + "name": "preferences", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_settings_user_id_auth_user_id_fk": { + "name": "user_settings_user_id_auth_user_id_fk", + "tableFrom": "user_settings", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_settings_active_workspace_id_workspace_id_fk": { + "name": "user_settings_active_workspace_id_workspace_id_fk", + "tableFrom": "user_settings", + "tableTo": "workspace", + "columnsFrom": [ + "active_workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_member": { + "name": "workspace_member", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "member_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'owner'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_member_unique": { + "name": "workspace_member_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_member_user_idx": { + "name": "workspace_member_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_member_workspace_id_workspace_id_fk": { + "name": "workspace_member_workspace_id_workspace_id_fk", + "tableFrom": "workspace_member", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_member_user_id_auth_user_id_fk": { + "name": "workspace_member_user_id_auth_user_id_fk", + "tableFrom": "workspace_member", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace": { + "name": "workspace", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "workspace_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "base_currency": { + "name": "base_currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true, + "default": "'BDT'" + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Asia/Dhaka'" + }, + "fiscal_year_start_month": { + "name": "fiscal_year_start_month", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "settings": { + "name": "settings", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.import_batch": { + "name": "import_batch", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "import_format", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "import_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'uploaded'" + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "headers": { + "name": "headers", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "mapping": { + "name": "mapping", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "options": { + "name": "options", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "total_rows": { + "name": "total_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "valid_rows": { + "name": "valid_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "invalid_rows": { + "name": "invalid_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "duplicate_rows": { + "name": "duplicate_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "imported_rows": { + "name": "imported_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "import_batch_workspace_idx": { + "name": "import_batch_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "import_batch_workspace_id_workspace_id_fk": { + "name": "import_batch_workspace_id_workspace_id_fk", + "tableFrom": "import_batch", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_batch_file_id_file_id_fk": { + "name": "import_batch_file_id_file_id_fk", + "tableFrom": "import_batch", + "tableTo": "file", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "import_batch_account_id_financial_account_id_fk": { + "name": "import_batch_account_id_financial_account_id_fk", + "tableFrom": "import_batch", + "tableTo": "financial_account", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "import_batch_created_by_auth_user_id_fk": { + "name": "import_batch_created_by_auth_user_id_fk", + "tableFrom": "import_batch", + "tableTo": "auth_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.import_row": { + "name": "import_row", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "batch_id": { + "name": "batch_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "row_number": { + "name": "row_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "raw": { + "name": "raw", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "normalized": { + "name": "normalized", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "import_row_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'valid'" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "duplicate_of_id": { + "name": "duplicate_of_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "transaction_id": { + "name": "transaction_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "import_row_batch_idx": { + "name": "import_row_batch_idx", + "columns": [ + { + "expression": "batch_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "row_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "import_row_workspace_id_workspace_id_fk": { + "name": "import_row_workspace_id_workspace_id_fk", + "tableFrom": "import_row", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_row_batch_id_import_batch_id_fk": { + "name": "import_row_batch_id_import_batch_id_fk", + "tableFrom": "import_row", + "tableTo": "import_batch", + "columnsFrom": [ + "batch_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integration_connection": { + "name": "integration_connection", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "connection_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'connected'" + }, + "credentials_encrypted": { + "name": "credentials_encrypted", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "sync_frequency": { + "name": "sync_frequency", + "type": "sync_frequency", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'daily'" + }, + "trust_level": { + "name": "trust_level", + "type": "trust_level", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'review'" + }, + "sync_cursor": { + "name": "sync_cursor", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "last_synced_at": { + "name": "last_synced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_success_at": { + "name": "last_success_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error_at": { + "name": "last_error_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "records_total": { + "name": "records_total", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "webhook_public_id": { + "name": "webhook_public_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_secret_encrypted": { + "name": "webhook_secret_encrypted", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "integration_connection_workspace_idx": { + "name": "integration_connection_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_connection_workspace_id_workspace_id_fk": { + "name": "integration_connection_workspace_id_workspace_id_fk", + "tableFrom": "integration_connection", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "integration_connection_account_id_financial_account_id_fk": { + "name": "integration_connection_account_id_financial_account_id_fk", + "tableFrom": "integration_connection", + "tableTo": "financial_account", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "integration_connection_project_id_project_id_fk": { + "name": "integration_connection_project_id_project_id_fk", + "tableFrom": "integration_connection", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "integration_connection_created_by_auth_user_id_fk": { + "name": "integration_connection_created_by_auth_user_id_fk", + "tableFrom": "integration_connection", + "tableTo": "auth_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "integration_connection_webhook_public_id_unique": { + "name": "integration_connection_webhook_public_id_unique", + "nullsNotDistinct": false, + "columns": [ + "webhook_public_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_run": { + "name": "sync_run", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "connection_id": { + "name": "connection_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "sync_trigger", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "sync_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'running'" + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "duration_ms": { + "name": "duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "records_found": { + "name": "records_found", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created": { + "name": "created", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated": { + "name": "updated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "skipped": { + "name": "skipped", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "duplicates": { + "name": "duplicates", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "errors": { + "name": "errors", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error_details": { + "name": "error_details", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "cursor_before": { + "name": "cursor_before", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "cursor_after": { + "name": "cursor_after", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "triggered_by": { + "name": "triggered_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_run_connection_idx": { + "name": "sync_run_connection_idx", + "columns": [ + { + "expression": "connection_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sync_run_workspace_idx": { + "name": "sync_run_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sync_run_workspace_id_workspace_id_fk": { + "name": "sync_run_workspace_id_workspace_id_fk", + "tableFrom": "sync_run", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sync_run_connection_id_integration_connection_id_fk": { + "name": "sync_run_connection_id_integration_connection_id_fk", + "tableFrom": "sync_run", + "tableTo": "integration_connection", + "columnsFrom": [ + "connection_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.webhook_event": { + "name": "webhook_event", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "connection_id": { + "name": "connection_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "provider_event_id": { + "name": "provider_event_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "signature_valid": { + "name": "signature_valid", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "webhook_event_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'received'" + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_at": { + "name": "received_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "processed_at": { + "name": "processed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "webhook_event_workspace_idx": { + "name": "webhook_event_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "webhook_event_workspace_id_workspace_id_fk": { + "name": "webhook_event_workspace_id_workspace_id_fk", + "tableFrom": "webhook_event", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "webhook_event_connection_id_integration_connection_id_fk": { + "name": "webhook_event_connection_id_integration_connection_id_fk", + "tableFrom": "webhook_event", + "tableTo": "integration_connection", + "columnsFrom": [ + "connection_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "webhook_event_unique": { + "name": "webhook_event_unique", + "nullsNotDistinct": false, + "columns": [ + "connection_id", + "provider_event_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.budget": { + "name": "budget", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "period": { + "name": "period", + "type": "budget_period", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'monthly'" + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "category_id": { + "name": "category_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "alert_threshold": { + "name": "alert_threshold", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 80 + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "budget_workspace_idx": { + "name": "budget_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "budget_workspace_id_workspace_id_fk": { + "name": "budget_workspace_id_workspace_id_fk", + "tableFrom": "budget", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "budget_category_id_category_id_fk": { + "name": "budget_category_id_category_id_fk", + "tableFrom": "budget", + "tableTo": "category", + "columnsFrom": [ + "category_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "budget_project_id_project_id_fk": { + "name": "budget_project_id_project_id_fk", + "tableFrom": "budget", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.category": { + "name": "category", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "category_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_system": { + "name": "is_system", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "archived": { + "name": "archived", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "category_workspace_idx": { + "name": "category_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "category_workspace_id_workspace_id_fk": { + "name": "category_workspace_id_workspace_id_fk", + "tableFrom": "category", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "category_parent_id_category_id_fk": { + "name": "category_parent_id_category_id_fk", + "tableFrom": "category", + "tableTo": "category", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "category_name_unique": { + "name": "category_name_unique", + "nullsNotDistinct": true, + "columns": [ + "workspace_id", + "kind", + "parent_id", + "name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.counterparty": { + "name": "counterparty", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "normalized_name": { + "name": "normalized_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "counterparty_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'merchant'" + }, + "aliases": { + "name": "aliases", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "default_category_id": { + "name": "default_category_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "default_project_id": { + "name": "default_project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "default_account_id": { + "name": "default_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "confirmations": { + "name": "confirmations", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "counterparty_name_unique": { + "name": "counterparty_name_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "normalized_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "counterparty_workspace_id_workspace_id_fk": { + "name": "counterparty_workspace_id_workspace_id_fk", + "tableFrom": "counterparty", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "counterparty_default_category_id_category_id_fk": { + "name": "counterparty_default_category_id_category_id_fk", + "tableFrom": "counterparty", + "tableTo": "category", + "columnsFrom": [ + "default_category_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "counterparty_default_project_id_project_id_fk": { + "name": "counterparty_default_project_id_project_id_fk", + "tableFrom": "counterparty", + "tableTo": "project", + "columnsFrom": [ + "default_project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "counterparty_default_account_id_financial_account_id_fk": { + "name": "counterparty_default_account_id_financial_account_id_fk", + "tableFrom": "counterparty", + "tableTo": "financial_account", + "columnsFrom": [ + "default_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.exchange_rate": { + "name": "exchange_rate", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "from_currency": { + "name": "from_currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "to_currency": { + "name": "to_currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "rate": { + "name": "rate", + "type": "numeric(20, 10)", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "rate_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "exchange_rate_unique": { + "name": "exchange_rate_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "from_currency", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "to_currency", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "exchange_rate_workspace_id_workspace_id_fk": { + "name": "exchange_rate_workspace_id_workspace_id_fk", + "tableFrom": "exchange_rate", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.financial_account": { + "name": "financial_account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "account_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "institution": { + "name": "institution", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mask": { + "name": "mask", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "currency": { + "name": "currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "opening_balance": { + "name": "opening_balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "opening_date": { + "name": "opening_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "credit_limit": { + "name": "credit_limit", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "is_liability": { + "name": "is_liability", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "include_in_net_worth": { + "name": "include_in_net_worth", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "status": { + "name": "status", + "type": "account_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_reconciled_at": { + "name": "last_reconciled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_reconciled_balance": { + "name": "last_reconciled_balance", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "financial_account_workspace_idx": { + "name": "financial_account_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "financial_account_workspace_id_workspace_id_fk": { + "name": "financial_account_workspace_id_workspace_id_fk", + "tableFrom": "financial_account", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ledger_entry": { + "name": "ledger_entry", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "transaction_id": { + "name": "transaction_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "base_amount": { + "name": "base_amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ledger_entry_account_date_idx": { + "name": "ledger_entry_account_date_idx", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ledger_entry_workspace_date_idx": { + "name": "ledger_entry_workspace_date_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ledger_entry_transaction_idx": { + "name": "ledger_entry_transaction_idx", + "columns": [ + { + "expression": "transaction_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ledger_entry_workspace_id_workspace_id_fk": { + "name": "ledger_entry_workspace_id_workspace_id_fk", + "tableFrom": "ledger_entry", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ledger_entry_transaction_id_transaction_id_fk": { + "name": "ledger_entry_transaction_id_transaction_id_fk", + "tableFrom": "ledger_entry", + "tableTo": "transaction", + "columnsFrom": [ + "transaction_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ledger_entry_account_id_financial_account_id_fk": { + "name": "ledger_entry_account_id_financial_account_id_fk", + "tableFrom": "ledger_entry", + "tableTo": "financial_account", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.project": { + "name": "project", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "project_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "budget_amount": { + "name": "budget_amount", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "project_workspace_idx": { + "name": "project_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "project_workspace_id_workspace_id_fk": { + "name": "project_workspace_id_workspace_id_fk", + "tableFrom": "project", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "project_name_unique": { + "name": "project_name_unique", + "nullsNotDistinct": false, + "columns": [ + "workspace_id", + "name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rule": { + "name": "rule", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "priority": { + "name": "priority", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 100 + }, + "match": { + "name": "match", + "type": "rule_match", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'all'" + }, + "conditions": { + "name": "conditions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "actions": { + "name": "actions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "stop_processing": { + "name": "stop_processing", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "times_applied": { + "name": "times_applied", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_applied_at": { + "name": "last_applied_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "rule_workspace_idx": { + "name": "rule_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "priority", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "rule_workspace_id_workspace_id_fk": { + "name": "rule_workspace_id_workspace_id_fk", + "tableFrom": "rule", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "rule_created_by_auth_user_id_fk": { + "name": "rule_created_by_auth_user_id_fk", + "tableFrom": "rule", + "tableTo": "auth_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.transaction_attachment": { + "name": "transaction_attachment", + "schema": "", + "columns": { + "transaction_id": { + "name": "transaction_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "transaction_attachment_transaction_id_transaction_id_fk": { + "name": "transaction_attachment_transaction_id_transaction_id_fk", + "tableFrom": "transaction_attachment", + "tableTo": "transaction", + "columnsFrom": [ + "transaction_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "transaction_attachment_file_id_file_id_fk": { + "name": "transaction_attachment_file_id_file_id_fk", + "tableFrom": "transaction_attachment", + "tableTo": "file", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "transaction_attachment_transaction_id_file_id_pk": { + "name": "transaction_attachment_transaction_id_file_id_pk", + "columns": [ + "transaction_id", + "file_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.transaction": { + "name": "transaction", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "transaction_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "direction": { + "name": "direction", + "type": "transaction_direction", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "transaction_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'posted'" + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "to_account_id": { + "name": "to_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "account_amount": { + "name": "account_amount", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "to_account_amount": { + "name": "to_account_amount", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "fx_rate": { + "name": "fx_rate", + "type": "numeric(20, 10)", + "primaryKey": false, + "notNull": false + }, + "base_amount": { + "name": "base_amount", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "base_currency": { + "name": "base_currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": false + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "merchant": { + "name": "merchant", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "counterparty_id": { + "name": "counterparty_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "category_id": { + "name": "category_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reference": { + "name": "reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "transaction_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "source_ref": { + "name": "source_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_key": { + "name": "external_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "connection_id": { + "name": "connection_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "attachment_file_id": { + "name": "attachment_file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "ai_confidence": { + "name": "ai_confidence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "cost_basis": { + "name": "cost_basis", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "liability_id": { + "name": "liability_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "receivable_id": { + "name": "receivable_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "asset_id": { + "name": "asset_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "investment_id": { + "name": "investment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "linked_transaction_id": { + "name": "linked_transaction_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "review_reason": { + "name": "review_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "posted_at": { + "name": "posted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "voided_at": { + "name": "voided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "transaction_workspace_date_idx": { + "name": "transaction_workspace_date_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_workspace_status_idx": { + "name": "transaction_workspace_status_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_workspace_type_date_idx": { + "name": "transaction_workspace_type_date_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_account_date_idx": { + "name": "transaction_account_date_idx", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_category_date_idx": { + "name": "transaction_category_date_idx", + "columns": [ + { + "expression": "category_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_project_date_idx": { + "name": "transaction_project_date_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_counterparty_idx": { + "name": "transaction_counterparty_idx", + "columns": [ + { + "expression": "counterparty_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_workspace_source_idx": { + "name": "transaction_workspace_source_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_workspace_created_idx": { + "name": "transaction_workspace_created_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_workspace_reference_idx": { + "name": "transaction_workspace_reference_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "reference", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_connection_idx": { + "name": "transaction_connection_idx", + "columns": [ + { + "expression": "connection_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_external_key_idx": { + "name": "transaction_external_key_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "external_key is not null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "transaction_workspace_id_workspace_id_fk": { + "name": "transaction_workspace_id_workspace_id_fk", + "tableFrom": "transaction", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "transaction_account_id_financial_account_id_fk": { + "name": "transaction_account_id_financial_account_id_fk", + "tableFrom": "transaction", + "tableTo": "financial_account", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "transaction_to_account_id_financial_account_id_fk": { + "name": "transaction_to_account_id_financial_account_id_fk", + "tableFrom": "transaction", + "tableTo": "financial_account", + "columnsFrom": [ + "to_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "transaction_counterparty_id_counterparty_id_fk": { + "name": "transaction_counterparty_id_counterparty_id_fk", + "tableFrom": "transaction", + "tableTo": "counterparty", + "columnsFrom": [ + "counterparty_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "transaction_category_id_category_id_fk": { + "name": "transaction_category_id_category_id_fk", + "tableFrom": "transaction", + "tableTo": "category", + "columnsFrom": [ + "category_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "transaction_project_id_project_id_fk": { + "name": "transaction_project_id_project_id_fk", + "tableFrom": "transaction", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "transaction_connection_id_integration_connection_id_fk": { + "name": "transaction_connection_id_integration_connection_id_fk", + "tableFrom": "transaction", + "tableTo": "integration_connection", + "columnsFrom": [ + "connection_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "transaction_attachment_file_id_file_id_fk": { + "name": "transaction_attachment_file_id_file_id_fk", + "tableFrom": "transaction", + "tableTo": "file", + "columnsFrom": [ + "attachment_file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "transaction_liability_id_liability_id_fk": { + "name": "transaction_liability_id_liability_id_fk", + "tableFrom": "transaction", + "tableTo": "liability", + "columnsFrom": [ + "liability_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "transaction_receivable_id_receivable_id_fk": { + "name": "transaction_receivable_id_receivable_id_fk", + "tableFrom": "transaction", + "tableTo": "receivable", + "columnsFrom": [ + "receivable_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "transaction_asset_id_asset_id_fk": { + "name": "transaction_asset_id_asset_id_fk", + "tableFrom": "transaction", + "tableTo": "asset", + "columnsFrom": [ + "asset_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "transaction_investment_id_investment_id_fk": { + "name": "transaction_investment_id_investment_id_fk", + "tableFrom": "transaction", + "tableTo": "investment", + "columnsFrom": [ + "investment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "transaction_linked_transaction_id_transaction_id_fk": { + "name": "transaction_linked_transaction_id_transaction_id_fk", + "tableFrom": "transaction", + "tableTo": "transaction", + "columnsFrom": [ + "linked_transaction_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "transaction_created_by_auth_user_id_fk": { + "name": "transaction_created_by_auth_user_id_fk", + "tableFrom": "transaction", + "tableTo": "auth_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "transaction_amount_positive": { + "name": "transaction_amount_positive", + "value": "\"transaction\".\"amount\" > 0" + }, + "transaction_posted_complete": { + "name": "transaction_posted_complete", + "value": "\"transaction\".\"status\" <> 'posted' or (\"transaction\".\"account_id\" is not null and \"transaction\".\"account_amount\" is not null and \"transaction\".\"base_amount\" is not null)" + }, + "transaction_transfer_destination": { + "name": "transaction_transfer_destination", + "value": "\"transaction\".\"type\" <> 'transfer' or \"transaction\".\"status\" <> 'posted' or (\"transaction\".\"to_account_id\" is not null and \"transaction\".\"to_account_amount\" is not null and \"transaction\".\"to_account_id\" <> \"transaction\".\"account_id\")" + } + }, + "isRLSEnabled": false + }, + "public.commitment_occurrence": { + "name": "commitment_occurrence", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "commitment_id": { + "name": "commitment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "due_date": { + "name": "due_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "occurrence_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'scheduled'" + }, + "transaction_id": { + "name": "transaction_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "paid_on": { + "name": "paid_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "paid_amount": { + "name": "paid_amount", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "commitment_occurrence_workspace_idx": { + "name": "commitment_occurrence_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "due_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "commitment_occurrence_transaction_idx": { + "name": "commitment_occurrence_transaction_idx", + "columns": [ + { + "expression": "transaction_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "transaction_id is not null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "commitment_occurrence_workspace_id_workspace_id_fk": { + "name": "commitment_occurrence_workspace_id_workspace_id_fk", + "tableFrom": "commitment_occurrence", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "commitment_occurrence_commitment_id_commitment_id_fk": { + "name": "commitment_occurrence_commitment_id_commitment_id_fk", + "tableFrom": "commitment_occurrence", + "tableTo": "commitment", + "columnsFrom": [ + "commitment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "commitment_occurrence_transaction_id_transaction_id_fk": { + "name": "commitment_occurrence_transaction_id_transaction_id_fk", + "tableFrom": "commitment_occurrence", + "tableTo": "transaction", + "columnsFrom": [ + "transaction_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "commitment_occurrence_due_unique": { + "name": "commitment_occurrence_due_unique", + "nullsNotDistinct": false, + "columns": [ + "commitment_id", + "due_date" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.commitment": { + "name": "commitment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "commitment_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "direction": { + "name": "direction", + "type": "transaction_direction", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'out'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "counterparty_id": { + "name": "counterparty_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "payee": { + "name": "payee", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "frequency": { + "name": "frequency", + "type": "commitment_frequency", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "interval_count": { + "name": "interval_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "interval_unit": { + "name": "interval_unit", + "type": "interval_unit", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "next_due_date": { + "name": "next_due_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "category_id": { + "name": "category_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "liability_id": { + "name": "liability_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "auto_pay": { + "name": "auto_pay", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "status": { + "name": "status", + "type": "commitment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "reminder_offsets": { + "name": "reminder_offsets", + "type": "integer[]", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "commitment_workspace_due_idx": { + "name": "commitment_workspace_due_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_due_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "commitment_workspace_kind_idx": { + "name": "commitment_workspace_kind_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "commitment_project_idx": { + "name": "commitment_project_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "commitment_workspace_id_workspace_id_fk": { + "name": "commitment_workspace_id_workspace_id_fk", + "tableFrom": "commitment", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "commitment_counterparty_id_counterparty_id_fk": { + "name": "commitment_counterparty_id_counterparty_id_fk", + "tableFrom": "commitment", + "tableTo": "counterparty", + "columnsFrom": [ + "counterparty_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "commitment_account_id_financial_account_id_fk": { + "name": "commitment_account_id_financial_account_id_fk", + "tableFrom": "commitment", + "tableTo": "financial_account", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "commitment_category_id_category_id_fk": { + "name": "commitment_category_id_category_id_fk", + "tableFrom": "commitment", + "tableTo": "category", + "columnsFrom": [ + "category_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "commitment_project_id_project_id_fk": { + "name": "commitment_project_id_project_id_fk", + "tableFrom": "commitment", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "commitment_liability_id_liability_id_fk": { + "name": "commitment_liability_id_liability_id_fk", + "tableFrom": "commitment", + "tableTo": "liability", + "columnsFrom": [ + "liability_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "commitment_created_by_auth_user_id_fk": { + "name": "commitment_created_by_auth_user_id_fk", + "tableFrom": "commitment", + "tableTo": "auth_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.goal_contribution": { + "name": "goal_contribution", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "goal_id": { + "name": "goal_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "transaction_id": { + "name": "transaction_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "goal_contribution_goal_idx": { + "name": "goal_contribution_goal_idx", + "columns": [ + { + "expression": "goal_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "goal_contribution_workspace_id_workspace_id_fk": { + "name": "goal_contribution_workspace_id_workspace_id_fk", + "tableFrom": "goal_contribution", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "goal_contribution_goal_id_goal_id_fk": { + "name": "goal_contribution_goal_id_goal_id_fk", + "tableFrom": "goal_contribution", + "tableTo": "goal", + "columnsFrom": [ + "goal_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "goal_contribution_transaction_id_transaction_id_fk": { + "name": "goal_contribution_transaction_id_transaction_id_fk", + "tableFrom": "goal_contribution", + "tableTo": "transaction", + "columnsFrom": [ + "transaction_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "goal_contribution_created_by_auth_user_id_fk": { + "name": "goal_contribution_created_by_auth_user_id_fk", + "tableFrom": "goal_contribution", + "tableTo": "auth_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.goal": { + "name": "goal", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "goal_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_amount": { + "name": "target_amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "target_date": { + "name": "target_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "priority": { + "name": "priority", + "type": "priority", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'medium'" + }, + "monthly_plan": { + "name": "monthly_plan", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "starting_amount": { + "name": "starting_amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "linked_account_id": { + "name": "linked_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "image_file_id": { + "name": "image_file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "goal_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "achieved_at": { + "name": "achieved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "goal_workspace_idx": { + "name": "goal_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "goal_workspace_id_workspace_id_fk": { + "name": "goal_workspace_id_workspace_id_fk", + "tableFrom": "goal", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "goal_linked_account_id_financial_account_id_fk": { + "name": "goal_linked_account_id_financial_account_id_fk", + "tableFrom": "goal", + "tableTo": "financial_account", + "columnsFrom": [ + "linked_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "goal_image_file_id_file_id_fk": { + "name": "goal_image_file_id_file_id_fk", + "tableFrom": "goal", + "tableTo": "file", + "columnsFrom": [ + "image_file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.subscription": { + "name": "subscription", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "commitment_id": { + "name": "commitment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "plan_name": { + "name": "plan_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "purchase_date": { + "name": "purchase_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "trial_ends_on": { + "name": "trial_ends_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "expiry_date": { + "name": "expiry_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "cancellation_deadline": { + "name": "cancellation_deadline", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "auto_renew": { + "name": "auto_renew", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "status": { + "name": "status", + "type": "subscription_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "external_provider_id": { + "name": "external_provider_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attachment_file_id": { + "name": "attachment_file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "subscription_workspace_idx": { + "name": "subscription_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "subscription_workspace_id_workspace_id_fk": { + "name": "subscription_workspace_id_workspace_id_fk", + "tableFrom": "subscription", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "subscription_commitment_id_commitment_id_fk": { + "name": "subscription_commitment_id_commitment_id_fk", + "tableFrom": "subscription", + "tableTo": "commitment", + "columnsFrom": [ + "commitment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "subscription_attachment_file_id_file_id_fk": { + "name": "subscription_attachment_file_id_file_id_fk", + "tableFrom": "subscription", + "tableTo": "file", + "columnsFrom": [ + "attachment_file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "subscription_commitment_id_unique": { + "name": "subscription_commitment_id_unique", + "nullsNotDistinct": false, + "columns": [ + "commitment_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.billing_payment": { + "name": "billing_payment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_ref": { + "name": "provider_ref", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_payment_id": { + "name": "provider_payment_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "interval": { + "name": "interval", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "credits": { + "name": "credits", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "paid_at": { + "name": "paid_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "receipt_url": { + "name": "receipt_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "billing_payment_provider_ref_idx": { + "name": "billing_payment_provider_ref_idx", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider_ref", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "billing_payment_user_idx": { + "name": "billing_payment_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_payment_user_id_auth_user_id_fk": { + "name": "billing_payment_user_id_auth_user_id_fk", + "tableFrom": "billing_payment", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.billing_subscription": { + "name": "billing_subscription", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'free'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_customer_id": { + "name": "provider_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_subscription_id": { + "name": "provider_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "interval": { + "name": "interval", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_period_start": { + "name": "current_period_start", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "current_period_end": { + "name": "current_period_end", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "trial_ends_at": { + "name": "trial_ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "billing_subscription_provider_idx": { + "name": "billing_subscription_provider_idx", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider_subscription_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_subscription_user_id_auth_user_id_fk": { + "name": "billing_subscription_user_id_auth_user_id_fk", + "tableFrom": "billing_subscription", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "billing_subscription_user_id_unique": { + "name": "billing_subscription_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credit_transaction": { + "name": "credit_transaction", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "credits": { + "name": "credits", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cost_usd": { + "name": "cost_usd", + "type": "numeric(14, 6)", + "primaryKey": false, + "notNull": false + }, + "ai_usage_id": { + "name": "ai_usage_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "payment_id": { + "name": "payment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_transaction_user_idx": { + "name": "credit_transaction_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credit_transaction_payment_idx": { + "name": "credit_transaction_payment_idx", + "columns": [ + { + "expression": "payment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credit_transaction_user_id_auth_user_id_fk": { + "name": "credit_transaction_user_id_auth_user_id_fk", + "tableFrom": "credit_transaction", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_transaction_workspace_id_workspace_id_fk": { + "name": "credit_transaction_workspace_id_workspace_id_fk", + "tableFrom": "credit_transaction", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "credit_transaction_payment_id_billing_payment_id_fk": { + "name": "credit_transaction_payment_id_billing_payment_id_fk", + "tableFrom": "credit_transaction", + "tableTo": "billing_payment", + "columnsFrom": [ + "payment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "credit_transaction_created_by_auth_user_id_fk": { + "name": "credit_transaction_created_by_auth_user_id_fk", + "tableFrom": "credit_transaction", + "tableTo": "auth_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.platform_audit_log": { + "name": "platform_audit_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_email": { + "name": "actor_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "details": { + "name": "details", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "platform_audit_created_idx": { + "name": "platform_audit_created_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "platform_audit_target_idx": { + "name": "platform_audit_target_idx", + "columns": [ + { + "expression": "target_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "target_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.scheduler_run": { + "name": "scheduler_run", + "schema": "", + "columns": { + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slot": { + "name": "slot", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "instance": { + "name": "instance", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "scheduler_run_name_slot_pk": { + "name": "scheduler_run_name_slot_pk", + "columns": [ + "name", + "slot" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.support_request": { + "name": "support_request", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page": { + "name": "page", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "support_request_status_idx": { + "name": "support_request_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "support_request_user_id_auth_user_id_fk": { + "name": "support_request_user_id_auth_user_id_fk", + "tableFrom": "support_request", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "support_request_workspace_id_workspace_id_fk": { + "name": "support_request_workspace_id_workspace_id_fk", + "tableFrom": "support_request", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_invitation": { + "name": "workspace_invitation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "member_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "token_hash": { + "name": "token_hash", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "accepted_at": { + "name": "accepted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_by": { + "name": "accepted_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_invitation_pending_idx": { + "name": "workspace_invitation_pending_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "status = 'pending'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_invitation_email_idx": { + "name": "workspace_invitation_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_invitation_workspace_id_workspace_id_fk": { + "name": "workspace_invitation_workspace_id_workspace_id_fk", + "tableFrom": "workspace_invitation", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_invitation_invited_by_auth_user_id_fk": { + "name": "workspace_invitation_invited_by_auth_user_id_fk", + "tableFrom": "workspace_invitation", + "tableTo": "auth_user", + "columnsFrom": [ + "invited_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "workspace_invitation_accepted_by_auth_user_id_fk": { + "name": "workspace_invitation_accepted_by_auth_user_id_fk", + "tableFrom": "workspace_invitation", + "tableTo": "auth_user", + "columnsFrom": [ + "accepted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "workspace_invitation_token_hash_unique": { + "name": "workspace_invitation_token_hash_unique", + "nullsNotDistinct": false, + "columns": [ + "token_hash" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.asset_valuation": { + "name": "asset_valuation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "asset_id": { + "name": "asset_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "asset_valuation_asset_date_idx": { + "name": "asset_valuation_asset_date_idx", + "columns": [ + { + "expression": "asset_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "asset_valuation_workspace_id_workspace_id_fk": { + "name": "asset_valuation_workspace_id_workspace_id_fk", + "tableFrom": "asset_valuation", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "asset_valuation_asset_id_asset_id_fk": { + "name": "asset_valuation_asset_id_asset_id_fk", + "tableFrom": "asset_valuation", + "tableTo": "asset", + "columnsFrom": [ + "asset_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.asset": { + "name": "asset", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "asset_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "purchase_price": { + "name": "purchase_price", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "currency": { + "name": "currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "purchase_date": { + "name": "purchase_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "current_value": { + "name": "current_value", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "valued_at": { + "name": "valued_at", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "owner": { + "name": "owner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "asset_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'owned'" + }, + "sold_on": { + "name": "sold_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "sold_amount": { + "name": "sold_amount", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "asset_workspace_idx": { + "name": "asset_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "asset_workspace_id_workspace_id_fk": { + "name": "asset_workspace_id_workspace_id_fk", + "tableFrom": "asset", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "asset_project_id_project_id_fk": { + "name": "asset_project_id_project_id_fk", + "tableFrom": "asset", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.investment_valuation": { + "name": "investment_valuation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "investment_id": { + "name": "investment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "investment_valuation_investment_date_idx": { + "name": "investment_valuation_investment_date_idx", + "columns": [ + { + "expression": "investment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "investment_valuation_workspace_id_workspace_id_fk": { + "name": "investment_valuation_workspace_id_workspace_id_fk", + "tableFrom": "investment_valuation", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "investment_valuation_investment_id_investment_id_fk": { + "name": "investment_valuation_investment_id_investment_id_fk", + "tableFrom": "investment_valuation", + "tableTo": "investment", + "columnsFrom": [ + "investment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.investment": { + "name": "investment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "investment_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "institution": { + "name": "institution", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "currency": { + "name": "currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "opened_on": { + "name": "opened_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "maturity_date": { + "name": "maturity_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "interest_rate": { + "name": "interest_rate", + "type": "numeric(7, 4)", + "primaryKey": false, + "notNull": false + }, + "opening_cost_basis": { + "name": "opening_cost_basis", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "current_value": { + "name": "current_value", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "valued_at": { + "name": "valued_at", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "investment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "investment_workspace_idx": { + "name": "investment_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "investment_workspace_id_workspace_id_fk": { + "name": "investment_workspace_id_workspace_id_fk", + "tableFrom": "investment", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.liability": { + "name": "liability", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "liability_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "counterparty_id": { + "name": "counterparty_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "counterparty_name": { + "name": "counterparty_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "principal": { + "name": "principal", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "opening_outstanding": { + "name": "opening_outstanding", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "interest_rate": { + "name": "interest_rate", + "type": "numeric(7, 4)", + "primaryKey": false, + "notNull": false + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "due_date": { + "name": "due_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "category_id": { + "name": "category_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "liability_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_key": { + "name": "external_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "liability_workspace_idx": { + "name": "liability_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "liability_external_key_idx": { + "name": "liability_external_key_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "external_key is not null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "liability_workspace_id_workspace_id_fk": { + "name": "liability_workspace_id_workspace_id_fk", + "tableFrom": "liability", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "liability_counterparty_id_counterparty_id_fk": { + "name": "liability_counterparty_id_counterparty_id_fk", + "tableFrom": "liability", + "tableTo": "counterparty", + "columnsFrom": [ + "counterparty_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "liability_category_id_category_id_fk": { + "name": "liability_category_id_category_id_fk", + "tableFrom": "liability", + "tableTo": "category", + "columnsFrom": [ + "category_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "liability_project_id_project_id_fk": { + "name": "liability_project_id_project_id_fk", + "tableFrom": "liability", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "liability_account_id_financial_account_id_fk": { + "name": "liability_account_id_financial_account_id_fk", + "tableFrom": "liability", + "tableTo": "financial_account", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.receivable": { + "name": "receivable", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "receivable_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'invoice'" + }, + "counterparty_id": { + "name": "counterparty_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "counterparty_name": { + "name": "counterparty_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reference": { + "name": "reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "varchar(5)", + "primaryKey": false, + "notNull": true + }, + "issue_date": { + "name": "issue_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "due_date": { + "name": "due_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "receivable_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "category_id": { + "name": "category_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "external_key": { + "name": "external_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "connection_id": { + "name": "connection_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "receivable_workspace_status_idx": { + "name": "receivable_workspace_status_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "due_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "receivable_project_idx": { + "name": "receivable_project_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "receivable_external_key_idx": { + "name": "receivable_external_key_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "external_key is not null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "receivable_workspace_id_workspace_id_fk": { + "name": "receivable_workspace_id_workspace_id_fk", + "tableFrom": "receivable", + "tableTo": "workspace", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "receivable_counterparty_id_counterparty_id_fk": { + "name": "receivable_counterparty_id_counterparty_id_fk", + "tableFrom": "receivable", + "tableTo": "counterparty", + "columnsFrom": [ + "counterparty_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "receivable_project_id_project_id_fk": { + "name": "receivable_project_id_project_id_fk", + "tableFrom": "receivable", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "receivable_category_id_category_id_fk": { + "name": "receivable_category_id_category_id_fk", + "tableFrom": "receivable", + "tableTo": "category", + "columnsFrom": [ + "category_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "receivable_connection_id_integration_connection_id_fk": { + "name": "receivable_connection_id_integration_connection_id_fk", + "tableFrom": "receivable", + "tableTo": "integration_connection", + "columnsFrom": [ + "connection_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.account_kind": { + "name": "account_kind", + "schema": "public", + "values": [ + "bank", + "cash", + "mobile_wallet", + "card", + "digital_wallet", + "payment_processor", + "savings", + "loan", + "other", + "crypto_wallet" + ] + }, + "public.account_status": { + "name": "account_status", + "schema": "public", + "values": [ + "active", + "archived" + ] + }, + "public.actor_type": { + "name": "actor_type", + "schema": "public", + "values": [ + "user", + "system", + "integration", + "ai", + "api" + ] + }, + "public.asset_kind": { + "name": "asset_kind", + "schema": "public", + "values": [ + "equipment", + "electronics", + "vehicle", + "property", + "land", + "jewelry", + "business_asset", + "other" + ] + }, + "public.asset_status": { + "name": "asset_status", + "schema": "public", + "values": [ + "owned", + "sold", + "disposed" + ] + }, + "public.budget_period": { + "name": "budget_period", + "schema": "public", + "values": [ + "monthly", + "quarterly", + "yearly", + "total" + ] + }, + "public.capture_kind": { + "name": "capture_kind", + "schema": "public", + "values": [ + "screenshot", + "receipt", + "text", + "voice", + "pdf", + "email" + ] + }, + "public.capture_stage": { + "name": "capture_stage", + "schema": "public", + "values": [ + "received", + "processing", + "suggested", + "confirmed", + "posted", + "failed", + "discarded" + ] + }, + "public.category_kind": { + "name": "category_kind", + "schema": "public", + "values": [ + "expense", + "income" + ] + }, + "public.commitment_frequency": { + "name": "commitment_frequency", + "schema": "public", + "values": [ + "once", + "weekly", + "monthly", + "quarterly", + "half_yearly", + "yearly", + "custom" + ] + }, + "public.commitment_kind": { + "name": "commitment_kind", + "schema": "public", + "values": [ + "subscription", + "salary", + "payroll", + "rent", + "loan_payment", + "insurance", + "tax", + "utility", + "domain", + "hosting", + "software", + "contractor", + "education", + "income", + "custom" + ] + }, + "public.commitment_status": { + "name": "commitment_status", + "schema": "public", + "values": [ + "active", + "paused", + "ended" + ] + }, + "public.connection_status": { + "name": "connection_status", + "schema": "public", + "values": [ + "connected", + "syncing", + "error", + "needs_attention", + "disconnected" + ] + }, + "public.copilot_role": { + "name": "copilot_role", + "schema": "public", + "values": [ + "user", + "assistant" + ] + }, + "public.counterparty_kind": { + "name": "counterparty_kind", + "schema": "public", + "values": [ + "merchant", + "customer", + "vendor", + "person", + "employee", + "institution", + "other" + ] + }, + "public.employee_status": { + "name": "employee_status", + "schema": "public", + "values": [ + "active", + "inactive" + ] + }, + "public.employment_type": { + "name": "employment_type", + "schema": "public", + "values": [ + "full_time", + "part_time", + "contractor", + "intern" + ] + }, + "public.file_kind": { + "name": "file_kind", + "schema": "public", + "values": [ + "screenshot", + "receipt", + "statement", + "import", + "attachment", + "report", + "other" + ] + }, + "public.goal_kind": { + "name": "goal_kind", + "schema": "public", + "values": [ + "savings", + "emergency_fund", + "asset_purchase", + "business_capital", + "travel", + "investment", + "education", + "dream_asset", + "custom" + ] + }, + "public.goal_status": { + "name": "goal_status", + "schema": "public", + "values": [ + "active", + "achieved", + "paused", + "archived" + ] + }, + "public.import_format": { + "name": "import_format", + "schema": "public", + "values": [ + "csv", + "xlsx", + "pdf" + ] + }, + "public.import_row_status": { + "name": "import_row_status", + "schema": "public", + "values": [ + "valid", + "invalid", + "duplicate", + "imported", + "skipped" + ] + }, + "public.import_status": { + "name": "import_status", + "schema": "public", + "values": [ + "uploaded", + "mapped", + "previewed", + "importing", + "completed", + "failed", + "cancelled" + ] + }, + "public.inbox_kind": { + "name": "inbox_kind", + "schema": "public", + "values": [ + "duplicate", + "recurring_candidate", + "subscription_candidate", + "anomaly", + "integration_error", + "budget_warning", + "price_change", + "renewal", + "large_transaction", + "forecast_warning", + "receivable_overdue", + "observation" + ] + }, + "public.inbox_status": { + "name": "inbox_status", + "schema": "public", + "values": [ + "open", + "resolved", + "dismissed", + "snoozed" + ] + }, + "public.interval_unit": { + "name": "interval_unit", + "schema": "public", + "values": [ + "day", + "week", + "month", + "year" + ] + }, + "public.investment_kind": { + "name": "investment_kind", + "schema": "public", + "values": [ + "stock", + "mutual_fund", + "fixed_deposit", + "savings_certificate", + "bond", + "dps", + "gold", + "crypto", + "real_estate", + "business_equity", + "retirement", + "other" + ] + }, + "public.investment_status": { + "name": "investment_status", + "schema": "public", + "values": [ + "active", + "closed" + ] + }, + "public.job_status": { + "name": "job_status", + "schema": "public", + "values": [ + "queued", + "running", + "succeeded", + "failed", + "dead" + ] + }, + "public.liability_kind": { + "name": "liability_kind", + "schema": "public", + "values": [ + "loan", + "credit", + "personal_debt", + "business_debt", + "payable", + "mortgage", + "other" + ] + }, + "public.liability_status": { + "name": "liability_status", + "schema": "public", + "values": [ + "active", + "paid_off", + "overdue", + "cancelled" + ] + }, + "public.member_role": { + "name": "member_role", + "schema": "public", + "values": [ + "owner", + "admin", + "member", + "viewer" + ] + }, + "public.narrative_source": { + "name": "narrative_source", + "schema": "public", + "values": [ + "ai", + "template" + ] + }, + "public.occurrence_status": { + "name": "occurrence_status", + "schema": "public", + "values": [ + "scheduled", + "paid", + "skipped", + "cancelled" + ] + }, + "public.payroll_run_status": { + "name": "payroll_run_status", + "schema": "public", + "values": [ + "draft", + "posted" + ] + }, + "public.priority": { + "name": "priority", + "schema": "public", + "values": [ + "low", + "medium", + "high" + ] + }, + "public.project_status": { + "name": "project_status", + "schema": "public", + "values": [ + "active", + "paused", + "completed", + "archived" + ] + }, + "public.rate_source": { + "name": "rate_source", + "schema": "public", + "values": [ + "manual", + "seed", + "api", + "transaction" + ] + }, + "public.receivable_kind": { + "name": "receivable_kind", + "schema": "public", + "values": [ + "invoice", + "loan", + "other" + ] + }, + "public.receivable_status": { + "name": "receivable_status", + "schema": "public", + "values": [ + "pending", + "partially_paid", + "paid", + "overdue", + "cancelled" + ] + }, + "public.report_kind": { + "name": "report_kind", + "schema": "public", + "values": [ + "weekly", + "monthly", + "quarterly", + "custom" + ] + }, + "public.rule_match": { + "name": "rule_match", + "schema": "public", + "values": [ + "all", + "any" + ] + }, + "public.severity": { + "name": "severity", + "schema": "public", + "values": [ + "info", + "success", + "warning", + "critical" + ] + }, + "public.subscription_status": { + "name": "subscription_status", + "schema": "public", + "values": [ + "trial", + "active", + "renewal_due", + "renewed", + "cancellation_pending", + "cancelled", + "expired", + "paused" + ] + }, + "public.sync_frequency": { + "name": "sync_frequency", + "schema": "public", + "values": [ + "manual", + "hourly", + "daily" + ] + }, + "public.sync_status": { + "name": "sync_status", + "schema": "public", + "values": [ + "running", + "succeeded", + "partial", + "failed" + ] + }, + "public.sync_trigger": { + "name": "sync_trigger", + "schema": "public", + "values": [ + "initial", + "incremental", + "manual", + "scheduled", + "webhook", + "retry" + ] + }, + "public.transaction_direction": { + "name": "transaction_direction", + "schema": "public", + "values": [ + "in", + "out" + ] + }, + "public.transaction_source": { + "name": "transaction_source", + "schema": "public", + "values": [ + "manual", + "screenshot", + "receipt", + "text", + "voice", + "csv", + "excel", + "pdf", + "integration", + "webhook", + "api", + "recurring", + "system" + ] + }, + "public.transaction_status": { + "name": "transaction_status", + "schema": "public", + "values": [ + "draft", + "pending", + "posted", + "void" + ] + }, + "public.transaction_type": { + "name": "transaction_type", + "schema": "public", + "values": [ + "expense", + "income", + "transfer", + "refund", + "adjustment", + "investment", + "asset_purchase", + "debt_payment", + "loan", + "equity" + ] + }, + "public.trust_level": { + "name": "trust_level", + "schema": "public", + "values": [ + "trusted", + "review" + ] + }, + "public.webhook_event_status": { + "name": "webhook_event_status", + "schema": "public", + "values": [ + "received", + "processed", + "ignored", + "failed", + "duplicate" + ] + }, + "public.workspace_kind": { + "name": "workspace_kind", + "schema": "public", + "values": [ + "personal", + "business" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/api/drizzle/meta/_journal.json b/apps/api/drizzle/meta/_journal.json index bd3cc9c..0c7674b 100644 --- a/apps/api/drizzle/meta/_journal.json +++ b/apps/api/drizzle/meta/_journal.json @@ -43,6 +43,13 @@ "when": 1790899953420, "tag": "0005_reminders_daily_last_3_days", "breakpoints": true + }, + { + "idx": 6, + "version": "7", + "when": 1791031460361, + "tag": "0006_digital_currency", + "breakpoints": true } ] } \ No newline at end of file diff --git a/apps/api/src/db/schema/_columns.ts b/apps/api/src/db/schema/_columns.ts index de12f96..f541489 100644 --- a/apps/api/src/db/schema/_columns.ts +++ b/apps/api/src/db/schema/_columns.ts @@ -10,7 +10,7 @@ export const pk = () => uuid("id").primaryKey().$defaultFn(uuidv7); */ export const money = (name: string) => bigint(name, { mode: "number" }); -export const currency = (name = "currency") => varchar(name, { length: 3 }); +export const currency = (name = "currency") => varchar(name, { length: 5 }); /** A calendar day, as `YYYY-MM-DD`. Financial dates are days, not instants. */ export const day = (name: string) => date(name, { mode: "string" }); diff --git a/apps/api/src/modules/business/business.controller.ts b/apps/api/src/modules/business/business.controller.ts index c58dc4f..c3df8dd 100644 --- a/apps/api/src/modules/business/business.controller.ts +++ b/apps/api/src/modules/business/business.controller.ts @@ -1,8 +1,11 @@ import { employeeUpdate, payrollItemUpdate, payrollRunInput } from "@expensewise/core"; import { type EmployeeCreateInput, + type EmployeePayInput, employeeCreateInput, + employeePayInput, employeeQuery, + employeeUnpayInput, type FinanceRangeQuery, financeRangeQuery, } from "@expensewise/core/contracts/business-extra"; @@ -69,6 +72,18 @@ export class PayrollController { return this.service.updateEmployee(ctx, id, input); } + @Post("employees/:id/pay") + @HttpCode(200) + payEmployee(@Ctx() ctx: WorkspaceContext, @Param("id", uuidParam) id: string, @Body(zod(employeePayInput)) input: EmployeePayInput) { + return this.service.payEmployee(ctx, id, input); + } + + @Post("employees/:id/unpay") + @HttpCode(200) + unpayEmployee(@Ctx() ctx: WorkspaceContext, @Param("id", uuidParam) id: string, @Body(zod(employeeUnpayInput)) input: z.input) { + return this.service.unpayEmployee(ctx, id, input); + } + @Delete("employees/:id") removeEmployee(@Ctx() ctx: WorkspaceContext, @Param("id", uuidParam) id: string) { return this.service.removeEmployee(ctx, id); diff --git a/apps/api/src/modules/business/payroll.service.ts b/apps/api/src/modules/business/payroll.service.ts index c9c3079..4efd227 100644 --- a/apps/api/src/modules/business/payroll.service.ts +++ b/apps/api/src/modules/business/payroll.service.ts @@ -1,7 +1,14 @@ import { addMonths, type Day, daysInMonth, employeeUpdate, endOfMonth, payrollItemUpdate, payrollRunInput } from "@expensewise/core"; -import { type EmployeeCreateInput, employeeCreateInput, employeeQuery } from "@expensewise/core/contracts/business-extra"; +import { + type EmployeeCreateInput, + type EmployeePayInput, + employeeCreateInput, + employeePayInput, + employeeQuery, + employeeUnpayInput, +} from "@expensewise/core/contracts/business-extra"; import { Inject, Injectable } from "@nestjs/common"; -import { and, asc, desc, eq, gte, inArray, isNull, lte, or } from "drizzle-orm"; +import { and, asc, desc, eq, gte, inArray, isNotNull, isNull, lte, or } from "drizzle-orm"; import type { z } from "zod"; import { todayFor, type WorkspaceContext } from "../../common/context.js"; import { assertFound, badRequest, conflict, unprocessable } from "../../common/errors.js"; @@ -106,9 +113,12 @@ export class PayrollService { deductions: payrollItems.deductions, net: payrollItems.net, transactionId: payrollItems.transactionId, + paidOn: transactions.date, + transactionStatus: transactions.status, }) .from(payrollItems) .innerJoin(payrollRuns, eq(payrollRuns.id, payrollItems.runId)) + .leftJoin(transactions, eq(transactions.id, payrollItems.transactionId)) .where(and(eq(payrollItems.workspaceId, ctx.workspaceId), eq(payrollItems.employeeId, id))) .orderBy(desc(payrollRuns.period)) .limit(24), @@ -139,10 +149,162 @@ export class PayrollService { accountName: row?.accountName ?? null, counterpartyName: row?.counterpartyName ?? null, payrollHistory: history, + months: this.salaryMonths(ctx, employee, history), commitments: schedules, }; } + /** + * Each month the employee was on the books (the last 12 at most, newest + * first) and whether that month's salary has been paid. + */ + private salaryMonths( + ctx: WorkspaceContext, + employee: EmployeeRow, + history: Array<{ period: string; net: number; transactionId: string | null; paidOn: Day | null; transactionStatus: string | null; runStatus: string }>, + ) { + const current = todayFor(ctx).slice(0, 7); + const last = employee.endDate && employee.endDate.slice(0, 7) < current ? employee.endDate.slice(0, 7) : current; + const months: string[] = []; + for (let month = last; months.length < 12; month = addMonths(`${month}-01`, -1).slice(0, 7)) { + if (employee.startDate && month < employee.startDate.slice(0, 7)) break; + months.push(month); + } + return months.map((period) => { + const item = history.find((h) => h.period === period); + const paid = Boolean(item?.transactionId && item.transactionStatus !== "void"); + return { + period, + status: paid ? ("paid" as const) : ("unpaid" as const), + amount: paid && item ? item.net : employee.salary, + currency: employee.currency, + paidOn: paid ? (item?.paidOn ?? null) : null, + transactionId: paid ? (item?.transactionId ?? null) : null, + }; + }); + } + + /** + * Pays one employee for one month: an expense in the Payroll category on + * their project, with the proof of payment attached. It shares the month's + * payroll run, so posting the run later never pays them twice. + */ + async payEmployee(ctx: WorkspaceContext, employeeId: string, raw: EmployeePayInput) { + assertBusiness(ctx); + const input = employeePayInput.parse(raw); + await db.transaction(async (tx) => { + const employee = await this.getEmployee(ctx, employeeId, tx); + const accountId = input.accountId ?? employee.accountId; + if (!accountId) throw unprocessable(`Choose the account ${employee.name} was paid from`, "missing_account"); + await this.checkRefs(tx, ctx, { accountId }); + const amount = input.amount ?? employee.salary; + + let [run] = await tx + .select() + .from(payrollRuns) + .where(and(eq(payrollRuns.workspaceId, ctx.workspaceId), eq(payrollRuns.period, input.period))) + .limit(1); + if (!run) { + [run] = await tx + .insert(payrollRuns) + .values({ workspaceId: ctx.workspaceId, period: input.period, payDate: input.paidOn, currency: ctx.baseCurrency, createdBy: ctx.userId }) + .returning(); + } + const payrollRun = assertFound(run, "Payroll run"); + + const [existing] = await tx + .select({ item: payrollItems, transactionStatus: transactions.status }) + .from(payrollItems) + .leftJoin(transactions, eq(transactions.id, payrollItems.transactionId)) + .where(and(eq(payrollItems.runId, payrollRun.id), eq(payrollItems.employeeId, employee.id))) + .limit(1); + if (existing?.item.transactionId && existing.transactionStatus !== "void") { + throw conflict(`${employee.name} is already paid for ${input.period}`, "already_paid"); + } + const values = { gross: amount, deductions: 0, net: amount, accountId, projectId: employee.defaultProjectId, note: input.note ?? null }; + const [item] = existing + ? await tx.update(payrollItems).set(values).where(eq(payrollItems.id, existing.item.id)).returning() + : await tx + .insert(payrollItems) + .values({ workspaceId: ctx.workspaceId, runId: payrollRun.id, employeeId: employee.id, ...values }) + .returning(); + const payrollItem = assertFound(item, "Payroll item"); + + let counterpartyId = employee.counterpartyId; + if (!counterpartyId) { + counterpartyId = (await this.counterparties.findOrCreate(tx, ctx.workspaceId, employee.name, "employee"))?.id ?? null; + if (counterpartyId) await tx.update(employees).set({ counterpartyId }).where(eq(employees.id, employee.id)); + } + const categoryId = await ensureCategory(tx, ctx, this.audit, PAYROLL_CATEGORY); + const { transaction } = await this.transactions.create( + ctx, + { + type: "expense", + direction: "out", + accountId, + amount, + currency: employee.currency, + date: input.paidOn, + categoryId, + projectId: employee.defaultProjectId, + counterpartyId, + description: `Salary ${input.period}: ${employee.name}`, + notes: input.note ?? null, + attachmentFileIds: input.attachmentFileIds, + }, + { + exec: tx, + skipLearning: true, + metadata: { + payrollRunId: payrollRun.id, + payrollItemId: payrollItem.id, + employeeId: employee.id, + gross: amount, + deductions: 0, + paidIndividually: true, + }, + }, + ); + await tx.update(payrollItems).set({ transactionId: transaction.id }).where(eq(payrollItems.id, payrollItem.id)); + await this.runTotal(tx, ctx, payrollRun); + await this.audit.record(tx, ctx, { + action: "payroll.employee_paid", + entityType: "employee", + entityId: employee.id, + after: { period: input.period, amount, transactionId: transaction.id, payrollRunId: payrollRun.id }, + }); + }); + return this.employeeDetail(ctx, employeeId); + } + + /** Undoes one month's salary payment: the expense is voided and the month is unpaid again. */ + async unpayEmployee(ctx: WorkspaceContext, employeeId: string, raw: z.input) { + assertBusiness(ctx); + const input = employeeUnpayInput.parse(raw); + await db.transaction(async (tx) => { + const employee = await this.getEmployee(ctx, employeeId, tx); + const [row] = await tx + .select({ item: payrollItems, run: payrollRuns }) + .from(payrollItems) + .innerJoin(payrollRuns, eq(payrollRuns.id, payrollItems.runId)) + .where(and(eq(payrollItems.workspaceId, ctx.workspaceId), eq(payrollItems.employeeId, employee.id), eq(payrollRuns.period, input.period))) + .limit(1); + if (!row?.item.transactionId) throw conflict(`${employee.name} has no salary payment for ${input.period}`, "not_paid"); + await this.transactions.void(ctx, row.item.transactionId, `Salary ${input.period} payment undone`, { exec: tx }); + // A posted run no longer pays them this month; a draft keeps them in line to be paid. + if (row.run.status === "posted") await tx.delete(payrollItems).where(eq(payrollItems.id, row.item.id)); + else await tx.update(payrollItems).set({ transactionId: null }).where(eq(payrollItems.id, row.item.id)); + await this.runTotal(tx, ctx, row.run); + await this.audit.record(tx, ctx, { + action: "payroll.employee_unpaid", + entityType: "employee", + entityId: employee.id, + before: { period: input.period, transactionId: row.item.transactionId }, + }); + }); + return this.employeeDetail(ctx, employeeId); + } + private async checkRefs(tx: Executor, ctx: WorkspaceContext, refs: { projectId?: string | null; accountId?: string | null }) { await assertInWorkspace(tx, projects, ctx.workspaceId, [refs.projectId], "Project"); await assertInWorkspace(tx, financialAccounts, ctx.workspaceId, [refs.accountId], "Account"); @@ -405,6 +567,12 @@ export class PayrollService { return db.transaction(async (tx) => { const run = await this.getRun(ctx, id, tx); if (run.status !== "draft") throw conflict("Un-post the run before deleting it", "run_posted"); + const [paid] = await tx + .select({ id: payrollItems.id }) + .from(payrollItems) + .where(and(eq(payrollItems.runId, id), isNotNull(payrollItems.transactionId))) + .limit(1); + if (paid) throw conflict("Someone in this run is already paid. Undo their salary payment first.", "run_has_payments"); await tx.delete(payrollRuns).where(eq(payrollRuns.id, id)); await this.audit.record(tx, ctx, { action: "payroll_run.deleted", entityType: "payroll_run", entityId: id, before: run }); return { deleted: true }; @@ -423,6 +591,7 @@ export class PayrollService { .where(and(eq(payrollItems.id, itemId), eq(payrollItems.runId, runId), eq(payrollItems.workspaceId, ctx.workspaceId))) .limit(1); const item = assertFound(before, "Payroll item"); + if (item.transactionId) throw conflict("This salary is already paid. Undo the payment to change it.", "item_paid"); await this.checkRefs(tx, ctx, { projectId: input.projectId, accountId: input.accountId }); const gross = input.gross ?? item.gross; const deductions = input.deductions ?? item.deductions; @@ -458,7 +627,7 @@ export class PayrollService { if (run.status !== "draft") throw conflict("This run is already posted", "run_posted"); const items = await this.items(ctx, [runId], tx); if (!items.length) throw unprocessable("The run has no employees", "empty_run"); - const missing = items.filter((item) => item.net > 0 && !item.accountId); + const missing = items.filter((item) => item.net > 0 && !item.accountId && !item.transactionId); if (missing.length) { throw unprocessable( `Choose the account to pay ${missing.map((item) => item.employeeName).join(", ")} from`, @@ -469,7 +638,8 @@ export class PayrollService { const categoryId = await ensureCategory(tx, ctx, this.audit, PAYROLL_CATEGORY); const posted: Array<{ itemId: string; transactionId: string }> = []; for (const item of items) { - if (item.net <= 0) continue; + // Already paid on their own (with proof); the run must not pay them twice. + if (item.net <= 0 || (item.transactionId && item.transactionStatus !== "void")) continue; let counterpartyId = item.counterpartyId; if (!counterpartyId) { counterpartyId = (await this.counterparties.findOrCreate(tx, ctx.workspaceId, item.employeeName, "employee"))?.id ?? null; @@ -517,14 +687,19 @@ export class PayrollService { await db.transaction(async (tx) => { const run = await this.getRun(ctx, runId, tx); if (run.status !== "posted") throw conflict("This run is not posted", "run_not_posted"); - const items = await tx.select().from(payrollItems).where(eq(payrollItems.runId, runId)); + const items = await tx + .select({ item: payrollItems, metadata: transactions.metadata }) + .from(payrollItems) + .leftJoin(transactions, eq(transactions.id, payrollItems.transactionId)) + .where(eq(payrollItems.runId, runId)); const voided: string[] = []; - for (const item of items) { - if (!item.transactionId) continue; + for (const { item, metadata } of items) { + // Salaries paid one by one, with their proof, stay paid. + if (!item.transactionId || (metadata as Record | null)?.paidIndividually) continue; await this.transactions.void(ctx, item.transactionId, `Payroll ${run.period} un-posted`, { exec: tx }); + await tx.update(payrollItems).set({ transactionId: null }).where(eq(payrollItems.id, item.id)); voided.push(item.transactionId); } - await tx.update(payrollItems).set({ transactionId: null }).where(eq(payrollItems.runId, runId)); await tx.update(payrollRuns).set({ status: "draft", postedAt: null }).where(eq(payrollRuns.id, runId)); await this.audit.record(tx, ctx, { action: "payroll_run.unposted", diff --git a/apps/api/src/modules/copilot/copilot.actions.ts b/apps/api/src/modules/copilot/copilot.actions.ts index 336b2d2..9450289 100644 --- a/apps/api/src/modules/copilot/copilot.actions.ts +++ b/apps/api/src/modules/copilot/copilot.actions.ts @@ -589,7 +589,9 @@ export class CopilotActions { description: "Add a money account: a bank account, cash, a mobile wallet (bKash, Nagad, Rocket), a card, savings or a loan account.", inputSchema: z.object({ name: z.string().trim().min(1).max(80), - kind: z.enum(ACCOUNT_KINDS).describe("bank, cash, mobile_wallet, card, digital_wallet, payment_processor, savings, loan or other"), + kind: z + .enum(ACCOUNT_KINDS) + .describe("bank, cash, mobile_wallet, card, digital_wallet, payment_processor, savings, loan, other or crypto_wallet (digital currency)"), currency, openingBalance: z.number().nullish().describe("Major units; negative for money owed on a card or loan. Defaults to 0"), openingDate: day.nullish().describe("Defaults to today"), diff --git a/apps/api/tests/integration/business.test.ts b/apps/api/tests/integration/business.test.ts index 4fb7dbd..52f0986 100644 --- a/apps/api/tests/integration/business.test.ts +++ b/apps/api/tests/integration/business.test.ts @@ -3,7 +3,7 @@ import { and, eq } from "drizzle-orm"; import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { todayFor, type WorkspaceContext } from "../../src/common/context.js"; import { db } from "../../src/db/index.js"; -import { auditLogs, categories } from "../../src/db/schema/index.js"; +import { auditLogs, categories, files } from "../../src/db/schema/index.js"; import { nextPayDate, PayrollService } from "../../src/modules/business/payroll.service.js"; import { ProjectFinanceService } from "../../src/modules/business/project-finance.service.js"; import { RevenueService } from "../../src/modules/business/revenue.service.js"; @@ -346,6 +346,63 @@ describe("payroll", () => { expect((await payroll.listRuns(ctx))[0]).toMatchObject({ period, itemCount: 3 }); }); + it("pays one employee for one month with proof, never twice, and the run skips them", async () => { + const proof = async () => { + const [row] = await db + .insert(files) + .values({ + workspaceId: ctx.workspaceId, + storageKey: `test/${crypto.randomUUID()}`, + filename: "bkash.png", + contentType: "image/png", + size: 10, + sha256: crypto.randomUUID(), + }) + .returning(); + return row?.id as string; + }; + const rahim = await payroll.createEmployee(ctx, { name: "Rahim Uddin", salary: 5_000_000, currency: "BDT", accountId: bank, defaultProjectId: app }); + const karim = await payroll.createEmployee(ctx, { name: "Karim Ahmed", salary: 4_000_000, currency: "BDT", accountId: bank, defaultProjectId: app }); + const period = monthKey(m1); + + // Proof is required. + await expect(payroll.payEmployee(ctx, rahim.id, { period, paidOn: m1, attachmentFileIds: [] })).rejects.toThrow(); + + const detail = await payroll.payEmployee(ctx, rahim.id, { period, paidOn: addDays(m1, 2), attachmentFileIds: [await proof()] }); + const month = detail.months.find((m) => m.period === period); + expect(month).toMatchObject({ status: "paid", amount: 5_000_000, paidOn: addDays(m1, 2) }); + const paid = await transactions.get(ctx, month?.transactionId as string); + expect(paid).toMatchObject({ type: "expense", amount: 5_000_000, projectId: app, categoryId: await category("Payroll") }); + expect(paid.attachmentFileId).toBeTruthy(); + + await expect(payroll.payEmployee(ctx, rahim.id, { period, paidOn: m1, attachmentFileIds: [await proof()] })).rejects.toMatchObject({ + code: "already_paid", + }); + + // The month's run already has Rahim paid; posting pays only Karim. + const run = (await payroll.listRuns(ctx)).find((r) => r.period === period); + const runId = run?.id as string; + const withKarim = await payroll.runDetail(ctx, runId); + expect(withKarim.items.map((i) => i.employeeId)).toEqual([rahim.id]); + await expect(payroll.deleteRun(ctx, runId)).rejects.toMatchObject({ code: "run_has_payments" }); + await payroll.payEmployee(ctx, karim.id, { period, paidOn: m1, amount: 3_500_000, attachmentFileIds: [await proof()] }); + const posted = await payroll.post(ctx, runId); + const salaryTx = (await transactions.list(ctx, { type: ["expense"], categoryId: await category("Payroll") })).items.filter( + (t) => t.status !== "void", + ); + expect(salaryTx.map((t) => t.amount).sort()).toEqual([3_500_000, 5_000_000]); + expect(posted.status).toBe("posted"); + + // Un-posting the run keeps the payments made one by one. + await payroll.unpost(ctx, runId); + expect((await payroll.employeeDetail(ctx, rahim.id)).months.find((m) => m.period === period)?.status).toBe("paid"); + + // Undoing a payment voids the expense and the month is unpaid again. + const undone = await payroll.unpayEmployee(ctx, rahim.id, { period }); + expect(undone.months.find((m) => m.period === period)?.status).toBe("unpaid"); + expect((await transactions.get(ctx, month?.transactionId as string)).status).toBe("void"); + }); + it("is only available in business workspaces", async () => { await expect(payroll.listRuns(user.personal)).rejects.toThrow(/available in business workspaces/); await expect(payroll.createEmployee(user.personal, { name: "X", salary: 1, currency: "BDT" })).rejects.toThrow(/available in business workspaces/); diff --git a/apps/web/src/components/accounts/account-form.tsx b/apps/web/src/components/accounts/account-form.tsx index 376710c..95c229b 100644 --- a/apps/web/src/components/accounts/account-form.tsx +++ b/apps/web/src/components/accounts/account-form.tsx @@ -1,6 +1,6 @@ "use client"; -import { ACCOUNT_KIND_LABELS, ACCOUNT_KINDS, type AccountKind, COMMON_CURRENCIES, minorToInput, parseMoneyInput, today } from "@expensewise/core"; +import { ACCOUNT_KIND_LABELS, ACCOUNT_KINDS, type AccountKind, minorToInput, parseMoneyInput, SELECTABLE_CURRENCIES, today } from "@expensewise/core"; import { useRouter } from "next/navigation"; import { type FormEvent, useEffect, useId, useState } from "react"; import { useApp } from "@/components/app/app-context"; @@ -29,6 +29,8 @@ export const PROVIDERS: Array<{ value: string; label: string; kind: AccountKind; { value: "payoneer", label: "Payoneer", kind: "digital_wallet", currency: "USD" }, { value: "paypal", label: "PayPal", kind: "digital_wallet", currency: "USD" }, { value: "stripe", label: "Stripe", kind: "payment_processor", currency: "USD" }, + { value: "binance", label: "Binance", kind: "crypto_wallet", currency: "USDT" }, + { value: "crypto", label: "Crypto wallet", kind: "crypto_wallet", currency: "BTC" }, { value: "other", label: "Other", kind: "other" }, ]; @@ -154,7 +156,7 @@ export function AccountFormDialog({ open, onOpenChange, account }: { open: boole {currency} - {[...new Set([currency, ...COMMON_CURRENCIES])].map((code) => ( + {[...new Set([currency, ...SELECTABLE_CURRENCIES])].map((code) => ( {code} diff --git a/apps/web/src/components/accounts/accounts-view.tsx b/apps/web/src/components/accounts/accounts-view.tsx index 104ac16..115ecd2 100644 --- a/apps/web/src/components/accounts/accounts-view.tsx +++ b/apps/web/src/components/accounts/accounts-view.tsx @@ -1,7 +1,7 @@ "use client"; import { ACCOUNT_KIND_LABELS, type AccountKind } from "@expensewise/core"; -import { Banknote, CheckCircle2, CircleAlert, CreditCard, Landmark, Plus, Smartphone, Wallet } from "lucide-react"; +import { Banknote, Bitcoin, CheckCircle2, CircleAlert, CreditCard, Landmark, Plus, Smartphone, Wallet } from "lucide-react"; import Link from "next/link"; import { useState } from "react"; import { useApp } from "@/components/app/app-context"; @@ -17,9 +17,10 @@ const KIND_ICON: Partial> = { cash: Banknote, mobile_wallet: Smartphone, card: CreditCard, + crypto_wallet: Bitcoin, }; -const ORDER: AccountKind[] = ["bank", "mobile_wallet", "cash", "digital_wallet", "payment_processor", "savings", "card", "loan", "other"]; +const ORDER: AccountKind[] = ["bank", "mobile_wallet", "cash", "digital_wallet", "payment_processor", "crypto_wallet", "savings", "card", "loan", "other"]; export function AccountsView({ accounts }: { accounts: Account[] }) { const { money, canWrite } = useApp(); diff --git a/apps/web/src/components/app/transaction-form.tsx b/apps/web/src/components/app/transaction-form.tsx index 07b511e..1875a38 100644 --- a/apps/web/src/components/app/transaction-form.tsx +++ b/apps/web/src/components/app/transaction-form.tsx @@ -1,12 +1,12 @@ "use client"; import { - COMMON_CURRENCIES, currencyDecimals, endOfMonth, minorToInput, monthKey, parseMoneyInput, + SELECTABLE_CURRENCIES, type TransactionType, TYPE_LABELS, TYPE_RULES, @@ -349,7 +349,7 @@ export function TransactionFormDialog({ {form.currency} - {[...new Set([form.currency, ...COMMON_CURRENCIES])].map((code) => ( + {[...new Set([form.currency, ...SELECTABLE_CURRENCIES])].map((code) => ( {code} diff --git a/apps/web/src/components/business/payroll.tsx b/apps/web/src/components/business/payroll.tsx index 12e28ba..17a6877 100644 --- a/apps/web/src/components/business/payroll.tsx +++ b/apps/web/src/components/business/payroll.tsx @@ -6,6 +6,7 @@ import Link from "next/link"; import { useRouter } from "next/navigation"; import { type FormEvent, useEffect, useId, useState } from "react"; import { useApp } from "@/components/app/app-context"; +import { type Attachment, AttachmentField, discardNewAttachments } from "@/components/app/attachment-field"; import { EmptyNote, EmptyState, Section, StatCard, StatusBadge } from "@/components/app/blocks"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; @@ -26,9 +27,10 @@ import { useRefresh, } from "@/components/wealth/shared"; import { clientApi, errorMessage } from "@/lib/api/client"; -import type { Employee, EmployeeList, EmploymentType, PayrollItem, PayrollRun, PayrollRunDetail } from "@/lib/api/types/business"; +import type { Employee, EmployeeDetail, EmployeeList, EmploymentType, PayrollItem, PayrollRun, PayrollRunDetail } from "@/lib/api/types/business"; import { cn } from "@/lib/cn"; import { toast } from "@/lib/toast"; +import { useApi } from "@/lib/use-api"; const EMPLOYMENT_LABELS: Record = { full_time: "Full-time", @@ -95,6 +97,7 @@ export function ProjectPayroll({ employees, projectId }: { employees: EmployeeLi function EmployeesTab({ employees, projectId }: { employees: EmployeeList; projectId?: string }) { const { money, canWrite } = useApp(); const [editing, setEditing] = useState(null); + const [viewing, setViewing] = useState(null); const [creating, setCreating] = useState(false); const { items, totals } = employees; @@ -160,9 +163,18 @@ function EmployeesTab({ employees, projectId }: { employees: EmployeeList; proje {items.map((e) => ( - td]:px-3 [&>td]:py-2", e.status === "inactive" && "text-muted-foreground")}> + setViewing(e)} + className={cn( + "cursor-pointer transition-colors hover:bg-accent/40 [&>td]:px-3 [&>td]:py-2", + e.status === "inactive" && "text-muted-foreground", + )} + > - {e.name} + {[e.title, EMPLOYMENT_LABELS[e.employmentType]].filter(Boolean).join(" · ")} @@ -176,7 +188,15 @@ function EmployeesTab({ employees, projectId }: { employees: EmployeeList; proje {canWrite && ( - @@ -188,6 +208,14 @@ function EmployeesTab({ employees, projectId }: { employees: EmployeeList; proje !open && setEditing(null)} employee={editing} /> + !open && setViewing(null)} + onEdit={(employee) => { + setViewing(null); + setEditing(employee); + }} + /> ); } @@ -832,3 +860,251 @@ function ItemRow({ runId, item, editable }: { runId: string; item: PayrollItem; ); } + +/** + * One employee's salary, month by month: which months are paid (with the + * proof) and which are not, and a way to pay or undo a month. + */ +export function EmployeeSalaryDialog({ + employee, + onOpenChange, + onEdit, +}: { + employee: Employee | null; + onOpenChange: (open: boolean) => void; + onEdit: (employee: Employee) => void; +}) { + const { money, canWrite } = useApp(); + const refresh = useRefresh(); + const detail = useApi(employee ? `/payroll/employees/${employee.id}` : null); + const [paying, setPaying] = useState(null); + const [undoing, setUndoing] = useState(null); + const months = detail.data?.months ?? []; + const paidCount = months.filter((m) => m.status === "paid").length; + + const changed = () => { + void detail.reload(); + refresh("/payroll"); + }; + + return ( + + + + {employee?.name} + {employee && ( +

+ {money(employee.salary, employee.currency)} a month · paid on the {ordinal(employee.payDay)} + {employee.projectName ? ` · ${employee.projectName}` : ""} +

+ )} +
+ +
+

Salary by month

+ {months.length > 0 && ( + + {paidCount} of {months.length} paid + + )} +
+ {detail.loading && !detail.data ? ( +

Loading…

+ ) : months.length === 0 ? ( + No months yet. Set when they started in their details. + ) : ( +
    + {months.map((m) => ( +
  • + + {m.status === "paid" ? : } + +
    +

    {formatMonth(m.period)}

    +

    + {m.status === "paid" ? ( + <> + Paid {m.paidOn ? formatDay(m.paidOn) : ""} ·{" "} + + View payment & proof + + + ) : ( + "Not paid yet" + )} +

    +
    + {money(m.amount, m.currency)} + {canWrite && + (m.status === "paid" ? ( + + ) : ( + + ))} +
  • + ))} +
+ )} +
+ + {canWrite && employee && ( + + )} + + +
+ {employee && ( + !open && setPaying(null)} + onPaid={() => { + setPaying(null); + changed(); + }} + /> + )} + !open && setUndoing(null)} + title={undoing ? `Undo ${formatMonth(undoing.period)} salary?` : "Undo salary?"} + description="The salary expense is cancelled (kept in history as void) and the month shows as not paid again." + confirmLabel="Undo payment" + onConfirm={async () => { + if (!employee || !undoing) return; + try { + await clientApi(`/payroll/employees/${employee.id}/unpay`, { method: "POST", body: { period: undoing.period } }); + toast.success(`${formatMonth(undoing.period)} salary undone`); + setUndoing(null); + changed(); + } catch (err) { + toast.error(errorMessage(err)); + } + }} + /> +
+ ); +} + +/** Records one month's salary as paid, with the screenshot or slip as proof. */ +function PaySalaryDialog({ + employee, + month, + onOpenChange, + onPaid, +}: { + employee: Employee; + month: EmployeeDetail["months"][number] | null; + onOpenChange: (open: boolean) => void; + onPaid: () => void; +}) { + const id = useId(); + const { workspace } = useApp(); + const [amount, setAmount] = useState(""); + const [paidOn, setPaidOn] = useState(""); + const [accountId, setAccountId] = useState(null); + const [note, setNote] = useState(""); + const [proof, setProof] = useState([]); + const [error, setError] = useState(null); + const [saving, setSaving] = useState(false); + const open = month !== null; + + useEffect(() => { + if (!month) return; + setAmount(minorToInput(month.amount, month.currency)); + setPaidOn(today(workspace.timezone)); + setAccountId(employee.accountId); + setNote(""); + setProof([]); + setError(null); + }, [month, employee.accountId, workspace.timezone]); + + const close = (next: boolean) => { + if (!next) discardNewAttachments(proof); + onOpenChange(next); + }; + + const submit = async (event: FormEvent) => { + event.preventDefault(); + if (!month) return; + setError(null); + const minor = toMinor(amount, month.currency); + if (!minor) return setError("Enter the amount paid"); + if (!paidOn) return setError("Choose the day it was paid"); + if (!accountId) return setError("Choose the account it was paid from"); + if (!proof.length) return setError("Attach the payment screenshot. If it is still uploading, wait for it to finish."); + setSaving(true); + try { + await clientApi(`/payroll/employees/${employee.id}/pay`, { + method: "POST", + body: { period: month.period, paidOn, amount: minor, accountId, note: note.trim() || null, attachmentFileIds: proof.map((f) => f.id) }, + }); + toast.success(`${employee.name}'s ${formatMonth(month.period)} salary recorded`, { + description: employee.projectName ? `Added to ${employee.projectName}'s cost.` : undefined, + }); + setProof([]); + onPaid(); + } catch (err) { + setError(errorMessage(err)); + } finally { + setSaving(false); + } + }; + + return ( + + +
+ + Pay {month ? formatMonth(month.period) : ""} salary +

{employee.name}

+
+ +
+ + + + + setPaidOn(e.target.value)} /> + +
+ + + + + + setNote(e.target.value)} placeholder="Optional, e.g. includes bonus" /> + + +
+ + + + +
+
+
+ ); +} diff --git a/apps/web/src/components/settings/misc-settings.tsx b/apps/web/src/components/settings/misc-settings.tsx index 85325d1..479aae3 100644 --- a/apps/web/src/components/settings/misc-settings.tsx +++ b/apps/web/src/components/settings/misc-settings.tsx @@ -1,6 +1,6 @@ "use client"; -import { COMMON_CURRENCIES, today } from "@expensewise/core"; +import { SELECTABLE_CURRENCIES, today } from "@expensewise/core"; import { ChevronLeft, ChevronRight, Plus, Trash2 } from "lucide-react"; import Link from "next/link"; import { usePathname, useRouter, useSearchParams } from "next/navigation"; @@ -97,7 +97,7 @@ export function CurrencySettings({ rates }: { rates: ExchangeRate[] }) { {from} - {COMMON_CURRENCIES.filter((c) => c !== workspace.baseCurrency).map((code) => ( + {SELECTABLE_CURRENCIES.filter((c) => c !== workspace.baseCurrency).map((code) => ( {code} diff --git a/apps/web/src/components/wealth/shared.tsx b/apps/web/src/components/wealth/shared.tsx index dafb78e..8d37075 100644 --- a/apps/web/src/components/wealth/shared.tsx +++ b/apps/web/src/components/wealth/shared.tsx @@ -1,6 +1,6 @@ "use client"; -import { COMMON_CURRENCIES, formatDay, parseMoneyInput, TYPE_LABELS } from "@expensewise/core"; +import { formatDay, parseMoneyInput, SELECTABLE_CURRENCIES, TYPE_LABELS } from "@expensewise/core"; import { ArrowUpRight } from "lucide-react"; import Link from "next/link"; import { usePathname, useRouter, useSearchParams } from "next/navigation"; @@ -217,7 +217,7 @@ export function CurrencySelect({ id, value, onChange, disabled }: { id?: string; {value} - {[...new Set([value, ...COMMON_CURRENCIES])].map((code) => ( + {[...new Set([value, ...SELECTABLE_CURRENCIES])].map((code) => ( {code} diff --git a/apps/web/src/lib/api/types/business.ts b/apps/web/src/lib/api/types/business.ts index 7d5cb33..de7b22a 100644 --- a/apps/web/src/lib/api/types/business.ts +++ b/apps/web/src/lib/api/types/business.ts @@ -274,6 +274,15 @@ export type EmployeeDetail = Employee & { net: number; transactionId: string | null; }>; + /** The last months they were employed, newest first, with whether each salary is paid. */ + months: Array<{ + period: string; + status: "paid" | "unpaid"; + amount: number; + currency: string; + paidOn: string | null; + transactionId: string | null; + }>; commitments: Array<{ id: string; name: string; diff --git a/packages/core/src/constants.ts b/packages/core/src/constants.ts index 0558615..810c482 100644 --- a/packages/core/src/constants.ts +++ b/packages/core/src/constants.ts @@ -7,7 +7,18 @@ export type WorkspaceKind = (typeof WORKSPACE_KINDS)[number]; export const MEMBER_ROLES = ["owner", "admin", "member", "viewer"] as const; export type MemberRole = (typeof MEMBER_ROLES)[number]; -export const ACCOUNT_KINDS = ["bank", "cash", "mobile_wallet", "card", "digital_wallet", "payment_processor", "savings", "loan", "other"] as const; +export const ACCOUNT_KINDS = [ + "bank", + "cash", + "mobile_wallet", + "card", + "digital_wallet", + "payment_processor", + "savings", + "loan", + "other", + "crypto_wallet", +] as const; export type AccountKind = (typeof ACCOUNT_KINDS)[number]; export const TRANSACTION_TYPES = [ @@ -173,6 +184,7 @@ export const ACCOUNT_KIND_LABELS: Record = { mobile_wallet: "Mobile wallet", card: "Credit card", digital_wallet: "Digital wallet", + crypto_wallet: "Digital currency (crypto)", payment_processor: "Payment processor", savings: "Savings", loan: "Loan account", @@ -220,3 +232,26 @@ export const SUBSCRIPTION_STATUS_LABELS: Record = { /** Currencies offered in pickers; any ISO code still works via the API. */ export const COMMON_CURRENCIES = ["BDT", "USD", "EUR", "GBP", "INR", "AED", "SAR", "SGD", "MYR", "CAD", "AUD", "JPY", "CNY"] as const; + +/** + * Digital currencies an account or transaction can hold. They are not ISO + * codes, so each carries its own precision (minor units per coin) and symbol. + * Prices move fast: their exchange rates are entered, never seeded. + */ +export const CRYPTO_CURRENCIES = { + BTC: { name: "Bitcoin", symbol: "₿", decimals: 8 }, + ETH: { name: "Ethereum", symbol: "Ξ", decimals: 8 }, + USDT: { name: "Tether", symbol: "₮", decimals: 2 }, + USDC: { name: "USD Coin", symbol: "USDC", decimals: 2 }, + BNB: { name: "BNB", symbol: "BNB", decimals: 8 }, + SOL: { name: "Solana", symbol: "SOL", decimals: 8 }, +} as const satisfies Record; +export type CryptoCurrency = keyof typeof CRYPTO_CURRENCIES; +export const CRYPTO_CURRENCY_CODES = Object.keys(CRYPTO_CURRENCIES) as CryptoCurrency[]; + +export function isCryptoCurrency(code: string): code is CryptoCurrency { + return Object.hasOwn(CRYPTO_CURRENCIES, code.toUpperCase()); +} + +/** Everything a money field can be in: common fiat first, then digital currencies. */ +export const SELECTABLE_CURRENCIES: string[] = [...COMMON_CURRENCIES, ...CRYPTO_CURRENCY_CODES]; diff --git a/packages/core/src/contracts/business-extra.ts b/packages/core/src/contracts/business-extra.ts index b1cbd62..08aff34 100644 --- a/packages/core/src/contracts/business-extra.ts +++ b/packages/core/src/contracts/business-extra.ts @@ -41,3 +41,20 @@ export const employeeQuery = z.object({ /** Only the people whose cost belongs to this project. */ projectId: uuid.optional(), }); + +const period = z.string().regex(/^\d{4}-(0[1-9]|1[0-2])$/, "Expected a month as YYYY-MM"); + +/** Pays one employee for one month, with the proof of payment. */ +export const employeePayInput = z.object({ + period, + paidOn: dayString, + /** Minor units in the employee's salary currency; defaults to their salary. */ + amount: z.number().int().positive().optional(), + /** Defaults to the employee's own "paid from" account. */ + accountId: uuid.nullish(), + attachmentFileIds: z.array(uuid).min(1, "Attach the payment screenshot").max(10), + note: z.string().trim().max(500).nullish(), +}); +export type EmployeePayInput = z.input; + +export const employeeUnpayInput = z.object({ period }); diff --git a/packages/core/src/contracts/common.ts b/packages/core/src/contracts/common.ts index 6f031c7..a74932d 100644 --- a/packages/core/src/contracts/common.ts +++ b/packages/core/src/contracts/common.ts @@ -4,7 +4,7 @@ import { isDay } from "../dates.ts"; export const dayString = z.string().refine(isDay, "Expected a date as YYYY-MM-DD"); export const currencyCode = z .string() - .regex(/^[A-Za-z]{3}$/, "Expected a 3-letter currency code") + .regex(/^[A-Za-z]{3,5}$/, "Expected a currency code such as BDT, USD or USDT") .transform((code) => code.toUpperCase()); /** Minor units, strictly positive. */ export const positiveMinor = z.number().int().positive().max(Number.MAX_SAFE_INTEGER); diff --git a/packages/core/src/money.ts b/packages/core/src/money.ts index 238f5ae..152defa 100644 --- a/packages/core/src/money.ts +++ b/packages/core/src/money.ts @@ -1,6 +1,8 @@ // Money is integer minor units everywhere: poisha for BDT, cents for USD. // Floats appear only at the edges (display), never in arithmetic. +import { CRYPTO_CURRENCIES, isCryptoCurrency } from "./constants.ts"; + const decimalsCache = new Map(); /** Minor-unit digits for a currency: BDT 2, USD 2, JPY 0, KWD 3. */ @@ -8,6 +10,7 @@ export function currencyDecimals(currency: string): number { const code = currency.toUpperCase(); const cached = decimalsCache.get(code); if (cached !== undefined) return cached; + if (isCryptoCurrency(code)) return CRYPTO_CURRENCIES[code].decimals; let digits = 2; try { digits = new Intl.NumberFormat("en", { style: "currency", currency: code }).resolvedOptions().maximumFractionDigits ?? 2; @@ -141,6 +144,17 @@ export function formatMoney(minor: number, currency: string, options: MoneyForma const major = minor / 10 ** digits; const fractionDigits = options.compact || (options.trimZeroFraction && Number.isInteger(major)) ? 0 : digits; const key = `${locale}|${code}|${options.compact ? "c" : "s"}|${fractionDigits}|${options.signed ? "+" : ""}`; + // Digital currencies are not ISO codes, so Intl cannot format them as currency. + if (isCryptoCurrency(code)) { + const number = formatter(`${key}|n`, locale, { + notation: options.compact ? "compact" : "standard", + minimumFractionDigits: options.compact ? 0 : fractionDigits, + maximumFractionDigits: options.compact ? 1 : fractionDigits, + }).format(Math.abs(major)); + const sign = major < 0 ? "-" : options.signed && major > 0 ? "+" : ""; + const symbol = CRYPTO_CURRENCIES[code].symbol; + return `${sign}${symbol}${symbol.length > 1 ? " " : ""}${number}`; + } const format = formatter(key, locale, { style: "currency", currency: code, diff --git a/packages/core/tests/money-dates.test.ts b/packages/core/tests/money-dates.test.ts index e62b882..f8718b8 100644 --- a/packages/core/tests/money-dates.test.ts +++ b/packages/core/tests/money-dates.test.ts @@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest"; import { addMonths, convertMinor, + currencyCode, currencyDecimals, diffDays, formatMoney, @@ -22,6 +23,19 @@ describe("money", () => { expect(currencyDecimals("JPY")).toBe(0); }); + it("handles digital currencies: precision, symbols, conversion and 4-letter codes", () => { + expect(currencyDecimals("BTC")).toBe(8); + expect(currencyDecimals("usdt")).toBe(2); + expect(parseMoneyInput("0.0025", "BTC")).toBe(250_000); + expect(formatMoney(50_000_000, "BTC")).toBe("₿0.50000000"); + expect(formatMoney(-150_050, "USDT", { signed: true })).toBe("-₮1,500.50"); + expect(formatMoney(123_456_789, "SOL")).toBe("SOL 1.23456789"); + // 0.5 BTC at ৳1,20,00,000 a coin. + expect(convertMinor(50_000_000, "BTC", "BDT", "12000000")).toBe(600_000_000); + expect(currencyCode.parse("usdt")).toBe("USDT"); + expect(currencyCode.safeParse("US").success).toBe(false); + }); + it("parses typed amounts including lakh grouping and Bangla digits", () => { expect(parseMoneyInput("40,000.50")).toBe(4_000_050); expect(parseMoneyInput("1,00,000")).toBe(10_000_000); From 86894780eb97eb0a79cdd372e515cda3e2ada3c7 Mon Sep 17 00:00:00 2001 From: Noor Fahim Date: Sat, 3 Oct 2026 19:03:51 +0600 Subject: [PATCH 2/2] Fix formatting and the 2FA test after the FinanceOS rename The rename shortened import lines (Biome now formats them on one line) and changed the authenticator issuer from "Expense Wise" to "FinanceOS". Co-Authored-By: Claude Opus 5.5 --- apps/api/src/modules/account/account.controller.ts | 6 +----- apps/api/src/modules/copilot/copilot.controller.ts | 9 +-------- apps/api/src/modules/wealth/liabilities.service.ts | 12 +----------- apps/api/tests/integration/accounts-auth.test.ts | 2 +- apps/api/tests/integration/business.test.ts | 4 +--- apps/web/src/app/(public)/privacy/page.tsx | 8 ++++---- apps/web/src/app/(public)/terms/page.tsx | 6 +++--- apps/web/src/app/(public)/welcome/page.tsx | 4 ++-- 8 files changed, 14 insertions(+), 37 deletions(-) diff --git a/apps/api/src/modules/account/account.controller.ts b/apps/api/src/modules/account/account.controller.ts index 9354bb3..56e219a 100644 --- a/apps/api/src/modules/account/account.controller.ts +++ b/apps/api/src/modules/account/account.controller.ts @@ -39,11 +39,7 @@ export class AccountController { @RateLimit("account-export", 30, 3600) async exportWorkspace(@Ctx() ctx: WorkspaceContext, @CurrentUser() user: SessionUser) { const data = await this.exports.workspace(ctx, user); - return download( - JSON.stringify(data, null, 2), - `financeos-${fileSlug(ctx.workspaceName)}-${today(ctx.timezone)}.json`, - "application/json; charset=utf-8", - ); + return download(JSON.stringify(data, null, 2), `financeos-${fileSlug(ctx.workspaceName)}-${today(ctx.timezone)}.json`, "application/json; charset=utf-8"); } /** The current workspace's transactions as CSV. Owners and admins only. */ diff --git a/apps/api/src/modules/copilot/copilot.controller.ts b/apps/api/src/modules/copilot/copilot.controller.ts index e724868..1928bc0 100644 --- a/apps/api/src/modules/copilot/copilot.controller.ts +++ b/apps/api/src/modules/copilot/copilot.controller.ts @@ -1,11 +1,4 @@ -import { - type AgentMemoryInput, - agentMemoryInput, - type CopilotActionsInput, - type CopilotAskInput, - copilotActionsInput, - copilotAskInput, -} from "@financeos/core"; +import { type AgentMemoryInput, agentMemoryInput, type CopilotActionsInput, type CopilotAskInput, copilotActionsInput, copilotAskInput } from "@financeos/core"; import { Body, Controller, Delete, Get, HttpCode, Inject, Param, ParseUUIDPipe, Post } from "@nestjs/common"; import type { WorkspaceContext } from "../../common/context.js"; import { AllowViewer, Ctx, WorkspaceScoped } from "../../common/guards.js"; diff --git a/apps/api/src/modules/wealth/liabilities.service.ts b/apps/api/src/modules/wealth/liabilities.service.ts index 08bfadd..6fc89ea 100644 --- a/apps/api/src/modules/wealth/liabilities.service.ts +++ b/apps/api/src/modules/wealth/liabilities.service.ts @@ -1,14 +1,4 @@ -import { - addDays, - type Day, - type DebtFlow, - diffDays, - type LiabilityKind, - liabilityInput, - liabilityOutstanding, - liabilityUpdate, - uuidv7, -} from "@financeos/core"; +import { addDays, type Day, type DebtFlow, diffDays, type LiabilityKind, liabilityInput, liabilityOutstanding, liabilityUpdate, uuidv7 } from "@financeos/core"; import { type LiabilityPaymentRequest, type LiabilityQuery, diff --git a/apps/api/tests/integration/accounts-auth.test.ts b/apps/api/tests/integration/accounts-auth.test.ts index 3758794..9df2d35 100644 --- a/apps/api/tests/integration/accounts-auth.test.ts +++ b/apps/api/tests/integration/accounts-auth.test.ts @@ -184,7 +184,7 @@ describe("two-factor sign-in", () => { const enabled = await auth.api.enableTwoFactor({ body: { password: PASSWORD }, headers: headers(person.cookie), asResponse: true }); expect(enabled.status).toBe(200); const { totpURI, backupCodes } = (await enabled.json()) as { totpURI: string; backupCodes: string[] }; - expect(totpURI).toMatch(/^otpauth:\/\/totp\/Expense%20Wise:/); + expect(totpURI).toMatch(/^otpauth:\/\/totp\/FinanceOS:/); expect(backupCodes).toHaveLength(10); // Not on until a code from the app proves it is set up. let [user] = await db.select().from(users).where(eq(users.id, person.id)); diff --git a/apps/api/tests/integration/business.test.ts b/apps/api/tests/integration/business.test.ts index 1408a8f..d878d4c 100644 --- a/apps/api/tests/integration/business.test.ts +++ b/apps/api/tests/integration/business.test.ts @@ -387,9 +387,7 @@ describe("payroll", () => { await expect(payroll.deleteRun(ctx, runId)).rejects.toMatchObject({ code: "run_has_payments" }); await payroll.payEmployee(ctx, karim.id, { period, paidOn: m1, amount: 3_500_000, attachmentFileIds: [await proof()] }); const posted = await payroll.post(ctx, runId); - const salaryTx = (await transactions.list(ctx, { type: ["expense"], categoryId: await category("Payroll") })).items.filter( - (t) => t.status !== "void", - ); + const salaryTx = (await transactions.list(ctx, { type: ["expense"], categoryId: await category("Payroll") })).items.filter((t) => t.status !== "void"); expect(salaryTx.map((t) => t.amount).sort()).toEqual([3_500_000, 5_000_000]); expect(posted.status).toBe("posted"); diff --git a/apps/web/src/app/(public)/privacy/page.tsx b/apps/web/src/app/(public)/privacy/page.tsx index 34adb78..6beba44 100644 --- a/apps/web/src/app/(public)/privacy/page.tsx +++ b/apps/web/src/app/(public)/privacy/page.tsx @@ -66,8 +66,8 @@ const sections: LegalSection[] = [
  • People you invite to a workspace, according to their role.
  • - Service providers that run parts of FinanceOS for us: hosting and databases, file storage, email delivery, AI model providers, error monitoring - and payment processors — each only for its task. + Service providers that run parts of FinanceOS for us: hosting and databases, file storage, email delivery, AI model providers, error monitoring and + payment processors — each only for its task.
  • Apps you connect or give an API key to, for the data you allow them to read or write.
  • Authorities, when the law requires it.
  • @@ -155,8 +155,8 @@ export default function PrivacyPage() { updated="26 September 2026" intro={

    - Your financial records are about as personal as data gets. This policy explains what FinanceOS collects, why, who helps us process it, and the - control you have over it. + Your financial records are about as personal as data gets. This policy explains what FinanceOS collects, why, who helps us process it, and the control + you have over it.

    } sections={sections} diff --git a/apps/web/src/app/(public)/terms/page.tsx b/apps/web/src/app/(public)/terms/page.tsx index 2cedd2e..cf4a406 100644 --- a/apps/web/src/app/(public)/terms/page.tsx +++ b/apps/web/src/app/(public)/terms/page.tsx @@ -10,9 +10,9 @@ const sections: LegalSection[] = [ title: "The service", body: (

    - FinanceOS is software for recording and understanding personal and business finances: accounts, transactions, receipts, bills, budgets, goals, - assets, debts and reports. It is a record-keeping and planning tool. It does not hold or move your money, is not a bank or payment service, and does not - give financial, tax, investment or legal advice. + FinanceOS is software for recording and understanding personal and business finances: accounts, transactions, receipts, bills, budgets, goals, assets, + debts and reports. It is a record-keeping and planning tool. It does not hold or move your money, is not a bank or payment service, and does not give + financial, tax, investment or legal advice.

    ), }, diff --git a/apps/web/src/app/(public)/welcome/page.tsx b/apps/web/src/app/(public)/welcome/page.tsx index 24d9e9a..8aec066 100644 --- a/apps/web/src/app/(public)/welcome/page.tsx +++ b/apps/web/src/app/(public)/welcome/page.tsx @@ -185,8 +185,8 @@ export default function WelcomePage() {

    Know where every taka goes.

    - Capture receipts, SMS and screenshots, connect bKash, banks and apps, and ask in English or বাংলা. FinanceOS keeps one clean ledger for your - household and your company — AI does the typing, you stay in control. + Capture receipts, SMS and screenshots, connect bKash, banks and apps, and ask in English or বাংলা. FinanceOS keeps one clean ledger for your household + and your company — AI does the typing, you stay in control.