From 35e06b047267dff088b41140681e9f8bcbbc0488 Mon Sep 17 00:00:00 2001 From: Pontus Abrahamsson Date: Mon, 14 Oct 2024 17:49:14 +0200 Subject: [PATCH] wip --- apps/dashboard/src/actions/invoice/schema.ts | 17 + .../invoice/update-invoice-settings-action.ts | 28 + .../dashboard/src/components/editor/index.tsx | 4 +- .../src/components/invoice/create-button.tsx | 11 +- .../components/invoice/customer-content.tsx | 68 +- .../src/components/invoice/due-date.tsx | 2 +- .../dashboard/src/components/invoice/form.tsx | 45 +- .../src/components/invoice/from-content.tsx | 18 +- .../src/components/invoice/invoice-no.tsx | 19 +- .../src/components/invoice/issue-date.tsx | 13 +- .../src/components/invoice/label-input.tsx | 4 +- .../src/components/invoice/line-items.tsx | 15 +- .../dashboard/src/components/invoice/logo.tsx | 4 +- .../src/components/invoice/note-content.tsx | 2 +- .../components/invoice/payment-details.tsx | 2 +- .../src/components/invoice/schema.ts | 18 +- .../src/components/invoice/summary.tsx | 4 +- .../src/components/sheets/global-sheets.tsx | 2 +- .../sheets/invoice-create-sheet.tsx | 8 +- packages/supabase/src/queries/index.ts | 12 + packages/supabase/src/types/db.ts | 2110 +++++++++++++++++ 21 files changed, 2300 insertions(+), 106 deletions(-) create mode 100644 apps/dashboard/src/actions/invoice/update-invoice-settings-action.ts create mode 100644 packages/supabase/src/types/db.ts diff --git a/apps/dashboard/src/actions/invoice/schema.ts b/apps/dashboard/src/actions/invoice/schema.ts index b65653ee2e..88c482b3c0 100644 --- a/apps/dashboard/src/actions/invoice/schema.ts +++ b/apps/dashboard/src/actions/invoice/schema.ts @@ -3,3 +3,20 @@ import { z } from "zod"; export const deleteInvoiceSchema = z.object({ id: z.string(), }); + +export const updateInvoiceSettingsSchema = z.object({ + customerLabel: z.string().optional(), + fromLabel: z.string().optional(), + invoiceNoLabel: z.string().optional(), + issueDateLabel: z.string().optional(), + dueDateLabel: z.string().optional(), + descriptionLabel: z.string().optional(), + priceLabel: z.string().optional(), + quantityLabel: z.string().optional(), + totalLabel: z.string().optional(), + vatLabel: z.string().optional(), + taxLabel: z.string().optional(), + paymentDetailsLabel: z.string().optional(), + noteLabel: z.string().optional(), + logoUrl: z.string().optional(), +}); diff --git a/apps/dashboard/src/actions/invoice/update-invoice-settings-action.ts b/apps/dashboard/src/actions/invoice/update-invoice-settings-action.ts new file mode 100644 index 0000000000..c6e5eb7dfd --- /dev/null +++ b/apps/dashboard/src/actions/invoice/update-invoice-settings-action.ts @@ -0,0 +1,28 @@ +"use server"; + +import { authActionClient } from "@/actions/safe-action"; +import { updateInvoiceSettingsSchema } from "./schema"; + +export const updateInvoiceSettingsAction = authActionClient + .metadata({ + name: "update-invoice-settings", + }) + .schema(updateInvoiceSettingsSchema) + .action(async ({ parsedInput: setting, ctx: { user, supabase } }) => { + const teamId = user.team_id; + + const { data, error } = await supabase + .rpc("update_team_setting", { + team_id: teamId, + setting_key: "invoice", + setting_path: [setting], + new_value: setting, + create_missing: true, + }) + .select("*") + .single(); + + console.log(data, error); + + return data; + }); diff --git a/apps/dashboard/src/components/editor/index.tsx b/apps/dashboard/src/components/editor/index.tsx index 0fce478def..c190766240 100644 --- a/apps/dashboard/src/components/editor/index.tsx +++ b/apps/dashboard/src/components/editor/index.tsx @@ -15,9 +15,10 @@ import { TextButtons } from "./selectors/text-buttons"; type Props = { initialContent?: JSONContent; className?: string; + onChange?: (content: JSONContent) => void; }; -export function Editor({ initialContent, className }: Props) { +export function Editor({ initialContent, className, onChange }: Props) { const [isFocused, setIsFocused] = useState(false); const [openLink, setOpenLink] = useState(false); const [content, setContent] = useState( @@ -41,6 +42,7 @@ export function Editor({ initialContent, className }: Props) { onUpdate={({ editor }) => { const json = editor.getJSON(); setContent(json); + onChange?.(json); }} onFocus={() => setIsFocused(true)} onBlur={() => setIsFocused(false)} diff --git a/apps/dashboard/src/components/invoice/create-button.tsx b/apps/dashboard/src/components/invoice/create-button.tsx index 18f0a2493b..3e0f7b345f 100644 --- a/apps/dashboard/src/components/invoice/create-button.tsx +++ b/apps/dashboard/src/components/invoice/create-button.tsx @@ -1,16 +1,7 @@ "use client"; import { Button } from "@midday/ui/button"; -import { useFormContext } from "react-hook-form"; -import type { InvoiceFormValues } from "./schema"; export function CreateButton() { - const { handleSubmit } = useFormContext(); - - const onSubmit = handleSubmit((data) => { - // Handle form submission - console.log(data); - }); - - return ; + return ; } diff --git a/apps/dashboard/src/components/invoice/customer-content.tsx b/apps/dashboard/src/components/invoice/customer-content.tsx index 452d3a4b28..6861c5767f 100644 --- a/apps/dashboard/src/components/invoice/customer-content.tsx +++ b/apps/dashboard/src/components/invoice/customer-content.tsx @@ -2,58 +2,44 @@ import { Editor } from "@/components/editor"; import type { JSONContent } from "novel"; +import { Controller, useFormContext } from "react-hook-form"; import { LabelInput } from "./label-input"; const defaultContent: JSONContent = { type: "paragraph", content: [ - { - type: "text", - text: "Acme inc", - }, - { - type: "hardBreak", - }, - { - type: "text", - text: "john.doe@acme.com", - }, - { - type: "hardBreak", - }, - { - type: "text", - text: "36182-4441", - }, - { - type: "hardBreak", - }, - { - type: "text", - text: "Street 56", - }, - { - type: "hardBreak", - }, - { - type: "text", - text: "243 21 California, USA", - }, - { - type: "hardBreak", - }, - { - type: "text", - text: "VAT ID: SE1246767676020", - }, + { type: "text", text: "Acme inc" }, + { type: "hardBreak" }, + { type: "text", text: "john.doe@acme.com" }, + { type: "hardBreak" }, + { type: "text", text: "36182-4441" }, + { type: "hardBreak" }, + { type: "text", text: "Street 56" }, + { type: "hardBreak" }, + { type: "text", text: "243 21 California, USA" }, + { type: "hardBreak" }, + { type: "text", text: "VAT ID: SE1246767676020" }, ], }; export function CustomerContent() { + const { control } = useFormContext(); + return (
- - + + ( + + )} + />
); } diff --git a/apps/dashboard/src/components/invoice/due-date.tsx b/apps/dashboard/src/components/invoice/due-date.tsx index 3e3e8d34c4..663caa2e19 100644 --- a/apps/dashboard/src/components/invoice/due-date.tsx +++ b/apps/dashboard/src/components/invoice/due-date.tsx @@ -21,7 +21,7 @@ export function DueDate() { return (
- + :
diff --git a/apps/dashboard/src/components/invoice/form.tsx b/apps/dashboard/src/components/invoice/form.tsx index a8eeb5d88f..dcb2ead8d5 100644 --- a/apps/dashboard/src/components/invoice/form.tsx +++ b/apps/dashboard/src/components/invoice/form.tsx @@ -1,5 +1,4 @@ import { zodResolver } from "@hookform/resolvers/zod"; -import { Button } from "@midday/ui/button"; import { ScrollArea } from "@midday/ui/scroll-area"; import { FormProvider, useForm } from "react-hook-form"; import { CreateButton } from "./create-button"; @@ -13,41 +12,53 @@ import { PaymentDetails } from "./payment-details"; import { type InvoiceFormValues, invoiceSchema } from "./schema"; import { Summary } from "./summary"; -export function Form() { +type Props = { + teamId: string; +}; + +export function Form({ teamId }: Props) { const form = useForm({ resolver: zodResolver(invoiceSchema), defaultValues: { settings: { - invoiceNo: "Invoice NO", - issueDate: "Issue Date", - dueDate: "Due Date", - customerContent: "To", - fromContent: "From", - description: "Description", - price: "Price", - quantity: "Quantity", - total: "Total", - vat: "VAT", - tax: "Tax", - paymentDetails: "Payment Details", - note: "Note", + customerLabel: "To", + fromLabel: "From", + invoiceNoLabel: "Invoice No", + issueDateLabel: "Issue Date", + dueDateLabel: "Due Date", + descriptionLabel: "Description", + priceLabel: "Price", + quantityLabel: "Quantity", + totalLabel: "Total", + vatLabel: "VAT", + taxLabel: "Tax", + paymentDetailsLabel: "Payment Details", + noteLabel: "Note", logoUrl: undefined, }, + invoiceNumber: "INV-0001", currency: "USD", lineItems: [{ name: "", quantity: 0, price: 0 }], }, }); + const onSubmit = (data: InvoiceFormValues) => { + console.log(data); + }; + return ( -
+
- +
diff --git a/apps/dashboard/src/components/invoice/from-content.tsx b/apps/dashboard/src/components/invoice/from-content.tsx index 2ed5bab6ba..e2f4e7918f 100644 --- a/apps/dashboard/src/components/invoice/from-content.tsx +++ b/apps/dashboard/src/components/invoice/from-content.tsx @@ -2,6 +2,7 @@ import { Editor } from "@/components/editor"; import type { JSONContent } from "novel"; +import { Controller, useFormContext } from "react-hook-form"; import { LabelInput } from "./label-input"; const defaultContent: JSONContent = { @@ -50,10 +51,23 @@ const defaultContent: JSONContent = { }; export function FromContent() { + const { control } = useFormContext(); + return (
- - + + ( + + )} + />
); } diff --git a/apps/dashboard/src/components/invoice/invoice-no.tsx b/apps/dashboard/src/components/invoice/invoice-no.tsx index 702a38f5c3..c5d624fa93 100644 --- a/apps/dashboard/src/components/invoice/invoice-no.tsx +++ b/apps/dashboard/src/components/invoice/invoice-no.tsx @@ -1,14 +1,29 @@ +import { updateInvoiceSettingsAction } from "@/actions/invoice/update-invoice-settings-action"; +import { useAction } from "next-safe-action/hooks"; +import { useFormContext } from "react-hook-form"; import { LabelInput } from "./label-input"; export function InvoiceNo() { + const { watch } = useFormContext(); + const invoiceNumber = watch("invoiceNumber"); + + const updateInvoiceSettings = useAction(updateInvoiceSettingsAction); + return (
- + { + updateInvoiceSettings.execute({ + invoiceNoLabel: value, + }); + }} + /> :
- INV-01 + {invoiceNumber}
); diff --git a/apps/dashboard/src/components/invoice/issue-date.tsx b/apps/dashboard/src/components/invoice/issue-date.tsx index 1b17557691..de333864eb 100644 --- a/apps/dashboard/src/components/invoice/issue-date.tsx +++ b/apps/dashboard/src/components/invoice/issue-date.tsx @@ -1,6 +1,8 @@ +import { updateInvoiceSettingsAction } from "@/actions/invoice/update-invoice-settings-action"; import { Calendar } from "@midday/ui/calendar"; import { Popover, PopoverContent, PopoverTrigger } from "@midday/ui/popover"; import { format } from "date-fns"; +import { useAction } from "next-safe-action/hooks"; import { useState } from "react"; import { useFormContext } from "react-hook-form"; import { LabelInput } from "./label-input"; @@ -18,10 +20,19 @@ export function IssueDate() { } }; + const updateInvoiceSettings = useAction(updateInvoiceSettingsAction); + return (
- + { + updateInvoiceSettings.execute({ + invoiceNoLabel: value, + }); + }} + /> :
diff --git a/apps/dashboard/src/components/invoice/label-input.tsx b/apps/dashboard/src/components/invoice/label-input.tsx index e7f36da89a..9798d22c96 100644 --- a/apps/dashboard/src/components/invoice/label-input.tsx +++ b/apps/dashboard/src/components/invoice/label-input.tsx @@ -7,9 +7,10 @@ type Props = { name: string; required?: boolean; className?: string; + onSave?: (value: string) => void; }; -export function LabelInput({ name, className }: Props) { +export function LabelInput({ name, className, onSave }: Props) { const { setValue, watch } = useFormContext(); const value = watch(name); @@ -22,6 +23,7 @@ export function LabelInput({ name, className }: Props) { onBlur={(e) => { const newValue = e.currentTarget.textContent || ""; setValue(name, newValue, { shouldValidate: true }); + onSave?.(newValue); }} > {value} diff --git a/apps/dashboard/src/components/invoice/line-items.tsx b/apps/dashboard/src/components/invoice/line-items.tsx index 77662788a0..610f68fe37 100644 --- a/apps/dashboard/src/components/invoice/line-items.tsx +++ b/apps/dashboard/src/components/invoice/line-items.tsx @@ -42,13 +42,18 @@ export function LineItems() { return (
- - - - + + + +
- + {fields.map((field, index) => ( (); const logoUrl = watch("logoUrl"); const { uploadFile, isLoading } = useUpload(); @@ -18,7 +18,7 @@ export function Logo() { try { const { url } = await uploadFile({ file, - path: ["dd6a039e-d071-423a-9a4d-9ba71325d890", "invoice", file.name], + path: [teamId, "invoice", file.name], bucket: "avatars", }); diff --git a/apps/dashboard/src/components/invoice/note-content.tsx b/apps/dashboard/src/components/invoice/note-content.tsx index 72e6021cad..14f0f287fb 100644 --- a/apps/dashboard/src/components/invoice/note-content.tsx +++ b/apps/dashboard/src/components/invoice/note-content.tsx @@ -6,7 +6,7 @@ import { LabelInput } from "./label-input"; export function NoteContent() { return (
- +
); diff --git a/apps/dashboard/src/components/invoice/payment-details.tsx b/apps/dashboard/src/components/invoice/payment-details.tsx index 6545823d56..bbc8e83328 100644 --- a/apps/dashboard/src/components/invoice/payment-details.tsx +++ b/apps/dashboard/src/components/invoice/payment-details.tsx @@ -6,7 +6,7 @@ import { LabelInput } from "./label-input"; export function PaymentDetails() { return (
- +
); diff --git a/apps/dashboard/src/components/invoice/schema.ts b/apps/dashboard/src/components/invoice/schema.ts index d5a6f45b0e..22fb3a8078 100644 --- a/apps/dashboard/src/components/invoice/schema.ts +++ b/apps/dashboard/src/components/invoice/schema.ts @@ -1,22 +1,8 @@ +import { updateInvoiceSettingsSchema } from "@/actions/invoice/schema"; import { z } from "zod"; export const invoiceSchema = z.object({ - settings: z.object({ - customerContent: z.string(), - fromContent: z.string(), - invoiceNo: z.string(), - issueDate: z.string(), - dueDate: z.string(), - description: z.string(), - price: z.string(), - quantity: z.string(), - total: z.string(), - vat: z.string(), - tax: z.string(), - paymentDetails: z.string(), - note: z.string(), - logoUrl: z.string().optional(), - }), + settings: updateInvoiceSettingsSchema, from: z.any(), customer: z.any(), paymentDetails: z.any(), diff --git a/apps/dashboard/src/components/invoice/summary.tsx b/apps/dashboard/src/components/invoice/summary.tsx index cad3654186..a9033adc56 100644 --- a/apps/dashboard/src/components/invoice/summary.tsx +++ b/apps/dashboard/src/components/invoice/summary.tsx @@ -30,7 +30,7 @@ export function Summary() { return (
- +
- + - + ); } diff --git a/apps/dashboard/src/components/sheets/invoice-create-sheet.tsx b/apps/dashboard/src/components/sheets/invoice-create-sheet.tsx index cabe3eb974..badd2ab03c 100644 --- a/apps/dashboard/src/components/sheets/invoice-create-sheet.tsx +++ b/apps/dashboard/src/components/sheets/invoice-create-sheet.tsx @@ -6,7 +6,11 @@ import { Icons } from "@midday/ui/icons"; import { Sheet, SheetContent, SheetHeader } from "@midday/ui/sheet"; import React from "react"; -export function InvoiceCreateSheet() { +type Props = { + teamId: string; +}; + +export function InvoiceCreateSheet({ teamId }: Props) { const { setParams, createInvoice } = useInvoiceParams(); const isOpen = Boolean(createInvoice); @@ -22,7 +26,7 @@ export function InvoiceCreateSheet() { - + ); diff --git a/packages/supabase/src/queries/index.ts b/packages/supabase/src/queries/index.ts index 991113aee5..62634730f4 100644 --- a/packages/supabase/src/queries/index.ts +++ b/packages/supabase/src/queries/index.ts @@ -1233,3 +1233,15 @@ export async function getCustomersQuery(supabase: Client, teamId: string) { .eq("team_id", teamId) .limit(100); } + +export async function getInvoiceSettingsQuery( + supabase: Client, + teamId: string, +) { + return supabase + .from("team_settings") + .select("*") + .eq("team_id", teamId) + .eq("setting_key", "invoice") + .single(); +} diff --git a/packages/supabase/src/types/db.ts b/packages/supabase/src/types/db.ts new file mode 100644 index 0000000000..37c7656a6d --- /dev/null +++ b/packages/supabase/src/types/db.ts @@ -0,0 +1,2110 @@ +export type Json = + | string + | number + | boolean + | null + | { [key: string]: Json | undefined } + | Json[] + +export type Database = { + public: { + Tables: { + apps: { + Row: { + app_id: string + config: Json | null + created_at: string | null + created_by: string | null + id: string + settings: Json | null + team_id: string | null + } + Insert: { + app_id: string + config?: Json | null + created_at?: string | null + created_by?: string | null + id?: string + settings?: Json | null + team_id?: string | null + } + Update: { + app_id?: string + config?: Json | null + created_at?: string | null + created_by?: string | null + id?: string + settings?: Json | null + team_id?: string | null + } + Relationships: [ + { + foreignKeyName: "apps_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "users" + referencedColumns: ["id"] + }, + { + foreignKeyName: "integrations_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + ] + } + bank_accounts: { + Row: { + account_id: string + balance: number | null + bank_connection_id: string | null + base_balance: number | null + base_currency: string | null + created_at: string + created_by: string + currency: string | null + enabled: boolean + id: string + manual: boolean | null + name: string | null + team_id: string + type: Database["public"]["Enums"]["account_type"] | null + } + Insert: { + account_id: string + balance?: number | null + bank_connection_id?: string | null + base_balance?: number | null + base_currency?: string | null + created_at?: string + created_by: string + currency?: string | null + enabled?: boolean + id?: string + manual?: boolean | null + name?: string | null + team_id: string + type?: Database["public"]["Enums"]["account_type"] | null + } + Update: { + account_id?: string + balance?: number | null + bank_connection_id?: string | null + base_balance?: number | null + base_currency?: string | null + created_at?: string + created_by?: string + currency?: string | null + enabled?: boolean + id?: string + manual?: boolean | null + name?: string | null + team_id?: string + type?: Database["public"]["Enums"]["account_type"] | null + } + Relationships: [ + { + 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: "public_bank_accounts_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + ] + } + bank_connections: { + Row: { + access_token: string | null + created_at: string + enrollment_id: string | null + error_details: string | null + expires_at: string | null + id: string + institution_id: string + last_accessed: string | null + logo_url: string | null + name: string + provider: Database["public"]["Enums"]["bank_providers"] | null + reference_id: string | null + status: Database["public"]["Enums"]["connection_status"] | null + team_id: string + } + Insert: { + access_token?: string | null + created_at?: string + enrollment_id?: string | null + error_details?: string | null + expires_at?: string | null + id?: string + institution_id: string + last_accessed?: string | null + logo_url?: string | null + name: string + provider?: Database["public"]["Enums"]["bank_providers"] | null + reference_id?: string | null + status?: Database["public"]["Enums"]["connection_status"] | null + team_id: string + } + Update: { + access_token?: string | null + created_at?: string + enrollment_id?: string | null + error_details?: string | null + expires_at?: string | null + id?: string + institution_id?: string + last_accessed?: string | null + logo_url?: string | null + name?: string + provider?: Database["public"]["Enums"]["bank_providers"] | null + reference_id?: string | null + status?: Database["public"]["Enums"]["connection_status"] | null + team_id?: string + } + Relationships: [ + { + foreignKeyName: "bank_connections_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + ] + } + customers: { + Row: { + address_line_1: string | null + address_line_2: string | null + city: string | null + country: string | null + created_at: string + email: string | null + id: string + name: string | null + note: string | null + state: string | null + team_id: string + website: string | null + zip: string | null + } + Insert: { + address_line_1?: string | null + address_line_2?: string | null + city?: string | null + country?: string | null + created_at?: string + email?: string | null + id?: string + name?: string | null + note?: string | null + state?: string | null + team_id?: string + website?: string | null + zip?: string | null + } + Update: { + address_line_1?: string | null + address_line_2?: string | null + city?: string | null + country?: string | null + created_at?: string + email?: string | null + id?: string + name?: string | null + note?: string | null + state?: string | null + team_id?: string + website?: string | null + zip?: string | null + } + Relationships: [ + { + foreignKeyName: "customers_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + ] + } + documents: { + Row: { + body: string | null + created_at: string | null + fts: unknown | null + id: string + metadata: Json | null + name: string | null + object_id: string | null + owner_id: string | null + parent_id: string | null + path_tokens: string[] | null + tag: string | null + team_id: string | null + title: string | null + } + Insert: { + body?: string | null + created_at?: string | null + fts?: unknown | null + id?: string + metadata?: Json | null + name?: string | null + object_id?: string | null + owner_id?: string | null + parent_id?: string | null + path_tokens?: string[] | null + tag?: string | null + team_id?: string | null + title?: string | null + } + Update: { + body?: string | null + created_at?: string | null + fts?: unknown | null + id?: string + metadata?: Json | null + name?: string | null + object_id?: string | null + owner_id?: string | null + parent_id?: string | null + path_tokens?: string[] | null + tag?: string | null + team_id?: string | null + title?: string | null + } + Relationships: [ + { + foreignKeyName: "documents_created_by_fkey" + columns: ["owner_id"] + isOneToOne: false + referencedRelation: "users" + referencedColumns: ["id"] + }, + { + foreignKeyName: "storage_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + ] + } + exchange_rates: { + Row: { + base: string | null + id: string + rate: number | null + target: string | null + updated_at: string | null + } + Insert: { + base?: string | null + id?: string + rate?: number | null + target?: string | null + updated_at?: string | null + } + Update: { + base?: string | null + id?: string + rate?: number | null + target?: string | null + updated_at?: string | null + } + Relationships: [] + } + inbox: { + Row: { + amount: number | null + attachment_id: string | null + base_amount: number | null + base_currency: string | null + content_type: string | null + created_at: string + currency: string | null + date: string | null + description: string | null + display_name: string | null + file_name: string | null + file_path: string[] | null + forwarded_to: string | null + fts: unknown | null + id: string + meta: Json | null + reference_id: string | null + size: number | null + status: Database["public"]["Enums"]["inbox_status"] | null + team_id: string | null + transaction_id: string | null + type: Database["public"]["Enums"]["inbox_type"] | null + website: string | null + inbox_amount_text: string | null + } + Insert: { + amount?: number | null + attachment_id?: string | null + base_amount?: number | null + base_currency?: string | null + content_type?: string | null + created_at?: string + currency?: string | null + date?: string | null + description?: string | null + display_name?: string | null + file_name?: string | null + file_path?: string[] | null + forwarded_to?: string | null + fts?: unknown | null + id?: string + meta?: Json | null + reference_id?: string | null + size?: number | null + status?: Database["public"]["Enums"]["inbox_status"] | null + team_id?: string | null + transaction_id?: string | null + type?: Database["public"]["Enums"]["inbox_type"] | null + website?: string | null + } + Update: { + amount?: number | null + attachment_id?: string | null + base_amount?: number | null + base_currency?: string | null + content_type?: string | null + created_at?: string + currency?: string | null + date?: string | null + description?: string | null + display_name?: string | null + file_name?: string | null + file_path?: string[] | null + forwarded_to?: string | null + fts?: unknown | null + id?: string + meta?: Json | null + reference_id?: string | null + size?: number | null + status?: Database["public"]["Enums"]["inbox_status"] | null + team_id?: string | null + transaction_id?: string | null + type?: Database["public"]["Enums"]["inbox_type"] | null + website?: string | null + } + Relationships: [ + { + foreignKeyName: "inbox_attachment_id_fkey" + columns: ["attachment_id"] + isOneToOne: false + referencedRelation: "transaction_attachments" + referencedColumns: ["id"] + }, + { + foreignKeyName: "public_inbox_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + { + foreignKeyName: "public_inbox_transaction_id_fkey" + columns: ["transaction_id"] + isOneToOne: false + referencedRelation: "transactions" + referencedColumns: ["id"] + }, + ] + } + invoices: { + Row: { + amount: number | null + company_datails: Json | null + created_at: string + currency: string | null + customer_datails: Json | null + customer_id: string | null + due_date: string | null + fts: unknown | null + id: string + internal_note: string | null + invoice_date: string | null + invoice_number: string | null + line_items: Json | null + note: string | null + paid_at: string | null + path_tokens: string[] | null + payment_datails: Json | null + status: Database["public"]["Enums"]["invoice_status"] + tax: number | null + team_id: string + updated_at: string | null + url: string | null + vat: number | null + } + Insert: { + amount?: number | null + company_datails?: Json | null + created_at?: string + currency?: string | null + customer_datails?: Json | null + customer_id?: string | null + due_date?: string | null + fts?: unknown | null + id?: string + internal_note?: string | null + invoice_date?: string | null + invoice_number?: string | null + line_items?: Json | null + note?: string | null + paid_at?: string | null + path_tokens?: string[] | null + payment_datails?: Json | null + status?: Database["public"]["Enums"]["invoice_status"] + tax?: number | null + team_id: string + updated_at?: string | null + url?: string | null + vat?: number | null + } + Update: { + amount?: number | null + company_datails?: Json | null + created_at?: string + currency?: string | null + customer_datails?: Json | null + customer_id?: string | null + due_date?: string | null + fts?: unknown | null + id?: string + internal_note?: string | null + invoice_date?: string | null + invoice_number?: string | null + line_items?: Json | null + note?: string | null + paid_at?: string | null + path_tokens?: string[] | null + payment_datails?: Json | null + status?: Database["public"]["Enums"]["invoice_status"] + tax?: number | null + team_id?: string + updated_at?: string | null + url?: string | null + vat?: number | null + } + Relationships: [ + { + foreignKeyName: "invoices_customer_id_fkey" + columns: ["customer_id"] + isOneToOne: false + referencedRelation: "customers" + referencedColumns: ["id"] + }, + { + foreignKeyName: "invoices_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + ] + } + reports: { + Row: { + created_at: string + created_by: string | null + currency: string | null + expire_at: string | null + from: string | null + id: string + link_id: string | null + short_link: string | null + team_id: string | null + to: string | null + type: Database["public"]["Enums"]["reportTypes"] | null + } + Insert: { + created_at?: string + created_by?: string | null + currency?: string | null + expire_at?: string | null + from?: string | null + id?: string + link_id?: string | null + short_link?: string | null + team_id?: string | null + to?: string | null + type?: Database["public"]["Enums"]["reportTypes"] | null + } + Update: { + created_at?: string + created_by?: string | null + currency?: string | null + expire_at?: string | null + from?: string | null + id?: string + link_id?: string | null + short_link?: string | null + team_id?: string | null + to?: string | null + type?: Database["public"]["Enums"]["reportTypes"] | null + } + Relationships: [ + { + foreignKeyName: "public_reports_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "users" + referencedColumns: ["id"] + }, + { + foreignKeyName: "reports_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + ] + } + team_settings: { + Row: { + created_at: string + id: string + setting_key: string + setting_value: Json + team_id: string + } + Insert: { + created_at?: string + id?: string + setting_key: string + setting_value: Json + team_id: string + } + Update: { + created_at?: string + id?: string + setting_key?: string + setting_value?: Json + team_id?: string + } + Relationships: [ + { + foreignKeyName: "team_settings_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + ] + } + teams: { + Row: { + base_currency: string | null + created_at: string + document_classification: boolean | null + email: string | null + id: string + inbox_email: string | null + inbox_forwarding: boolean | null + inbox_id: string | null + logo_url: string | null + name: string | null + } + Insert: { + base_currency?: string | null + created_at?: string + document_classification?: boolean | null + email?: string | null + id?: string + inbox_email?: string | null + inbox_forwarding?: boolean | null + inbox_id?: string | null + logo_url?: string | null + name?: string | null + } + Update: { + base_currency?: string | null + created_at?: string + document_classification?: boolean | null + email?: string | null + id?: string + inbox_email?: string | null + inbox_forwarding?: boolean | null + inbox_id?: string | null + logo_url?: string | null + name?: string | null + } + Relationships: [] + } + tracker_entries: { + Row: { + assigned_id: string | null + billed: boolean | null + created_at: string + currency: string | null + date: string | null + description: string | null + duration: number | null + id: string + project_id: string | null + rate: number | null + start: string | null + stop: string | null + team_id: string | null + project_members: Record | null + } + Insert: { + assigned_id?: string | null + billed?: boolean | null + created_at?: string + currency?: string | null + date?: string | null + description?: string | null + duration?: number | null + id?: string + project_id?: string | null + rate?: number | null + start?: string | null + stop?: string | null + team_id?: string | null + } + Update: { + assigned_id?: string | null + billed?: boolean | null + created_at?: string + currency?: string | null + date?: string | null + description?: string | null + duration?: number | null + id?: string + project_id?: string | null + rate?: number | null + start?: string | null + stop?: string | null + team_id?: string | null + } + Relationships: [ + { + foreignKeyName: "tracker_entries_assigned_id_fkey" + columns: ["assigned_id"] + isOneToOne: false + referencedRelation: "users" + referencedColumns: ["id"] + }, + { + foreignKeyName: "tracker_entries_project_id_fkey" + columns: ["project_id"] + isOneToOne: false + referencedRelation: "tracker_projects" + referencedColumns: ["id"] + }, + { + foreignKeyName: "tracker_entries_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + ] + } + tracker_projects: { + Row: { + billable: boolean | null + created_at: string + currency: string | null + description: string | null + estimate: number | null + id: string + name: string + rate: number | null + status: Database["public"]["Enums"]["trackerStatus"] + team_id: string | null + get_assigned_users_for_project: Json | null + get_project_total_amount: number | null + project_members: Record | null + total_duration: number | null + } + Insert: { + billable?: boolean | null + created_at?: string + currency?: string | null + description?: string | null + estimate?: number | null + id?: string + name: string + rate?: number | null + status?: Database["public"]["Enums"]["trackerStatus"] + team_id?: string | null + } + Update: { + billable?: boolean | null + created_at?: string + currency?: string | null + description?: string | null + estimate?: number | null + id?: string + name?: string + rate?: number | null + status?: Database["public"]["Enums"]["trackerStatus"] + team_id?: string | null + } + Relationships: [ + { + foreignKeyName: "tracker_projects_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + ] + } + tracker_reports: { + Row: { + created_at: string + created_by: string | null + id: string + link_id: string | null + project_id: string | null + short_link: string | null + team_id: string | null + } + Insert: { + created_at?: string + created_by?: string | null + id?: string + link_id?: string | null + project_id?: string | null + short_link?: string | null + team_id?: string | null + } + Update: { + created_at?: string + created_by?: string | null + id?: string + link_id?: string | null + project_id?: string | null + short_link?: string | null + team_id?: string | null + } + Relationships: [ + { + foreignKeyName: "public_tracker_reports_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "users" + referencedColumns: ["id"] + }, + { + foreignKeyName: "public_tracker_reports_project_id_fkey" + columns: ["project_id"] + isOneToOne: false + referencedRelation: "tracker_projects" + referencedColumns: ["id"] + }, + { + foreignKeyName: "tracker_reports_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + ] + } + transaction_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 + } + 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 + } + 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 + } + Relationships: [ + { + foreignKeyName: "public_transaction_attachments_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + { + foreignKeyName: "public_transaction_attachments_transaction_id_fkey" + columns: ["transaction_id"] + isOneToOne: false + referencedRelation: "transactions" + referencedColumns: ["id"] + }, + ] + } + transaction_categories: { + Row: { + color: string | null + created_at: string | null + description: string | null + embedding: string | null + id: string + name: string + slug: string + system: boolean | null + team_id: string + vat: number | null + } + Insert: { + color?: string | null + created_at?: string | null + description?: string | null + embedding?: string | null + id?: string + name: string + slug: string + system?: boolean | null + team_id?: string + vat?: number | null + } + Update: { + color?: string | null + created_at?: string | null + description?: string | null + embedding?: string | null + id?: string + name?: string + slug?: string + system?: boolean | null + team_id?: string + vat?: number | null + } + Relationships: [ + { + foreignKeyName: "transaction_categories_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + ] + } + transaction_enrichments: { + Row: { + category_slug: string | null + created_at: string + id: string + name: string | null + system: boolean | null + team_id: string | null + } + Insert: { + category_slug?: string | null + created_at?: string + id?: string + name?: string | null + system?: boolean | null + team_id?: string | null + } + Update: { + category_slug?: string | null + created_at?: string + id?: string + name?: string | null + system?: boolean | null + team_id?: string | null + } + Relationships: [ + { + foreignKeyName: "transaction_enrichments_category_slug_team_id_fkey" + columns: ["category_slug", "team_id"] + isOneToOne: false + referencedRelation: "transaction_categories" + referencedColumns: ["slug", "team_id"] + }, + { + foreignKeyName: "transaction_enrichments_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + ] + } + transactions: { + Row: { + amount: number + assigned_id: string | null + balance: number | null + bank_account_id: string | null + base_amount: number | null + base_currency: string | null + category: Database["public"]["Enums"]["transactionCategories"] | null + category_slug: string | null + created_at: string + currency: string + date: string + description: string | null + frequency: Database["public"]["Enums"]["transaction_frequency"] | null + fts_vector: unknown | null + id: string + internal_id: string + manual: boolean | null + method: Database["public"]["Enums"]["transactionMethods"] + name: string + note: string | null + recurring: boolean | null + status: Database["public"]["Enums"]["transactionStatus"] | null + team_id: string + updated_at: string | null + amount_text: string | null + calculated_vat: number | null + is_fulfilled: boolean | null + } + Insert: { + amount: number + assigned_id?: string | null + balance?: number | null + bank_account_id?: string | null + base_amount?: number | null + base_currency?: string | null + category?: Database["public"]["Enums"]["transactionCategories"] | null + category_slug?: string | null + created_at?: string + currency: string + date: string + description?: string | null + frequency?: + | Database["public"]["Enums"]["transaction_frequency"] + | null + fts_vector?: unknown | null + id?: string + internal_id: string + manual?: boolean | null + method: Database["public"]["Enums"]["transactionMethods"] + name: string + note?: string | null + recurring?: boolean | null + status?: Database["public"]["Enums"]["transactionStatus"] | null + team_id: string + updated_at?: string | null + } + Update: { + amount?: number + assigned_id?: string | null + balance?: number | null + bank_account_id?: string | null + base_amount?: number | null + base_currency?: string | null + category?: Database["public"]["Enums"]["transactionCategories"] | null + category_slug?: string | null + created_at?: string + currency?: string + date?: string + description?: string | null + frequency?: + | Database["public"]["Enums"]["transaction_frequency"] + | null + fts_vector?: unknown | null + id?: string + internal_id?: string + manual?: boolean | null + method?: Database["public"]["Enums"]["transactionMethods"] + name?: string + note?: string | null + recurring?: boolean | null + status?: Database["public"]["Enums"]["transactionStatus"] | null + team_id?: string + updated_at?: string | null + } + Relationships: [ + { + foreignKeyName: "public_transactions_assigned_id_fkey" + columns: ["assigned_id"] + isOneToOne: false + referencedRelation: "users" + referencedColumns: ["id"] + }, + { + foreignKeyName: "public_transactions_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + { + foreignKeyName: "transactions_bank_account_id_fkey" + columns: ["bank_account_id"] + isOneToOne: false + referencedRelation: "bank_accounts" + referencedColumns: ["id"] + }, + { + foreignKeyName: "transactions_category_slug_team_id_fkey" + columns: ["category_slug", "team_id"] + isOneToOne: false + referencedRelation: "transaction_categories" + referencedColumns: ["slug", "team_id"] + }, + ] + } + user_invites: { + Row: { + code: string | null + created_at: string + email: string | null + id: string + invited_by: string | null + role: Database["public"]["Enums"]["teamRoles"] | null + team_id: string | null + } + Insert: { + code?: string | null + created_at?: string + email?: string | null + id?: string + invited_by?: string | null + role?: Database["public"]["Enums"]["teamRoles"] | null + team_id?: string | null + } + Update: { + code?: string | null + created_at?: string + email?: string | null + id?: string + invited_by?: string | null + role?: Database["public"]["Enums"]["teamRoles"] | null + team_id?: string | null + } + Relationships: [ + { + foreignKeyName: "public_user_invites_team_id_fkey" + columns: ["team_id"] + isOneToOne: false + referencedRelation: "teams" + referencedColumns: ["id"] + }, + { + foreignKeyName: "user_invites_invited_by_fkey" + columns: ["invited_by"] + isOneToOne: false + referencedRelation: "users" + 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 + time_format: number | null + timezone: string | null + week_starts_on_monday: boolean | 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 + time_format?: number | null + timezone?: string | null + week_starts_on_monday?: boolean | 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 + time_format?: number | null + timezone?: string | null + week_starts_on_monday?: boolean | null + } + Relationships: [ + { + 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"] + }, + ] + } + users_on_team: { + Row: { + created_at: string | null + id: string + role: Database["public"]["Enums"]["teamRoles"] | null + team_id: string + user_id: string + } + Insert: { + created_at?: string | null + id?: string + role?: Database["public"]["Enums"]["teamRoles"] | null + team_id: string + user_id: string + } + Update: { + created_at?: string | null + 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_user_id_fkey" + columns: ["user_id"] + isOneToOne: false + referencedRelation: "users" + referencedColumns: ["id"] + }, + ] + } + } + Views: { + [_ in never]: never + } + Functions: { + amount_text: { + Args: { + "": unknown + } + Returns: string + } + calculate_amount_similarity: { + Args: { + transaction_currency: string + inbox_currency: string + transaction_amount: number + inbox_amount: number + } + Returns: number + } + calculate_base_amount_score: { + Args: { + transaction_base_currency: string + inbox_base_currency: string + transaction_base_amount: number + inbox_base_amount: number + } + Returns: number + } + calculate_date_proximity_score: { + Args: { + t_date: string + i_date: string + } + Returns: number + } + calculate_date_similarity: { + Args: { + transaction_date: string + inbox_date: string + } + Returns: number + } + calculate_match_score: { + Args: { + t_record: Record + i_record: Record + } + Returns: number + } + calculate_name_similarity_score: { + Args: { + transaction_name: string + inbox_name: string + } + Returns: number + } + calculate_overall_similarity: { + Args: { + transaction_record: Record + inbox_record: Record + } + Returns: number + } + calculate_total_sum: { + Args: { + target_currency: string + } + Returns: number + } + calculate_transaction_differences_v2: { + Args: { + p_team_id: string + } + Returns: { + transaction_group: string + date: string + team_id: string + recurring: boolean + frequency: Database["public"]["Enums"]["transaction_frequency"] + days_diff: number + }[] + } + calculate_transaction_frequency: { + Args: { + p_transaction_group: string + p_team_id: string + p_new_date: string + } + Returns: { + avg_days_between: number + transaction_count: number + is_recurring: boolean + latest_frequency: string + }[] + } + calculated_vat: { + Args: { + "": unknown + } + Returns: number + } + classify_frequency_v2: { + Args: { + p_team_id: string + } + Returns: { + transaction_group: string + team_id: string + transaction_count: number + avg_days_between: number + stddev_days_between: number + frequency: Database["public"]["Enums"]["transaction_frequency"] + }[] + } + create_team: { + Args: { + name: string + } + Returns: string + } + determine_transaction_frequency: + | { + Args: { + p_avg_days_between: number + p_transaction_count: number + } + Returns: string + } + | { + Args: { + p_avg_days_between: number + p_transaction_count: number + p_is_recurring: boolean + p_latest_frequency: string + } + Returns: string + } + extract_product_names: { + Args: { + products_json: Json + } + Returns: string + } + find_matching_inbox_item: { + Args: { + input_transaction_id: string + specific_inbox_id?: string + } + Returns: { + inbox_id: string + transaction_id: string + transaction_name: string + similarity_score: number + file_name: string + }[] + } + generate_hmac: { + Args: { + secret_key: string + message: string + } + Returns: string + } + generate_id: { + Args: { + size: number + } + Returns: string + } + generate_inbox: { + Args: { + size: number + } + Returns: string + } + generate_inbox_fts: + | { + Args: { + display_name: string + products_json: Json + } + Returns: unknown + } + | { + Args: { + display_name_text: string + product_names: string + } + Returns: unknown + } + | { + Args: { + display_name_text: string + product_names: string + amount: number + due_date: string + } + Returns: unknown + } + generate_invoice_sequence: { + Args: { + team_id: string + } + Returns: number + } + get_all_transactions_by_account: { + Args: { + account_id: string + } + Returns: { + amount: number + assigned_id: string | null + balance: number | null + bank_account_id: string | null + base_amount: number | null + base_currency: string | null + category: Database["public"]["Enums"]["transactionCategories"] | null + category_slug: string | null + created_at: string + currency: string + date: string + description: string | null + frequency: Database["public"]["Enums"]["transaction_frequency"] | null + fts_vector: unknown | null + id: string + internal_id: string + manual: boolean | null + method: Database["public"]["Enums"]["transactionMethods"] + name: string + note: string | null + recurring: boolean | null + status: Database["public"]["Enums"]["transactionStatus"] | null + team_id: string + updated_at: string | null + }[] + } + get_assigned_users_for_project: { + Args: { + "": unknown + } + Returns: Json + } + get_bank_account_currencies: { + Args: { + team_id: string + } + Returns: { + currency: string + }[] + } + get_burn_rate: { + Args: { + team_id: string + date_from: string + date_to: string + currency: string + } + Returns: { + date: string + value: number + }[] + } + get_burn_rate_v2: { + Args: { + team_id: string + date_from: string + date_to: string + base_currency?: string + } + Returns: { + date: string + value: number + currency: string + }[] + } + get_burn_rate_v3: { + Args: { + team_id: string + date_from: string + date_to: string + base_currency?: string + } + Returns: { + date: string + value: number + currency: string + }[] + } + get_burn_rate_v4: { + Args: { + team_id: string + date_from: string + date_to: string + base_currency?: string + } + Returns: { + date: string + value: number + currency: string + }[] + } + get_current_burn_rate: { + Args: { + team_id: string + currency: string + } + Returns: number + } + get_current_burn_rate_v2: { + Args: { + team_id: string + base_currency?: string + } + Returns: { + currency: string + value: number + }[] + } + get_current_burn_rate_v3: { + Args: { + team_id: string + base_currency?: string + } + Returns: { + currency: string + value: number + }[] + } + get_current_user_team_id: { + Args: Record + Returns: string + } + get_expenses: { + Args: { + team_id: string + date_from: string + date_to: string + base_currency?: string + } + Returns: { + date: string + value: number + recurring_value: number + currency: string + }[] + } + get_invoice_summary: { + Args: { + team_id: string + status?: Database["public"]["Enums"]["invoice_status"] + } + Returns: { + total_amount: number + currency: string + invoice_count: number + }[] + } + get_payment_score: { + Args: { + team_id: string + } + Returns: { + score: number + payment_status: string + }[] + } + get_profit: { + Args: { + team_id: string + date_from: string + date_to: string + currency: string + } + Returns: { + date: string + value: number + }[] + } + get_profit_v2: { + Args: { + team_id: string + date_from: string + date_to: string + base_currency?: string + } + Returns: { + date: string + value: number + currency: string + }[] + } + get_profit_v3: { + Args: { + team_id: string + date_from: string + date_to: string + base_currency?: string + } + Returns: { + date: string + value: number + currency: string + }[] + } + get_profit_v4: { + Args: { + team_id: string + date_from: string + date_to: string + base_currency?: string + } + Returns: { + date: string + value: number + currency: string + }[] + } + get_project_total_amount: { + Args: { + "": unknown + } + Returns: number + } + get_revenue: { + Args: { + team_id: string + date_from: string + date_to: string + currency: string + } + Returns: { + date: string + value: number + }[] + } + get_revenue_v2: { + Args: { + team_id: string + date_from: string + date_to: string + base_currency?: string + } + Returns: { + date: string + value: number + currency: string + }[] + } + get_revenue_v3: { + Args: { + team_id: string + date_from: string + date_to: string + base_currency?: string + } + Returns: { + date: string + value: number + currency: string + }[] + } + get_runway: { + Args: { + team_id: string + date_from: string + date_to: string + currency: string + } + Returns: number + } + get_runway_v2: { + Args: { + team_id: string + date_from: string + date_to: string + base_currency?: string + } + Returns: number + } + get_runway_v3: { + Args: { + team_id: string + date_from: string + date_to: string + base_currency?: string + } + Returns: number + } + get_runway_v4: { + Args: { + team_id: string + date_from: string + date_to: string + base_currency?: string + } + Returns: number + } + get_spending: { + Args: { + team_id: string + date_from: string + date_to: string + currency_target: string + } + Returns: { + name: string + slug: string + amount: number + currency: string + color: string + percentage: number + }[] + } + get_spending_v2: { + Args: { + team_id: string + date_from: string + date_to: string + base_currency?: string + } + Returns: { + name: string + slug: string + amount: number + currency: string + color: string + percentage: number + }[] + } + get_spending_v3: { + Args: { + team_id: string + date_from: string + date_to: string + base_currency?: string + } + Returns: { + name: string + slug: string + amount: number + currency: string + color: string + percentage: number + }[] + } + get_total_balance: { + Args: { + team_id: string + currency: string + } + Returns: number + } + get_total_balance_v2: { + Args: { + team_id: string + currency: string + } + Returns: number + } + get_total_balance_v3: { + Args: { + team_id: string + currency: string + } + Returns: number + } + group_transactions_v2: { + Args: { + p_team_id: string + } + Returns: { + transaction_group: string + date: string + team_id: string + recurring: boolean + frequency: Database["public"]["Enums"]["transaction_frequency"] + }[] + } + gtrgm_compress: { + Args: { + "": unknown + } + Returns: unknown + } + gtrgm_decompress: { + Args: { + "": unknown + } + Returns: unknown + } + gtrgm_in: { + Args: { + "": unknown + } + Returns: unknown + } + gtrgm_options: { + Args: { + "": unknown + } + Returns: undefined + } + gtrgm_out: { + Args: { + "": unknown + } + Returns: unknown + } + identify_similar_transactions_v2: { + Args: { + p_team_id: string + } + Returns: { + original_transaction_name: string + similar_transaction_name: string + team_id: string + }[] + } + identify_transaction_group: { + Args: { + p_name: string + p_team_id: string + } + Returns: string + } + inbox_amount_text: { + Args: { + "": unknown + } + Returns: string + } + is_fulfilled: { + Args: { + "": unknown + } + Returns: boolean + } + match_transaction_with_inbox: { + Args: { + p_transaction_id: string + p_inbox_id?: string + } + Returns: { + inbox_id: string + transaction_id: string + transaction_name: string + score: number + file_name: string + }[] + } + nanoid: { + Args: { + size?: number + alphabet?: string + additionalbytesfactor?: number + } + Returns: string + } + nanoid_optimized: { + Args: { + size: number + alphabet: string + mask: number + step: number + } + Returns: string + } + project_members: + | { + Args: { + "": unknown + } + Returns: { + id: string + avatar_url: string + full_name: string + }[] + } + | { + Args: { + "": unknown + } + Returns: { + id: string + avatar_url: string + full_name: string + }[] + } + set_limit: { + Args: { + "": number + } + Returns: number + } + show_limit: { + Args: Record + Returns: number + } + show_trgm: { + Args: { + "": string + } + Returns: string[] + } + slugify: { + Args: { + value: string + } + Returns: string + } + total_duration: { + Args: { + "": unknown + } + Returns: number + } + unaccent: { + Args: { + "": string + } + Returns: string + } + unaccent_init: { + Args: { + "": unknown + } + Returns: unknown + } + update_team_setting: { + Args: { + team_id: string + setting_key: string + setting_path: string[] + new_value: Json + create_missing?: boolean + } + Returns: { + created_at: string + id: string + setting_key: string + setting_value: Json + team_id: string + }[] + } + } + Enums: { + account_type: + | "depository" + | "credit" + | "other_asset" + | "loan" + | "other_liability" + bank_providers: "gocardless" | "plaid" | "teller" + bankProviders: "gocardless" | "plaid" | "teller" + connection_status: "disconnected" | "connected" | "unknown" + inbox_status: "processing" | "pending" | "archived" | "new" | "deleted" + inbox_type: "invoice" | "expense" + invoice_status: "draft" | "overdue" | "paid" | "unpaid" | "canceled" + reportTypes: "profit" | "revenue" | "burn_rate" | "expense" + teamRoles: "owner" | "member" + trackerStatus: "in_progress" | "completed" + transaction_frequency: + | "weekly" + | "biweekly" + | "monthly" + | "semi_monthly" + | "annually" + | "irregular" + | "unknown" + transactionCategories: + | "travel" + | "office_supplies" + | "meals" + | "software" + | "rent" + | "income" + | "equipment" + | "transfer" + | "internet_and_telephone" + | "facilities_expenses" + | "activity" + | "uncategorized" + | "taxes" + | "other" + | "salary" + | "fees" + transactionMethods: + | "payment" + | "card_purchase" + | "card_atm" + | "transfer" + | "other" + | "unknown" + | "ach" + | "interest" + | "deposit" + | "wire" + | "fee" + transactionStatus: "posted" | "pending" | "excluded" | "completed" + } + CompositeTypes: { + metrics_record: { + date: string | null + value: number | null + } + } + } +} + +type PublicSchema = Database[Extract] + +export type Tables< + PublicTableNameOrOptions extends + | keyof (PublicSchema["Tables"] & PublicSchema["Views"]) + | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } + ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] & + Database[PublicTableNameOrOptions["schema"]]["Views"]) + : never = never, +> = PublicTableNameOrOptions extends { schema: keyof Database } + ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] & + Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends { + Row: infer R + } + ? R + : never + : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] & + PublicSchema["Views"]) + ? (PublicSchema["Tables"] & + PublicSchema["Views"])[PublicTableNameOrOptions] extends { + Row: infer R + } + ? R + : never + : never + +export type TablesInsert< + PublicTableNameOrOptions extends + | keyof PublicSchema["Tables"] + | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } + ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] + : never = never, +> = PublicTableNameOrOptions extends { schema: keyof Database } + ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { + Insert: infer I + } + ? I + : never + : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] + ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { + Insert: infer I + } + ? I + : never + : never + +export type TablesUpdate< + PublicTableNameOrOptions extends + | keyof PublicSchema["Tables"] + | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } + ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] + : never = never, +> = PublicTableNameOrOptions extends { schema: keyof Database } + ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { + Update: infer U + } + ? U + : never + : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] + ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { + Update: infer U + } + ? U + : never + : never + +export type Enums< + PublicEnumNameOrOptions extends + | keyof PublicSchema["Enums"] + | { schema: keyof Database }, + EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database } + ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"] + : never = never, +> = PublicEnumNameOrOptions extends { schema: keyof Database } + ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName] + : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"] + ? PublicSchema["Enums"][PublicEnumNameOrOptions] + : never