Skip to content

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

feat: add assignee to contractor table

Brad Barbin0238399baba7
diff --git a/apps/carbon/app/components/Combobox.tsx b/apps/carbon/app/components/Combobox.tsx
index 6058dc57a4..a58ded35ce 100644
--- a/apps/carbon/app/components/Combobox.tsx
+++ b/apps/carbon/app/components/Combobox.tsx
@@ -64,7 +64,7 @@ const Combobox = forwardRef<HTMLButtonElement, ComboboxProps>(
{value ? (
options.find((option) => option.value === value)?.label
) : (
- <span className="text-muted-foreground">
+ <span className="!text-muted-foreground">
{placeholder ?? "Select"}
</span>
)}
diff --git a/apps/carbon/app/components/CreateableCombobox.tsx b/apps/carbon/app/components/CreateableCombobox.tsx
index 2afd41c8be..f28b50d5bb 100644
--- a/apps/carbon/app/components/CreateableCombobox.tsx
+++ b/apps/carbon/app/components/CreateableCombobox.tsx
@@ -71,9 +71,13 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
{...props}
onClick={() => setOpen(true)}
>
- {value
- ? options.find((option) => option.value === value)?.label
- : placeholder ?? "Select"}
+ {value ? (
+ options.find((option) => option.value === value)?.label
+ ) : (
+ <span className="!text-muted-foreground">
+ {placeholder ?? "Select"}
+ </span>
+ )}
</CommandTrigger>
</PopoverTrigger>
<PopoverContent className="min-w-[200px] w-[--radix-popover-trigger-width] p-0">
diff --git a/apps/carbon/app/components/EmployeeAvatar.tsx b/apps/carbon/app/components/EmployeeAvatar.tsx
new file mode 100644
index 0000000000..f4d8c1492a
--- /dev/null
+++ b/apps/carbon/app/components/EmployeeAvatar.tsx
@@ -0,0 +1,36 @@
+import { HStack } from "@carbon/react";
+import { usePeople } from "~/stores";
+import Avatar from "./Avatar";
+
+const EmployeeAvatar = ({ employeeId }: { employeeId: string | null }) => {
+ const [people] = usePeople();
+ if (!employeeId) return null;
+
+ const person = people.find((p) => p.id === employeeId);
+
+ if (!person && people.length > 0) {
+ return (
+ <HStack>
+ <Avatar size="sm" />
+ <span className="text-muted-foreground">Deactivated user</span>
+ </HStack>
+ );
+ }
+
+ if (!person) {
+ return null;
+ }
+
+ return (
+ <HStack>
+ <Avatar
+ size="sm"
+ src={person.avatarUrl ?? undefined}
+ name={person?.name ?? ""}
+ />
+ <span>{person.name}</span>
+ </HStack>
+ );
+};
+
+export default EmployeeAvatar;
diff --git a/apps/carbon/app/components/Form/Employee.tsx b/apps/carbon/app/components/Form/Employee.tsx
index f13b847691..07fa6b184c 100644
--- a/apps/carbon/app/components/Form/Employee.tsx
+++ b/apps/carbon/app/components/Form/Employee.tsx
@@ -3,19 +3,26 @@ import { usePeople } from "~/stores";
import type { ComboboxProps } from "./Combobox";
import CreatableCombobox from "./CreatableCombobox";
-type EmployeeSelectProps = Omit<ComboboxProps, "options"> & {};
+type EmployeeSelectProps = Omit<ComboboxProps, "options" | "type"> & {
+ type?: "assignee";
+};
-const Employee = (props: EmployeeSelectProps) => {
+const Employee = ({ type, ...props }: EmployeeSelectProps) => {
const [people] = usePeople();
- const options = useMemo(
- () =>
+ const options = useMemo(() => {
+ const base =
people.map((part) => ({
value: part.id,
label: part.name,
- })) ?? [],
- [people]
- );
+ })) ?? [];
+
+ if (type === "assignee") {
+ return [{ value: "", label: "Unassigned" }, ...base];
+ }
+
+ return base;
+ }, [type, people]);
return (
<>
@@ -23,6 +30,7 @@ const Employee = (props: EmployeeSelectProps) => {
options={options}
{...props}
label={props?.label ?? "Employee"}
+ placeholder={props?.placeholder ?? "Select Employee"}
/>
</>
);
diff --git a/apps/carbon/app/components/SupplierAvatar.tsx b/apps/carbon/app/components/SupplierAvatar.tsx
new file mode 100644
index 0000000000..d64a0cbef0
--- /dev/null
+++ b/apps/carbon/app/components/SupplierAvatar.tsx
@@ -0,0 +1,22 @@
+import { HStack } from "@carbon/react";
+import { useSuppliers } from "~/stores";
+import Avatar from "./Avatar";
+
+const SupplierAvatar = ({ supplierId }: { supplierId: string | null }) => {
+ const [suppliers] = useSuppliers();
+ if (!supplierId) return null;
+
+ const supplier = suppliers.find((s) => s.id === supplierId) ?? {
+ name: "",
+ id: "",
+ };
+
+ return (
+ <HStack>
+ <Avatar size="sm" name={supplier?.name ?? ""} />
+ <span>{supplier.name}</span>
+ </HStack>
+ );
+};
+
+export default SupplierAvatar;
diff --git a/apps/carbon/app/components/Table/components/Filter/ActiveFilters.tsx b/apps/carbon/app/components/Table/components/Filter/ActiveFilters.tsx
index d56e69308f..81b65d2588 100644
--- a/apps/carbon/app/components/Table/components/Filter/ActiveFilters.tsx
+++ b/apps/carbon/app/components/Table/components/Filter/ActiveFilters.tsx
@@ -65,6 +65,13 @@ const ActiveFilter = ({ filter, operator, value }: ActiveFilterProps) => {
const [options, setOptions] = useState(
filter.filter.type === "static" ? filter.filter.options : []
);
+
+ useEffect(() => {
+ if (filter.filter.type === "static") {
+ setOptions(filter.filter.options);
+ }
+ }, [filter.filter]);
+
useEffect(() => {
if (!open) {
setInput("");
@@ -111,6 +118,8 @@ const ActiveFilter = ({ filter, operator, value }: ActiveFilterProps) => {
}
};
+ console.log({ options });
+
return (
<HStack spacing={0}>
<Button className="rounded-r-none" size="sm" variant="secondary">
diff --git a/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx b/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
index 14505ada12..dfb2e9024a 100644
--- a/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
+++ b/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
@@ -36,8 +36,7 @@ export type PaginationProps = {
const Pagination = (props: PaginationProps) => {
const { pageSize, setPageSize } = props;
- const pageSizes = [15, 25, 50, 100];
- const pageSizeLabel = "results per page";
+ const pageSizes = [100, 500, 1000];
if (!pageSizes.includes(pageSize)) {
pageSizes.push(pageSize);
pageSizes.sort();
@@ -50,9 +49,7 @@ const Pagination = (props: PaginationProps) => {
>
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button variant="ghost">
- {pageSize} {pageSizeLabel}
- </Button>
+ <Button variant="secondary">{pageSize}/page</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" className="w-48">
<DropdownMenuLabel>Results per page</DropdownMenuLabel>
@@ -66,7 +63,7 @@ const Pagination = (props: PaginationProps) => {
setPageSize(size);
}}
>
- {size} {pageSizeLabel}
+ {size}
</DropdownMenuRadioItem>
))}
</DropdownMenuRadioGroup>
diff --git a/apps/carbon/app/components/Table/components/Pagination/usePagination.tsx b/apps/carbon/app/components/Table/components/Pagination/usePagination.tsx
index fc04a6bc20..e115d09566 100644
--- a/apps/carbon/app/components/Table/components/Pagination/usePagination.tsx
+++ b/apps/carbon/app/components/Table/components/Pagination/usePagination.tsx
@@ -9,7 +9,7 @@ export function usePagination(
setRowSelections: Dispatch<SetStateAction<RowSelectionState>>
) {
const [params, setParams] = useUrlParams();
- const pageSize = parseNumberFromUrlParam(params, "limit", 15);
+ const pageSize = parseNumberFromUrlParam(params, "limit", 100);
const offset = parseNumberFromUrlParam(params, "offset", 0);
const pageIndex = Math.floor(offset / pageSize) + 1;
diff --git a/apps/carbon/app/components/index.ts b/apps/carbon/app/components/index.ts
index 65a3054330..e656dddbfc 100644
--- a/apps/carbon/app/components/index.ts
+++ b/apps/carbon/app/components/index.ts
@@ -4,10 +4,12 @@ import { BreadcrumbItem, BreadcrumbLink, Breadcrumbs } from "./Breadcrumb";
import Combobox from "./Combobox";
import Contact from "./Contact";
import CreatableCombobox from "./CreateableCombobox";
+import EmployeeAvatar from "./EmployeeAvatar";
import Hyperlink from "./Hyperlink";
import MultiSelect from "./MultiSelect";
import New from "./New";
import Select from "./Select";
+import SupplierAvatar from "./SupplierAvatar";
import Table from "./Table";
export {
@@ -19,9 +21,11 @@ export {
Combobox,
Contact,
CreatableCombobox,
+ EmployeeAvatar,
Hyperlink,
MultiSelect,
New,
Select,
+ SupplierAvatar,
Table,
};
diff --git a/apps/carbon/app/modules/resources/resources.models.ts b/apps/carbon/app/modules/resources/resources.models.ts
index 302b0fd400..6f45767327 100644
--- a/apps/carbon/app/modules/resources/resources.models.ts
+++ b/apps/carbon/app/modules/resources/resources.models.ts
@@ -86,6 +86,7 @@ export const contractorValidator = z.object({
abilities: z
.array(z.string().min(20, { message: "Invalid ability" }))
.optional(),
+ assignee: zfd.text(z.string().optional()),
});
export const departmentValidator = z.object({
diff --git a/apps/carbon/app/modules/resources/resources.service.ts b/apps/carbon/app/modules/resources/resources.service.ts
index 332e1b6bb9..3f222b8684 100644
--- a/apps/carbon/app/modules/resources/resources.service.ts
+++ b/apps/carbon/app/modules/resources/resources.service.ts
@@ -288,13 +288,13 @@ export async function getContractors(
if (args?.search) {
query = query.or(
- `supplierName.ilike.%${args.search}%,firstName.ilike.%${args.search}%,lastName.ilike.%${args.search}%`
+ `firstName.ilike.%${args.search}%,lastName.ilike.%${args.search}%`
);
}
if (args) {
query = setGenericQueryFilters(query, args, [
- { column: "supplierName", ascending: true },
+ { column: "lastName", ascending: true },
]);
}
diff --git a/apps/carbon/app/modules/resources/ui/Contractors/ContractorForm.tsx b/apps/carbon/app/modules/resources/ui/Contractors/ContractorForm.tsx
index 3715ee5777..18299f6534 100644
--- a/apps/carbon/app/modules/resources/ui/Contractors/ContractorForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Contractors/ContractorForm.tsx
@@ -18,6 +18,7 @@ import type { z } from "zod";
import {
Abilities,
CustomFormFields,
+ Employee,
Number,
Submit,
Supplier,
@@ -93,6 +94,7 @@ const ContractorForm = ({ initialValues }: ContractorFormProps) => {
minValue={0}
maxValue={10000}
/>
+ <Employee name="assignee" label="Assignee" type="assignee" />
<CustomFormFields table="contractor" />
</VStack>
</DrawerBody>
diff --git a/apps/carbon/app/modules/resources/ui/Contractors/ContractorsTable.tsx b/apps/carbon/app/modules/resources/ui/Contractors/ContractorsTable.tsx
index 1c73f8a312..906bb0dee8 100644
--- a/apps/carbon/app/modules/resources/ui/Contractors/ContractorsTable.tsx
+++ b/apps/carbon/app/modules/resources/ui/Contractors/ContractorsTable.tsx
@@ -4,11 +4,17 @@ import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useMemo } from "react";
import { BsFillPenFill } from "react-icons/bs";
import { IoMdTrash } from "react-icons/io";
-import { Hyperlink, New, Table } from "~/components";
+import {
+ EmployeeAvatar,
+ Hyperlink,
+ New,
+ SupplierAvatar,
+ Table,
+} from "~/components";
import { usePermissions, useUrlParams } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Ability, Contractor } from "~/modules/resources";
-import { useSuppliers } from "~/stores";
+import { usePeople, useSuppliers } from "~/stores";
import { path } from "~/utils/path";
type ContractorsTableProps = {
@@ -22,6 +28,8 @@ const ContractorsTable = memo(
const navigate = useNavigate();
const permissions = usePermissions();
const [params] = useUrlParams();
+
+ const [people] = usePeople();
const [suppliers] = useSuppliers();
const customColumns = useCustomColumns<Contractor>("contractor");
@@ -48,21 +56,16 @@ const ContractorsTable = memo(
),
},
{
- accessorKey: "supplierName",
+ id: "supplierId",
header: "Supplier",
cell: ({ row }) => (
- <HStack>
- <Avatar size="sm" name={row.original.supplierName ?? ""} />
- <Hyperlink to={path.to.supplier(row.original.supplierId!)}>
- {row.original.supplierName}
- </Hyperlink>
- </HStack>
+ <SupplierAvatar supplierId={row.original.supplierId} />
),
meta: {
filter: {
type: "static",
options: suppliers.map((supplier) => ({
- value: supplier.name,
+ value: supplier.id,
label: supplier.name,
})),
},
@@ -70,7 +73,7 @@ const ContractorsTable = memo(
},
{
- accessorKey: "abilityIds",
+ id: "abilityIds",
header: "Abilities",
cell: ({ row }) => {
if (!row.original.abilityIds) {
@@ -107,10 +110,26 @@ const ContractorsTable = memo(
header: "Hours per Week",
cell: (item) => item.getValue(),
},
+ {
+ id: "assignee",
+ header: "Assignee",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.assignee} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ },
+ },
];
return [...defaultColumns, ...customColumns];
- }, [abilities, params, suppliers, customColumns]);
+ }, [suppliers, abilities, people, customColumns, params]);
const renderContextMenu = useCallback(
(row: Contractor) => {
diff --git a/apps/carbon/app/routes/x+/resources+/contractors.$supplierContactId.tsx b/apps/carbon/app/routes/x+/resources+/contractors.$supplierContactId.tsx
index 4356e1869f..9f8e722a97 100644
--- a/apps/carbon/app/routes/x+/resources+/contractors.$supplierContactId.tsx
+++ b/apps/carbon/app/routes/x+/resources+/contractors.$supplierContactId.tsx
@@ -50,13 +50,13 @@ export async function action({ request }: ActionFunctionArgs) {
return validationError(validation.error);
}
- const { id, hoursPerWeek, abilities } = validation.data;
+ const { id, supplierId, ...data } = validation.data;
if (!id) throw notFound("Contractor ID was not found");
const updateContractor = await upsertContractor(client, {
id,
- hoursPerWeek,
- abilities: abilities ?? [],
+ ...data,
+ abilities: data.abilities ?? [],
customFields: setCustomFields(formData),
updatedBy: userId,
});
@@ -85,6 +85,7 @@ export default function ContractorRoute() {
supplierId: contractor.supplierId ?? "",
hoursPerWeek: contractor.hoursPerWeek ?? 0,
abilities: contractor.abilityIds ?? ([] as string[]),
+ assignee: contractor.assignee ?? "",
...getCustomFields(contractor.customFields),
};
diff --git a/apps/carbon/app/routes/x+/resources+/people.tsx b/apps/carbon/app/routes/x+/resources+/people.tsx
index 8a3a9a7a85..29c0abb0e8 100644
--- a/apps/carbon/app/routes/x+/resources+/people.tsx
+++ b/apps/carbon/app/routes/x+/resources+/people.tsx
@@ -40,7 +40,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
]);
if (attributeCategories.error) {
return redirect(
- path.to.resources,
+ path.to.authenticatedRoot,
await flash(
request,
error(attributeCategories.error, "Error loading attribute categories")
@@ -49,7 +49,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
if (employeeTypes.error) {
return redirect(
- path.to.resources,
+ path.to.authenticatedRoot,
await flash(
request,
error(employeeTypes.error, "Error loading employee types")
@@ -58,7 +58,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
if (people.error) {
return redirect(
- path.to.resources,
+ path.to.authenticatedRoot,
await flash(request, error(people.error, "Error loading people"))
);
}
diff --git a/apps/carbon/app/utils/query.ts b/apps/carbon/app/utils/query.ts
index dcdfae6866..2d8db31e93 100644
--- a/apps/carbon/app/utils/query.ts
+++ b/apps/carbon/app/utils/query.ts
@@ -23,7 +23,7 @@ export interface GenericQueryFilters {
export function getGenericQueryFilters(
params: URLSearchParams
): GenericQueryFilters {
- const limit = parseNumberFromUrlParam(params, "limit", 15);
+ const limit = parseNumberFromUrlParam(params, "limit", 100);
const offset = parseNumberFromUrlParam(params, "offset", 0);
const sortParams = params.getAll("sort");
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 57d48fd508..b5192b833a 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -132,6 +132,7 @@ export type Database = {
accountCategoryId: string | null
accountSubcategoryId: string | null
active: boolean
+ assignee: string | null
class: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -152,6 +153,7 @@ export type Database = {
accountCategoryId?: string | null
accountSubcategoryId?: string | null
active?: boolean
+ assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -172,6 +174,7 @@ export type Database = {
accountCategoryId?: string | null
accountSubcategoryId?: string | null
active?: boolean
+ assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -203,6 +206,34 @@ export type Database = {
referencedRelation: "accountCategory"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "account_createdBy_fkey"
columns: ["createdBy"]
@@ -1512,6 +1543,7 @@ export type Database = {
contractor: {
Row: {
active: boolean
+ assignee: string | null
createdAt: string
createdBy: string
customFields: Json | null
@@ -1522,6 +1554,7 @@ export type Database = {
}
Insert: {
active?: boolean
+ assignee?: string | null
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -1532,6 +1565,7 @@ export type Database = {
}
Update: {
active?: boolean
+ assignee?: string | null
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -1541,6 +1575,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "contractor_createdBy_fkey"
columns: ["createdBy"]
@@ -1956,6 +2018,7 @@ export type Database = {
customer: {
Row: {
accountManagerId: string | null
+ assignee: string | null
createdAt: string
createdBy: string | null
customerStatusId: string | null
@@ -1970,6 +2033,7 @@ export type Database = {
}
Insert: {
accountManagerId?: string | null
+ assignee?: string | null
createdAt?: string
createdBy?: string | null
customerStatusId?: string | null
@@ -1984,6 +2048,7 @@ export type Database = {
}
Update: {
accountManagerId?: string | null
+ assignee?: string | null
createdAt?: string
createdBy?: string | null
customerStatusId?: string | null
@@ -2025,6 +2090,34 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "customer_createdBy_fkey"
columns: ["createdBy"]
@@ -4408,6 +4501,7 @@ export type Database = {
active: boolean
approved: boolean
approvedBy: string | null
+ assignee: string | null
blocked: boolean
createdAt: string
createdBy: string
@@ -4429,6 +4523,7 @@ export type Database = {
active?: boolean
approved?: boolean
approvedBy?: string | null
+ assignee?: string | null
blocked?: boolean
createdAt?: string
createdBy: string
@@ -4450,6 +4545,7 @@ export type Database = {
active?: boolean
approved?: boolean
approvedBy?: string | null
+ assignee?: string | null
blocked?: boolean
createdAt?: string
createdBy?: string
@@ -4496,6 +4592,34 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "part_createdBy_fkey"
columns: ["createdBy"]
@@ -5022,6 +5146,7 @@ export type Database = {
Row: {
abilityId: string
active: boolean
+ assignee: string | null
createdAt: string
createdBy: string
customFields: Json | null
@@ -5033,6 +5158,7 @@ export type Database = {
Insert: {
abilityId: string
active?: boolean
+ assignee?: string | null
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -5044,6 +5170,7 @@ export type Database = {
Update: {
abilityId?: string
active?: boolean
+ assignee?: string | null
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -5060,6 +5187,34 @@ export type Database = {
referencedRelation: "ability"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "partner_createdBy_fkey"
columns: ["createdBy"]
@@ -6523,6 +6678,7 @@ export type Database = {
}
purchaseInvoice: {
Row: {
+ assignee: string | null
balance: number
createdAt: string
createdBy: string
@@ -6550,6 +6706,7 @@ export type Database = {
updatedBy: string | null
}
Insert: {
+ assignee?: string | null
balance?: number
createdAt?: string
createdBy: string
@@ -6577,6 +6734,7 @@ export type Database = {
updatedBy?: string | null
}
Update: {
+ assignee?: string | null
balance?: number
createdAt?: string
createdBy?: string
@@ -6604,6 +6762,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "purchaseInvoice_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseInvoice_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseInvoice_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseInvoice_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "purchaseInvoice_createdBy_fkey"
columns: ["createdBy"]
@@ -7196,6 +7382,7 @@ export type Database = {
}
purchaseOrder: {
Row: {
+ assignee: string | null
closedAt: string | null
closedBy: string | null
createdAt: string
@@ -7216,6 +7403,7 @@ export type Database = {
updatedBy: string | null
}
Insert: {
+ assignee?: string | null
closedAt?: string | null
closedBy?: string | null
createdAt?: string
@@ -7236,6 +7424,7 @@ export type Database = {
updatedBy?: string | null
}
Update: {
+ assignee?: string | null
closedAt?: string | null
closedBy?: string | null
createdAt?: string
@@ -7256,6 +7445,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "purchaseOrder_closedBy_fkey"
columns: ["closedBy"]
@@ -8262,6 +8479,7 @@ export type Database = {
}
quote: {
Row: {
+ assignee: string | null
createdAt: string
createdBy: string
customerContactId: string | null
@@ -8283,6 +8501,7 @@ export type Database = {
updatedBy: string | null
}
Insert: {
+ assignee?: string | null
createdAt?: string
createdBy: string
customerContactId?: string | null
@@ -8304,6 +8523,7 @@ export type Database = {
updatedBy?: string | null
}
Update: {
+ assignee?: string | null
createdAt?: string
createdBy?: string
customerContactId?: string | null
@@ -8325,6 +8545,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "quote_createdBy_fkey"
columns: ["createdBy"]
@@ -9286,6 +9534,7 @@ export type Database = {
}
receipt: {
Row: {
+ assignee: string | null
createdAt: string
createdBy: string
customFields: Json | null
@@ -9306,6 +9555,7 @@ export type Database = {
updatedBy: string | null
}
Insert: {
+ assignee?: string | null
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -9326,6 +9576,7 @@ export type Database = {
updatedBy?: string | null
}
Update: {
+ assignee?: string | null
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -9346,6 +9597,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "receipt_createdBy_fkey"
columns: ["createdBy"]
@@ -9643,6 +9922,7 @@ export type Database = {
}
requestForQuote: {
Row: {
+ assignee: string | null
createdAt: string | null
createdBy: string
customFields: Json | null
@@ -9659,6 +9939,7 @@ export type Database = {
updatedBy: string | null
}
Insert: {
+ assignee?: string | null
createdAt?: string | null
createdBy: string
customFields?: Json | null
@@ -9675,6 +9956,7 @@ export type Database = {
updatedBy?: string | null
}
Update: {
+ assignee?: string | null
createdAt?: string | null
createdBy?: string
customFields?: Json | null
@@ -9691,6 +9973,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "requestForQuote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "requestForQuote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "requestForQuote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "requestForQuote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "requestForQuote_createdBy_fkey"
columns: ["createdBy"]
@@ -10395,6 +10705,7 @@ export type Database = {
active: boolean
approved: boolean
approvedBy: string | null
+ assignee: string | null
blocked: boolean
createdAt: string
createdBy: string
@@ -10413,6 +10724,7 @@ export type Database = {
active?: boolean
approved?: boolean
approvedBy?: string | null
+ assignee?: string | null
blocked?: boolean
createdAt?: string
createdBy: string
@@ -10431,6 +10743,7 @@ export type Database = {
active?: boolean
approved?: boolean
approvedBy?: string | null
+ assignee?: string | null
blocked?: boolean
createdAt?: string
createdBy?: string
@@ -10474,6 +10787,34 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "service_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "service_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "service_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "service_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "service_createdBy_fkey"
columns: ["createdBy"]
@@ -11149,6 +11490,7 @@ export type Database = {
supplier: {
Row: {
accountManagerId: string | null
+ assignee: string | null
createdAt: string
createdBy: string | null
customFields: Json | null
@@ -11163,6 +11505,7 @@ export type Database = {
}
Insert: {
accountManagerId?: string | null
+ assignee?: string | null
createdAt?: string
createdBy?: string | null
customFields?: Json | null
@@ -11177,6 +11520,7 @@ export type Database = {
}
Update: {
accountManagerId?: string | null
+ assignee?: string | null
createdAt?: string
createdBy?: string | null
customFields?: Json | null
@@ -11218,6 +11562,34 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "supplier_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplier_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplier_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplier_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "supplier_createdBy_fkey"
columns: ["createdBy"]
@@ -13104,6 +13476,7 @@ export type Database = {
accountSubCategory: string | null
accountSubcategoryId: string | null
active: boolean | null
+ assignee: string | null
class: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -13126,6 +13499,7 @@ export type Database = {
accountSubCategory?: never
accountSubcategoryId?: string | null
active?: boolean | null
+ assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -13148,6 +13522,7 @@ export type Database = {
accountSubCategory?: never
accountSubcategoryId?: string | null
active?: boolean | null
+ assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -13179,6 +13554,34 @@ export type Database = {
referencedRelation: "accountCategories"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "account_createdBy_fkey"
columns: ["createdBy"]
@@ -13241,6 +13644,7 @@ export type Database = {
Row: {
abilityIds: string[] | null
active: boolean | null
+ assignee: string | null
customFields: Json | null
email: string | null
firstName: string | null
@@ -13248,9 +13652,36 @@ export type Database = {
lastName: string | null
supplierContactId: string | null
supplierId: string | null
- supplierName: string | null
}
Relationships: [
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "contractor_id_fkey"
columns: ["supplierContactId"]
@@ -13543,6 +13974,7 @@ export type Database = {
abilityId: string | null
abilityName: string | null
active: boolean | null
+ assignee: string | null
city: string | null
createdAt: string | null
createdBy: string | null
@@ -13564,6 +13996,34 @@ export type Database = {
referencedRelation: "ability"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "partner_createdBy_fkey"
columns: ["createdBy"]
@@ -14125,6 +14585,7 @@ export type Database = {
}
purchaseOrders: {
Row: {
+ assignee: string | null
closedAt: string | null
closedBy: string | null
closedByAvatar: string | null
@@ -14161,6 +14622,34 @@ export type Database = {
updatedByFullName: string | null
}
Relationships: [
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "purchaseOrder_closedBy_fkey"
columns: ["closedBy"]
@@ -14463,6 +14952,7 @@ export type Database = {
}
receipts: {
Row: {
+ assignee: string | null
createdAt: string | null
createdBy: string | null
createdByAvatar: string | null
@@ -14489,6 +14979,34 @@ export type Database = {
updatedByFullName: string | null
}
Relationships: [
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "receipt_createdBy_fkey"
columns: ["createdBy"]
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 57d48fd508..b5192b833a 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -132,6 +132,7 @@ export type Database = {
accountCategoryId: string | null
accountSubcategoryId: string | null
active: boolean
+ assignee: string | null
class: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -152,6 +153,7 @@ export type Database = {
accountCategoryId?: string | null
accountSubcategoryId?: string | null
active?: boolean
+ assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -172,6 +174,7 @@ export type Database = {
accountCategoryId?: string | null
accountSubcategoryId?: string | null
active?: boolean
+ assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -203,6 +206,34 @@ export type Database = {
referencedRelation: "accountCategory"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "account_createdBy_fkey"
columns: ["createdBy"]
@@ -1512,6 +1543,7 @@ export type Database = {
contractor: {
Row: {
active: boolean
+ assignee: string | null
createdAt: string
createdBy: string
customFields: Json | null
@@ -1522,6 +1554,7 @@ export type Database = {
}
Insert: {
active?: boolean
+ assignee?: string | null
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -1532,6 +1565,7 @@ export type Database = {
}
Update: {
active?: boolean
+ assignee?: string | null
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -1541,6 +1575,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "contractor_createdBy_fkey"
columns: ["createdBy"]
@@ -1956,6 +2018,7 @@ export type Database = {
customer: {
Row: {
accountManagerId: string | null
+ assignee: string | null
createdAt: string
createdBy: string | null
customerStatusId: string | null
@@ -1970,6 +2033,7 @@ export type Database = {
}
Insert: {
accountManagerId?: string | null
+ assignee?: string | null
createdAt?: string
createdBy?: string | null
customerStatusId?: string | null
@@ -1984,6 +2048,7 @@ export type Database = {
}
Update: {
accountManagerId?: string | null
+ assignee?: string | null
createdAt?: string
createdBy?: string | null
customerStatusId?: string | null
@@ -2025,6 +2090,34 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "customer_createdBy_fkey"
columns: ["createdBy"]
@@ -4408,6 +4501,7 @@ export type Database = {
active: boolean
approved: boolean
approvedBy: string | null
+ assignee: string | null
blocked: boolean
createdAt: string
createdBy: string
@@ -4429,6 +4523,7 @@ export type Database = {
active?: boolean
approved?: boolean
approvedBy?: string | null
+ assignee?: string | null
blocked?: boolean
createdAt?: string
createdBy: string
@@ -4450,6 +4545,7 @@ export type Database = {
active?: boolean
approved?: boolean
approvedBy?: string | null
+ assignee?: string | null
blocked?: boolean
createdAt?: string
createdBy?: string
@@ -4496,6 +4592,34 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "part_createdBy_fkey"
columns: ["createdBy"]
@@ -5022,6 +5146,7 @@ export type Database = {
Row: {
abilityId: string
active: boolean
+ assignee: string | null
createdAt: string
createdBy: string
customFields: Json | null
@@ -5033,6 +5158,7 @@ export type Database = {
Insert: {
abilityId: string
active?: boolean
+ assignee?: string | null
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -5044,6 +5170,7 @@ export type Database = {
Update: {
abilityId?: string
active?: boolean
+ assignee?: string | null
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -5060,6 +5187,34 @@ export type Database = {
referencedRelation: "ability"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "partner_createdBy_fkey"
columns: ["createdBy"]
@@ -6523,6 +6678,7 @@ export type Database = {
}
purchaseInvoice: {
Row: {
+ assignee: string | null
balance: number
createdAt: string
createdBy: string
@@ -6550,6 +6706,7 @@ export type Database = {
updatedBy: string | null
}
Insert: {
+ assignee?: string | null
balance?: number
createdAt?: string
createdBy: string
@@ -6577,6 +6734,7 @@ export type Database = {
updatedBy?: string | null
}
Update: {
+ assignee?: string | null
balance?: number
createdAt?: string
createdBy?: string
@@ -6604,6 +6762,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "purchaseInvoice_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseInvoice_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseInvoice_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseInvoice_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "purchaseInvoice_createdBy_fkey"
columns: ["createdBy"]
@@ -7196,6 +7382,7 @@ export type Database = {
}
purchaseOrder: {
Row: {
+ assignee: string | null
closedAt: string | null
closedBy: string | null
createdAt: string
@@ -7216,6 +7403,7 @@ export type Database = {
updatedBy: string | null
}
Insert: {
+ assignee?: string | null
closedAt?: string | null
closedBy?: string | null
createdAt?: string
@@ -7236,6 +7424,7 @@ export type Database = {
updatedBy?: string | null
}
Update: {
+ assignee?: string | null
closedAt?: string | null
closedBy?: string | null
createdAt?: string
@@ -7256,6 +7445,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "purchaseOrder_closedBy_fkey"
columns: ["closedBy"]
@@ -8262,6 +8479,7 @@ export type Database = {
}
quote: {
Row: {
+ assignee: string | null
createdAt: string
createdBy: string
customerContactId: string | null
@@ -8283,6 +8501,7 @@ export type Database = {
updatedBy: string | null
}
Insert: {
+ assignee?: string | null
createdAt?: string
createdBy: string
customerContactId?: string | null
@@ -8304,6 +8523,7 @@ export type Database = {
updatedBy?: string | null
}
Update: {
+ assignee?: string | null
createdAt?: string
createdBy?: string
customerContactId?: string | null
@@ -8325,6 +8545,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "quote_createdBy_fkey"
columns: ["createdBy"]
@@ -9286,6 +9534,7 @@ export type Database = {
}
receipt: {
Row: {
+ assignee: string | null
createdAt: string
createdBy: string
customFields: Json | null
@@ -9306,6 +9555,7 @@ export type Database = {
updatedBy: string | null
}
Insert: {
+ assignee?: string | null
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -9326,6 +9576,7 @@ export type Database = {
updatedBy?: string | null
}
Update: {
+ assignee?: string | null
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -9346,6 +9597,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "receipt_createdBy_fkey"
columns: ["createdBy"]
@@ -9643,6 +9922,7 @@ export type Database = {
}
requestForQuote: {
Row: {
+ assignee: string | null
createdAt: string | null
createdBy: string
customFields: Json | null
@@ -9659,6 +9939,7 @@ export type Database = {
updatedBy: string | null
}
Insert: {
+ assignee?: string | null
createdAt?: string | null
createdBy: string
customFields?: Json | null
@@ -9675,6 +9956,7 @@ export type Database = {
updatedBy?: string | null
}
Update: {
+ assignee?: string | null
createdAt?: string | null
createdBy?: string
customFields?: Json | null
@@ -9691,6 +9973,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "requestForQuote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "requestForQuote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "requestForQuote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "requestForQuote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "requestForQuote_createdBy_fkey"
columns: ["createdBy"]
@@ -10395,6 +10705,7 @@ export type Database = {
active: boolean
approved: boolean
approvedBy: string | null
+ assignee: string | null
blocked: boolean
createdAt: string
createdBy: string
@@ -10413,6 +10724,7 @@ export type Database = {
active?: boolean
approved?: boolean
approvedBy?: string | null
+ assignee?: string | null
blocked?: boolean
createdAt?: string
createdBy: string
@@ -10431,6 +10743,7 @@ export type Database = {
active?: boolean
approved?: boolean
approvedBy?: string | null
+ assignee?: string | null
blocked?: boolean
createdAt?: string
createdBy?: string
@@ -10474,6 +10787,34 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "service_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "service_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "service_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "service_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "service_createdBy_fkey"
columns: ["createdBy"]
@@ -11149,6 +11490,7 @@ export type Database = {
supplier: {
Row: {
accountManagerId: string | null
+ assignee: string | null
createdAt: string
createdBy: string | null
customFields: Json | null
@@ -11163,6 +11505,7 @@ export type Database = {
}
Insert: {
accountManagerId?: string | null
+ assignee?: string | null
createdAt?: string
createdBy?: string | null
customFields?: Json | null
@@ -11177,6 +11520,7 @@ export type Database = {
}
Update: {
accountManagerId?: string | null
+ assignee?: string | null
createdAt?: string
createdBy?: string | null
customFields?: Json | null
@@ -11218,6 +11562,34 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "supplier_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplier_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplier_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplier_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "supplier_createdBy_fkey"
columns: ["createdBy"]
@@ -13104,6 +13476,7 @@ export type Database = {
accountSubCategory: string | null
accountSubcategoryId: string | null
active: boolean | null
+ assignee: string | null
class: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -13126,6 +13499,7 @@ export type Database = {
accountSubCategory?: never
accountSubcategoryId?: string | null
active?: boolean | null
+ assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -13148,6 +13522,7 @@ export type Database = {
accountSubCategory?: never
accountSubcategoryId?: string | null
active?: boolean | null
+ assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -13179,6 +13554,34 @@ export type Database = {
referencedRelation: "accountCategories"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "account_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "account_createdBy_fkey"
columns: ["createdBy"]
@@ -13241,6 +13644,7 @@ export type Database = {
Row: {
abilityIds: string[] | null
active: boolean | null
+ assignee: string | null
customFields: Json | null
email: string | null
firstName: string | null
@@ -13248,9 +13652,36 @@ export type Database = {
lastName: string | null
supplierContactId: string | null
supplierId: string | null
- supplierName: string | null
}
Relationships: [
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "contractor_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "contractor_id_fkey"
columns: ["supplierContactId"]
@@ -13543,6 +13974,7 @@ export type Database = {
abilityId: string | null
abilityName: string | null
active: boolean | null
+ assignee: string | null
city: string | null
createdAt: string | null
createdBy: string | null
@@ -13564,6 +13996,34 @@ export type Database = {
referencedRelation: "ability"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "partner_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "partner_createdBy_fkey"
columns: ["createdBy"]
@@ -14125,6 +14585,7 @@ export type Database = {
}
purchaseOrders: {
Row: {
+ assignee: string | null
closedAt: string | null
closedBy: string | null
closedByAvatar: string | null
@@ -14161,6 +14622,34 @@ export type Database = {
updatedByFullName: string | null
}
Relationships: [
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrder_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "purchaseOrder_closedBy_fkey"
columns: ["closedBy"]
@@ -14463,6 +14952,7 @@ export type Database = {
}
receipts: {
Row: {
+ assignee: string | null
createdAt: string | null
createdBy: string | null
createdByAvatar: string | null
@@ -14489,6 +14979,34 @@ export type Database = {
updatedByFullName: string | null
}
Relationships: [
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "receipt_createdBy_fkey"
columns: ["createdBy"]
diff --git a/packages/database/supabase/migrations/20230704160029_supplier-view.sql b/packages/database/supabase/migrations/20230704160029_supplier-view.sql
index dc719d3043..c4d65c6ab6 100644
--- a/packages/database/supabase/migrations/20230704160029_supplier-view.sql
+++ b/packages/database/supabase/migrations/20230704160029_supplier-view.sql
@@ -27,7 +27,7 @@ CREATE OR REPLACE VIEW "suppliers" AS
GROUP BY "supplierId"
) p ON p."supplierId" = s.id;
- CREATE OR REPLACE VIEW "customers" AS
+CREATE OR REPLACE VIEW "customers" AS
SELECT
c.id,
c.name,
diff --git a/packages/database/supabase/migrations/20240324175747_assignee.sql b/packages/database/supabase/migrations/20240324175747_assignee.sql
new file mode 100644
index 0000000000..6c74fc9a5c
--- /dev/null
+++ b/packages/database/supabase/migrations/20240324175747_assignee.sql
@@ -0,0 +1,401 @@
+ALTER TABLE "account" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+ALTER TABLE "contractor" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+ALTER TABLE "customer" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+ALTER TABLE "part" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+ALTER TABLE "partner" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+ALTER TABLE "purchaseOrder" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+ALTER TABLE "purchaseInvoice" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+ALTER TABLE "quote" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+ALTER TABLE "receipt" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+ALTER TABLE "requestForQuote" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+ALTER TABLE "service" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+ALTER TABLE "supplier" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+
+DROP VIEW "accounts";
+CREATE OR REPLACE VIEW "accounts" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ "account".*,
+ (SELECT "category" FROM "accountCategory" WHERE "accountCategory"."id" = "account"."accountCategoryId") AS "accountCategory",
+ (SELECT "name" FROM "accountSubcategory" WHERE "accountSubcategory"."id" = "account"."accountSubcategoryId") AS "accountSubCategory"
+ FROM "account"
+;
+
+DROP VIEW "contractors";
+CREATE OR REPLACE VIEW "contractors" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ p.id AS "supplierContactId",
+ p."active",
+ p."hoursPerWeek",
+ p."customFields",
+ p."assignee",
+ s.id AS "supplierId",
+ c."firstName",
+ c."lastName",
+ c."email",
+ array_agg(pa."abilityId") AS "abilityIds"
+ FROM "contractor" p
+ INNER JOIN "supplierContact" sc
+ ON sc.id = p.id
+ INNER JOIN "supplier" s
+ ON s.id = sc."supplierId"
+ INNER JOIN "contact" c
+ ON c.id = sc."contactId"
+ LEFT JOIN "contractorAbility" pa
+ ON pa."contractorId" = p.id
+ WHERE p."active" = true
+ GROUP BY p.id, p.active, p."hoursPerWeek", p."customFields", s.id, c.id, s.name, c."firstName", c."lastName", c."email";
+
+-- DROP VIEW "customers";
+-- CREATE OR REPLACE VIEW "customers" AS
+-- SELECT
+-- c.id,
+-- c.name,
+-- c."customerTypeId",
+-- ct.name AS "type",
+-- c."customerStatusId",
+-- cs.name AS "status",
+-- c."customFields"
+-- -- so.count AS "orderCount"
+-- FROM "customer" c
+-- LEFT JOIN "customerType" ct ON ct.id = c."customerTypeId"
+-- LEFT JOIN "customerStatus" cs ON cs.id = c."customerStatusId";
+
+-- DROP VIEW "documents";
+-- CREATE OR REPLACE VIEW "documents" WITH(SECURITY_INVOKER=true) AS
+-- SELECT
+-- d.*,
+-- u."avatarUrl" AS "createdByAvatar",
+-- u."fullName" AS "createdByFullName",
+-- u2."avatarUrl" AS "updatedByAvatar",
+-- u2."fullName" AS "updatedByFullName",
+-- ARRAY(SELECT dl.label FROM "documentLabel" dl WHERE dl."documentId" = d.id AND dl."userId" = auth.uid()::text) AS labels,
+-- EXISTS(SELECT 1 FROM "documentFavorite" df WHERE df."documentId" = d.id AND df."userId" = auth.uid()::text) AS favorite,
+-- (SELECT MAX("createdAt") FROM "documentTransaction" dt WHERE dt."documentId" = d.id) AS "lastActivityAt"
+-- FROM "document" d
+-- LEFT JOIN "user" u ON u.id = d."createdBy"
+-- LEFT JOIN "user" u2 ON u2.id = d."updatedBy";
+
+-- DROP VIEW "partners";
+-- CREATE OR REPLACE VIEW "partners" WITH(SECURITY_INVOKER=true) AS
+-- SELECT
+-- p.*,
+-- p.id AS "supplierLocationId",
+-- a2.name AS "abilityName",
+-- s.id AS "supplierId",
+-- s.name AS "supplierName",
+-- a.city,
+-- a.state
+-- FROM "partner" p
+-- INNER JOIN "supplierLocation" sl
+-- ON sl.id = p.id
+-- INNER JOIN "supplier" s
+-- ON s.id = sl."supplierId"
+-- INNER JOIN "address" a
+-- ON a.id = sl."addressId"
+-- INNER JOIN "ability" a2
+-- ON a2.id = p."abilityId"
+-- WHERE p."active" = true;
+
+-- DROP VIEW "parts";
+-- CREATE OR REPLACE VIEW "parts" WITH(SECURITY_INVOKER=true) AS
+-- SELECT
+-- p.id,
+-- p.name,
+-- p.description,
+-- p."partType",
+-- p."partGroupId",
+-- pg.name AS "partGroup",
+-- p."replenishmentSystem",
+-- p.active,
+-- p."customFields",
+-- array_agg(ps."supplierId") AS "supplierIds"
+-- FROM "part" p
+-- LEFT JOIN "partGroup" pg ON pg.id = p."partGroupId"
+-- LEFT JOIN "partSupplier" ps ON ps."partId" = p.id
+-- GROUP BY p.id,
+-- p.name,
+-- p.description,
+-- p."partType",
+-- p."partGroupId",
+-- pg.name,
+-- p."replenishmentSystem",
+-- p.active,
+-- p."customFields";
+
+-- DROP VIEW "purchaseOrders";
+-- CREATE OR REPLACE VIEW "purchaseOrders" WITH(SECURITY_INVOKER=true) AS
+-- SELECT
+-- p.*,
+-- sm."name" AS "shippingMethodName",
+-- st."name" AS "shippingTermName",
+-- pt."name" AS "paymentTermName",
+-- pd."receiptRequestedDate",
+-- pd."receiptPromisedDate",
+-- pd."dropShipment",
+-- l."id" AS "locationId",
+-- l."name" AS "locationName",
+-- s."name" AS "supplierName",
+-- u."avatarUrl" AS "createdByAvatar",
+-- u."fullName" AS "createdByFullName",
+-- u2."avatarUrl" AS "updatedByAvatar",
+-- u2."fullName" AS "updatedByFullName",
+-- u3."avatarUrl" AS "closedByAvatar",
+-- u3."fullName" AS "closedByFullName",
+-- EXISTS(SELECT 1 FROM "purchaseOrderFavorite" pf WHERE pf."purchaseOrderId" = p.id AND pf."userId" = auth.uid()::text) AS favorite
+-- FROM "purchaseOrder" p
+-- LEFT JOIN "purchaseOrderDelivery" pd ON pd."id" = p."id"
+-- LEFT JOIN "shippingMethod" sm ON sm."id" = pd."shippingMethodId"
+-- LEFT JOIN "shippingTerm" st ON st."id" = pd."shippingTermId"
+-- LEFT JOIN "purchaseOrderPayment" pp ON pp."id" = p."id"
+-- LEFT JOIN "paymentTerm" pt ON pt."id" = pp."paymentTermId"
+-- LEFT JOIN "location" l ON l."id" = pd."locationId"
+-- LEFT JOIN "supplier" s ON s."id" = p."supplierId"
+-- LEFT JOIN "user" u ON u."id" = p."createdBy"
+-- LEFT JOIN "user" u2 ON u2."id" = p."updatedBy"
+-- LEFT JOIN "user" u3 ON u3."id" = p."closedBy";
+
+-- DROP VIEW "purchaseInvoices";
+-- CREATE OR REPLACE VIEW "purchaseInvoices" WITH(SECURITY_INVOKER=true) AS
+-- SELECT
+-- pi."id",
+-- pi."invoiceId",
+-- pi."supplierId",
+-- pi."supplierReference",
+-- pi."invoiceSupplierId",
+-- pi."invoiceSupplierLocationId",
+-- pi."invoiceSupplierContactId",
+-- pi."postingDate",
+-- pi."dateIssued",
+-- pi."dateDue",
+-- pi."datePaid",
+-- pi."paymentTermId",
+-- pi."currencyCode",
+-- pi."exchangeRate",
+-- pi."subtotal",
+-- pi."totalDiscount",
+-- pi."totalAmount",
+-- pi."totalTax",
+-- pi."balance",
+-- pi."createdBy",
+-- pi."createdAt",
+-- pi."updatedBy",
+-- pi."updatedAt",
+-- pi."customFields",
+-- CASE
+-- WHEN pi."dateDue" < CURRENT_DATE AND pi."status" = 'Submitted' THEN 'Overdue'
+-- ELSE pi."status"
+-- END AS status,
+-- s."name" AS "supplierName",
+-- c."fullName" AS "contactName",
+-- u."avatarUrl" AS "createdByAvatar",
+-- u."fullName" AS "createdByFullName",
+-- u2."avatarUrl" AS "updatedByAvatar",
+-- u2."fullName" AS "updatedByFullName"
+-- FROM "purchaseInvoice" pi
+-- LEFT JOIN "supplier" s ON s.id = pi."supplierId"
+-- LEFT JOIN "supplierContact" sc ON sc.id = pi."invoiceSupplierContactId"
+-- LEFT JOIN "contact" c ON c.id = sc."contactId"
+-- LEFT JOIN "user" u ON u."id" = pi."createdBy"
+-- LEFT JOIN "user" u2 ON u2."id" = pi."updatedBy";
+
+-- DROP VIEW "quotes";
+-- CREATE OR REPLACE VIEW "quotes" WITH(SECURITY_INVOKER=true) AS
+-- SELECT
+-- q."id",
+-- q."quoteId",
+-- q."customerId",
+-- q."customerLocationId",
+-- q."customerContactId",
+-- q."name",
+-- q."status",
+-- q."notes",
+-- q."quoteDate",
+-- q."expirationDate",
+-- q."customerReference",
+-- q."locationId",
+-- q."createdAt",
+-- q."createdBy",
+-- q."ownerId",
+-- q."customFields",
+-- uo."fullName" AS "ownerFullName",
+-- uo."avatarUrl" AS "ownerAvatar",
+-- c."name" AS "customerName",
+-- uc."fullName" AS "createdByFullName",
+-- uc."avatarUrl" AS "createdByAvatar",
+-- uu."fullName" AS "updatedByFullName",
+-- uu."avatarUrl" AS "updatedByAvatar",
+-- l."name" AS "locationName",
+-- array_agg(ql."partId") AS "partIds",
+-- EXISTS(SELECT 1 FROM "quoteFavorite" pf WHERE pf."quoteId" = q.id AND pf."userId" = auth.uid()::text) AS favorite
+-- FROM "quote" q
+-- LEFT JOIN "customer" c
+-- ON c.id = q."customerId"
+-- LEFT JOIN "location" l
+-- ON l.id = q."locationId"
+-- LEFT JOIN "quoteLine" ql
+-- ON ql."quoteId" = q.id
+-- LEFT JOIN "user" uo
+-- ON uo.id = q."ownerId"
+-- LEFT JOIN "user" uc
+-- ON uc.id = q."createdBy"
+-- LEFT JOIN "user" uu
+-- ON uu.id = q."updatedBy"
+-- GROUP BY
+-- q."id",
+-- q."quoteId",
+-- q."customerId",
+-- q."customerLocationId",
+-- q."customerContactId",
+-- q."name",
+-- q."status",
+-- q."notes",
+-- q."quoteDate",
+-- q."expirationDate",
+-- q."customerReference",
+-- q."locationId",
+-- q."createdAt",
+-- q."createdBy",
+-- q."customFields",
+-- c."name",
+-- uo."fullName",
+-- uo."avatarUrl",
+-- uc."fullName",
+-- uc."avatarUrl",
+-- uu."fullName",
+-- uu."avatarUrl",
+-- l."name";
+
+-- DROP VIEW "receipts";
+-- CREATE OR REPLACE VIEW "receipts" WITH(SECURITY_INVOKER=true) AS
+-- SELECT
+-- r.*,
+-- cb."fullName" as "createdByFullName",
+-- cb."avatarUrl" as "createdByAvatar",
+-- ub."fullName" as "updatedByFullName",
+-- ub."avatarUrl" as "updatedByAvatar",
+-- l."name" as "locationName",
+-- s."name" as "supplierName"
+-- FROM "receipt" r
+-- LEFT JOIN "user" cb
+-- ON cb.id = r."createdBy"
+-- LEFT JOIN "user" ub
+-- ON ub.id = r."updatedBy"
+-- LEFT JOIN "location" l
+-- ON l.id = r."locationId"
+-- LEFT JOIN "supplier" s
+-- ON s.id = r."supplierId";
+
+-- DROP VIEW "requestForQuotes";
+-- CREATE OR REPLACE VIEW "requestForQuotes" WITH(SECURITY_INVOKER=true) AS
+-- SELECT
+-- r."id",
+-- r."requestForQuoteId",
+-- r."name",
+-- r."status",
+-- r."notes",
+-- r."receiptDate",
+-- r."expirationDate",
+-- r."locationId",
+-- r."customFields",
+-- r."createdAt",
+-- r."createdBy",
+-- uc."fullName" AS "createdByFullName",
+-- uc."avatarUrl" AS "createdByAvatar",
+-- uu."fullName" AS "updatedByFullName",
+-- uu."avatarUrl" AS "updatedByAvatar",
+-- l."name" AS "locationName",
+-- array_agg(rs."supplierId") AS "supplierIds",
+-- array_agg(rl."partId") AS "partIds",
+-- EXISTS(SELECT 1 FROM "requestForQuoteFavorite" pf WHERE pf."requestForQuoteId" = r.id AND pf."userId" = auth.uid()::text) AS favorite
+-- FROM "requestForQuote" r
+-- LEFT JOIN "location" l
+-- ON l.id = r."locationId"
+-- LEFT JOIN "requestForQuoteSupplier" rs
+-- ON rs."requestForQuoteId" = r.id
+-- LEFT JOIN "requestForQuoteLine" rl
+-- ON rl."requestForQuoteId" = r.id
+-- LEFT JOIN "user" uc
+-- ON uc.id = r."createdBy"
+-- LEFT JOIN "user" uu
+-- ON uu.id = r."updatedBy"
+-- GROUP BY
+-- r."id",
+-- r."requestForQuoteId",
+-- r."name",
+-- r."status",
+-- r."notes",
+-- r."receiptDate",
+-- r."expirationDate",
+-- r."locationId",
+-- r."customFields",
+-- r."createdAt",
+-- r."createdBy",
+-- uc."fullName",
+-- uc."avatarUrl",
+-- uu."fullName",
+-- uu."avatarUrl",
+-- l."name";
+
+-- DROP VIEW "services";
+-- CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS
+-- SELECT
+-- s."id",
+-- s."name",
+-- s."description",
+-- s."blocked",
+-- s."partGroupId",
+-- s."serviceType",
+-- s."active",
+-- s."approved",
+-- s."approvedBy",
+-- s."fromDate",
+-- s."toDate",
+-- s."customFields",
+-- pg.name AS "partGroup",
+-- array_agg(ss."supplierId") AS "supplierIds"
+-- FROM "service" s
+-- LEFT JOIN "partGroup" pg ON pg.id = s."partGroupId"
+-- LEFT JOIN "serviceSupplier" ss ON ss."serviceId" = s.id
+-- GROUP BY
+-- s."id",
+-- s."name",
+-- s."description",
+-- s."blocked",
+-- s."partGroupId",
+-- s."serviceType",
+-- s."active",
+-- s."approved",
+-- s."approvedBy",
+-- s."fromDate",
+-- s."toDate",
+-- s."customFields",
+-- pg.name;
+
+-- CREATE OR REPLACE VIEW "suppliers" AS
+-- SELECT
+-- s.id,
+-- s.name,
+-- s."supplierTypeId",
+-- st.name AS "type",
+-- s."supplierStatusId",
+-- ss.name AS "status",
+-- po.count AS "orderCount",
+-- p.count AS "partCount",
+-- s."customFields"
+-- FROM "supplier" s
+-- LEFT JOIN "supplierType" st ON st.id = s."supplierTypeId"
+-- LEFT JOIN "supplierStatus" ss ON ss.id = s."supplierStatusId"
+-- LEFT JOIN (
+-- SELECT
+-- "supplierId",
+-- COUNT(*) AS "count"
+-- FROM "purchaseOrder"
+-- GROUP BY "supplierId"
+-- ) po ON po."supplierId" = s.id
+-- LEFT JOIN (
+-- SELECT
+-- "supplierId",
+-- COUNT(*) AS "count"
+-- FROM "partSupplier"
+-- GROUP BY "supplierId"
+-- ) p ON p."supplierId" = s.id;
\ No newline at end of file
diff --git a/packages/database/supabase/migrations/20240324185857_employee-realtime.sql b/packages/database/supabase/migrations/20240324185857_employee-realtime.sql
new file mode 100644
index 0000000000..d8c0288825
--- /dev/null
+++ b/packages/database/supabase/migrations/20240324185857_employee-realtime.sql
@@ -0,0 +1 @@
+ALTER publication supabase_realtime ADD TABLE "employee";
\ No newline at end of file
diff --git a/packages/react/src/DataTable/DataTablePagination.tsx b/packages/react/src/DataTable/DataTablePagination.tsx
index 73b0e7b2ef..1530b1b98e 100644
--- a/packages/react/src/DataTable/DataTablePagination.tsx
+++ b/packages/react/src/DataTable/DataTablePagination.tsx
@@ -16,8 +16,7 @@ interface DataTablePaginationProps<TData> {
export function DataTablePagination<TData>({
table,
}: DataTablePaginationProps<TData>) {
- const pageSizes = [15, 25, 50, 100];
- const pageSizeLabel = "results per page";
+ const pageSizes = [100, 500, 1000];
const scrollToTop = () => {
window.scrollTo({ top: 0, behavior: "smooth" });
@@ -30,8 +29,8 @@ export function DataTablePagination<TData>({
>
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button variant="ghost">
- {table.getState().pagination.pageSize} {pageSizeLabel}
+ <Button variant="secondary">
+ {table.getState().pagination.pageSize}/page
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-48">
@@ -42,7 +41,7 @@ export function DataTablePagination<TData>({
table.setPageSize(Number(size));
}}
>
- {size} {pageSizeLabel}
+ {size}
</DropdownMenuItem>
))}
</DropdownMenuContent>