diff --git a/apps/dashboard/src/components/charts/realtime.tsx b/apps/dashboard/src/components/charts/realtime.tsx index 935a2ac7d1..978ff962a0 100644 --- a/apps/dashboard/src/components/charts/realtime.tsx +++ b/apps/dashboard/src/components/charts/realtime.tsx @@ -24,7 +24,7 @@ export function Realtime({ teamId }) { `spending-${teamId}`, `metrics-${teamId}`, ]); - }, + } ) .subscribe(); diff --git a/apps/dashboard/src/components/modals/export-transactions-modal.tsx b/apps/dashboard/src/components/modals/export-transactions-modal.tsx index 998f8c5f76..c49bbfdc7a 100644 --- a/apps/dashboard/src/components/modals/export-transactions-modal.tsx +++ b/apps/dashboard/src/components/modals/export-transactions-modal.tsx @@ -17,7 +17,7 @@ export function ExportTransactionsModal({ isOpen, setOpen }) { Export Heads up, we’ve noticed that 12 of your transactions are missing - receipts. Click show more and we’ll filter them for you. + receipts. Click “show more” and we’ll filter them for you. diff --git a/apps/dashboard/src/jobs/transactions.ts b/apps/dashboard/src/jobs/transactions.ts index fd4241639d..a28675e25e 100644 --- a/apps/dashboard/src/jobs/transactions.ts +++ b/apps/dashboard/src/jobs/transactions.ts @@ -33,7 +33,7 @@ const transformTransactions = (transactions, { teamId, accountId }) => name: capitalCase(data.additionalInformation), original: data.additionalInformation, method: mapTransactionMethod(data.proprietaryBankTransactionCode), - provider_transaction_id: data.internalTransactionId, + internal_id: data.internalTransactionId, amount: data.transactionAmount.amount, currency: data.transactionAmount.currency, bank_account_id: accountId, @@ -100,7 +100,6 @@ client.defineJob({ .single(); if (!data) { - // TODO: Remove schedule await io.logger.error(`Bank account not found: ${ctx.source.id}`); await dynamicSchedule.unregister(ctx.source.id); } @@ -121,7 +120,7 @@ client.defineJob({ teamId: data?.team_id, }), { - onConflict: "provider_transaction_id", + onConflict: "internal_id", ignoreDuplicates: true, }, ); diff --git a/packages/supabase/src/queries/index.ts b/packages/supabase/src/queries/index.ts index 7b3b0b8b0e..30f143a1ba 100644 --- a/packages/supabase/src/queries/index.ts +++ b/packages/supabase/src/queries/index.ts @@ -305,6 +305,7 @@ export async function getTransaction(supabase: Client, id: string) { `) .eq("id", id) .single() + .throwOnError(); } diff --git a/packages/supabase/src/types/db.ts b/packages/supabase/src/types/db.ts index c1a85d17f3..b861c0a772 100644 --- a/packages/supabase/src/types/db.ts +++ b/packages/supabase/src/types/db.ts @@ -4,370 +4,374 @@ export type Json = | boolean | null | { [key: string]: Json | undefined } - | Json[] + | Json[]; export interface Database { public: { Tables: { attachments: { Row: { - created_at: string - id: string - name: string | null - path: string | null - size: number | null - team_id: string | null - transaction_id: string | null - type: string | null - } + created_at: string; + id: string; + name: string | null; + path: string | null; + size: number | null; + team_id: string | null; + transaction_id: string | null; + type: string | null; + }; Insert: { - created_at?: string - id?: string - name?: string | null - path?: string | null - size?: number | null - team_id?: string | null - transaction_id?: string | null - type?: string | null - } + created_at?: string; + id?: string; + name?: string | null; + path?: string | null; + size?: number | null; + team_id?: string | null; + transaction_id?: string | null; + type?: string | null; + }; Update: { - created_at?: string - id?: string - name?: string | null - path?: string | null - size?: number | null - team_id?: string | null - transaction_id?: string | null - type?: string | null - } + created_at?: string; + id?: string; + name?: string | null; + path?: string | null; + size?: number | null; + team_id?: string | null; + transaction_id?: string | null; + type?: string | null; + }; Relationships: [ { - foreignKeyName: "attachments_team_id_fkey" - columns: ["team_id"] - isOneToOne: false - referencedRelation: "teams" - referencedColumns: ["id"] + foreignKeyName: "attachments_team_id_fkey"; + columns: ["team_id"]; + isOneToOne: false; + referencedRelation: "teams"; + referencedColumns: ["id"]; }, { - foreignKeyName: "attachments_transaction_id_fkey" - columns: ["transaction_id"] - isOneToOne: false - referencedRelation: "transactions" - referencedColumns: ["id"] - } - ] - } + foreignKeyName: "attachments_transaction_id_fkey"; + columns: ["transaction_id"]; + isOneToOne: false; + referencedRelation: "transactions"; + referencedColumns: ["id"]; + }, + ]; + }; bank_accounts: { Row: { - account_id: string - bank_connection_id: string | null - bban: string | null - bic: string | null - created_at: string - created_by: string - currency: string | null - iban: string | null - id: string - last_accessed: string | null - name: string | null - owner_name: string | null - team_id: string | null - } + account_id: string; + bank_connection_id: string | null; + bban: string | null; + bic: string | null; + created_at: string; + created_by: string; + currency: string | null; + iban: string | null; + id: string; + last_accessed: string | null; + name: string | null; + owner_name: string | null; + team_id: string | null; + }; Insert: { - account_id: string - bank_connection_id?: string | null - bban?: string | null - bic?: string | null - created_at?: string - created_by: string - currency?: string | null - iban?: string | null - id?: string - last_accessed?: string | null - name?: string | null - owner_name?: string | null - team_id?: string | null - } + account_id: string; + bank_connection_id?: string | null; + bban?: string | null; + bic?: string | null; + created_at?: string; + created_by: string; + currency?: string | null; + iban?: string | null; + id?: string; + last_accessed?: string | null; + name?: string | null; + owner_name?: string | null; + team_id?: string | null; + }; Update: { - account_id?: string - bank_connection_id?: string | null - bban?: string | null - bic?: string | null - created_at?: string - created_by?: string - currency?: string | null - iban?: string | null - id?: string - last_accessed?: string | null - name?: string | null - owner_name?: string | null - team_id?: string | null - } + account_id?: string; + bank_connection_id?: string | null; + bban?: string | null; + bic?: string | null; + created_at?: string; + created_by?: string; + currency?: string | null; + iban?: string | null; + id?: string; + last_accessed?: string | null; + name?: string | null; + owner_name?: string | null; + team_id?: string | null; + }; Relationships: [ { - foreignKeyName: "bank_accounts_bank_connection_id_fkey" - columns: ["bank_connection_id"] - isOneToOne: false - referencedRelation: "bank_connections" - referencedColumns: ["id"] + foreignKeyName: "bank_accounts_bank_connection_id_fkey"; + columns: ["bank_connection_id"]; + isOneToOne: false; + referencedRelation: "bank_connections"; + referencedColumns: ["id"]; }, { - foreignKeyName: "bank_accounts_created_by_fkey" - columns: ["created_by"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: "bank_accounts_created_by_fkey"; + columns: ["created_by"]; + isOneToOne: false; + referencedRelation: "users"; + referencedColumns: ["id"]; }, { - foreignKeyName: "bank_accounts_team_id_fkey" - columns: ["team_id"] - isOneToOne: false - referencedRelation: "teams" - referencedColumns: ["id"] - } - ] - } + foreignKeyName: "bank_accounts_team_id_fkey"; + columns: ["team_id"]; + isOneToOne: false; + referencedRelation: "teams"; + referencedColumns: ["id"]; + }, + ]; + }; bank_connections: { Row: { - created_at: string - expires_at: string | null - id: string - institution_id: string | null - logo_url: string | null - name: string | null - provider: Database["public"]["Enums"]["bankProviders"] | null - team_id: string | null - } + created_at: string; + expires_at: string | null; + id: string; + institution_id: string | null; + logo_url: string | null; + name: string | null; + provider: Database["public"]["Enums"]["bankProviders"] | null; + team_id: string | null; + }; Insert: { - created_at?: string - expires_at?: string | null - id?: string - institution_id?: string | null - logo_url?: string | null - name?: string | null - provider?: Database["public"]["Enums"]["bankProviders"] | null - team_id?: string | null - } + created_at?: string; + expires_at?: string | null; + id?: string; + institution_id?: string | null; + logo_url?: string | null; + name?: string | null; + provider?: Database["public"]["Enums"]["bankProviders"] | null; + team_id?: string | null; + }; Update: { - created_at?: string - expires_at?: string | null - id?: string - institution_id?: string | null - logo_url?: string | null - name?: string | null - provider?: Database["public"]["Enums"]["bankProviders"] | null - team_id?: string | null - } + created_at?: string; + expires_at?: string | null; + id?: string; + institution_id?: string | null; + logo_url?: string | null; + name?: string | null; + provider?: Database["public"]["Enums"]["bankProviders"] | null; + team_id?: string | null; + }; Relationships: [ { - foreignKeyName: "bank_connections_team_id_fkey" - columns: ["team_id"] - isOneToOne: false - referencedRelation: "teams" - referencedColumns: ["id"] - } - ] - } + foreignKeyName: "bank_connections_team_id_fkey"; + columns: ["team_id"]; + isOneToOne: false; + referencedRelation: "teams"; + referencedColumns: ["id"]; + }, + ]; + }; teams: { Row: { - created_at: string - id: string - logo_url: string | null - name: string | null - } + created_at: string; + id: string; + logo_url: string | null; + name: string | null; + }; Insert: { - created_at?: string - id?: string - logo_url?: string | null - name?: string | null - } + created_at?: string; + id?: string; + logo_url?: string | null; + name?: string | null; + }; Update: { - created_at?: string - id?: string - logo_url?: string | null - name?: string | null - } - Relationships: [] - } + created_at?: string; + id?: string; + logo_url?: string | null; + name?: string | null; + }; + Relationships: []; + }; transactions: { Row: { - amount: number | null - assigned_id: string | null - bank_account_id: string | null - booking_date: string | null - category: Database["public"]["Enums"]["transactionCategories"] | null - created_at: string - currency: string | null - date: string | null - id: string - method: Database["public"]["Enums"]["transactionMethods"] | null - name: string | null - note: string | null - order: number - original: string | null - provider_transaction_id: string | null - reference: string - team_id: string | null - transaction_id: string - vat: Database["public"]["Enums"]["vatRates"] | null - } + amount: number | null; + assigned_id: string | null; + bank_account_id: string | null; + booking_date: string | null; + category: Database["public"]["Enums"]["transactionCategories"] | null; + created_at: string; + currency: string | null; + date: string | null; + id: string; + method: Database["public"]["Enums"]["transactionMethods"] | null; + name: string | null; + note: string | null; + order: number; + original: string | null; + internal_id: string | null; + reference: string; + team_id: string | null; + transaction_id: string; + vat: Database["public"]["Enums"]["vatRates"] | null; + }; Insert: { - amount?: number | null - assigned_id?: string | null - bank_account_id?: string | null - booking_date?: string | null - category?: Database["public"]["Enums"]["transactionCategories"] | null - created_at?: string - currency?: string | null - date?: string | null - id?: string - method?: Database["public"]["Enums"]["transactionMethods"] | null - name?: string | null - note?: string | null - order?: number - original?: string | null - provider_transaction_id?: string | null - reference: string - team_id?: string | null - transaction_id: string - vat?: Database["public"]["Enums"]["vatRates"] | null - } + amount?: number | null; + assigned_id?: string | null; + bank_account_id?: string | null; + booking_date?: string | null; + category?: + | Database["public"]["Enums"]["transactionCategories"] + | null; + created_at?: string; + currency?: string | null; + date?: string | null; + id?: string; + method?: Database["public"]["Enums"]["transactionMethods"] | null; + name?: string | null; + note?: string | null; + order?: number; + original?: string | null; + internal_id?: string | null; + reference: string; + team_id?: string | null; + transaction_id: string; + vat?: Database["public"]["Enums"]["vatRates"] | null; + }; Update: { - amount?: number | null - assigned_id?: string | null - bank_account_id?: string | null - booking_date?: string | null - category?: Database["public"]["Enums"]["transactionCategories"] | null - created_at?: string - currency?: string | null - date?: string | null - id?: string - method?: Database["public"]["Enums"]["transactionMethods"] | null - name?: string | null - note?: string | null - order?: number - original?: string | null - provider_transaction_id?: string | null - reference?: string - team_id?: string | null - transaction_id?: string - vat?: Database["public"]["Enums"]["vatRates"] | null - } + amount?: number | null; + assigned_id?: string | null; + bank_account_id?: string | null; + booking_date?: string | null; + category?: + | Database["public"]["Enums"]["transactionCategories"] + | null; + created_at?: string; + currency?: string | null; + date?: string | null; + id?: string; + method?: Database["public"]["Enums"]["transactionMethods"] | null; + name?: string | null; + note?: string | null; + order?: number; + original?: string | null; + internal_id?: string | null; + reference?: string; + team_id?: string | null; + transaction_id?: string; + vat?: Database["public"]["Enums"]["vatRates"] | null; + }; Relationships: [ { - foreignKeyName: "transactions_assigned_id_fkey" - columns: ["assigned_id"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: "transactions_assigned_id_fkey"; + columns: ["assigned_id"]; + isOneToOne: false; + referencedRelation: "users"; + referencedColumns: ["id"]; }, { - foreignKeyName: "transactions_bank_account_id_fkey" - columns: ["bank_account_id"] - isOneToOne: false - referencedRelation: "bank_accounts" - referencedColumns: ["id"] + foreignKeyName: "transactions_bank_account_id_fkey"; + columns: ["bank_account_id"]; + isOneToOne: false; + referencedRelation: "bank_accounts"; + referencedColumns: ["id"]; }, { - foreignKeyName: "transactions_team_id_fkey" - columns: ["team_id"] - isOneToOne: false - referencedRelation: "teams" - referencedColumns: ["id"] - } - ] - } + foreignKeyName: "transactions_team_id_fkey"; + columns: ["team_id"]; + isOneToOne: false; + referencedRelation: "teams"; + referencedColumns: ["id"]; + }, + ]; + }; users: { Row: { - avatar_url: string | null - created_at: string | null - email: string | null - full_name: string | null - id: string - locale: string | null - team_id: string | null - } + avatar_url: string | null; + created_at: string | null; + email: string | null; + full_name: string | null; + id: string; + locale: string | null; + team_id: string | null; + }; Insert: { - avatar_url?: string | null - created_at?: string | null - email?: string | null - full_name?: string | null - id: string - locale?: string | null - team_id?: string | null - } + avatar_url?: string | null; + created_at?: string | null; + email?: string | null; + full_name?: string | null; + id: string; + locale?: string | null; + team_id?: string | null; + }; Update: { - avatar_url?: string | null - created_at?: string | null - email?: string | null - full_name?: string | null - id?: string - locale?: string | null - team_id?: string | null - } + avatar_url?: string | null; + created_at?: string | null; + email?: string | null; + full_name?: string | null; + id?: string; + locale?: string | null; + team_id?: string | null; + }; Relationships: [ { - foreignKeyName: "users_id_fkey" - columns: ["id"] - isOneToOne: true - referencedRelation: "users" - referencedColumns: ["id"] + foreignKeyName: "users_id_fkey"; + columns: ["id"]; + isOneToOne: true; + referencedRelation: "users"; + referencedColumns: ["id"]; }, { - foreignKeyName: "users_team_id_fkey" - columns: ["team_id"] - isOneToOne: false - referencedRelation: "teams" - referencedColumns: ["id"] - } - ] - } + foreignKeyName: "users_team_id_fkey"; + columns: ["team_id"]; + isOneToOne: false; + referencedRelation: "teams"; + referencedColumns: ["id"]; + }, + ]; + }; users_on_team: { Row: { - id: string - role: Database["public"]["Enums"]["teamRoles"] | null - team_id: string - user_id: string - } + id: string; + role: Database["public"]["Enums"]["teamRoles"] | null; + team_id: string; + user_id: string; + }; Insert: { - id?: string - role?: Database["public"]["Enums"]["teamRoles"] | null - team_id: string - user_id: string - } + id?: string; + role?: Database["public"]["Enums"]["teamRoles"] | null; + team_id: string; + user_id: string; + }; Update: { - id?: string - role?: Database["public"]["Enums"]["teamRoles"] | null - team_id?: string - user_id?: string - } + id?: string; + role?: Database["public"]["Enums"]["teamRoles"] | null; + team_id?: string; + user_id?: string; + }; Relationships: [ { - foreignKeyName: "users_on_team_team_id_fkey" - columns: ["team_id"] - isOneToOne: false - referencedRelation: "teams" - referencedColumns: ["id"] + foreignKeyName: "users_on_team_team_id_fkey"; + columns: ["team_id"]; + isOneToOne: false; + referencedRelation: "teams"; + referencedColumns: ["id"]; }, { - foreignKeyName: "users_on_team_user_id_fkey" - columns: ["user_id"] - isOneToOne: false - referencedRelation: "users" - referencedColumns: ["id"] - } - ] - } - } + foreignKeyName: "users_on_team_user_id_fkey"; + columns: ["user_id"]; + isOneToOne: false; + referencedRelation: "users"; + referencedColumns: ["id"]; + }, + ]; + }; + }; Views: { - [_ in never]: never - } + [_ in never]: never; + }; Functions: { - [_ in never]: never - } + [_ in never]: never; + }; Enums: { - bankProviders: "gocardless" | "plaid" - teamRoles: "admin" | "member" + bankProviders: "gocardless" | "plaid"; + teamRoles: "admin" | "member"; transactionCategories: | "office_supplies" | "travel" @@ -378,18 +382,18 @@ export interface Database { | "meals" | "equipment" | "activity" - | "other" + | "other"; transactionMethods: | "payment" | "card_purchase" | "card_atm" | "transfer" - | "other" - transactionStatus: "booked" | "pending" - vatRates: "25" | "12" | "6" | "0" - } + | "other"; + transactionStatus: "booked" | "pending"; + vatRates: "25" | "12" | "6" | "0"; + }; CompositeTypes: { - [_ in never]: never - } - } + [_ in never]: never; + }; + }; }