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 crud for demand forecasting

Brad Barbin8e17f2f82ea3
diff --git a/apps/erp/app/components/Form/Procedure.tsx b/apps/erp/app/components/Form/Procedure.tsx
index 6911dd36f4..f55bd0b310 100644
--- a/apps/erp/app/components/Form/Procedure.tsx
+++ b/apps/erp/app/components/Form/Procedure.tsx
@@ -3,7 +3,7 @@ import { Combobox } from "@carbon/form";
import { HStack, useMount } from "@carbon/react";
import { useFetcher } from "@remix-run/react";
import { useMemo } from "react";
-import { getProceduresList } from "~/modules/production/production.service";
+import type { getProceduresList } from "~/modules/production/production.service";
import ProcedureStatus from "~/modules/production/ui/Procedures/ProcedureStatus";
import { path } from "~/utils/path";
diff --git a/apps/erp/app/hooks/useSavedViews.tsx b/apps/erp/app/hooks/useSavedViews.tsx
index abbf417a90..ae587438cc 100644
--- a/apps/erp/app/hooks/useSavedViews.tsx
+++ b/apps/erp/app/hooks/useSavedViews.tsx
@@ -1,7 +1,7 @@
import { useRouteData, useUrlParams } from "@carbon/remix";
import { path } from "~/utils/path";
import type { SavedView } from "~/modules/shared/types";
-import { Route } from "~/types";
+import type { Route } from "~/types";
type SavedViews = SavedView[];
diff --git a/apps/erp/app/modules/inventory/ui/Shipments/ShipmentForm/useShipmentForm.tsx b/apps/erp/app/modules/inventory/ui/Shipments/ShipmentForm/useShipmentForm.tsx
index f76179b0ee..790610a371 100644
--- a/apps/erp/app/modules/inventory/ui/Shipments/ShipmentForm/useShipmentForm.tsx
+++ b/apps/erp/app/modules/inventory/ui/Shipments/ShipmentForm/useShipmentForm.tsx
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useState } from "react";
import { useUser } from "~/hooks";
import type { z } from "zod";
import type { ShipmentSourceDocument } from "~/modules/inventory/types";
-import { shipmentStatusType, shipmentValidator } from "~/modules/inventory";
+import type { shipmentStatusType, shipmentValidator } from "~/modules/inventory";
import type { ListItem } from "~/types";
export default function useShipmentForm({
diff --git a/apps/erp/app/modules/production/production.models.ts b/apps/erp/app/modules/production/production.models.ts
index a0931c6136..8497132877 100644
--- a/apps/erp/app/modules/production/production.models.ts
+++ b/apps/erp/app/modules/production/production.models.ts
@@ -840,3 +840,15 @@ export const scrapReasonValidator = z.object({
id: zfd.text(z.string().optional()),
name: z.string().min(1, { message: "Name is required" }),
});
+
+export const productionProjectionsValidator = z.object({
+ itemId: z.string().min(1, { message: "Item is required" }),
+ locationId: z.string().min(1, { message: "Location is required" }),
+ periods: z.array(z.string()).optional(),
+ ...Object.fromEntries(
+ Array.from({ length: 52 }, (_, i) => [
+ `week${i}`,
+ zfd.numeric(z.number().min(0).optional()),
+ ])
+ ),
+});
diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.ts
index 63b2fd1786..c9184eb6d0 100644
--- a/apps/erp/app/modules/production/production.service.ts
+++ b/apps/erp/app/modules/production/production.service.ts
@@ -772,6 +772,40 @@ export async function getProductionPlanning(
return query;
}
+export async function getProductionProjections(
+ client: SupabaseClient<Database>,
+ locationId: string,
+ periods: string[],
+ companyId: string,
+ args: GenericQueryFilters & {
+ search: string | null;
+ }
+) {
+ let query = client.rpc(
+ "get_production_projections",
+ {
+ location_id: locationId,
+ company_id: companyId,
+ periods,
+ },
+ {
+ count: "exact",
+ }
+ );
+
+ if (args?.search) {
+ query = query.or(
+ `name.ilike.%${args.search}%,readableIdWithRevision.ilike.%${args.search}%`
+ );
+ }
+
+ query = setGenericQueryFilters(query, args, [
+ { column: "readableIdWithRevision", ascending: true },
+ ]);
+
+ return query;
+}
+
export async function getProductionQuantity(
client: SupabaseClient<Database>,
id: string
@@ -1692,3 +1726,102 @@ export async function upsertScrapReason(
.eq("id", scrapReason.id);
}
}
+
+export async function getDemandForecasts(
+ client: SupabaseClient<Database>,
+ params: {
+ itemId: string;
+ locationId: string;
+ companyId: string;
+ periodIds: string[];
+ }
+) {
+ return client
+ .from("demandForecast")
+ .select("*")
+ .eq("itemId", params.itemId)
+ .eq("locationId", params.locationId)
+ .eq("companyId", params.companyId)
+ .in("periodId", params.periodIds);
+}
+
+export async function upsertDemandForecasts(
+ client: SupabaseClient<Database>,
+ forecasts: Array<{
+ itemId: string;
+ locationId: string;
+ periodId: string;
+ forecastQuantity: number;
+ companyId: string;
+ createdBy: string;
+ updatedBy?: string;
+ }>
+) {
+ // Delete existing forecasts with 0 quantity, upsert others
+ const toDelete = forecasts.filter((f) => f.forecastQuantity === 0);
+ const toUpsert = forecasts.filter((f) => f.forecastQuantity > 0);
+
+ const promises = [];
+
+ if (toDelete.length > 0) {
+ for (const forecast of toDelete) {
+ promises.push(
+ client
+ .from("demandForecast")
+ .delete()
+ .eq("itemId", forecast.itemId)
+ .eq("locationId", forecast.locationId)
+ .eq("periodId", forecast.periodId)
+ .eq("companyId", forecast.companyId)
+ );
+ }
+ }
+
+ if (toUpsert.length > 0) {
+ promises.push(
+ client.from("demandForecast").upsert(
+ toUpsert.map((f) => ({
+ ...f,
+ updatedBy: f.updatedBy ?? f.createdBy ?? "system",
+ updatedAt: new Date().toISOString(),
+ })),
+ {
+ onConflict: "itemId,locationId,periodId,companyId",
+ }
+ )
+ );
+ }
+
+ const results = await Promise.all(promises);
+ const hasError = results.some((r) => r.error);
+
+ return {
+ data: hasError ? null : toUpsert,
+ error: hasError ? results.find((r) => r.error)?.error : null,
+ };
+}
+
+export async function deleteFutureDemandForecasts(
+ client: SupabaseClient<Database>,
+ params: {
+ itemId: string;
+ locationId: string;
+ companyId: string;
+ futurePeriodIds: string[];
+ }
+) {
+ const { itemId, locationId, companyId, futurePeriodIds } = params;
+
+ const result = await client
+ .from("demandForecast")
+ .delete()
+ .eq("itemId", itemId)
+ .eq("locationId", locationId)
+ .eq("companyId", companyId)
+ .in("periodId", futurePeriodIds);
+
+ return {
+ data: result.data,
+ error: result.error,
+ };
+}
diff --git a/apps/erp/app/modules/production/types.ts b/apps/erp/app/modules/production/types.ts
index 4344d63b4f..0a3899b53b 100644
--- a/apps/erp/app/modules/production/types.ts
+++ b/apps/erp/app/modules/production/types.ts
@@ -12,6 +12,7 @@ import type {
getProcedures,
getProductionEvents,
getProductionPlanning,
+ getProductionProjections,
getProductionQuantities,
getScrapReasons,
} from "./production.service";
@@ -50,6 +51,10 @@ export type ProductionQuantity = NonNullable<
Awaited<ReturnType<typeof getProductionQuantities>>["data"]
>[number];
+export type ProductionProjection = NonNullable<
+ Awaited<ReturnType<typeof getProductionProjections>>["data"]
+>[number];
+
export type Procedures = NonNullable<
Awaited<ReturnType<typeof getProcedures>>["data"]
>[number];
diff --git a/apps/erp/app/modules/production/ui/Projections/ProductionProjectionsForm.tsx b/apps/erp/app/modules/production/ui/Projections/ProductionProjectionsForm.tsx
new file mode 100644
index 0000000000..575ab7d04e
--- /dev/null
+++ b/apps/erp/app/modules/production/ui/Projections/ProductionProjectionsForm.tsx
@@ -0,0 +1,144 @@
+import { ValidatedForm } from "@carbon/form";
+import {
+ CardDescription,
+ CardTitle,
+ Drawer,
+ DrawerBody,
+ DrawerContent,
+ DrawerFooter,
+ DrawerHeader,
+ HStack,
+ VStack,
+} from "@carbon/react";
+import { getLocalTimeZone, startOfWeek, today } from "@internationalized/date";
+import { useFetcher, useLoaderData } from "@remix-run/react";
+import type { z } from "zod";
+import { Hidden, Item, Location, Number, Submit } from "~/components/Form";
+import { usePermissions } from "~/hooks";
+import { path } from "~/utils/path";
+import { productionProjectionsValidator } from "../../production.models";
+
+type LoaderData = {
+ periods?: Array<{ id: string; name: string }>;
+ initialValues?: z.infer<typeof productionProjectionsValidator>;
+};
+
+type ProductionProjectionsFormProps = {
+ initialValues?: z.infer<typeof productionProjectionsValidator>;
+ isEditing?: boolean;
+ onClose: () => void;
+};
+
+const ProductionProjectionsForm = ({
+ initialValues: propInitialValues,
+ isEditing = false,
+ onClose,
+}: ProductionProjectionsFormProps) => {
+ const permissions = usePermissions();
+ const fetcher = useFetcher<{ id: string }>();
+ const loaderData = useLoaderData<LoaderData>();
+ const periods = loaderData?.periods ?? [];
+ const initialValues = loaderData?.initialValues ??
+ propInitialValues ?? {
+ itemId: "",
+ locationId: "",
+ ...Object.fromEntries(
+ Array.from({ length: 52 }, (_, i) => [`week${i}`, 0])
+ ),
+ };
+
+ const isDisabled = isEditing
+ ? !permissions.can("update", "production")
+ : !permissions.can("create", "production");
+
+ // Generate week labels based on periods
+ const startDate = startOfWeek(today(getLocalTimeZone()), "en-US");
+ const weekLabels = Array.from({ length: 52 }, (_, i) => {
+ const weekDate = startDate.add({ weeks: i });
+ return `Week ${i + 1} (${weekDate.month}/${weekDate.day})`;
+ });
+
+ return (
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose?.();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={productionProjectionsValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.productionProjection(
+ initialValues.itemId!,
+ initialValues.locationId!
+ )
+ : path.to.newProductionProjection
+ }
+ defaultValues={initialValues}
+ fetcher={fetcher}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <CardTitle>
+ {isEditing ? "Edit" : "New"} Production Projection
+ </CardTitle>
+ <CardDescription>
+ Set demand forecast values for each week
+ </CardDescription>
+ </DrawerHeader>
+ <DrawerBody>
+ <div>
+ {/* Hidden fields for periods */}
+ {periods?.map((period, index) => (
+ <Hidden
+ key={period.id}
+ name={`periods[${index}]`}
+ value={period.id}
+ />
+ ))}
+ </div>
+ <VStack spacing={4}>
+ <Item
+ name="itemId"
+ label="Item"
+ type="Part"
+ replenishmentSystem="Make"
+ isReadOnly={isEditing}
+ />
+ <Location
+ name="locationId"
+ label="Location"
+ isReadOnly={isEditing}
+ />
+
+ {weekLabels.map((label, index) => (
+ <Number
+ key={index}
+ name={`week${index}`}
+ label={label}
+ minValue={0}
+ />
+ ))}
+ </VStack>
+ </DrawerBody>
+
+ <DrawerFooter>
+ <HStack className="justify-end">
+ <Submit
+ isLoading={fetcher.state !== "idle"}
+ isDisabled={fetcher.state !== "idle" || isDisabled}
+ >
+ {isEditing ? "Update" : "Create"} Projection
+ </Submit>
+ </HStack>
+ </DrawerFooter>
+ </ValidatedForm>
+ </DrawerContent>
+ </Drawer>
+ );
+};
+
+export default ProductionProjectionsForm;
diff --git a/apps/erp/app/modules/production/ui/Projections/ProductionProjectionsTable.tsx b/apps/erp/app/modules/production/ui/Projections/ProductionProjectionsTable.tsx
new file mode 100644
index 0000000000..a11f6cc7b3
--- /dev/null
+++ b/apps/erp/app/modules/production/ui/Projections/ProductionProjectionsTable.tsx
@@ -0,0 +1,220 @@
+import {
+ Combobox,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuIcon,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ HStack,
+ IconButton,
+ VStack,
+} from "@carbon/react";
+import { useUrlParams } from "@carbon/remix";
+import { getLocalTimeZone, parseDate } from "@internationalized/date";
+import { useDateFormatter, useNumberFormatter } from "@react-aria/i18n";
+import type { ColumnDef } from "@tanstack/react-table";
+import { memo, useMemo, useState } from "react";
+import {
+ LuBookMarked,
+ LuEllipsisVertical,
+ LuPencil,
+ LuTrash2,
+} from "react-icons/lu";
+import { Hyperlink, New, Table } from "~/components";
+
+import { Link } from "@remix-run/react";
+import { useLocations } from "~/components/Form/Location";
+import ItemThumbnail from "~/components/ItemThumbnail";
+import { ConfirmDelete } from "~/components/Modals";
+import { usePermissions } from "~/hooks";
+import { path } from "~/utils/path";
+import type { ProductionProjection } from "../../types";
+
+type ProductionProjectionsTableProps = {
+ data: ProductionProjection[];
+ count: number;
+ locationId: string;
+ periods: { id: string; startDate: string; endDate: string }[];
+};
+
+const defaultColumnPinning = {
+ left: ["readableIdWithRevision"],
+ right: ["actions"],
+};
+
+const ProductionProjectionsTable = memo(
+ ({ data, count, locationId, periods }: ProductionProjectionsTableProps) => {
+ const numberFormatter = useNumberFormatter();
+ const dateFormatter = useDateFormatter({
+ month: "short",
+ day: "numeric",
+ });
+ const [params] = useUrlParams();
+ const permissions = usePermissions();
+ const locations = useLocations();
+ const [selectedItem, setSelectedItem] =
+ useState<ProductionProjection | null>(null);
+
+ const columns = useMemo<ColumnDef<ProductionProjection>[]>(() => {
+ const periodColumns: ColumnDef<ProductionProjection>[] = periods.map(
+ (period, index) => {
+ const isCurrentWeek = index === 0;
+ const weekNumber = index + 1;
+ const weekKey = `week${weekNumber}` as keyof ProductionProjection;
+ const startDate = parseDate(period.startDate).toDate(
+ getLocalTimeZone()
+ );
+ const endDate = parseDate(period.endDate).toDate(getLocalTimeZone());
+
+ return {
+ accessorKey: weekKey,
+ header: () => (
+ <VStack spacing={0}>
+ <div>
+ {isCurrentWeek ? "Present Week" : `Week ${weekNumber}`}
+ </div>
+ <div className="text-xs text-muted-foreground">
+ {dateFormatter.format(startDate)} -{" "}
+ {dateFormatter.format(endDate)}
+ </div>
+ </VStack>
+ ),
+ cell: ({ row }) => {
+ const value = row.getValue<number>(weekKey);
+ if (value === undefined || value === null || value === 0)
+ return "-";
+ return <span>{numberFormatter.format(value)}</span>;
+ },
+ };
+ }
+ );
+
+ return [
+ {
+ accessorKey: "readableIdWithRevision",
+ header: "Part ID",
+ cell: ({ row }) => (
+ <Hyperlink
+ to={path.to.productionProjection(row.original.id!, locationId)}
+ >
+ <HStack className="py-1 cursor-pointer">
+ <ItemThumbnail
+ size="sm"
+ thumbnailPath={row.original.thumbnailPath}
+ // @ts-ignore
+ type={row.original.type}
+ />
+
+ <VStack spacing={0} className="font-medium">
+ {row.original.readableIdWithRevision}
+ <div className="w-full truncate text-muted-foreground text-xs">
+ {row.original.name}
+ </div>
+ </VStack>
+ </HStack>
+ </Hyperlink>
+ ),
+ meta: {
+ icon: <LuBookMarked />,
+ },
+ },
+ ...periodColumns,
+ {
+ id: "actions",
+ header: "",
+ cell: ({ row }) => {
+ const canDelete = permissions.can("delete", "production");
+ if (!canDelete) return null;
+
+ return (
+ <div className="flex justify-end">
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ aria-label="Actions"
+ variant="secondary"
+ icon={<LuEllipsisVertical />}
+ />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem asChild>
+ <Link
+ to={path.to.productionProjection(
+ row.original.id!,
+ locationId
+ )}
+ >
+ <DropdownMenuIcon icon={<LuPencil />} />
+ Edit
+ </Link>
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onSelect={() => setSelectedItem(row.original)}
+ destructive
+ >
+ <DropdownMenuIcon icon={<LuTrash2 />} />
+ Delete
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ );
+ },
+ },
+ ];
+ }, [periods, dateFormatter, numberFormatter, locationId, permissions]);
+
+ return (
+ <>
+ <Table<ProductionProjection>
+ data={data}
+ columns={columns}
+ count={count}
+ defaultColumnPinning={defaultColumnPinning}
+ title="Projections"
+ table="production-planning"
+ withSavedView
+ withSelectableRows
+ withSimpleSorting
+ primaryAction={
+ <div className="flex items-center gap-2">
+ <Combobox
+ asButton
+ size="sm"
+ value={locationId}
+ options={locations}
+ onChange={(selected) => {
+ // hard refresh because initialValues update has no effect otherwise
+ window.location.href = getLocationPath(selected);
+ }}
+ />
+ {permissions.can("create", "production") && (
+ <New label="Part" to={`new?${params.toString()}`} />
+ )}
+ </div>
+ }
+ />
+
+ {selectedItem && (
+ <ConfirmDelete
+ action={path.to.deleteProductionProjections(
+ selectedItem.id!,
+ locationId
+ )}
+ name={`${selectedItem.readableIdWithRevision} forecasts`}
+ text={`Are you sure you want to delete all forecasts for ${selectedItem.readableIdWithRevision}? This action cannot be undone.`}
+ onCancel={() => setSelectedItem(null)}
+ onSubmit={() => setSelectedItem(null)}
+ />
+ )}
+ </>
+ );
+ }
+);
+
+ProductionProjectionsTable.displayName = "ProductionProjectionsTable";
+export default ProductionProjectionsTable;
+
+function getLocationPath(locationId: string) {
+ return `${path.to.productionProjections}?location=${locationId}`;
+}
diff --git a/apps/erp/app/modules/production/ui/Projections/index.ts b/apps/erp/app/modules/production/ui/Projections/index.ts
new file mode 100644
index 0000000000..e4ab2d433f
--- /dev/null
+++ b/apps/erp/app/modules/production/ui/Projections/index.ts
@@ -0,0 +1,4 @@
+import ProductionProjectionsTable from "./ProductionProjectionsTable";
+import ProductionProjectionsForm from "./ProductionProjectionsForm";
+
+export { ProductionProjectionsTable, ProductionProjectionsForm };
diff --git a/apps/erp/app/modules/production/ui/useProductionSubmodules.tsx b/apps/erp/app/modules/production/ui/useProductionSubmodules.tsx
index d606b58450..c36b336b20 100644
--- a/apps/erp/app/modules/production/ui/useProductionSubmodules.tsx
+++ b/apps/erp/app/modules/production/ui/useProductionSubmodules.tsx
@@ -1,4 +1,5 @@
import {
+ LuChartLine,
LuHardHat,
LuListChecks,
LuSquareChartGantt,
@@ -31,6 +32,12 @@ const productionRoutes: AuthenticatedRouteGroup[] = [
icon: <LuSquareChartGantt />,
table: "production-planning",
},
+ {
+ name: "Projections",
+ to: path.to.productionProjections,
+ icon: <LuChartLine />,
+ table: "production-projection",
+ },
{
name: "Schedule",
to: path.to.schedule,
diff --git a/apps/erp/app/routes/x+/production+/projections.$itemId.$locationId.tsx b/apps/erp/app/routes/x+/production+/projections.$itemId.$locationId.tsx
new file mode 100644
index 0000000000..9776e89fb0
--- /dev/null
+++ b/apps/erp/app/routes/x+/production+/projections.$itemId.$locationId.tsx
@@ -0,0 +1,147 @@
+import { assertIsPost, error, success } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { validationError, validator } from "@carbon/form";
+import { getLocalTimeZone, startOfWeek, today } from "@internationalized/date";
+import { useLoaderData, useNavigate } from "@remix-run/react";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
+import { json, redirect } from "@vercel/remix";
+import { productionProjectionsValidator } from "~/modules/production/production.models";
+import {
+ getDemandForecasts,
+ upsertDemandForecasts,
+} from "~/modules/production/production.service";
+import ProductionProjectionsForm from "~/modules/production/ui/Projections/ProductionProjectionsForm";
+import { getPeriods } from "~/modules/shared/shared.service";
+import { path } from "~/utils/path";
+
+const WEEKS_TO_PROJECT = 52;
+
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client, companyId } = await requirePermissions(request, {
+ view: "production",
+ });
+
+ const { itemId, locationId } = params;
+
+ if (!itemId || !locationId) {
+ throw new Error("Item ID and Location ID are required");
+ }
+
+ const startDate = startOfWeek(today(getLocalTimeZone()), "en-US");
+ const endDate = startDate.add({ weeks: WEEKS_TO_PROJECT });
+ const periods = await getPeriods(client, {
+ startDate: startDate.toString(),
+ endDate: endDate.toString(),
+ });
+
+ if (periods.error) {
+ throw new Error("Failed to load periods");
+ }
+
+ // Load existing demand forecasts for this item and location
+ const existingForecasts = await getDemandForecasts(client, {
+ itemId,
+ locationId,
+ companyId,
+ periodIds: periods.data?.map((p) => p.id) ?? [],
+ });
+
+ // Map existing forecasts to week fields
+ const weekValues: Record<string, number> = {};
+ if (existingForecasts.data && periods.data) {
+ periods.data.forEach((period, index) => {
+ const forecast = existingForecasts.data?.find(
+ (f) => f.periodId === period.id
+ );
+ weekValues[`week${index}`] = forecast?.forecastQuantity ?? 0;
+ });
+ }
+
+ const initialValues = {
+ itemId,
+ locationId,
+ ...weekValues,
+ };
+
+ return json({
+ periods: periods.data ?? [],
+ initialValues,
+ });
+}
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, companyId, userId } = await requirePermissions(request, {
+ update: "production",
+ });
+
+ const { itemId: routeItemId, locationId: routeLocationId } = params;
+
+ if (!routeItemId || !routeLocationId) {
+ throw new Error("Item ID and Location ID are required");
+ }
+
+ const formData = await request.formData();
+ const validation = await validator(productionProjectionsValidator).validate(
+ formData
+ );
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const { periods, ...weekData } = validation.data;
+
+ // Extract week values and create/update demand forecast records
+ const demandForecasts = [];
+
+ for (let i = 0; i < 52; i++) {
+ const weekKey = `week${i}` as keyof typeof weekData;
+ const quantity = weekData[weekKey];
+
+ if (periods?.[i]) {
+ // Include all periods, even with 0 quantity (to handle deletions)
+ demandForecasts.push({
+ itemId: routeItemId,
+ locationId: routeLocationId,
+ periodId: periods[i],
+ forecastQuantity: Number(quantity) ?? 0,
+ companyId,
+ createdBy: userId,
+ updatedBy: userId,
+ });
+ }
+ }
+
+ const result = await upsertDemandForecasts(client, demandForecasts);
+
+ if (result.error) {
+ return json(
+ {},
+ await flash(
+ request,
+ error(result.error, "Failed to update demand forecasts")
+ )
+ );
+ }
+
+ return redirect(
+ path.to.productionProjections + `?location=${routeLocationId}`,
+ await flash(request, success("Demand forecasts updated successfully"))
+ );
+}
+
+export default function EditProjectionRoute() {
+ const { initialValues } = useLoaderData<typeof loader>();
+
+ const navigate = useNavigate();
+
+ return (
+ <ProductionProjectionsForm
+ initialValues={initialValues}
+ isEditing
+ onClose={() => navigate(-1)}
+ />
+ );
+}
diff --git a/apps/erp/app/routes/x+/production+/projections.delete.$itemId.$locationId.tsx b/apps/erp/app/routes/x+/production+/projections.delete.$itemId.$locationId.tsx
new file mode 100644
index 0000000000..fb869590ea
--- /dev/null
+++ b/apps/erp/app/routes/x+/production+/projections.delete.$itemId.$locationId.tsx
@@ -0,0 +1,71 @@
+import { assertIsPost, error, success } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { getLocalTimeZone, startOfWeek, today } from "@internationalized/date";
+import type { ActionFunctionArgs } from "@vercel/remix";
+import { json, redirect } from "@vercel/remix";
+import { deleteFutureDemandForecasts } from "~/modules/production/production.service";
+import { getPeriods } from "~/modules/shared/shared.service";
+import { path } from "~/utils/path";
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, companyId } = await requirePermissions(request, {
+ delete: "production",
+ });
+
+ const { itemId, locationId } = params;
+
+ if (!itemId || !locationId) {
+ return json(
+ {},
+ await flash(
+ request,
+ error("Item ID and Location ID are required", "Missing parameters")
+ )
+ );
+ }
+
+ // Get current date to determine future periods
+ const startDate = startOfWeek(today(getLocalTimeZone()), "en-US");
+ const endDate = startDate.add({ weeks: 52 });
+ const periods = await getPeriods(client, {
+ startDate: startDate.toString(),
+ endDate: endDate.toString(),
+ });
+
+ if (periods.error) {
+ return json(
+ {},
+ await flash(
+ request,
+ error(periods.error, "Failed to load periods")
+ )
+ );
+ }
+
+ // Only delete forecasts for future periods (current week and beyond)
+ const futurePeriodIds = periods.data?.map(p => p.id) ?? [];
+
+ const result = await deleteFutureDemandForecasts(client, {
+ itemId,
+ locationId,
+ companyId,
+ futurePeriodIds,
+ });
+
+ if (result.error) {
+ return json(
+ {},
+ await flash(
+ request,
+ error("Failed to delete demand forecasts", "Delete failed")
+ )
+ );
+ }
+
+ return redirect(
+ path.to.productionProjections + `?location=${locationId}`,
+ await flash(request, success("Demand forecasts deleted successfully"))
+ );
+}
\ No newline at end of file
diff --git a/apps/erp/app/routes/x+/production+/projections.delete.$itemId.locationId.tsx b/apps/erp/app/routes/x+/production+/projections.delete.$itemId.locationId.tsx
new file mode 100644
index 0000000000..4d2352b2d9
--- /dev/null
+++ b/apps/erp/app/routes/x+/production+/projections.delete.$itemId.locationId.tsx
@@ -0,0 +1,63 @@
+import { assertIsPost, error, success } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { getLocalTimeZone, startOfWeek, today } from "@internationalized/date";
+import type { ActionFunctionArgs } from "@vercel/remix";
+import { json, redirect } from "@vercel/remix";
+import { deleteFutureDemandForecasts } from "~/modules/production/production.service";
+import { getPeriods } from "~/modules/shared/shared.service";
+import { path } from "~/utils/path";
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, companyId } = await requirePermissions(request, {
+ delete: "production",
+ });
+
+ const { itemId, locationId } = params;
+ if (!itemId || !locationId) {
+ throw new Error("Item ID and Location ID are required");
+ }
+
+ // Get current date to determine future periods
+ const startDate = startOfWeek(today(getLocalTimeZone()), "en-US");
+ const endDate = startDate.add({ weeks: 52 });
+ const periods = await getPeriods(client, {
+ startDate: startDate.toString(),
+ endDate: endDate.toString(),
+ });
+
+ if (periods.error) {
+ return json(
+ {},
+ await flash(request, error(periods.error, "Failed to load periods"))
+ );
+ }
+
+ // Only delete forecasts for future periods (current week and beyond)
+ const futurePeriodIds = periods.data?.map((p) => p.id) ?? [];
+
+ const deleteDemand = await deleteFutureDemandForecasts(client, {
+ itemId,
+ locationId,
+ companyId,
+ futurePeriodIds,
+ });
+
+ if (deleteDemand.error) {
+ return json(
+ {
+ success: false,
+ },
+ await flash(
+ request,
+ error(deleteDemand.error, "Failed to delete demand forecasts")
+ )
+ );
+ }
+
+ return redirect(
+ path.to.productionProjections + `?location=${locationId}`,
+ await flash(request, success("Demand forecasts deleted successfully"))
+ );
+}
diff --git a/apps/erp/app/routes/x+/production+/projections.new.tsx b/apps/erp/app/routes/x+/production+/projections.new.tsx
new file mode 100644
index 0000000000..79750cf548
--- /dev/null
+++ b/apps/erp/app/routes/x+/production+/projections.new.tsx
@@ -0,0 +1,123 @@
+import { assertIsPost, error, success } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { validationError, validator } from "@carbon/form";
+import { useRouteData } from "@carbon/remix";
+import { getLocalTimeZone, startOfWeek, today } from "@internationalized/date";
+import { useNavigate } from "@remix-run/react";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
+import { json, redirect } from "@vercel/remix";
+import { productionProjectionsValidator } from "~/modules/production/production.models";
+import { upsertDemandForecasts } from "~/modules/production/production.service";
+import ProductionProjectionsForm from "~/modules/production/ui/Projections/ProductionProjectionsForm";
+import { getPeriods } from "~/modules/shared/shared.service";
+import { path } from "~/utils/path";
+
+const WEEKS_TO_PROJECT = 52;
+
+export async function loader({ request }: LoaderFunctionArgs) {
+ const { client } = await requirePermissions(request, {
+ create: "production",
+ });
+
+ const startDate = startOfWeek(today(getLocalTimeZone()), "en-US");
+ const endDate = startDate.add({ weeks: WEEKS_TO_PROJECT });
+ const periods = await getPeriods(client, {
+ startDate: startDate.toString(),
+ endDate: endDate.toString(),
+ });
+
+ if (periods.error) {
+ throw new Error("Failed to load periods");
+ }
+
+ return json({ periods: periods.data ?? [] });
+}
+
+export async function action({ request }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, companyId, userId } = await requirePermissions(request, {
+ create: "production",
+ });
+
+ const formData = await request.formData();
+ const validation = await validator(productionProjectionsValidator).validate(
+ formData
+ );
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const { itemId, locationId, periods, ...weekData } = validation.data;
+
+ // Extract week values and create demand forecast records
+ const demandForecasts = [];
+
+ for (let i = 0; i < 52; i++) {
+ const weekKey = `week${i}` as keyof typeof weekData;
+ const quantity = weekData[weekKey];
+
+ if (
+ quantity !== undefined &&
+ quantity !== null &&
+ quantity > 0 &&
+ periods?.[i]
+ ) {
+ demandForecasts.push({
+ itemId,
+ locationId,
+ periodId: periods[i],
+ forecastQuantity: quantity,
+ companyId,
+ createdBy: userId,
+ });
+ }
+ }
+
+ if (demandForecasts.length === 0) {
+ return json(
+ {},
+ await flash(request, error(null, "No forecast quantities provided"))
+ );
+ }
+
+ const result = await upsertDemandForecasts(client, demandForecasts);
+
+ if (result.error) {
+ return json(
+ {},
+ await flash(
+ request,
+ error(result.error, "Failed to save demand forecasts")
+ )
+ );
+ }
+
+ return redirect(
+ path.to.productionProjections + `?location=${locationId}`,
+ await flash(request, success("Demand forecasts created successfully"))
+ );
+}
+
+export default function NewProjectionRoute() {
+ const navigate = useNavigate();
+ const routeData = useRouteData<{
+ locationId: string;
+ }>(path.to.productionProjections);
+
+ const initialValues = {
+ itemId: "",
+ locationId: routeData?.locationId ?? "",
+ ...Object.fromEntries(
+ Array.from({ length: 52 }, (_, i) => [`week${i}`, 0])
+ ),
+ };
+
+ return (
+ <ProductionProjectionsForm
+ onClose={() => navigate(-1)}
+ initialValues={initialValues}
+ />
+ );
+}
diff --git a/apps/erp/app/routes/x+/production+/projections.tsx b/apps/erp/app/routes/x+/production+/projections.tsx
new file mode 100644
index 0000000000..18d1d8537f
--- /dev/null
+++ b/apps/erp/app/routes/x+/production+/projections.tsx
@@ -0,0 +1,130 @@
+import { error } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { VStack } from "@carbon/react";
+import { getLocalTimeZone, startOfWeek, today } from "@internationalized/date";
+import { Outlet, useLoaderData } from "@remix-run/react";
+import type { LoaderFunctionArgs } from "@vercel/remix";
+import { json, redirect } from "@vercel/remix";
+import { getProductionProjections } from "~/modules/production";
+import { ProductionProjectionsTable } from "~/modules/production/ui/Projections";
+import { getLocationsList } from "~/modules/resources";
+import { getPeriods } from "~/modules/shared/shared.service";
+import { getUserDefaults } from "~/modules/users/users.server";
+
+import type { Handle } from "~/utils/handle";
+import { path } from "~/utils/path";
+import { getGenericQueryFilters } from "~/utils/query";
+
+export const handle: Handle = {
+ breadcrumb: "Projections",
+ to: path.to.productionProjections,
+};
+
+export const WEEKS_TO_PROJECT = 12 * 4;
+
+export async function loader({ request }: LoaderFunctionArgs) {
+ const { client, companyId, userId } = await requirePermissions(request, {
+ view: "production",
+ role: "employee",
+ bypassRls: true,
+ });
+
+ const url = new URL(request.url);
+ const searchParams = new URLSearchParams(url.search);
+ const search = searchParams.get("search");
+ const { limit, offset, sorts, filters } =
+ getGenericQueryFilters(searchParams);
+
+ let locationId = searchParams.get("location");
+
+ if (!locationId) {
+ const userDefaults = await getUserDefaults(client, userId, companyId);
+ if (userDefaults.error) {
+ throw redirect(
+ path.to.production,
+ await flash(
+ request,
+ error(userDefaults.error, "Failed to load default location")
+ )
+ );
+ }
+
+ locationId = userDefaults.data?.locationId ?? null;
+ }
+
+ if (!locationId) {
+ const locations = await getLocationsList(client, companyId);
+ if (locations.error || !locations.data?.length) {
+ throw redirect(
+ path.to.inventory,
+ await flash(
+ request,
+ error(locations.error, "Failed to load any locations")
+ )
+ );
+ }
+ locationId = locations.data?.[0].id as string;
+ }
+
+ const startDate = startOfWeek(today(getLocalTimeZone()), "en-US");
+ const endDate = startDate.add({ weeks: WEEKS_TO_PROJECT });
+ const periods = await getPeriods(client, {
+ startDate: startDate.toString(),
+ endDate: endDate.toString(),
+ });
+
+ if (periods.error) {
+ redirect(
+ path.to.authenticatedRoot,
+ await flash(request, error(periods.error, "Failed to load periods"))
+ );
+ }
+
+ const projections = await getProductionProjections(
+ client,
+ locationId,
+ periods.data?.map((p) => p.id) ?? [],
+ companyId,
+ {
+ search,
+ limit,
+ offset,
+ sorts,
+ filters,
+ }
+ );
+
+ if (projections.error) {
+ throw redirect(
+ path.to.production,
+ await flash(
+ request,
+ error(projections.error, "Failed to get production projections")
+ )
+ );
+ }
+
+ return json({
+ projections: projections.data ?? [],
+ count: projections.data?.length ?? 0,
+ locationId,
+ periods: periods.data ?? [],
+ });
+}
+
+export default function ProductionProjectionsRoute() {
+ const { projections, count, locationId, periods } = useLoaderData<typeof loader>();
+
+ return (
+ <VStack spacing={0} className="h-full">
+ <ProductionProjectionsTable
+ data={projections}
+ count={count}
+ locationId={locationId}
+ periods={periods}
+ />
+ <Outlet />
+ </VStack>
+ );
+}
diff --git a/apps/erp/app/routes/x+/settings+/labels.tsx b/apps/erp/app/routes/x+/settings+/labels.tsx
index 9fae803c99..ce6968751f 100644
--- a/apps/erp/app/routes/x+/settings+/labels.tsx
+++ b/apps/erp/app/routes/x+/settings+/labels.tsx
@@ -20,13 +20,12 @@ import { Select, Submit, ValidatedForm, validator } from "@carbon/form";
import { labelSizes } from "@carbon/utils";
import { useFetcher, useLoaderData } from "@remix-run/react";
import { useEffect } from "react";
-import { getCompanySettings } from "~/modules/settings";
-import type { Handle } from "~/utils/handle";
-import { path } from "~/utils/path";
-import {
+import { getCompanySettings ,
productLabelSizeValidator,
updateProductLabelSize,
} from "~/modules/settings";
+import type { Handle } from "~/utils/handle";
+import { path } from "~/utils/path";
export const handle: Handle = {
breadcrumb: "Labels",
to: path.to.labelsSettings,
diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.processes.$id.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.processes.$id.tsx
index 8c9168d7a9..4a1f39e53e 100644
--- a/apps/erp/app/routes/x+/supplier+/$supplierId.processes.$id.tsx
+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.processes.$id.tsx
@@ -2,8 +2,9 @@ import { assertIsPost, error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
+import type {
+ ClientActionFunctionArgs} from "@remix-run/react";
import {
- ClientActionFunctionArgs,
useNavigate,
useParams,
} from "@remix-run/react";
diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.processes.delete.$id.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.processes.delete.$id.tsx
index 55a4121ef6..77c236e404 100644
--- a/apps/erp/app/routes/x+/supplier+/$supplierId.processes.delete.$id.tsx
+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.processes.delete.$id.tsx
@@ -1,8 +1,9 @@
import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
+import type {
+ ClientActionFunctionArgs} from "@remix-run/react";
import {
- ClientActionFunctionArgs,
useNavigate,
useParams,
} from "@remix-run/react";
diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.processes.new.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.processes.new.tsx
index 017ef09610..5057e3ec85 100644
--- a/apps/erp/app/routes/x+/supplier+/$supplierId.processes.new.tsx
+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.processes.new.tsx
@@ -2,8 +2,9 @@ import { assertIsPost, error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
+import type {
+ ClientActionFunctionArgs} from "@remix-run/react";
import {
- ClientActionFunctionArgs,
useNavigate,
useParams,
} from "@remix-run/react";
diff --git a/apps/erp/app/routes/x+/traceability+/_index.tsx b/apps/erp/app/routes/x+/traceability+/_index.tsx
index fa10924bfa..b668d1a8a6 100644
--- a/apps/erp/app/routes/x+/traceability+/_index.tsx
+++ b/apps/erp/app/routes/x+/traceability+/_index.tsx
@@ -1,10 +1,10 @@
import { useCarbon } from "@carbon/auth";
import { Button, cn, toast, useMount } from "@carbon/react";
import { useNavigate } from "@remix-run/react";
-import { ComponentProps, useState } from "react";
-import { forwardRef } from "react";
+import type { ComponentProps} from "react";
+import { useState , forwardRef } from "react";
import { LuBarcode, LuQrCode } from "react-icons/lu";
-import { Handle } from "~/utils/handle";
+import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
export const handle: Handle = {
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index fe2b3758e6..e50f2e9f00 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -566,6 +566,10 @@ export const path = {
generatePath(`${x}/job/methods/event/delete/${id}`),
deleteProductionQuantity: (id: string) =>
generatePath(`${x}/job/methods/quantity/delete/${id}`),
+ deleteProductionProjections: (itemId: string, locationId: string) =>
+ generatePath(
+ `${x}/production/projections/delete/${itemId}/${locationId}`
+ ),
deletePurchaseInvoice: (id: string) =>
generatePath(`${x}/purchase-invoice/${id}/delete`),
deletePurchaseInvoiceLine: (invoiceId: string, lineId: string) =>
@@ -885,6 +889,7 @@ export const path = {
generatePath(`${x}/procedure/${id}/attributes/new`),
newProcedureParameter: (id: string) =>
generatePath(`${x}/procedure/${id}/parameters/new`),
+ newProductionProjection: `${x}/production/projections/new`,
newItemPostingGroup: `${x}/items/groups/new`,
newMaterialDimension: `${x}/items/dimensions/new`,
newMaterialFinish: `${x}/items/finishes/new`,
@@ -1023,6 +1028,10 @@ export const path = {
processes: `${x}/resources/processes`,
production: `${x}/production`,
productionPlanning: `${x}/production/planning`,
+ productionProjection: (itemId: string, locationId: string) =>
+ generatePath(`${x}/production/projections/${itemId}/${locationId}`),
+ productionProjections: `${x}/production/projections`,
+
productionPlanningItem: (itemId: string) =>
generatePath(`${x}/production/planning/${itemId}`),
productionSettings: `${x}/settings/production`,
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index 4e1352a562..5bfa1085d5 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -3115,10 +3115,10 @@ export default {
$ref: "#/parameters/rowFilter.qualityActions.nonConformanceCloseDate",
},
{
- $ref: "#/parameters/rowFilter.qualityActions.nonConformanceItemId",
+ $ref: "#/parameters/rowFilter.qualityActions.nonConformanceTypeName",
},
{
- $ref: "#/parameters/rowFilter.qualityActions.nonConformanceTypeName",
+ $ref: "#/parameters/rowFilter.qualityActions.items",
},
{
$ref: "#/parameters/select",
@@ -9693,6 +9693,129 @@ export default {
tags: ["holidayYears"],
},
},
+ "/issues": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.issues.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.nonConformanceId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.name",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.description",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.source",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.status",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.priority",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.approvalRequirements",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.nonConformanceWorkflowId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.content",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.locationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.nonConformanceTypeId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.openDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.dueDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.closeDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.quantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.assignee",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.customFields",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.tags",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.updatedBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.investigationTypeIds",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.requiredActionIds",
+ },
+ {
+ $ref: "#/parameters/rowFilter.issues.items",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/order",
+ },
+ {
+ $ref: "#/parameters/range",
+ },
+ {
+ $ref: "#/parameters/rangeUnit",
+ },
+ {
+ $ref: "#/parameters/offset",
+ },
+ {
+ $ref: "#/parameters/limit",
+ },
+ {
+ $ref: "#/parameters/preferCount",
+ },
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ schema: {
+ items: {
+ $ref: "#/definitions/issues",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["issues"],
+ },
+ },
"/openPurchaseOrderLines": {
get: {
parameters: [
@@ -31938,185 +32061,32 @@ export default {
tags: ["supplierQuote"],
},
},
- "/configurationRule": {
+ "/nonConformanceItem": {
get: {
parameters: [
{
- $ref: "#/parameters/rowFilter.configurationRule.itemId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationRule.field",
- },
- {
- $ref: "#/parameters/rowFilter.configurationRule.code",
- },
- {
- $ref: "#/parameters/rowFilter.configurationRule.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationRule.updatedAt",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.id",
},
{
- $ref: "#/parameters/rowFilter.configurationRule.updatedBy",
- },
- {
- $ref: "#/parameters/select",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.nonConformanceId",
},
{
- $ref: "#/parameters/order",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.itemId",
},
{
- $ref: "#/parameters/range",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.companyId",
},
{
- $ref: "#/parameters/rangeUnit",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.createdAt",
},
{
- $ref: "#/parameters/offset",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.createdBy",
},
{
- $ref: "#/parameters/limit",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.updatedAt",
},
{
- $ref: "#/parameters/preferCount",
- },
- ],
- responses: {
- "200": {
- description: "OK",
- schema: {
- items: {
- $ref: "#/definitions/configurationRule",
- },
- type: "array",
- },
- },
- "206": {
- description: "Partial Content",
- },
- },
- tags: ["configurationRule"],
- },
- post: {
- parameters: [
- {
- $ref: "#/parameters/body.configurationRule",
- },
- {
- $ref: "#/parameters/select",
- },
- {
- $ref: "#/parameters/preferPost",
- },
- ],
- responses: {
- "201": {
- description: "Created",
- },
- },
- tags: ["configurationRule"],
- },
- delete: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.configurationRule.itemId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationRule.field",
- },
- {
- $ref: "#/parameters/rowFilter.configurationRule.code",
- },
- {
- $ref: "#/parameters/rowFilter.configurationRule.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationRule.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.configurationRule.updatedBy",
- },
- {
- $ref: "#/parameters/preferReturn",
- },
- ],
- responses: {
- "204": {
- description: "No Content",
- },
- },
- tags: ["configurationRule"],
- },
- patch: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.configurationRule.itemId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationRule.field",
- },
- {
- $ref: "#/parameters/rowFilter.configurationRule.code",
- },
- {
- $ref: "#/parameters/rowFilter.configurationRule.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationRule.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.configurationRule.updatedBy",
- },
- {
- $ref: "#/parameters/body.configurationRule",
- },
- {
- $ref: "#/parameters/preferReturn",
- },
- ],
- responses: {
- "204": {
- description: "No Content",
- },
- },
- tags: ["configurationRule"],
- },
- },
- "/nonConformanceReviewer": {
- get: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.id",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.title",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.status",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.nonConformanceId",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.notes",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.assignee",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.createdAt",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.updatedBy",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.updatedBy",
},
{
$ref: "#/parameters/select",
@@ -32145,7 +32115,7 @@ export default {
description: "OK",
schema: {
items: {
- $ref: "#/definitions/nonConformanceReviewer",
+ $ref: "#/definitions/nonConformanceItem",
},
type: "array",
},
@@ -32154,12 +32124,12 @@ export default {
description: "Partial Content",
},
},
- tags: ["nonConformanceReviewer"],
+ tags: ["nonConformanceItem"],
},
post: {
parameters: [
{
- $ref: "#/parameters/body.nonConformanceReviewer",
+ $ref: "#/parameters/body.nonConformanceItem",
},
{
$ref: "#/parameters/select",
@@ -32173,42 +32143,33 @@ export default {
description: "Created",
},
},
- tags: ["nonConformanceReviewer"],
+ tags: ["nonConformanceItem"],
},
delete: {
parameters: [
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.id",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.id",
},
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.title",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.nonConformanceId",
},
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.status",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.itemId",
},
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.nonConformanceId",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.companyId",
},
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.notes",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.createdAt",
},
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.assignee",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.companyId",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.createdBy",
},
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.createdAt",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.updatedAt",
},
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.updatedBy",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.updatedBy",
},
{
$ref: "#/parameters/preferReturn",
@@ -32219,45 +32180,36 @@ export default {
description: "No Content",
},
},
- tags: ["nonConformanceReviewer"],
+ tags: ["nonConformanceItem"],
},
patch: {
parameters: [
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.id",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.title",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.status",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.id",
},
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.nonConformanceId",
- },
- {
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.notes",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.nonConformanceId",
},
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.assignee",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.itemId",
},
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.companyId",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.companyId",
},
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.createdAt",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.createdAt",
},
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.createdBy",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.createdBy",
},
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.updatedAt",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.updatedAt",
},
{
- $ref: "#/parameters/rowFilter.nonConformanceReviewer.updatedBy",
+ $ref: "#/parameters/rowFilter.nonConformanceItem.updatedBy",
},
{
- $ref: "#/parameters/body.nonConformanceReviewer",
+ $ref: "#/parameters/body.nonConformanceItem",
},
{
$ref: "#/parameters/preferReturn",
@@ -32268,23 +32220,29 @@ export default {
description: "No Content",
},
},
- tags: ["nonConformanceReviewer"],
+ tags: ["nonConformanceItem"],
},
},
- "/employee": {
+ "/configurationRule": {
get: {
parameters: [
{
- $ref: "#/parameters/rowFilter.employee.id",
+ $ref: "#/parameters/rowFilter.configurationRule.itemId",
},
{
- $ref: "#/parameters/rowFilter.employee.companyId",
+ $ref: "#/parameters/rowFilter.configurationRule.field",
},
{
- $ref: "#/parameters/rowFilter.employee.employeeTypeId",
+ $ref: "#/parameters/rowFilter.configurationRule.code",
},
{
- $ref: "#/parameters/rowFilter.employee.active",
+ $ref: "#/parameters/rowFilter.configurationRule.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationRule.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationRule.updatedBy",
},
{
$ref: "#/parameters/select",
@@ -32313,7 +32271,7 @@ export default {
description: "OK",
schema: {
items: {
- $ref: "#/definitions/employee",
+ $ref: "#/definitions/configurationRule",
},
type: "array",
},
@@ -32322,12 +32280,12 @@ export default {
description: "Partial Content",
},
},
- tags: ["employee"],
+ tags: ["configurationRule"],
},
post: {
parameters: [
{
- $ref: "#/parameters/body.employee",
+ $ref: "#/parameters/body.configurationRule",
},
{
$ref: "#/parameters/select",
@@ -32341,21 +32299,27 @@ export default {
description: "Created",
},
},
- tags: ["employee"],
+ tags: ["configurationRule"],
},
delete: {
parameters: [
{
- $ref: "#/parameters/rowFilter.employee.id",
+ $ref: "#/parameters/rowFilter.configurationRule.itemId",
},
{
- $ref: "#/parameters/rowFilter.employee.companyId",
+ $ref: "#/parameters/rowFilter.configurationRule.field",
},
{
- $ref: "#/parameters/rowFilter.employee.employeeTypeId",
+ $ref: "#/parameters/rowFilter.configurationRule.code",
},
{
- $ref: "#/parameters/rowFilter.employee.active",
+ $ref: "#/parameters/rowFilter.configurationRule.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationRule.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationRule.updatedBy",
},
{
$ref: "#/parameters/preferReturn",
@@ -32366,24 +32330,30 @@ export default {
description: "No Content",
},
},
- tags: ["employee"],
+ tags: ["configurationRule"],
},
patch: {
parameters: [
{
- $ref: "#/parameters/rowFilter.employee.id",
+ $ref: "#/parameters/rowFilter.configurationRule.itemId",
},
{
- $ref: "#/parameters/rowFilter.employee.companyId",
+ $ref: "#/parameters/rowFilter.configurationRule.field",
},
{
- $ref: "#/parameters/rowFilter.employee.employeeTypeId",
+ $ref: "#/parameters/rowFilter.configurationRule.code",
},
{
- $ref: "#/parameters/rowFilter.employee.active",
+ $ref: "#/parameters/rowFilter.configurationRule.companyId",
},
{
- $ref: "#/parameters/body.employee",
+ $ref: "#/parameters/rowFilter.configurationRule.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationRule.updatedBy",
+ },
+ {
+ $ref: "#/parameters/body.configurationRule",
},
{
$ref: "#/parameters/preferReturn",
@@ -32394,47 +32364,44 @@ export default {
description: "No Content",
},
},
- tags: ["employee"],
+ tags: ["configurationRule"],
},
},
- "/userAttributeValue": {
+ "/nonConformanceReviewer": {
get: {
parameters: [
{
- $ref: "#/parameters/rowFilter.userAttributeValue.id",
- },
- {
- $ref: "#/parameters/rowFilter.userAttributeValue.userAttributeId",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.id",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.userId",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.title",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueBoolean",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.status",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueDate",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.nonConformanceId",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueNumeric",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.notes",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueText",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.assignee",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueUser",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.companyId",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.createdAt",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.createdAt",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.createdBy",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.createdBy",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.updatedAt",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.updatedAt",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.updatedBy",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.updatedBy",
},
{
$ref: "#/parameters/select",
@@ -32463,7 +32430,7 @@ export default {
description: "OK",
schema: {
items: {
- $ref: "#/definitions/userAttributeValue",
+ $ref: "#/definitions/nonConformanceReviewer",
},
type: "array",
},
@@ -32472,12 +32439,12 @@ export default {
description: "Partial Content",
},
},
- tags: ["userAttributeValue"],
+ tags: ["nonConformanceReviewer"],
},
post: {
parameters: [
{
- $ref: "#/parameters/body.userAttributeValue",
+ $ref: "#/parameters/body.nonConformanceReviewer",
},
{
$ref: "#/parameters/select",
@@ -32491,45 +32458,42 @@ export default {
description: "Created",
},
},
- tags: ["userAttributeValue"],
+ tags: ["nonConformanceReviewer"],
},
delete: {
parameters: [
{
- $ref: "#/parameters/rowFilter.userAttributeValue.id",
- },
- {
- $ref: "#/parameters/rowFilter.userAttributeValue.userAttributeId",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.id",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.userId",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.title",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueBoolean",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.status",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueDate",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.nonConformanceId",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueNumeric",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.notes",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueText",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.assignee",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueUser",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.companyId",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.createdAt",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.createdAt",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.createdBy",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.createdBy",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.updatedAt",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.updatedAt",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.updatedBy",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.updatedBy",
},
{
$ref: "#/parameters/preferReturn",
@@ -32540,48 +32504,45 @@ export default {
description: "No Content",
},
},
- tags: ["userAttributeValue"],
+ tags: ["nonConformanceReviewer"],
},
patch: {
parameters: [
{
- $ref: "#/parameters/rowFilter.userAttributeValue.id",
- },
- {
- $ref: "#/parameters/rowFilter.userAttributeValue.userAttributeId",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.id",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.userId",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.title",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueBoolean",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.status",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueDate",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.nonConformanceId",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueNumeric",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.notes",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueText",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.assignee",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.valueUser",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.companyId",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.createdAt",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.createdAt",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.createdBy",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.createdBy",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.updatedAt",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.updatedAt",
},
{
- $ref: "#/parameters/rowFilter.userAttributeValue.updatedBy",
+ $ref: "#/parameters/rowFilter.nonConformanceReviewer.updatedBy",
},
{
- $ref: "#/parameters/body.userAttributeValue",
+ $ref: "#/parameters/body.nonConformanceReviewer",
},
{
$ref: "#/parameters/preferReturn",
@@ -32592,23 +32553,23 @@ export default {
description: "No Content",
},
},
- tags: ["userAttributeValue"],
+ tags: ["nonConformanceReviewer"],
},
},
- "/fiscalYearSettings": {
+ "/employee": {
get: {
parameters: [
{
- $ref: "#/parameters/rowFilter.fiscalYearSettings.companyId",
+ $ref: "#/parameters/rowFilter.employee.id",
},
{
- $ref: "#/parameters/rowFilter.fiscalYearSettings.startMonth",
+ $ref: "#/parameters/rowFilter.employee.companyId",
},
{
- $ref: "#/parameters/rowFilter.fiscalYearSettings.taxStartMonth",
+ $ref: "#/parameters/rowFilter.employee.employeeTypeId",
},
{
- $ref: "#/parameters/rowFilter.fiscalYearSettings.updatedBy",
+ $ref: "#/parameters/rowFilter.employee.active",
},
{
$ref: "#/parameters/select",
@@ -32637,7 +32598,7 @@ export default {
description: "OK",
schema: {
items: {
- $ref: "#/definitions/fiscalYearSettings",
+ $ref: "#/definitions/employee",
},
type: "array",
},
@@ -32646,12 +32607,12 @@ export default {
description: "Partial Content",
},
},
- tags: ["fiscalYearSettings"],
+ tags: ["employee"],
},
post: {
parameters: [
{
- $ref: "#/parameters/body.fiscalYearSettings",
+ $ref: "#/parameters/body.employee",
},
{
$ref: "#/parameters/select",
@@ -32665,21 +32626,21 @@ export default {
description: "Created",
},
},
- tags: ["fiscalYearSettings"],
+ tags: ["employee"],
},
delete: {
parameters: [
{
- $ref: "#/parameters/rowFilter.fiscalYearSettings.companyId",
+ $ref: "#/parameters/rowFilter.employee.id",
},
{
- $ref: "#/parameters/rowFilter.fiscalYearSettings.startMonth",
+ $ref: "#/parameters/rowFilter.employee.companyId",
},
{
- $ref: "#/parameters/rowFilter.fiscalYearSettings.taxStartMonth",
+ $ref: "#/parameters/rowFilter.employee.employeeTypeId",
},
{
- $ref: "#/parameters/rowFilter.fiscalYearSettings.updatedBy",
+ $ref: "#/parameters/rowFilter.employee.active",
},
{
$ref: "#/parameters/preferReturn",
@@ -32690,24 +32651,24 @@ export default {
description: "No Content",
},
},
- tags: ["fiscalYearSettings"],
+ tags: ["employee"],
},
patch: {
parameters: [
{
- $ref: "#/parameters/rowFilter.fiscalYearSettings.companyId",
+ $ref: "#/parameters/rowFilter.employee.id",
},
{
- $ref: "#/parameters/rowFilter.fiscalYearSettings.startMonth",
+ $ref: "#/parameters/rowFilter.employee.companyId",
},
{
- $ref: "#/parameters/rowFilter.fiscalYearSettings.taxStartMonth",
+ $ref: "#/parameters/rowFilter.employee.employeeTypeId",
},
{
- $ref: "#/parameters/rowFilter.fiscalYearSettings.updatedBy",
+ $ref: "#/parameters/rowFilter.employee.active",
},
{
- $ref: "#/parameters/body.fiscalYearSettings",
+ $ref: "#/parameters/body.employee",
},
{
$ref: "#/parameters/preferReturn",
@@ -32718,23 +32679,347 @@ export default {
description: "No Content",
},
},
- tags: ["fiscalYearSettings"],
+ tags: ["employee"],
},
},
- "/purchaseInvoiceStatusHistory": {
+ "/userAttributeValue": {
get: {
parameters: [
{
- $ref: "#/parameters/rowFilter.purchaseInvoiceStatusHistory.id",
+ $ref: "#/parameters/rowFilter.userAttributeValue.id",
},
{
- $ref: "#/parameters/rowFilter.purchaseInvoiceStatusHistory.invoiceId",
+ $ref: "#/parameters/rowFilter.userAttributeValue.userAttributeId",
},
{
- $ref: "#/parameters/rowFilter.purchaseInvoiceStatusHistory.status",
+ $ref: "#/parameters/rowFilter.userAttributeValue.userId",
},
{
- $ref: "#/parameters/rowFilter.purchaseInvoiceStatusHistory.createdAt",
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueBoolean",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueNumeric",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueText",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueUser",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.updatedBy",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/order",
+ },
+ {
+ $ref: "#/parameters/range",
+ },
+ {
+ $ref: "#/parameters/rangeUnit",
+ },
+ {
+ $ref: "#/parameters/offset",
+ },
+ {
+ $ref: "#/parameters/limit",
+ },
+ {
+ $ref: "#/parameters/preferCount",
+ },
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ schema: {
+ items: {
+ $ref: "#/definitions/userAttributeValue",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["userAttributeValue"],
+ },
+ post: {
+ parameters: [
+ {
+ $ref: "#/parameters/body.userAttributeValue",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/preferPost",
+ },
+ ],
+ responses: {
+ "201": {
+ description: "Created",
+ },
+ },
+ tags: ["userAttributeValue"],
+ },
+ delete: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.userAttributeId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.userId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueBoolean",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueNumeric",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueText",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueUser",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.updatedBy",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["userAttributeValue"],
+ },
+ patch: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.userAttributeId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.userId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueBoolean",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueNumeric",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueText",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.valueUser",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.userAttributeValue.updatedBy",
+ },
+ {
+ $ref: "#/parameters/body.userAttributeValue",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["userAttributeValue"],
+ },
+ },
+ "/fiscalYearSettings": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.fiscalYearSettings.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.fiscalYearSettings.startMonth",
+ },
+ {
+ $ref: "#/parameters/rowFilter.fiscalYearSettings.taxStartMonth",
+ },
+ {
+ $ref: "#/parameters/rowFilter.fiscalYearSettings.updatedBy",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/order",
+ },
+ {
+ $ref: "#/parameters/range",
+ },
+ {
+ $ref: "#/parameters/rangeUnit",
+ },
+ {
+ $ref: "#/parameters/offset",
+ },
+ {
+ $ref: "#/parameters/limit",
+ },
+ {
+ $ref: "#/parameters/preferCount",
+ },
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ schema: {
+ items: {
+ $ref: "#/definitions/fiscalYearSettings",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["fiscalYearSettings"],
+ },
+ post: {
+ parameters: [
+ {
+ $ref: "#/parameters/body.fiscalYearSettings",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/preferPost",
+ },
+ ],
+ responses: {
+ "201": {
+ description: "Created",
+ },
+ },
+ tags: ["fiscalYearSettings"],
+ },
+ delete: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.fiscalYearSettings.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.fiscalYearSettings.startMonth",
+ },
+ {
+ $ref: "#/parameters/rowFilter.fiscalYearSettings.taxStartMonth",
+ },
+ {
+ $ref: "#/parameters/rowFilter.fiscalYearSettings.updatedBy",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["fiscalYearSettings"],
+ },
+ patch: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.fiscalYearSettings.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.fiscalYearSettings.startMonth",
+ },
+ {
+ $ref: "#/parameters/rowFilter.fiscalYearSettings.taxStartMonth",
+ },
+ {
+ $ref: "#/parameters/rowFilter.fiscalYearSettings.updatedBy",
+ },
+ {
+ $ref: "#/parameters/body.fiscalYearSettings",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["fiscalYearSettings"],
+ },
+ },
+ "/purchaseInvoiceStatusHistory": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.purchaseInvoiceStatusHistory.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseInvoiceStatusHistory.invoiceId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseInvoiceStatusHistory.status",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseInvoiceStatusHistory.createdAt",
},
{
$ref: "#/parameters/select",
@@ -45138,9 +45423,6 @@ export default {
{
$ref: "#/parameters/rowFilter.nonConformance.quantity",
},
- {
- $ref: "#/parameters/rowFilter.nonConformance.itemId",
- },
{
$ref: "#/parameters/rowFilter.nonConformance.assignee",
},
@@ -45278,9 +45560,6 @@ export default {
{
$ref: "#/parameters/rowFilter.nonConformance.quantity",
},
- {
- $ref: "#/parameters/rowFilter.nonConformance.itemId",
- },
{
$ref: "#/parameters/rowFilter.nonConformance.assignee",
},
@@ -45372,9 +45651,6 @@ export default {
{
$ref: "#/parameters/rowFilter.nonConformance.quantity",
},
- {
- $ref: "#/parameters/rowFilter.nonConformance.itemId",
- },
{
$ref: "#/parameters/rowFilter.nonConformance.assignee",
},
@@ -55948,6 +56224,88 @@ export default {
tags: ["(rpc) update_receipt_line_serial_tracking"],
},
},
+ "/rpc/get_production_projections": {
+ get: {
+ parameters: [
+ {
+ format: "text",
+ in: "query",
+ name: "company_id",
+ required: true,
+ type: "string",
+ },
+ {
+ format: "text",
+ in: "query",
+ name: "location_id",
+ required: true,
+ type: "string",
+ },
+ {
+ format: "text[]",
+ in: "query",
+ name: "periods",
+ required: true,
+ type: "string",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) get_production_projections"],
+ },
+ post: {
+ parameters: [
+ {
+ in: "body",
+ name: "args",
+ required: true,
+ schema: {
+ properties: {
+ company_id: {
+ format: "text",
+ type: "string",
+ },
+ location_id: {
+ format: "text",
+ type: "string",
+ },
+ periods: {
+ format: "text[]",
+ items: {
+ type: "string",
+ },
+ type: "array",
+ },
+ },
+ required: ["company_id", "location_id", "periods"],
+ type: "object",
+ },
+ },
+ {
+ $ref: "#/parameters/preferParams",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) get_production_projections"],
+ },
+ },
"/rpc/get_job_operations_by_work_center": {
get: {
parameters: [
@@ -61028,16 +61386,17 @@ export default {
format: "date",
type: "string",
},
- nonConformanceItemId: {
- description:
- "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
- format: "text",
- type: "string",
- },
nonConformanceTypeName: {
format: "text",
type: "string",
},
+ items: {
+ format: "text[]",
+ items: {
+ type: "string",
+ },
+ type: "array",
+ },
},
type: "object",
},
@@ -64052,6 +64411,150 @@ export default {
},
type: "object",
},
+ issues: {
+ properties: {
+ id: {
+ description: "Note:\nThis is a Primary Key.<pk/>",
+ format: "text",
+ type: "string",
+ },
+ nonConformanceId: {
+ format: "text",
+ type: "string",
+ },
+ name: {
+ format: "text",
+ type: "string",
+ },
+ description: {
+ format: "text",
+ type: "string",
+ },
+ source: {
+ enum: ["Internal", "External"],
+ format: 'public."nonConformanceSource"',
+ type: "string",
+ },
+ status: {
+ enum: ["Registered", "In Progress", "Closed"],
+ format: 'public."nonConformanceStatus"',
+ type: "string",
+ },
+ priority: {
+ enum: ["Low", "Medium", "High", "Critical"],
+ format: 'public."nonConformancePriority"',
+ type: "string",
+ },
+ approvalRequirements: {
+ format: 'public."nonConformanceApproval"[]',
+ items: {
+ type: "string",
+ },
+ type: "array",
+ },
+ nonConformanceWorkflowId: {
+ description:
+ "Note:\nThis is a Foreign Key to `nonConformanceWorkflow.id`.<fk table='nonConformanceWorkflow' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ content: {
+ format: "json",
+ },
+ locationId: {
+ description:
+ "Note:\nThis is a Foreign Key to `location.id`.<fk table='location' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ nonConformanceTypeId: {
+ description:
+ "Note:\nThis is a Foreign Key to `nonConformanceType.id`.<fk table='nonConformanceType' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ openDate: {
+ format: "date",
+ type: "string",
+ },
+ dueDate: {
+ format: "date",
+ type: "string",
+ },
+ closeDate: {
+ format: "date",
+ type: "string",
+ },
+ quantity: {
+ format: "numeric",
+ type: "number",
+ },
+ assignee: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ customFields: {
+ format: "jsonb",
+ },
+ tags: {
+ format: "text[]",
+ items: {
+ type: "string",
+ },
+ type: "array",
+ },
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdAt: {
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ updatedAt: {
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ investigationTypeIds: {
+ format: "text[]",
+ items: {
+ type: "string",
+ },
+ type: "array",
+ },
+ requiredActionIds: {
+ format: "text[]",
+ items: {
+ type: "string",
+ },
+ type: "array",
+ },
+ items: {
+ format: "text[]",
+ items: {
+ type: "string",
+ },
+ type: "array",
+ },
+ },
+ type: "object",
+ },
openPurchaseOrderLines: {
properties: {
id: {
@@ -74352,6 +74855,64 @@ export default {
},
type: "object",
},
+ nonConformanceItem: {
+ required: [
+ "id",
+ "nonConformanceId",
+ "itemId",
+ "companyId",
+ "createdAt",
+ "createdBy",
+ ],
+ properties: {
+ id: {
+ default: "public.xid()",
+ description: "Note:\nThis is a Primary Key.<pk/>",
+ format: "text",
+ type: "string",
+ },
+ nonConformanceId: {
+ description:
+ "Note:\nThis is a Foreign Key to `nonConformance.id`.<fk table='nonConformance' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ itemId: {
+ description:
+ "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdAt: {
+ default: "now()",
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ updatedAt: {
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ },
+ type: "object",
+ },
configurationRule: {
required: ["itemId", "field", "code", "companyId", "updatedAt"],
properties: {
@@ -80790,12 +81351,6 @@ export default {
format: "numeric",
type: "number",
},
- itemId: {
- description:
- "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
- format: "text",
- type: "string",
- },
assignee: {
description:
"Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
@@ -86831,14 +87386,14 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.qualityActions.nonConformanceItemId": {
- name: "nonConformanceItemId",
+ "rowFilter.qualityActions.nonConformanceTypeName": {
+ name: "nonConformanceTypeName",
required: false,
in: "query",
type: "string",
},
- "rowFilter.qualityActions.nonConformanceTypeName": {
- name: "nonConformanceTypeName",
+ "rowFilter.qualityActions.items": {
+ name: "items",
required: false,
in: "query",
type: "string",
@@ -90227,6 +90782,177 @@ export default {
in: "query",
type: "string",
},
+ "body.issues": {
+ name: "issues",
+ description: "issues",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/issues",
+ },
+ },
+ "rowFilter.issues.id": {
+ name: "id",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.nonConformanceId": {
+ name: "nonConformanceId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.name": {
+ name: "name",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.description": {
+ name: "description",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.source": {
+ name: "source",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.status": {
+ name: "status",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.priority": {
+ name: "priority",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.approvalRequirements": {
+ name: "approvalRequirements",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.nonConformanceWorkflowId": {
+ name: "nonConformanceWorkflowId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.content": {
+ name: "content",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.locationId": {
+ name: "locationId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.nonConformanceTypeId": {
+ name: "nonConformanceTypeId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.openDate": {
+ name: "openDate",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.dueDate": {
+ name: "dueDate",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.closeDate": {
+ name: "closeDate",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.quantity": {
+ name: "quantity",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.assignee": {
+ name: "assignee",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.customFields": {
+ name: "customFields",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.tags": {
+ name: "tags",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.companyId": {
+ name: "companyId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.createdAt": {
+ name: "createdAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.createdBy": {
+ name: "createdBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.updatedAt": {
+ name: "updatedAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.updatedBy": {
+ name: "updatedBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.investigationTypeIds": {
+ name: "investigationTypeIds",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.requiredActionIds": {
+ name: "requiredActionIds",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.issues.items": {
+ name: "items",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.openPurchaseOrderLines": {
name: "openPurchaseOrderLines",
description: "openPurchaseOrderLines",
@@ -101825,6 +102551,63 @@ export default {
in: "query",
type: "string",
},
+ "body.nonConformanceItem": {
+ name: "nonConformanceItem",
+ description: "nonConformanceItem",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/nonConformanceItem",
+ },
+ },
+ "rowFilter.nonConformanceItem.id": {
+ name: "id",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.nonConformanceItem.nonConformanceId": {
+ name: "nonConformanceId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.nonConformanceItem.itemId": {
+ name: "itemId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.nonConformanceItem.companyId": {
+ name: "companyId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.nonConformanceItem.createdAt": {
+ name: "createdAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.nonConformanceItem.createdBy": {
+ name: "createdBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.nonConformanceItem.updatedAt": {
+ name: "updatedAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.nonConformanceItem.updatedBy": {
+ name: "updatedBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.configurationRule": {
name: "configurationRule",
description: "configurationRule",
@@ -109097,12 +109880,6 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.nonConformance.itemId": {
- name: "itemId",
- required: false,
- in: "query",
- type: "string",
- },
"rowFilter.nonConformance.assignee": {
name: "assignee",
required: false,
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 974c040148..f3061caad8 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -40110,14 +40110,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -47479,6 +47479,89 @@ export type Database = {
week52: number
}[]
}
+ get_production_projections: {
+ Args: {
+ company_id: string
+ location_id: string
+ periods: string[]
+ }
+ Returns: {
+ id: string
+ readableIdWithRevision: string
+ name: string
+ active: boolean
+ type: Database["public"]["Enums"]["itemType"]
+ itemTrackingType: Database["public"]["Enums"]["itemTrackingType"]
+ replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ thumbnailPath: string
+ unitOfMeasureCode: string
+ leadTime: number
+ manufacturingBlocked: boolean
+ lotSize: number
+ reorderingPolicy: Database["public"]["Enums"]["itemReorderingPolicy"]
+ demandAccumulationPeriod: number
+ demandAccumulationSafetyStock: number
+ reorderPoint: number
+ reorderQuantity: number
+ minimumOrderQuantity: number
+ maximumOrderQuantity: number
+ orderMultiple: number
+ quantityOnHand: number
+ maximumInventoryQuantity: number
+ week1: number
+ week2: number
+ week3: number
+ week4: number
+ week5: number
+ week6: number
+ week7: number
+ week8: number
+ week9: number
+ week10: number
+ week11: number
+ week12: number
+ week13: number
+ week14: number
+ week15: number
+ week16: number
+ week17: number
+ week18: number
+ week19: number
+ week20: number
+ week21: number
+ week22: number
+ week23: number
+ week24: number
+ week25: number
+ week26: number
+ week27: number
+ week28: number
+ week29: number
+ week30: number
+ week31: number
+ week32: number
+ week33: number
+ week34: number
+ week35: number
+ week36: number
+ week37: number
+ week38: number
+ week39: number
+ week40: number
+ week41: number
+ week42: number
+ week43: number
+ week44: number
+ week45: number
+ week46: number
+ week47: number
+ week48: number
+ week49: number
+ week50: number
+ week51: number
+ week52: number
+ }[]
+ }
get_purchasing_planning: {
Args: {
company_id: string
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 974c040148..f3061caad8 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -40110,14 +40110,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -47479,6 +47479,89 @@ export type Database = {
week52: number
}[]
}
+ get_production_projections: {
+ Args: {
+ company_id: string
+ location_id: string
+ periods: string[]
+ }
+ Returns: {
+ id: string
+ readableIdWithRevision: string
+ name: string
+ active: boolean
+ type: Database["public"]["Enums"]["itemType"]
+ itemTrackingType: Database["public"]["Enums"]["itemTrackingType"]
+ replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ thumbnailPath: string
+ unitOfMeasureCode: string
+ leadTime: number
+ manufacturingBlocked: boolean
+ lotSize: number
+ reorderingPolicy: Database["public"]["Enums"]["itemReorderingPolicy"]
+ demandAccumulationPeriod: number
+ demandAccumulationSafetyStock: number
+ reorderPoint: number
+ reorderQuantity: number
+ minimumOrderQuantity: number
+ maximumOrderQuantity: number
+ orderMultiple: number
+ quantityOnHand: number
+ maximumInventoryQuantity: number
+ week1: number
+ week2: number
+ week3: number
+ week4: number
+ week5: number
+ week6: number
+ week7: number
+ week8: number
+ week9: number
+ week10: number
+ week11: number
+ week12: number
+ week13: number
+ week14: number
+ week15: number
+ week16: number
+ week17: number
+ week18: number
+ week19: number
+ week20: number
+ week21: number
+ week22: number
+ week23: number
+ week24: number
+ week25: number
+ week26: number
+ week27: number
+ week28: number
+ week29: number
+ week30: number
+ week31: number
+ week32: number
+ week33: number
+ week34: number
+ week35: number
+ week36: number
+ week37: number
+ week38: number
+ week39: number
+ week40: number
+ week41: number
+ week42: number
+ week43: number
+ week44: number
+ week45: number
+ week46: number
+ week47: number
+ week48: number
+ week49: number
+ week50: number
+ week51: number
+ week52: number
+ }[]
+ }
get_purchasing_planning: {
Args: {
company_id: string
diff --git a/packages/database/supabase/migrations/20250907202514_production-projections.sql b/packages/database/supabase/migrations/20250907202514_production-projections.sql
new file mode 100644
index 0000000000..9cd0b2e3ec
--- /dev/null
+++ b/packages/database/supabase/migrations/20250907202514_production-projections.sql
@@ -0,0 +1,198 @@
+DROP FUNCTION IF EXISTS get_production_projections;
+CREATE OR REPLACE FUNCTION get_production_projections(company_id TEXT, location_id TEXT, periods TEXT[])
+ RETURNS TABLE (
+ "id" TEXT,
+ "readableIdWithRevision" TEXT,
+ "name" TEXT,
+ "active" BOOLEAN,
+ "type" "itemType",
+ "itemTrackingType" "itemTrackingType",
+ "replenishmentSystem" "itemReplenishmentSystem",
+ "thumbnailPath" TEXT,
+ "unitOfMeasureCode" TEXT,
+ "leadTime" INTEGER,
+ "manufacturingBlocked" BOOLEAN,
+ "lotSize" INTEGER,
+ "reorderingPolicy" "itemReorderingPolicy",
+ "demandAccumulationPeriod" INTEGER,
+ "demandAccumulationSafetyStock" NUMERIC,
+ "reorderPoint" INTEGER,
+ "reorderQuantity" INTEGER,
+ "minimumOrderQuantity" INTEGER,
+ "maximumOrderQuantity" INTEGER,
+ "orderMultiple" INTEGER,
+ "quantityOnHand" NUMERIC,
+ "maximumInventoryQuantity" NUMERIC,
+ "week1" NUMERIC,
+ "week2" NUMERIC,
+ "week3" NUMERIC,
+ "week4" NUMERIC,
+ "week5" NUMERIC,
+ "week6" NUMERIC,
+ "week7" NUMERIC,
+ "week8" NUMERIC,
+ "week9" NUMERIC,
+ "week10" NUMERIC,
+ "week11" NUMERIC,
+ "week12" NUMERIC,
+ "week13" NUMERIC,
+ "week14" NUMERIC,
+ "week15" NUMERIC,
+ "week16" NUMERIC,
+ "week17" NUMERIC,
+ "week18" NUMERIC,
+ "week19" NUMERIC,
+ "week20" NUMERIC,
+ "week21" NUMERIC,
+ "week22" NUMERIC,
+ "week23" NUMERIC,
+ "week24" NUMERIC,
+ "week25" NUMERIC,
+ "week26" NUMERIC,
+ "week27" NUMERIC,
+ "week28" NUMERIC,
+ "week29" NUMERIC,
+ "week30" NUMERIC,
+ "week31" NUMERIC,
+ "week32" NUMERIC,
+ "week33" NUMERIC,
+ "week34" NUMERIC,
+ "week35" NUMERIC,
+ "week36" NUMERIC,
+ "week37" NUMERIC,
+ "week38" NUMERIC,
+ "week39" NUMERIC,
+ "week40" NUMERIC,
+ "week41" NUMERIC,
+ "week42" NUMERIC,
+ "week43" NUMERIC,
+ "week44" NUMERIC,
+ "week45" NUMERIC,
+ "week46" NUMERIC,
+ "week47" NUMERIC,
+ "week48" NUMERIC,
+ "week49" NUMERIC,
+ "week50" NUMERIC,
+ "week51" NUMERIC,
+ "week52" NUMERIC
+ ) AS $$
+ SELECT
+ i."id",
+ i."readableIdWithRevision",
+ i."name",
+ i."active",
+ i."type",
+ i."itemTrackingType",
+ i."replenishmentSystem",
+ CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END AS "thumbnailPath",
+ i."unitOfMeasureCode",
+ ir."leadTime",
+ ir."manufacturingBlocked",
+ ir."lotSize",
+ ip."reorderingPolicy",
+ ip."demandAccumulationPeriod",
+ ip."demandAccumulationSafetyStock",
+ ip."reorderPoint",
+ ip."reorderQuantity",
+ ip."minimumOrderQuantity",
+ ip."maximumOrderQuantity",
+ ip."orderMultiple",
+ COALESCE((
+ SELECT SUM("quantity")
+ FROM "itemLedger"
+ WHERE "companyId" = company_id
+ AND "locationId" = location_id
+ AND "itemId" = i."id"
+ ), 0) AS "quantityOnHand",
+ ip."maximumInventoryQuantity",
+ MAX(CASE WHEN df."periodId" = periods[1] THEN df."forecastQuantity" END) AS "week1",
+ MAX(CASE WHEN df."periodId" = periods[2] THEN df."forecastQuantity" END) AS "week2",
+ MAX(CASE WHEN df."periodId" = periods[3] THEN df."forecastQuantity" END) AS "week3",
+ MAX(CASE WHEN df."periodId" = periods[4] THEN df."forecastQuantity" END) AS "week4",
+ MAX(CASE WHEN df."periodId" = periods[5] THEN df."forecastQuantity" END) AS "week5",
+ MAX(CASE WHEN df."periodId" = periods[6] THEN df."forecastQuantity" END) AS "week6",
+ MAX(CASE WHEN df."periodId" = periods[7] THEN df."forecastQuantity" END) AS "week7",
+ MAX(CASE WHEN df."periodId" = periods[8] THEN df."forecastQuantity" END) AS "week8",
+ MAX(CASE WHEN df."periodId" = periods[9] THEN df."forecastQuantity" END) AS "week9",
+ MAX(CASE WHEN df."periodId" = periods[10] THEN df."forecastQuantity" END) AS "week10",
+ MAX(CASE WHEN df."periodId" = periods[11] THEN df."forecastQuantity" END) AS "week11",
+ MAX(CASE WHEN df."periodId" = periods[12] THEN df."forecastQuantity" END) AS "week12",
+ MAX(CASE WHEN df."periodId" = periods[13] THEN df."forecastQuantity" END) AS "week13",
+ MAX(CASE WHEN df."periodId" = periods[14] THEN df."forecastQuantity" END) AS "week14",
+ MAX(CASE WHEN df."periodId" = periods[15] THEN df."forecastQuantity" END) AS "week15",
+ MAX(CASE WHEN df."periodId" = periods[16] THEN df."forecastQuantity" END) AS "week16",
+ MAX(CASE WHEN df."periodId" = periods[17] THEN df."forecastQuantity" END) AS "week17",
+ MAX(CASE WHEN df."periodId" = periods[18] THEN df."forecastQuantity" END) AS "week18",
+ MAX(CASE WHEN df."periodId" = periods[19] THEN df."forecastQuantity" END) AS "week19",
+ MAX(CASE WHEN df."periodId" = periods[20] THEN df."forecastQuantity" END) AS "week20",
+ MAX(CASE WHEN df."periodId" = periods[21] THEN df."forecastQuantity" END) AS "week21",
+ MAX(CASE WHEN df."periodId" = periods[22] THEN df."forecastQuantity" END) AS "week22",
+ MAX(CASE WHEN df."periodId" = periods[23] THEN df."forecastQuantity" END) AS "week23",
+ MAX(CASE WHEN df."periodId" = periods[24] THEN df."forecastQuantity" END) AS "week24",
+ MAX(CASE WHEN df."periodId" = periods[25] THEN df."forecastQuantity" END) AS "week25",
+ MAX(CASE WHEN df."periodId" = periods[26] THEN df."forecastQuantity" END) AS "week26",
+ MAX(CASE WHEN df."periodId" = periods[27] THEN df."forecastQuantity" END) AS "week27",
+ MAX(CASE WHEN df."periodId" = periods[28] THEN df."forecastQuantity" END) AS "week28",
+ MAX(CASE WHEN df."periodId" = periods[29] THEN df."forecastQuantity" END) AS "week29",
+ MAX(CASE WHEN df."periodId" = periods[30] THEN df."forecastQuantity" END) AS "week30",
+ MAX(CASE WHEN df."periodId" = periods[31] THEN df."forecastQuantity" END) AS "week31",
+ MAX(CASE WHEN df."periodId" = periods[32] THEN df."forecastQuantity" END) AS "week32",
+ MAX(CASE WHEN df."periodId" = periods[33] THEN df."forecastQuantity" END) AS "week33",
+ MAX(CASE WHEN df."periodId" = periods[34] THEN df."forecastQuantity" END) AS "week34",
+ MAX(CASE WHEN df."periodId" = periods[35] THEN df."forecastQuantity" END) AS "week35",
+ MAX(CASE WHEN df."periodId" = periods[36] THEN df."forecastQuantity" END) AS "week36",
+ MAX(CASE WHEN df."periodId" = periods[37] THEN df."forecastQuantity" END) AS "week37",
+ MAX(CASE WHEN df."periodId" = periods[38] THEN df."forecastQuantity" END) AS "week38",
+ MAX(CASE WHEN df."periodId" = periods[39] THEN df."forecastQuantity" END) AS "week39",
+ MAX(CASE WHEN df."periodId" = periods[40] THEN df."forecastQuantity" END) AS "week40",
+ MAX(CASE WHEN df."periodId" = periods[41] THEN df."forecastQuantity" END) AS "week41",
+ MAX(CASE WHEN df."periodId" = periods[42] THEN df."forecastQuantity" END) AS "week42",
+ MAX(CASE WHEN df."periodId" = periods[43] THEN df."forecastQuantity" END) AS "week43",
+ MAX(CASE WHEN df."periodId" = periods[44] THEN df."forecastQuantity" END) AS "week44",
+ MAX(CASE WHEN df."periodId" = periods[45] THEN df."forecastQuantity" END) AS "week45",
+ MAX(CASE WHEN df."periodId" = periods[46] THEN df."forecastQuantity" END) AS "week46",
+ MAX(CASE WHEN df."periodId" = periods[47] THEN df."forecastQuantity" END) AS "week47",
+ MAX(CASE WHEN df."periodId" = periods[48] THEN df."forecastQuantity" END) AS "week48",
+ MAX(CASE WHEN df."periodId" = periods[49] THEN df."forecastQuantity" END) AS "week49",
+ MAX(CASE WHEN df."periodId" = periods[50] THEN df."forecastQuantity" END) AS "week50",
+ MAX(CASE WHEN df."periodId" = periods[51] THEN df."forecastQuantity" END) AS "week51",
+ MAX(CASE WHEN df."periodId" = periods[52] THEN df."forecastQuantity" END) AS "week52"
+ FROM "item" i
+ INNER JOIN "itemReplenishment" ir ON i."id" = ir."itemId"
+ INNER JOIN "itemPlanning" ip ON i."id" = ip."itemId" AND ip."locationId" = location_id
+ LEFT JOIN "modelUpload" mu ON mu."id" = i."modelUploadId"
+ INNER JOIN "demandForecast" df ON df."itemId" = i."id"
+ AND df."companyId" = company_id
+ AND df."locationId" = location_id
+ AND df."periodId" = ANY(periods)
+ WHERE i."companyId" = company_id
+ AND i."replenishmentSystem" = 'Make'
+ AND i."itemTrackingType" != 'Non-Inventory'
+ AND i."active" = TRUE
+ GROUP BY
+ i."id",
+ i."readableIdWithRevision",
+ i."name",
+ i."active",
+ i."type",
+ i."itemTrackingType",
+ i."replenishmentSystem",
+ i."thumbnailPath",
+ mu."thumbnailPath",
+ i."unitOfMeasureCode",
+ ir."leadTime",
+ ir."manufacturingBlocked",
+ ir."lotSize",
+ ip."reorderingPolicy",
+ ip."demandAccumulationPeriod",
+ ip."demandAccumulationSafetyStock",
+ ip."reorderPoint",
+ ip."reorderQuantity",
+ ip."minimumOrderQuantity",
+ ip."maximumOrderQuantity",
+ ip."orderMultiple",
+ ip."maximumInventoryQuantity";
+$$ LANGUAGE sql SECURITY DEFINER;
\ No newline at end of file
diff --git a/packages/database/supabase/migrations/20250907225239_demand-forecast.sql b/packages/database/supabase/migrations/20250907225239_demand-forecast.sql
new file mode 100644
index 0000000000..d56a181cb5
--- /dev/null
+++ b/packages/database/supabase/migrations/20250907225239_demand-forecast.sql
@@ -0,0 +1,3 @@
+ALTER TABLE "demandForecast"
+ADD CONSTRAINT "demandForecast_itemId_locationId_periodId_companyId_key"
+UNIQUE ("itemId", "locationId", "periodId", "companyId");