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 supply to planning chart

Brad Barbin4df28b4c9270
diff --git a/apps/erp/app/modules/items/items.service.ts b/apps/erp/app/modules/items/items.service.ts
index a5661e3ca0..b2e74de724 100644
--- a/apps/erp/app/modules/items/items.service.ts
+++ b/apps/erp/app/modules/items/items.service.ts
@@ -579,6 +579,29 @@ export async function getItemShelfQuantities(
});
}
+export async function getItemSupply(
+ client: SupabaseClient<Database>,
+ {
+ itemId,
+ locationId,
+ periods,
+ companyId,
+ }: {
+ itemId: string;
+ locationId: string;
+ periods: string[];
+ companyId: string;
+ }
+) {
+ return client
+ .from("supplyActual")
+ .select("*")
+ .eq("itemId", itemId)
+ .eq("locationId", locationId)
+ .eq("companyId", companyId)
+ .in("periodId", periods);
+}
+
export async function getItemUnitSalePrice(
client: SupabaseClient<Database>,
id: string,
diff --git a/apps/erp/app/modules/items/ui/Item/ItemPlanningChart.tsx b/apps/erp/app/modules/items/ui/Item/ItemPlanningChart.tsx
index fa57d1d437..b9592d3d32 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemPlanningChart.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemPlanningChart.tsx
@@ -17,12 +17,21 @@ import { useDateFormatter } from "@react-aria/i18n";
import { useFetcher } from "@remix-run/react";
import { useMemo } from "react";
-import { Bar, BarChart, CartesianGrid, Line, XAxis, YAxis } from "recharts";
+import {
+ Bar,
+ CartesianGrid,
+ ComposedChart,
+ Legend,
+ Line,
+ ReferenceLine,
+ XAxis,
+ YAxis,
+} from "recharts";
import { Empty } from "~/components";
import type { loader as forecastLoader } from "~/routes/api+/items.$id.$locationId.forecast";
import { path } from "~/utils/path";
-interface DemandData {
+interface Data {
actualQuantity: number;
companyId: string;
createdAt: string;
@@ -31,17 +40,28 @@ interface DemandData {
locationId: string;
notes: string | null;
periodId: string;
- sourceType: "Sales Order" | "Job Material";
updatedAt: string;
updatedBy: string;
}
+const supplySourceTypes = ["Purchase Order", "Production Order"] as const;
+const demandSourceTypes = ["Sales Order", "Job Material"] as const;
+
+interface DemandData extends Data {
+ sourceType: (typeof demandSourceTypes)[number];
+}
+
+interface SupplyData extends Data {
+ sourceType: (typeof supplySourceTypes)[number];
+}
interface ChartDataPoint {
startDate: string;
period: string;
"Sales Order": number;
"Job Material": number;
- forecast: number;
+ "Purchase Order": number;
+ "Production Order": number;
+ Projection: number;
}
export const ItemPlanningChart = ({
@@ -69,7 +89,8 @@ export const ItemPlanningChart = ({
const periods = forecastFetcher.data.periods;
const demand = forecastFetcher.data.demand;
- const forecast = forecastFetcher.data?.forecast ?? 5;
+ const supply = forecastFetcher.data.supply;
+ let currentQuantity = forecastFetcher.data.quantityOnHand ?? 0;
// Initialize all periods with zero values
const groupedData = periods.reduce(
@@ -79,7 +100,9 @@ export const ItemPlanningChart = ({
startDate: period.startDate,
"Sales Order": 0,
"Job Material": 0,
- forecast,
+ "Purchase Order": 0,
+ "Production Order": 0,
+ Projection: currentQuantity, // Initialize with current quantity
};
return acc;
},
@@ -88,40 +111,50 @@ export const ItemPlanningChart = ({
// Add demand data
demand.forEach((curr: DemandData) => {
+ if (groupedData[curr.periodId]) {
+ groupedData[curr.periodId][curr.sourceType] -= curr.actualQuantity;
+ }
+ });
+
+ // Add supply data
+ supply.forEach((curr: SupplyData) => {
if (groupedData[curr.periodId]) {
groupedData[curr.periodId][curr.sourceType] += curr.actualQuantity;
}
});
- return Object.values(groupedData).sort(
+ // Calculate running projection
+ let runningProjection = currentQuantity;
+ const sortedData = Object.values(groupedData).sort(
(a, b) =>
new Date(a.startDate).getTime() - new Date(b.startDate).getTime()
);
- }, [
- forecastFetcher.data?.demand,
- forecastFetcher.data?.periods,
- forecastFetcher.data?.forecast,
- ]);
-
- const sourceTypes = useMemo(() => {
- if (!forecastFetcher.data?.demand) return [];
- return [
- ...new Set(
- forecastFetcher.data.demand.map((item: DemandData) => item.sourceType)
- ),
- ];
- }, [forecastFetcher.data?.demand]);
+
+ return sortedData.map((period) => {
+ // Add supply
+ runningProjection +=
+ period["Purchase Order"] + period["Production Order"];
+ // Subtract demand
+ runningProjection += period["Sales Order"] + period["Job Material"];
+ // Update projection
+ period.Projection = runningProjection;
+ return period;
+ });
+ }, [forecastFetcher.data]);
const chartConfig = {} satisfies ChartConfig;
- if (forecastFetcher.data?.demand.length === 0) {
+ if (
+ forecastFetcher.data?.demand.length === 0 &&
+ forecastFetcher.data?.supply.length === 0
+ ) {
return (
<Card>
<CardHeader>
- <CardTitle>Demand</CardTitle>
+ <CardTitle>Projections</CardTitle>
</CardHeader>
<CardContent className="min-h-[360px] flex items-center justify-center">
- <Empty>No demand data</Empty>
+ <Empty>No planning data</Empty>
</CardContent>
</Card>
);
@@ -131,13 +164,13 @@ export const ItemPlanningChart = ({
<>
<Card>
<CardHeader>
- <CardTitle>Demand</CardTitle>
+ <CardTitle>Projections</CardTitle>
</CardHeader>
<CardContent>
<div className="w-full h-[360px]">
<Loading isLoading={isFetching}>
<ChartContainer config={chartConfig} className="w-full h-full">
- <BarChart data={chartData}>
+ <ComposedChart data={chartData} stackOffset="sign">
<CartesianGrid vertical={false} />
<XAxis
dataKey="startDate"
@@ -150,6 +183,18 @@ export const ItemPlanningChart = ({
}
/>
<YAxis tickLine={false} axisLine={false} />
+ <ReferenceLine y={0} stroke="#94a3b8" strokeDasharray="3 3" />
+ <Legend
+ payload={[
+ { value: "Demand", type: "rect", color: "#14b8a6" },
+ { value: "Supply", type: "rect", color: "#2563eb" },
+ {
+ value: "Projection",
+ type: "line",
+ color: "#7c3aed",
+ },
+ ]}
+ />
<ChartTooltip
content={
<ChartTooltipContent
@@ -161,25 +206,35 @@ export const ItemPlanningChart = ({
/>
}
/>
- {sourceTypes.map((sourceType: string, index: number) => (
- <Bar
- key={sourceType}
- dataKey={sourceType}
- stackId="demand"
- className={
- sourceType === "Sales Order"
- ? "fill-violet-600"
- : "fill-teal-500"
- }
- />
- ))}
+ {demandSourceTypes.map(
+ (sourceType: string, index: number) => (
+ <Bar
+ key={sourceType}
+ dataKey={sourceType}
+ stackId="stack"
+ className="fill-teal-500"
+ />
+ )
+ )}
+ {supplySourceTypes.map(
+ (sourceType: string, index: number) => (
+ <Bar
+ key={sourceType}
+ dataKey={sourceType}
+ stackId="stack"
+ className="fill-blue-600"
+ />
+ )
+ )}
<Line
type="monotone"
- dataKey="forecast"
- stroke="#ff7300"
+ dataKey="Projection"
strokeWidth={2}
+ dot={false}
+ stroke="#7c3aed"
+ isAnimationActive={false}
/>
- </BarChart>
+ </ComposedChart>
</ChartContainer>
</Loading>
</div>
diff --git a/apps/erp/app/modules/production/production.models.ts b/apps/erp/app/modules/production/production.models.ts
index 869ecaa294..020ae3ea36 100644
--- a/apps/erp/app/modules/production/production.models.ts
+++ b/apps/erp/app/modules/production/production.models.ts
@@ -36,6 +36,7 @@ export const deadlineTypes = [
export const jobStatus = [
"Draft",
+ "Planned",
"Ready",
"In Progress",
"Paused",
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
index 8723a6a478..7fda01c303 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
@@ -715,7 +715,8 @@ function MaterialForm({
method="post"
defaultValues={item.data}
validator={
- job?.status === "Draft" || jobOperations?.length === 0
+ ["Draft", "Planned"].includes(job?.status ?? "") ||
+ jobOperations?.length === 0
? jobMaterialValidator
: jobMaterialValidatorForReleasedJob
}
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
index 3e42bf1d2c..1c1485060e 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
@@ -2004,7 +2004,7 @@ function OperationForm({
method="post"
defaultValues={item.data}
validator={
- job?.status === "Draft"
+ ["Draft", "Planned"].includes(job?.status ?? "")
? jobOperationValidator
: jobOperationValidatorForReleasedJob
}
@@ -2133,7 +2133,7 @@ function OperationForm({
label="Work Center"
autoSelectSingleOption={Boolean(processData.processId)}
locationId={locationId}
- isOptional={job?.status === "Draft"}
+ isOptional={["Draft", "Planned"].includes(job?.status ?? "")}
processId={processData.processId}
onChange={(value) => {
if (value) {
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx b/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
index e88db2c42b..9842110656 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
@@ -21,6 +21,7 @@ import {
ModalHeader,
ModalTitle,
Spinner,
+ SplitButton,
VStack,
useDisclosure,
useMount,
@@ -33,6 +34,7 @@ import { Link, useFetcher, useNavigate, useParams } from "@remix-run/react";
import { useState } from "react";
import { flushSync } from "react-dom";
import {
+ LuCheckCheck,
LuChevronDown,
LuCircleCheck,
LuCirclePause,
@@ -94,6 +96,15 @@ const JobHeader = () => {
const currentValue = getOptionFromPath(jobId);
+ const markAsPlanned = () => {
+ statusFetcher.submit(
+ {
+ status: "Planned",
+ },
+ { method: "post", action: path.to.jobStatus(jobId) }
+ );
+ };
+
return (
<>
<div className="flex flex-shrink-0 items-center justify-between p-2 bg-card border-b border-border h-[50px] overflow-x-auto scrollbar-hide dark:border-none dark:shadow-[inset_0_0_1px_rgb(255_255_255_/_0.24),_0_0_0_0.5px_rgb(0,0,0,1),0px_0px_4px_rgba(0,_0,_0,_0.08)] ">
@@ -203,24 +214,35 @@ const JobHeader = () => {
</statusFetcher.Form>
)}
- <Button
+ <SplitButton
onClick={releaseModal.onOpen}
isLoading={
statusFetcher.state !== "idle" &&
- statusFetcher.formData?.get("status") === "Ready"
+ ["Ready", "Planned"].includes(status ?? "")
}
isDisabled={
- status !== "Draft" ||
+ !["Draft", "Planned"].includes(status ?? "") ||
statusFetcher.state !== "idle" ||
!permissions.can("update", "production") ||
(routeData?.job?.quantity === 0 &&
routeData?.job?.scrapQuantity === 0)
}
leftIcon={<LuCirclePlay />}
- variant={status === "Draft" ? "primary" : "secondary"}
+ variant={
+ ["Draft", "Planned"].includes(status ?? "")
+ ? "primary"
+ : "secondary"
+ }
+ dropdownItems={[
+ {
+ label: "Mark as Planned",
+ icon: <LuCheckCheck />,
+ onClick: markAsPlanned,
+ },
+ ]}
>
Release
- </Button>
+ </SplitButton>
<Button
onClick={completeModal.onOpen}
@@ -229,7 +251,9 @@ const JobHeader = () => {
statusFetcher.formAction === path.to.jobComplete(jobId)
}
isDisabled={
- ["Completed", "Cancelled", "Draft"].includes(status ?? "") ||
+ ["Completed", "Cancelled", "Draft", "Planned"].includes(
+ status ?? ""
+ ) ||
statusFetcher.state !== "idle" ||
!permissions.can("update", "production")
}
@@ -263,7 +287,7 @@ const JobHeader = () => {
<Button
isLoading={
statusFetcher.state !== "idle" &&
- ["Draft", "In Progress"].includes(
+ ["Draft", "Planned", "In Progress"].includes(
(statusFetcher.formData?.get("status") as string) ?? ""
)
}
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobStatus.tsx b/apps/erp/app/modules/production/ui/Jobs/JobStatus.tsx
index a73d1d2e25..9e9c68dc84 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobStatus.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobStatus.tsx
@@ -9,15 +9,16 @@ function JobStatus({ status }: JobStatusProps) {
switch (status) {
case "Draft":
return <Status color="gray">{status}</Status>;
- case "Ready":
+ case "Planned":
return <Status color="yellow">{status}</Status>;
+ case "Ready":
case "In Progress":
- return <Status color="blue">{status}</Status>;
+ return <Status color="green">{status}</Status>;
case "Paused":
case "Due Today":
return <Status color="orange">{status}</Status>;
case "Completed":
- return <Status color="green">{status}</Status>;
+ return <Status color="blue">{status}</Status>;
case "Overdue":
case "Cancelled":
return <Status color="red">{status}</Status>;
diff --git a/apps/erp/app/modules/purchasing/purchasing.models.ts b/apps/erp/app/modules/purchasing/purchasing.models.ts
index 34ac17d9ff..b1a4a31885 100644
--- a/apps/erp/app/modules/purchasing/purchasing.models.ts
+++ b/apps/erp/app/modules/purchasing/purchasing.models.ts
@@ -49,6 +49,7 @@ export const purchaseOrderTypeType = [
export const purchaseOrderStatusType = [
"Draft",
+ "Planned",
"To Review",
"To Receive",
"To Receive and Invoice",
@@ -129,19 +130,20 @@ export const purchaseOrderLineValidator = z
itemReadableId: zfd.text(z.string().optional()),
accountNumber: zfd.text(z.string().optional()),
assetId: zfd.text(z.string().optional()),
+ conversionFactor: zfd.numeric(z.number().optional()),
description: zfd.text(z.string().optional()),
+ exchangeRate: zfd.numeric(z.number().optional()),
+ inventoryUnitOfMeasureCode: zfd.text(z.string().optional()),
+ jobId: zfd.text(z.string().optional()),
+ jobOperationId: zfd.text(z.string().optional()),
+ locationId: zfd.text(z.string().optional()),
+ promisedDate: zfd.text(z.string().optional()),
purchaseQuantity: zfd.numeric(z.number().optional()),
purchaseUnitOfMeasureCode: zfd.text(z.string().optional()),
- inventoryUnitOfMeasureCode: zfd.text(z.string().optional()),
- conversionFactor: zfd.numeric(z.number().optional()),
- supplierUnitPrice: zfd.numeric(z.number().optional()),
+ shelfId: zfd.text(z.string().optional()),
supplierShippingCost: zfd.numeric(z.number().optional()),
supplierTaxAmount: zfd.numeric(z.number().optional()),
- locationId: zfd.text(z.string().optional()),
- shelfId: zfd.text(z.string().optional()),
- jobId: zfd.text(z.string().optional()),
- jobOperationId: zfd.text(z.string().optional()),
- exchangeRate: zfd.numeric(z.number().optional()),
+ supplierUnitPrice: zfd.numeric(z.number().optional()),
})
.refine(
(data) =>
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
index e9e942b89b..2b2e933f53 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
@@ -10,6 +10,7 @@ import {
HStack,
Heading,
IconButton,
+ SplitButton,
useDisclosure,
} from "@carbon/react";
@@ -18,6 +19,7 @@ import {
LuCheckCheck,
LuChevronDown,
LuCirclePlus,
+ LuCircleStop,
LuCreditCard,
LuEye,
LuFile,
@@ -73,6 +75,13 @@ const PurchaseOrderHeader = () => {
const hasShipments = shipments.length > 0;
const requiresShipment = isOutsideProcessing && !hasShipments;
+ const markAsPlanned = () => {
+ statusFetcher.submit(
+ { status: "Planned" },
+ { method: "post", action: path.to.purchaseOrderStatus(orderId) }
+ );
+ };
+
return (
<>
<div className="flex flex-shrink-0 items-center justify-between p-2 bg-card border-b border-border h-[50px] overflow-x-auto scrollbar-hide dark:border-none dark:shadow-[inset_0_0_1px_rgb(255_255_255_/_0.24),_0_0_0_0.5px_rgb(0,0,0,1),0px_0px_4px_rgba(0,_0,_0,_0.08)]">
@@ -122,21 +131,31 @@ const PurchaseOrderHeader = () => {
</DropdownMenuContent>
</DropdownMenu>
- <Button
+ <SplitButton
leftIcon={<LuCheckCheck />}
variant={
- routeData?.purchaseOrder?.status === "Draft"
+ ["Draft", "Planned"].includes(
+ routeData?.purchaseOrder?.status ?? ""
+ )
? "primary"
: "secondary"
}
onClick={finalizeDisclosure.onOpen}
isDisabled={
- routeData?.purchaseOrder?.status !== "Draft" ||
- routeData?.lines.length === 0
+ !["Draft", "Planned"].includes(
+ routeData?.purchaseOrder?.status ?? ""
+ ) || routeData?.lines.length === 0
}
+ dropdownItems={[
+ {
+ label: "Mark as Planned",
+ icon: <LuCheckCheck />,
+ onClick: markAsPlanned,
+ },
+ ]}
>
Finalize
- </Button>
+ </SplitButton>
{routeData?.purchaseOrder?.purchaseOrderType ===
"Outside Processing" &&
(shipments.length > 0 ? (
@@ -339,7 +358,30 @@ const PurchaseOrderHeader = () => {
Invoice
</Button>
)}
-
+ <statusFetcher.Form
+ method="post"
+ action={path.to.purchaseOrderStatus(orderId)}
+ >
+ <input type="hidden" name="status" value="Closed" />
+ <Button
+ type="submit"
+ isLoading={
+ statusFetcher.state !== "idle" &&
+ statusFetcher.formData?.get("status") === "Closed"
+ }
+ isDisabled={
+ ["Closed", "Completed"].includes(
+ routeData?.purchaseOrder?.status ?? ""
+ ) ||
+ statusFetcher.state !== "idle" ||
+ !permissions.can("update", "production")
+ }
+ leftIcon={<LuCircleStop />}
+ variant="secondary"
+ >
+ Cancel
+ </Button>
+ </statusFetcher.Form>
<statusFetcher.Form
method="post"
action={path.to.purchaseOrderStatus(orderId)}
@@ -350,11 +392,9 @@ const PurchaseOrderHeader = () => {
variant="secondary"
leftIcon={<LuLoaderCircle />}
isDisabled={
- ["Draft", "Cancelled", "Closed", "Completed"].includes(
- routeData?.purchaseOrder?.status ?? ""
- ) ||
+ ["Draft"].includes(routeData?.purchaseOrder?.status ?? "") ||
statusFetcher.state !== "idle" ||
- !permissions.can("update", "sales")
+ !permissions.can("update", "purchasing")
}
isLoading={
statusFetcher.state !== "idle" &&
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchasingStatus.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchasingStatus.tsx
index 350bcd1a1b..c67f46d50a 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchasingStatus.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchasingStatus.tsx
@@ -9,6 +9,7 @@ const PurchasingStatus = ({ status }: PurchasingStatusProps) => {
switch (status) {
case "Draft":
return <Status color="gray">{status}</Status>;
+ case "Planned":
case "To Review":
return <Status color="yellow">{status}</Status>;
case "To Receive":
diff --git a/apps/erp/app/routes/api+/items.$id.$locationId.forecast.ts b/apps/erp/app/routes/api+/items.$id.$locationId.forecast.ts
index 33e1b72e00..0077b74abe 100644
--- a/apps/erp/app/routes/api+/items.$id.$locationId.forecast.ts
+++ b/apps/erp/app/routes/api+/items.$id.$locationId.forecast.ts
@@ -3,14 +3,22 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { getLocalTimeZone, startOfWeek, today } from "@internationalized/date";
import { json, type LoaderFunctionArgs } from "@vercel/remix";
-import { getItemDemand, getPeriods } from "~/modules/items/items.service";
+import {
+ getItemDemand,
+ getItemQuantities,
+ getItemSupply,
+ getPeriods,
+} from "~/modules/items/items.service";
const defaultResponse = {
demand: [],
+ supply: [],
periods: [],
- forecast: 0,
+ quantityOnHand: 0,
};
+const WEEKS_TO_FORECAST = 12 * 4;
+
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -21,7 +29,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (!locationId) throw new Error("Could not find locationId");
const startDate = startOfWeek(today(getLocalTimeZone()), "en-US");
- const endDate = startDate.add({ weeks: 18 * 4 });
+ const endDate = startDate.add({ weeks: WEEKS_TO_FORECAST });
const periods = await getPeriods(client, {
startDate: startDate.toString(),
endDate: endDate.toString(),
@@ -34,13 +42,20 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
);
}
- const [demand] = await Promise.all([
+ const [demand, supply, quantities] = await Promise.all([
getItemDemand(client, {
itemId,
locationId,
periods: periods.data.map((p) => p.id ?? ""),
companyId,
}),
+ getItemSupply(client, {
+ itemId,
+ locationId,
+ periods: periods.data.map((p) => p.id ?? ""),
+ companyId,
+ }),
+ getItemQuantities(client, itemId, companyId, locationId),
]);
if (demand.error) {
@@ -50,5 +65,17 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
);
}
- return json({ demand: demand.data, periods: periods.data, forecast: 10 });
+ if (supply.error) {
+ return json(
+ defaultResponse,
+ await flash(request, error(supply.error, "Failed to load supply"))
+ );
+ }
+
+ return json({
+ demand: demand.data,
+ supply: supply.data,
+ periods: periods.data,
+ quantityOnHand: quantities.data?.quantityOnHand ?? 0,
+ });
}
diff --git a/apps/erp/app/routes/onboarding+/_index.tsx b/apps/erp/app/routes/onboarding+/_index.tsx
index 18eb28c781..0a3e84aa7c 100644
--- a/apps/erp/app/routes/onboarding+/_index.tsx
+++ b/apps/erp/app/routes/onboarding+/_index.tsx
@@ -1,9 +1,10 @@
-import { Heading as _Heading, Button, VStack } from "@carbon/react";
-import { Link } from "@remix-run/react";
+import { Button as _Button, Heading as _Heading, VStack } from "@carbon/react";
+import { useNavigate } from "@remix-run/react";
import { AnimatePresence, motion } from "framer-motion";
import { onboardingSequence } from "~/utils/path";
const Heading = motion(_Heading);
+const Button = motion(_Button);
const fade = {
initial: { opacity: 0 },
@@ -11,6 +12,8 @@ const fade = {
};
export default function GetStarted() {
+ const navigate = useNavigate();
+
return (
<AnimatePresence>
<VStack spacing={4} className="max-w-lg p-4 items-center text-center">
@@ -40,8 +43,13 @@ export default function GetStarted() {
Carbon is the operational system for manufacturing
</motion.p>
- <Button size="lg" asChild>
- <Link to={onboardingSequence[0]}>Get Started</Link>
+ <Button
+ {...fade}
+ transition={{ duration: 0.8, ease: "easeInOut", delay: 0.7 }}
+ size="lg"
+ onClick={() => navigate(onboardingSequence[0])}
+ >
+ Get Started
</Button>
</VStack>
</AnimatePresence>
diff --git a/apps/erp/app/routes/x+/job+/$jobId.status.tsx b/apps/erp/app/routes/x+/job+/$jobId.status.tsx
index df49574a54..d3283cd545 100644
--- a/apps/erp/app/routes/x+/job+/$jobId.status.tsx
+++ b/apps/erp/app/routes/x+/job+/$jobId.status.tsx
@@ -8,7 +8,12 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import type { ActionFunctionArgs } from "@vercel/remix";
import { redirect } from "@vercel/remix";
-import { jobStatus, updateJobStatus } from "~/modules/production";
+import {
+ jobStatus,
+ recalculateJobRequirements,
+ runMRP,
+ updateJobStatus,
+} from "~/modules/production";
import { path, requestReferrer } from "~/utils/path";
export async function action({ request, params }: ActionFunctionArgs) {
@@ -51,7 +56,22 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
}
- if (status === "Ready" && shouldSchedule) {
+ if (["Planned", "Ready"].includes(status)) {
+ const serviceRole = getCarbonServiceRole();
+ await recalculateJobRequirements(serviceRole, {
+ id,
+ companyId,
+ userId,
+ });
+ await runMRP(getCarbonServiceRole(), {
+ type: "job",
+ id,
+ companyId,
+ userId,
+ });
+ }
+
+ if (["Ready", "Planned"].includes(status) && shouldSchedule) {
try {
const purchaseOrdersBySupplierId = JSON.parse(
selectedPurchaseOrdersBySupplierId ?? "{}"
@@ -85,12 +105,14 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- await client
- .from("job")
- .update({
- releasedDate: new Date().toISOString(),
- })
- .eq("id", id);
+ if (status === "Ready") {
+ await client
+ .from("job")
+ .update({
+ releasedDate: new Date().toISOString(),
+ })
+ .eq("id", id);
+ }
} catch (err) {
console.error(err);
throw redirect(
diff --git a/apps/erp/app/routes/x+/purchase-order+/$orderId.finalize.tsx b/apps/erp/app/routes/x+/purchase-order+/$orderId.finalize.tsx
index b9402a61ae..656a593b71 100644
--- a/apps/erp/app/routes/x+/purchase-order+/$orderId.finalize.tsx
+++ b/apps/erp/app/routes/x+/purchase-order+/$orderId.finalize.tsx
@@ -14,6 +14,7 @@ import { redirect, type ActionFunctionArgs } from "@vercel/remix";
import { parseAcceptLanguage } from "intl-parse-accept-language";
import { getPaymentTermsList } from "~/modules/accounting";
import { upsertDocument } from "~/modules/documents";
+import { runMRP } from "~/modules/production/production.service";
import {
finalizePurchaseOrder,
getPurchaseOrder,
@@ -61,6 +62,12 @@ export async function action(args: ActionFunctionArgs) {
const [purchaseOrder] = await Promise.all([
getPurchaseOrder(serviceRole, orderId),
+ runMRP(serviceRole, {
+ type: "purchaseOrder",
+ id: orderId,
+ companyId,
+ userId,
+ }),
]);
if (purchaseOrder.error) {
throw redirect(
@@ -212,20 +219,22 @@ export async function action(args: ActionFunctionArgs) {
const html = await renderAsync(emailTemplate);
const text = await renderAsync(emailTemplate, { plainText: true });
- await tasks.trigger<typeof sendEmailResendTask>("send-email-resend", {
- to: [buyer.data.email, supplier.data.contact.email],
- from: buyer.data.email,
- subject: `Purchase Order ${purchaseOrder.data.purchaseOrderId} from ${company.data.name}`,
- html,
- text,
- attachments: [
- {
- content: Buffer.from(file).toString("base64"),
- filename: fileName,
- },
- ],
- companyId,
- });
+ await Promise.all([
+ tasks.trigger<typeof sendEmailResendTask>("send-email-resend", {
+ to: [buyer.data.email, supplier.data.contact.email],
+ from: buyer.data.email,
+ subject: `Purchase Order ${purchaseOrder.data.purchaseOrderId} from ${company.data.name}`,
+ html,
+ text,
+ attachments: [
+ {
+ content: Buffer.from(file).toString("base64"),
+ filename: fileName,
+ },
+ ],
+ companyId,
+ }),
+ ]);
} catch (err) {
throw redirect(
path.to.purchaseOrder(orderId),
diff --git a/apps/erp/app/routes/x+/purchase-order+/$orderId.status.tsx b/apps/erp/app/routes/x+/purchase-order+/$orderId.status.tsx
index 3337be07dc..ac109aeb3c 100644
--- a/apps/erp/app/routes/x+/purchase-order+/$orderId.status.tsx
+++ b/apps/erp/app/routes/x+/purchase-order+/$orderId.status.tsx
@@ -1,8 +1,14 @@
-import { assertIsPost, error, success } from "@carbon/auth";
+import {
+ assertIsPost,
+ error,
+ getCarbonServiceRole,
+ success,
+} from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import type { ActionFunctionArgs } from "@vercel/remix";
import { redirect } from "@vercel/remix";
+import { runMRP } from "~/modules/production";
import {
purchaseOrderStatusType,
updatePurchaseOrderStatus,
@@ -11,7 +17,7 @@ import { path, requestReferrer } from "~/utils/path";
export async function action({ request, params }: ActionFunctionArgs) {
assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
+ const { client, userId, companyId } = await requirePermissions(request, {
update: "purchasing",
});
@@ -48,6 +54,15 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
+ if (status === "Planned") {
+ await runMRP(getCarbonServiceRole(), {
+ type: "purchaseOrder",
+ id,
+ companyId,
+ userId,
+ });
+ }
+
throw redirect(
requestReferrer(request) ?? path.to.quote(id),
await flash(request, success("Updated purchasing order status"))
diff --git a/apps/erp/app/routes/x+/purchase-order+/update.tsx b/apps/erp/app/routes/x+/purchase-order+/update.tsx
index 3d2f06fb19..6de5cc2f0c 100644
--- a/apps/erp/app/routes/x+/purchase-order+/update.tsx
+++ b/apps/erp/app/routes/x+/purchase-order+/update.tsx
@@ -62,10 +62,34 @@ export async function action({ request }: ActionFunctionArgs) {
})
.in("id", ids as string[])
);
+ case "receiptRequestedDate":
case "locationId":
case "deliveryDate":
+ return json(
+ await client
+ .from("purchaseOrderDelivery")
+ .update({
+ [field]: value ?? undefined,
+ updatedBy: userId,
+ updatedAt: new Date().toISOString(),
+ })
+ .in("id", ids as string[])
+ );
case "receiptPromisedDate":
- case "receiptRequestedDate":
+ const lineUpdates = await client
+ .from("purchaseOrderLine")
+ .update({
+ promisedDate: value ?? undefined,
+ updatedBy: userId,
+ updatedAt: new Date().toISOString(),
+ })
+ .in("purchaseOrderId", ids as string[])
+ .is("promisedDate", null);
+
+ if (lineUpdates.error) {
+ return json(lineUpdates);
+ }
+
return json(
await client
.from("purchaseOrderDelivery")
diff --git a/apps/mes/app/services/models.ts b/apps/mes/app/services/models.ts
index 4320e08d70..d5ebfe0359 100644
--- a/apps/mes/app/services/models.ts
+++ b/apps/mes/app/services/models.ts
@@ -23,6 +23,7 @@ export const deadlineTypes = [
export const jobStatus = [
"Draft",
+ "Planned",
"Ready",
"In Progress",
"Paused",
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index ef119ab495..9c2bf470e8 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -8814,6 +8814,87 @@ export default {
tags: ["holidayYears"],
},
},
+ "/openPurchaseOrderLines": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.openPurchaseOrderLines.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openPurchaseOrderLines.purchaseOrderId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openPurchaseOrderLines.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openPurchaseOrderLines.quantityToReceive",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openPurchaseOrderLines.unitOfMeasureCode",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openPurchaseOrderLines.purchaseOrderLineType",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openPurchaseOrderLines.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openPurchaseOrderLines.locationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openPurchaseOrderLines.orderDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openPurchaseOrderLines.promisedDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openPurchaseOrderLines.replenishmentSystem",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openPurchaseOrderLines.itemTrackingType",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openPurchaseOrderLines.leadTime",
+ },
+ {
+ $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/openPurchaseOrderLines",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["openPurchaseOrderLines"],
+ },
+ },
"/supplierPart": {
get: {
parameters: [
@@ -9963,6 +10044,204 @@ export default {
tags: ["quoteOperationAttribute"],
},
},
+ "/supplyForecast": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.locationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.periodId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.forecastQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.forecastMethod",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.confidence",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.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/supplyForecast",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["supplyForecast"],
+ },
+ post: {
+ parameters: [
+ {
+ $ref: "#/parameters/body.supplyForecast",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/preferPost",
+ },
+ ],
+ responses: {
+ "201": {
+ description: "Created",
+ },
+ },
+ tags: ["supplyForecast"],
+ },
+ delete: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.locationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.periodId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.forecastQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.forecastMethod",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.confidence",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.updatedBy",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["supplyForecast"],
+ },
+ patch: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.locationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.periodId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.forecastQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.forecastMethod",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.confidence",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.supplyForecast.updatedBy",
+ },
+ {
+ $ref: "#/parameters/body.supplyForecast",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["supplyForecast"],
+ },
+ },
"/jobs": {
get: {
parameters: [
@@ -20043,6 +20322,78 @@ export default {
tags: ["salesOrderFavorite"],
},
},
+ "/openProductionOrders": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.openProductionOrders.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openProductionOrders.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openProductionOrders.quantityToReceive",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openProductionOrders.unitOfMeasureCode",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openProductionOrders.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openProductionOrders.replenishmentSystem",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openProductionOrders.itemTrackingType",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openProductionOrders.leadTime",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openProductionOrders.locationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.openProductionOrders.dueDate",
+ },
+ {
+ $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/openProductionOrders",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["openProductionOrders"],
+ },
+ },
"/purchaseOrderLine": {
get: {
parameters: [
@@ -20181,6 +20532,9 @@ export default {
{
$ref: "#/parameters/rowFilter.purchaseOrderLine.quantityShipped",
},
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.promisedDate",
+ },
{
$ref: "#/parameters/select",
},
@@ -20375,6 +20729,9 @@ export default {
{
$ref: "#/parameters/rowFilter.purchaseOrderLine.quantityShipped",
},
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.promisedDate",
+ },
{
$ref: "#/parameters/preferReturn",
},
@@ -20523,6 +20880,9 @@ export default {
{
$ref: "#/parameters/rowFilter.purchaseOrderLine.quantityShipped",
},
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderLine.promisedDate",
+ },
{
$ref: "#/parameters/body.purchaseOrderLine",
},
@@ -44379,206 +44739,41 @@ export default {
tags: ["purchaseOrderPayment"],
},
},
- "/apiKey": {
+ "/supplyActual": {
get: {
parameters: [
{
- $ref: "#/parameters/rowFilter.apiKey.id",
+ $ref: "#/parameters/rowFilter.supplyActual.itemId",
},
{
- $ref: "#/parameters/rowFilter.apiKey.name",
+ $ref: "#/parameters/rowFilter.supplyActual.locationId",
},
{
- $ref: "#/parameters/rowFilter.apiKey.key",
+ $ref: "#/parameters/rowFilter.supplyActual.periodId",
},
{
- $ref: "#/parameters/rowFilter.apiKey.companyId",
+ $ref: "#/parameters/rowFilter.supplyActual.actualQuantity",
},
{
- $ref: "#/parameters/rowFilter.apiKey.createdBy",
+ $ref: "#/parameters/rowFilter.supplyActual.sourceType",
},
{
- $ref: "#/parameters/rowFilter.apiKey.createdAt",
+ $ref: "#/parameters/rowFilter.supplyActual.notes",
},
{
- $ref: "#/parameters/select",
+ $ref: "#/parameters/rowFilter.supplyActual.companyId",
},
{
- $ref: "#/parameters/order",
+ $ref: "#/parameters/rowFilter.supplyActual.createdBy",
},
{
- $ref: "#/parameters/range",
+ $ref: "#/parameters/rowFilter.supplyActual.createdAt",
},
{
- $ref: "#/parameters/rangeUnit",
- },
- {
- $ref: "#/parameters/offset",
- },
- {
- $ref: "#/parameters/limit",
- },
- {
- $ref: "#/parameters/preferCount",
- },
- ],
- responses: {
- "200": {
- description: "OK",
- schema: {
- items: {
- $ref: "#/definitions/apiKey",
- },
- type: "array",
- },
- },
- "206": {
- description: "Partial Content",
+ $ref: "#/parameters/rowFilter.supplyActual.updatedAt",
},
- },
- tags: ["apiKey"],
- },
- post: {
- parameters: [
{
- $ref: "#/parameters/body.apiKey",
- },
- {
- $ref: "#/parameters/select",
- },
- {
- $ref: "#/parameters/preferPost",
- },
- ],
- responses: {
- "201": {
- description: "Created",
- },
- },
- tags: ["apiKey"],
- },
- delete: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.apiKey.id",
- },
- {
- $ref: "#/parameters/rowFilter.apiKey.name",
- },
- {
- $ref: "#/parameters/rowFilter.apiKey.key",
- },
- {
- $ref: "#/parameters/rowFilter.apiKey.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.apiKey.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.apiKey.createdAt",
- },
- {
- $ref: "#/parameters/preferReturn",
- },
- ],
- responses: {
- "204": {
- description: "No Content",
- },
- },
- tags: ["apiKey"],
- },
- patch: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.apiKey.id",
- },
- {
- $ref: "#/parameters/rowFilter.apiKey.name",
- },
- {
- $ref: "#/parameters/rowFilter.apiKey.key",
- },
- {
- $ref: "#/parameters/rowFilter.apiKey.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.apiKey.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.apiKey.createdAt",
- },
- {
- $ref: "#/parameters/body.apiKey",
- },
- {
- $ref: "#/parameters/preferReturn",
- },
- ],
- responses: {
- "204": {
- description: "No Content",
- },
- },
- tags: ["apiKey"],
- },
- },
- "/purchaseOrderDelivery": {
- get: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.id",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.locationId",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.shippingMethodId",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.shippingTermId",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.receiptRequestedDate",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.receiptPromisedDate",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.deliveryDate",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.notes",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.trackingNumber",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.dropShipment",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customerId",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customerLocationId",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.updatedBy",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customFields",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.tags",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.supplierShippingCost",
+ $ref: "#/parameters/rowFilter.supplyActual.updatedBy",
},
{
$ref: "#/parameters/select",
@@ -44607,7 +44802,7 @@ export default {
description: "OK",
schema: {
items: {
- $ref: "#/definitions/purchaseOrderDelivery",
+ $ref: "#/definitions/supplyActual",
},
type: "array",
},
@@ -44616,12 +44811,12 @@ export default {
description: "Partial Content",
},
},
- tags: ["purchaseOrderDelivery"],
+ tags: ["supplyActual"],
},
post: {
parameters: [
{
- $ref: "#/parameters/body.purchaseOrderDelivery",
+ $ref: "#/parameters/body.supplyActual",
},
{
$ref: "#/parameters/select",
@@ -44635,63 +44830,42 @@ export default {
description: "Created",
},
},
- tags: ["purchaseOrderDelivery"],
+ tags: ["supplyActual"],
},
delete: {
parameters: [
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.id",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.locationId",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.shippingMethodId",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.shippingTermId",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.receiptRequestedDate",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.receiptPromisedDate",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.deliveryDate",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.notes",
+ $ref: "#/parameters/rowFilter.supplyActual.itemId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.trackingNumber",
+ $ref: "#/parameters/rowFilter.supplyActual.locationId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.dropShipment",
+ $ref: "#/parameters/rowFilter.supplyActual.periodId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customerId",
+ $ref: "#/parameters/rowFilter.supplyActual.actualQuantity",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customerLocationId",
+ $ref: "#/parameters/rowFilter.supplyActual.sourceType",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.companyId",
+ $ref: "#/parameters/rowFilter.supplyActual.notes",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.updatedBy",
+ $ref: "#/parameters/rowFilter.supplyActual.companyId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.updatedAt",
+ $ref: "#/parameters/rowFilter.supplyActual.createdBy",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customFields",
+ $ref: "#/parameters/rowFilter.supplyActual.createdAt",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.tags",
+ $ref: "#/parameters/rowFilter.supplyActual.updatedAt",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.supplierShippingCost",
+ $ref: "#/parameters/rowFilter.supplyActual.updatedBy",
},
{
$ref: "#/parameters/preferReturn",
@@ -44702,66 +44876,45 @@ export default {
description: "No Content",
},
},
- tags: ["purchaseOrderDelivery"],
+ tags: ["supplyActual"],
},
patch: {
parameters: [
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.id",
+ $ref: "#/parameters/rowFilter.supplyActual.itemId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.locationId",
+ $ref: "#/parameters/rowFilter.supplyActual.locationId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.shippingMethodId",
+ $ref: "#/parameters/rowFilter.supplyActual.periodId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.shippingTermId",
+ $ref: "#/parameters/rowFilter.supplyActual.actualQuantity",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.receiptRequestedDate",
+ $ref: "#/parameters/rowFilter.supplyActual.sourceType",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.receiptPromisedDate",
+ $ref: "#/parameters/rowFilter.supplyActual.notes",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.deliveryDate",
+ $ref: "#/parameters/rowFilter.supplyActual.companyId",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.notes",
+ $ref: "#/parameters/rowFilter.supplyActual.createdBy",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.trackingNumber",
+ $ref: "#/parameters/rowFilter.supplyActual.createdAt",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.dropShipment",
+ $ref: "#/parameters/rowFilter.supplyActual.updatedAt",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customerId",
+ $ref: "#/parameters/rowFilter.supplyActual.updatedBy",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customerLocationId",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.updatedBy",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customFields",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.tags",
- },
- {
- $ref: "#/parameters/rowFilter.purchaseOrderDelivery.supplierShippingCost",
- },
- {
- $ref: "#/parameters/body.purchaseOrderDelivery",
+ $ref: "#/parameters/body.supplyActual",
},
{
$ref: "#/parameters/preferReturn",
@@ -44772,38 +44925,434 @@ export default {
description: "No Content",
},
},
- tags: ["purchaseOrderDelivery"],
+ tags: ["supplyActual"],
},
},
- "/note": {
+ "/apiKey": {
get: {
parameters: [
{
- $ref: "#/parameters/rowFilter.note.id",
- },
- {
- $ref: "#/parameters/rowFilter.note.documentId",
- },
- {
- $ref: "#/parameters/rowFilter.note.note",
- },
- {
- $ref: "#/parameters/rowFilter.note.noteRichText",
+ $ref: "#/parameters/rowFilter.apiKey.id",
},
{
- $ref: "#/parameters/rowFilter.note.active",
+ $ref: "#/parameters/rowFilter.apiKey.name",
},
{
- $ref: "#/parameters/rowFilter.note.companyId",
+ $ref: "#/parameters/rowFilter.apiKey.key",
},
{
- $ref: "#/parameters/rowFilter.note.createdAt",
+ $ref: "#/parameters/rowFilter.apiKey.companyId",
},
{
- $ref: "#/parameters/rowFilter.note.createdBy",
+ $ref: "#/parameters/rowFilter.apiKey.createdBy",
},
{
- $ref: "#/parameters/rowFilter.note.updatedAt",
+ $ref: "#/parameters/rowFilter.apiKey.createdAt",
+ },
+ {
+ $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/apiKey",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["apiKey"],
+ },
+ post: {
+ parameters: [
+ {
+ $ref: "#/parameters/body.apiKey",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/preferPost",
+ },
+ ],
+ responses: {
+ "201": {
+ description: "Created",
+ },
+ },
+ tags: ["apiKey"],
+ },
+ delete: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.apiKey.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.apiKey.name",
+ },
+ {
+ $ref: "#/parameters/rowFilter.apiKey.key",
+ },
+ {
+ $ref: "#/parameters/rowFilter.apiKey.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.apiKey.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.apiKey.createdAt",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["apiKey"],
+ },
+ patch: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.apiKey.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.apiKey.name",
+ },
+ {
+ $ref: "#/parameters/rowFilter.apiKey.key",
+ },
+ {
+ $ref: "#/parameters/rowFilter.apiKey.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.apiKey.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.apiKey.createdAt",
+ },
+ {
+ $ref: "#/parameters/body.apiKey",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["apiKey"],
+ },
+ },
+ "/purchaseOrderDelivery": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.locationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.shippingMethodId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.shippingTermId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.receiptRequestedDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.receiptPromisedDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.deliveryDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.trackingNumber",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.dropShipment",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customerId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customerLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.updatedBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customFields",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.tags",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.supplierShippingCost",
+ },
+ {
+ $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/purchaseOrderDelivery",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["purchaseOrderDelivery"],
+ },
+ post: {
+ parameters: [
+ {
+ $ref: "#/parameters/body.purchaseOrderDelivery",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/preferPost",
+ },
+ ],
+ responses: {
+ "201": {
+ description: "Created",
+ },
+ },
+ tags: ["purchaseOrderDelivery"],
+ },
+ delete: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.locationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.shippingMethodId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.shippingTermId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.receiptRequestedDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.receiptPromisedDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.deliveryDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.trackingNumber",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.dropShipment",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customerId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customerLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.updatedBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customFields",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.tags",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.supplierShippingCost",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["purchaseOrderDelivery"],
+ },
+ patch: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.locationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.shippingMethodId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.shippingTermId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.receiptRequestedDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.receiptPromisedDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.deliveryDate",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.trackingNumber",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.dropShipment",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customerId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customerLocationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.updatedBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.customFields",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.tags",
+ },
+ {
+ $ref: "#/parameters/rowFilter.purchaseOrderDelivery.supplierShippingCost",
+ },
+ {
+ $ref: "#/parameters/body.purchaseOrderDelivery",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["purchaseOrderDelivery"],
+ },
+ },
+ "/note": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.note.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.note.documentId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.note.note",
+ },
+ {
+ $ref: "#/parameters/rowFilter.note.noteRichText",
+ },
+ {
+ $ref: "#/parameters/rowFilter.note.active",
+ },
+ {
+ $ref: "#/parameters/rowFilter.note.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.note.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.note.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.note.updatedAt",
},
{
$ref: "#/parameters/select",
@@ -59882,6 +60431,81 @@ export default {
},
type: "object",
},
+ openPurchaseOrderLines: {
+ properties: {
+ id: {
+ description: "Note:\nThis is a Primary Key.<pk/>",
+ format: "text",
+ type: "string",
+ },
+ purchaseOrderId: {
+ description:
+ "Note:\nThis is a Foreign Key to `purchaseOrder.id`.<fk table='purchaseOrder' 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",
+ },
+ quantityToReceive: {
+ format: "numeric",
+ type: "number",
+ },
+ unitOfMeasureCode: {
+ format: "text",
+ type: "string",
+ },
+ purchaseOrderLineType: {
+ enum: [
+ "Comment",
+ "G/L Account",
+ "Fixed Asset",
+ "Part",
+ "Material",
+ "Tool",
+ "Service",
+ "Consumable",
+ "Fixture",
+ ],
+ format: 'public."purchaseOrderLineType"',
+ type: "string",
+ },
+ companyId: {
+ format: "text",
+ type: "string",
+ },
+ locationId: {
+ format: "text",
+ type: "string",
+ },
+ orderDate: {
+ format: "date",
+ type: "string",
+ },
+ promisedDate: {
+ format: "date",
+ type: "string",
+ },
+ replenishmentSystem: {
+ enum: ["Buy", "Make", "Buy and Make"],
+ format: 'public."itemReplenishmentSystem"',
+ type: "string",
+ },
+ itemTrackingType: {
+ enum: ["Inventory", "Non-Inventory", "Serial", "Batch"],
+ format: 'public."itemTrackingType"',
+ type: "string",
+ },
+ leadTime: {
+ format: "integer",
+ type: "integer",
+ },
+ },
+ type: "object",
+ },
supplierPart: {
required: [
"id",
@@ -60349,6 +60973,85 @@ export default {
},
type: "object",
},
+ supplyForecast: {
+ required: [
+ "itemId",
+ "locationId",
+ "periodId",
+ "forecastQuantity",
+ "companyId",
+ "createdBy",
+ "createdAt",
+ "updatedAt",
+ "updatedBy",
+ ],
+ properties: {
+ itemId: {
+ description:
+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ locationId: {
+ description:
+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `location.id`.<fk table='location' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ periodId: {
+ description:
+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `period.id`.<fk table='period' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ forecastQuantity: {
+ default: 0,
+ format: "numeric",
+ type: "number",
+ },
+ forecastMethod: {
+ format: "text",
+ type: "string",
+ },
+ confidence: {
+ format: "numeric",
+ type: "number",
+ },
+ notes: {
+ format: "text",
+ type: "string",
+ },
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdAt: {
+ default: "now()",
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedAt: {
+ default: "now()",
+ 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",
+ },
jobs: {
properties: {
id: {
@@ -60392,6 +61095,7 @@ export default {
"Cancelled",
"Overdue",
"Due Today",
+ "Planned",
],
format: 'public."jobStatus"',
type: "string",
@@ -60533,6 +61237,7 @@ export default {
"Cancelled",
"Overdue",
"Due Today",
+ "Planned",
],
format: 'public."jobStatus"',
type: "string",
@@ -64294,6 +64999,7 @@ export default {
"Cancelled",
"Overdue",
"Due Today",
+ "Planned",
],
format: 'public."jobStatus"',
type: "string",
@@ -64690,6 +65396,7 @@ export default {
"To Invoice",
"Completed",
"Closed",
+ "Planned",
],
format: 'public."purchaseOrderStatus"',
type: "string",
@@ -64957,6 +65664,60 @@ export default {
},
type: "object",
},
+ openProductionOrders: {
+ properties: {
+ id: {
+ description: "Note:\nThis is a Primary Key.<pk/>",
+ format: "text",
+ type: "string",
+ },
+ itemId: {
+ description:
+ "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ quantityToReceive: {
+ format: "numeric",
+ type: "number",
+ },
+ unitOfMeasureCode: {
+ format: "text",
+ type: "string",
+ },
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ replenishmentSystem: {
+ enum: ["Buy", "Make", "Buy and Make"],
+ format: 'public."itemReplenishmentSystem"',
+ type: "string",
+ },
+ itemTrackingType: {
+ enum: ["Inventory", "Non-Inventory", "Serial", "Batch"],
+ format: 'public."itemTrackingType"',
+ type: "string",
+ },
+ leadTime: {
+ format: "integer",
+ type: "integer",
+ },
+ locationId: {
+ description:
+ "Note:\nThis is a Foreign Key to `location.id`.<fk table='location' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ dueDate: {
+ format: "date",
+ type: "string",
+ },
+ },
+ type: "object",
+ },
purchaseOrderLine: {
required: [
"id",
@@ -65193,6 +65954,10 @@ export default {
format: "numeric",
type: "number",
},
+ promisedDate: {
+ format: "date",
+ type: "string",
+ },
},
type: "object",
},
@@ -70175,6 +70940,7 @@ export default {
"To Invoice",
"Completed",
"Closed",
+ "Planned",
],
format: 'public."purchaseOrderStatus"',
type: "string",
@@ -76605,6 +77371,84 @@ export default {
},
type: "object",
},
+ supplyActual: {
+ required: [
+ "itemId",
+ "locationId",
+ "periodId",
+ "actualQuantity",
+ "sourceType",
+ "companyId",
+ "createdBy",
+ "createdAt",
+ "updatedAt",
+ "updatedBy",
+ ],
+ properties: {
+ itemId: {
+ description:
+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ locationId: {
+ description:
+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `location.id`.<fk table='location' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ periodId: {
+ description:
+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `period.id`.<fk table='period' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ actualQuantity: {
+ default: 0,
+ format: "numeric",
+ type: "number",
+ },
+ sourceType: {
+ description: "Note:\nThis is a Primary Key.<pk/>",
+ enum: ["Purchase Order", "Production Order"],
+ format: 'public."supplySourceType"',
+ type: "string",
+ },
+ notes: {
+ format: "text",
+ type: "string",
+ },
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdAt: {
+ default: "now()",
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedAt: {
+ default: "now()",
+ 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",
+ },
apiKey: {
required: ["id", "name", "key", "companyId", "createdBy", "createdAt"],
properties: {
@@ -76967,6 +77811,7 @@ export default {
"To Invoice",
"Completed",
"Closed",
+ "Planned",
],
format: 'public."purchaseOrderStatus"',
type: "string",
@@ -84568,6 +85413,93 @@ export default {
in: "query",
type: "string",
},
+ "body.openPurchaseOrderLines": {
+ name: "openPurchaseOrderLines",
+ description: "openPurchaseOrderLines",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/openPurchaseOrderLines",
+ },
+ },
+ "rowFilter.openPurchaseOrderLines.id": {
+ name: "id",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openPurchaseOrderLines.purchaseOrderId": {
+ name: "purchaseOrderId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openPurchaseOrderLines.itemId": {
+ name: "itemId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openPurchaseOrderLines.quantityToReceive": {
+ name: "quantityToReceive",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openPurchaseOrderLines.unitOfMeasureCode": {
+ name: "unitOfMeasureCode",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openPurchaseOrderLines.purchaseOrderLineType": {
+ name: "purchaseOrderLineType",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openPurchaseOrderLines.companyId": {
+ name: "companyId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openPurchaseOrderLines.locationId": {
+ name: "locationId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openPurchaseOrderLines.orderDate": {
+ name: "orderDate",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openPurchaseOrderLines.promisedDate": {
+ name: "promisedDate",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openPurchaseOrderLines.replenishmentSystem": {
+ name: "replenishmentSystem",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openPurchaseOrderLines.itemTrackingType": {
+ name: "itemTrackingType",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openPurchaseOrderLines.leadTime": {
+ name: "leadTime",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.supplierPart": {
name: "supplierPart",
description: "supplierPart",
@@ -85072,6 +86004,87 @@ export default {
in: "query",
type: "string",
},
+ "body.supplyForecast": {
+ name: "supplyForecast",
+ description: "supplyForecast",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/supplyForecast",
+ },
+ },
+ "rowFilter.supplyForecast.itemId": {
+ name: "itemId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyForecast.locationId": {
+ name: "locationId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyForecast.periodId": {
+ name: "periodId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyForecast.forecastQuantity": {
+ name: "forecastQuantity",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyForecast.forecastMethod": {
+ name: "forecastMethod",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyForecast.confidence": {
+ name: "confidence",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyForecast.notes": {
+ name: "notes",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyForecast.companyId": {
+ name: "companyId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyForecast.createdBy": {
+ name: "createdBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyForecast.createdAt": {
+ name: "createdAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyForecast.updatedAt": {
+ name: "updatedAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyForecast.updatedBy": {
+ name: "updatedBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.jobs": {
name: "jobs",
description: "jobs",
@@ -90253,6 +91266,75 @@ export default {
in: "query",
type: "string",
},
+ "body.openProductionOrders": {
+ name: "openProductionOrders",
+ description: "openProductionOrders",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/openProductionOrders",
+ },
+ },
+ "rowFilter.openProductionOrders.id": {
+ name: "id",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openProductionOrders.itemId": {
+ name: "itemId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openProductionOrders.quantityToReceive": {
+ name: "quantityToReceive",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openProductionOrders.unitOfMeasureCode": {
+ name: "unitOfMeasureCode",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openProductionOrders.companyId": {
+ name: "companyId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openProductionOrders.replenishmentSystem": {
+ name: "replenishmentSystem",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openProductionOrders.itemTrackingType": {
+ name: "itemTrackingType",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openProductionOrders.leadTime": {
+ name: "leadTime",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openProductionOrders.locationId": {
+ name: "locationId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.openProductionOrders.dueDate": {
+ name: "dueDate",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.purchaseOrderLine": {
name: "purchaseOrderLine",
description: "purchaseOrderLine",
@@ -90532,6 +91614,12 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.purchaseOrderLine.promisedDate": {
+ name: "promisedDate",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.accountDefault": {
name: "accountDefault",
description: "accountDefault",
@@ -103456,6 +104544,81 @@ export default {
in: "query",
type: "string",
},
+ "body.supplyActual": {
+ name: "supplyActual",
+ description: "supplyActual",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/supplyActual",
+ },
+ },
+ "rowFilter.supplyActual.itemId": {
+ name: "itemId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyActual.locationId": {
+ name: "locationId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyActual.periodId": {
+ name: "periodId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyActual.actualQuantity": {
+ name: "actualQuantity",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyActual.sourceType": {
+ name: "sourceType",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyActual.notes": {
+ name: "notes",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyActual.companyId": {
+ name: "companyId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyActual.createdBy": {
+ name: "createdBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyActual.createdAt": {
+ name: "createdAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyActual.updatedAt": {
+ name: "updatedAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.supplyActual.updatedBy": {
+ name: "updatedBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.apiKey": {
name: "apiKey",
description: "apiKey",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 416f9909c3..07b2350428 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -6698,6 +6698,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "fulfillment_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "fulfillment_salesOrderLineId_fkey"
columns: ["salesOrderLineId"]
@@ -9400,6 +9407,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobFavorites_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobFavorites_userId_fkey"
columns: ["userId"]
@@ -9602,6 +9616,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobMakeMethod_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobMakeMethod_parentMaterialId_fkey"
columns: ["parentMaterialId"]
@@ -9871,6 +9892,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobMaterial_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobMaterial_jobMakeMethodId_fkey"
columns: ["jobMakeMethodId"]
@@ -10197,6 +10225,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobOperation_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobOperation_jobMakeMethodId_fkey"
columns: ["jobMakeMethodId"]
@@ -10708,6 +10743,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobOperationDependency_jobId_fk"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobOperationDependency_operationId_fk"
columns: ["operationId"]
@@ -14443,6 +14485,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "nonConformanceJobOperation_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "nonConformanceJobOperation_jobOperationId_fkey"
columns: ["jobOperationId"]
@@ -14637,6 +14686,13 @@ export type Database = {
referencedRelation: "purchaseOrders"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "nonConformancePurchaseOrderLine_purchaseOrderLineId_fkey"
+ columns: ["purchaseOrderLineId"]
+ isOneToOne: false
+ referencedRelation: "openPurchaseOrderLines"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "nonConformancePurchaseOrderLine_purchaseOrderLineId_fkey"
columns: ["purchaseOrderLineId"]
@@ -19759,6 +19815,13 @@ export type Database = {
referencedRelation: "purchaseOrders"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "purchaseInvoiceLines_purchaseOrderLineId_fkey"
+ columns: ["purchaseOrderLineId"]
+ isOneToOne: false
+ referencedRelation: "openPurchaseOrderLines"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "purchaseInvoiceLines_purchaseOrderLineId_fkey"
columns: ["purchaseOrderLineId"]
@@ -20243,6 +20306,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "purchaseOrder_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "purchaseOrder_supplierContactId_fkey"
columns: ["supplierContactId"]
@@ -20600,6 +20670,7 @@ export type Database = {
jobOperationId: string | null
locationId: string | null
modelUploadId: string | null
+ promisedDate: string | null
purchaseOrderId: string
purchaseOrderLineType: Database["public"]["Enums"]["purchaseOrderLineType"]
purchaseQuantity: number | null
@@ -20647,6 +20718,7 @@ export type Database = {
jobOperationId?: string | null
locationId?: string | null
modelUploadId?: string | null
+ promisedDate?: string | null
purchaseOrderId: string
purchaseOrderLineType: Database["public"]["Enums"]["purchaseOrderLineType"]
purchaseQuantity?: number | null
@@ -20694,6 +20766,7 @@ export type Database = {
jobOperationId?: string | null
locationId?: string | null
modelUploadId?: string | null
+ promisedDate?: string | null
purchaseOrderId?: string
purchaseOrderLineType?: Database["public"]["Enums"]["purchaseOrderLineType"]
purchaseQuantity?: number | null
@@ -20825,6 +20898,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "purchaseOrderLine_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "purchaseOrderLine_jobOperationId_fkey"
columns: ["jobOperationId"]
@@ -31332,6 +31412,389 @@ export type Database = {
},
]
}
+ supplyActual: {
+ Row: {
+ actualQuantity: number
+ companyId: string
+ createdAt: string
+ createdBy: string
+ itemId: string
+ locationId: string
+ notes: string | null
+ periodId: string
+ sourceType: Database["public"]["Enums"]["supplySourceType"]
+ updatedAt: string
+ updatedBy: string
+ }
+ Insert: {
+ actualQuantity?: number
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ itemId: string
+ locationId: string
+ notes?: string | null
+ periodId: string
+ sourceType: Database["public"]["Enums"]["supplySourceType"]
+ updatedAt?: string
+ updatedBy: string
+ }
+ Update: {
+ actualQuantity?: number
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ itemId?: string
+ locationId?: string
+ notes?: string | null
+ periodId?: string
+ sourceType?: Database["public"]["Enums"]["supplySourceType"]
+ updatedAt?: string
+ updatedBy?: string
+ }
+ Relationships: [
+ {
+ foreignKeyName: "supplyActual_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "supplyActual_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "supplyActual_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "supplyActual_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_periodId_fkey"
+ columns: ["periodId"]
+ isOneToOne: false
+ referencedRelation: "period"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
+ supplyForecast: {
+ Row: {
+ companyId: string
+ confidence: number | null
+ createdAt: string
+ createdBy: string
+ forecastMethod: string | null
+ forecastQuantity: number
+ itemId: string
+ locationId: string
+ notes: string | null
+ periodId: string
+ updatedAt: string
+ updatedBy: string
+ }
+ Insert: {
+ companyId: string
+ confidence?: number | null
+ createdAt?: string
+ createdBy: string
+ forecastMethod?: string | null
+ forecastQuantity?: number
+ itemId: string
+ locationId: string
+ notes?: string | null
+ periodId: string
+ updatedAt?: string
+ updatedBy: string
+ }
+ Update: {
+ companyId?: string
+ confidence?: number | null
+ createdAt?: string
+ createdBy?: string
+ forecastMethod?: string | null
+ forecastQuantity?: number
+ itemId?: string
+ locationId?: string
+ notes?: string | null
+ periodId?: string
+ updatedAt?: string
+ updatedBy?: string
+ }
+ Relationships: [
+ {
+ foreignKeyName: "supplyForecast_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "supplyForecast_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "supplyForecast_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "supplyForecast_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_periodId_fkey"
+ columns: ["periodId"]
+ isOneToOne: false
+ referencedRelation: "period"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
tableView: {
Row: {
columnOrder: string[] | null
@@ -35867,6 +36330,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobMaterial_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobMaterial_jobMakeMethodId_fkey"
columns: ["jobMakeMethodId"]
@@ -36196,6 +36666,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobOperation_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobOperation_jobMakeMethodId_fkey"
columns: ["jobMakeMethodId"]
@@ -36446,6 +36923,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobOperation_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobOperation_jobMakeMethodId_fkey"
columns: ["jobMakeMethodId"]
@@ -37195,6 +37679,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobMaterial_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobMaterial_unitOfMeasureCode_fkey"
columns: ["unitOfMeasureCode", "companyId"]
@@ -37204,6 +37695,184 @@ export type Database = {
},
]
}
+ openProductionOrders: {
+ Row: {
+ companyId: string | null
+ dueDate: string | null
+ id: string | null
+ itemId: string | null
+ itemTrackingType:
+ | Database["public"]["Enums"]["itemTrackingType"]
+ | null
+ leadTime: number | null
+ locationId: string | null
+ quantityToReceive: number | null
+ replenishmentSystem:
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | null
+ unitOfMeasureCode: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "job_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "job_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "job_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode", "companyId"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
+ },
+ ]
+ }
+ openPurchaseOrderLines: {
+ Row: {
+ companyId: string | null
+ id: string | null
+ itemId: string | null
+ itemTrackingType:
+ | Database["public"]["Enums"]["itemTrackingType"]
+ | null
+ leadTime: number | null
+ locationId: string | null
+ orderDate: string | null
+ promisedDate: string | null
+ purchaseOrderId: string | null
+ purchaseOrderLineType:
+ | Database["public"]["Enums"]["purchaseOrderLineType"]
+ | null
+ quantityToReceive: number | null
+ replenishmentSystem:
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | null
+ unitOfMeasureCode: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_purchaseOrderId_fkey"
+ columns: ["purchaseOrderId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrder"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_purchaseOrderId_fkey"
+ columns: ["purchaseOrderId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrderLocations"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_purchaseOrderId_fkey"
+ columns: ["purchaseOrderId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["id"]
+ },
+ ]
+ }
openSalesOrderLines: {
Row: {
companyId: string | null
@@ -37384,14 +38053,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -38045,6 +38714,13 @@ export type Database = {
referencedRelation: "purchaseOrders"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "purchaseInvoiceLines_purchaseOrderLineId_fkey"
+ columns: ["purchaseOrderLineId"]
+ isOneToOne: false
+ referencedRelation: "openPurchaseOrderLines"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "purchaseInvoiceLines_purchaseOrderLineId_fkey"
columns: ["purchaseOrderLineId"]
@@ -38569,6 +39245,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "purchaseOrderLine_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "purchaseOrderLine_jobOperationId_fkey"
columns: ["jobOperationId"]
@@ -38715,14 +39398,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -38929,6 +39612,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "purchaseOrder_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "purchaseOrder_supplierContactId_fkey"
columns: ["supplierContactId"]
@@ -40950,14 +41640,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -44883,6 +45573,7 @@ export type Database = {
| "Cancelled"
| "Overdue"
| "Due Today"
+ | "Planned"
journalLineDocumentType:
| "Receipt"
| "Invoice"
@@ -44999,6 +45690,7 @@ export type Database = {
| "To Invoice"
| "Completed"
| "Closed"
+ | "Planned"
purchaseOrderTransactionType:
| "Edit"
| "Favorite"
@@ -45120,6 +45812,7 @@ export type Database = {
| "Reminder"
| "Refund"
supplierQuoteStatus: "Active" | "Expired"
+ supplySourceType: "Purchase Order" | "Production Order"
tableViewType: "Public" | "Private"
trackedEntityStatus: "Available" | "Reserved" | "On Hold" | "Consumed"
trackingSource: "Purchased" | "Manufactured"
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 416f9909c3..07b2350428 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -6698,6 +6698,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "fulfillment_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "fulfillment_salesOrderLineId_fkey"
columns: ["salesOrderLineId"]
@@ -9400,6 +9407,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobFavorites_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobFavorites_userId_fkey"
columns: ["userId"]
@@ -9602,6 +9616,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobMakeMethod_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobMakeMethod_parentMaterialId_fkey"
columns: ["parentMaterialId"]
@@ -9871,6 +9892,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobMaterial_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobMaterial_jobMakeMethodId_fkey"
columns: ["jobMakeMethodId"]
@@ -10197,6 +10225,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobOperation_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobOperation_jobMakeMethodId_fkey"
columns: ["jobMakeMethodId"]
@@ -10708,6 +10743,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobOperationDependency_jobId_fk"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobOperationDependency_operationId_fk"
columns: ["operationId"]
@@ -14443,6 +14485,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "nonConformanceJobOperation_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "nonConformanceJobOperation_jobOperationId_fkey"
columns: ["jobOperationId"]
@@ -14637,6 +14686,13 @@ export type Database = {
referencedRelation: "purchaseOrders"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "nonConformancePurchaseOrderLine_purchaseOrderLineId_fkey"
+ columns: ["purchaseOrderLineId"]
+ isOneToOne: false
+ referencedRelation: "openPurchaseOrderLines"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "nonConformancePurchaseOrderLine_purchaseOrderLineId_fkey"
columns: ["purchaseOrderLineId"]
@@ -19759,6 +19815,13 @@ export type Database = {
referencedRelation: "purchaseOrders"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "purchaseInvoiceLines_purchaseOrderLineId_fkey"
+ columns: ["purchaseOrderLineId"]
+ isOneToOne: false
+ referencedRelation: "openPurchaseOrderLines"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "purchaseInvoiceLines_purchaseOrderLineId_fkey"
columns: ["purchaseOrderLineId"]
@@ -20243,6 +20306,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "purchaseOrder_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "purchaseOrder_supplierContactId_fkey"
columns: ["supplierContactId"]
@@ -20600,6 +20670,7 @@ export type Database = {
jobOperationId: string | null
locationId: string | null
modelUploadId: string | null
+ promisedDate: string | null
purchaseOrderId: string
purchaseOrderLineType: Database["public"]["Enums"]["purchaseOrderLineType"]
purchaseQuantity: number | null
@@ -20647,6 +20718,7 @@ export type Database = {
jobOperationId?: string | null
locationId?: string | null
modelUploadId?: string | null
+ promisedDate?: string | null
purchaseOrderId: string
purchaseOrderLineType: Database["public"]["Enums"]["purchaseOrderLineType"]
purchaseQuantity?: number | null
@@ -20694,6 +20766,7 @@ export type Database = {
jobOperationId?: string | null
locationId?: string | null
modelUploadId?: string | null
+ promisedDate?: string | null
purchaseOrderId?: string
purchaseOrderLineType?: Database["public"]["Enums"]["purchaseOrderLineType"]
purchaseQuantity?: number | null
@@ -20825,6 +20898,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "purchaseOrderLine_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "purchaseOrderLine_jobOperationId_fkey"
columns: ["jobOperationId"]
@@ -31332,6 +31412,389 @@ export type Database = {
},
]
}
+ supplyActual: {
+ Row: {
+ actualQuantity: number
+ companyId: string
+ createdAt: string
+ createdBy: string
+ itemId: string
+ locationId: string
+ notes: string | null
+ periodId: string
+ sourceType: Database["public"]["Enums"]["supplySourceType"]
+ updatedAt: string
+ updatedBy: string
+ }
+ Insert: {
+ actualQuantity?: number
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ itemId: string
+ locationId: string
+ notes?: string | null
+ periodId: string
+ sourceType: Database["public"]["Enums"]["supplySourceType"]
+ updatedAt?: string
+ updatedBy: string
+ }
+ Update: {
+ actualQuantity?: number
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ itemId?: string
+ locationId?: string
+ notes?: string | null
+ periodId?: string
+ sourceType?: Database["public"]["Enums"]["supplySourceType"]
+ updatedAt?: string
+ updatedBy?: string
+ }
+ Relationships: [
+ {
+ foreignKeyName: "supplyActual_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "supplyActual_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "supplyActual_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "supplyActual_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_periodId_fkey"
+ columns: ["periodId"]
+ isOneToOne: false
+ referencedRelation: "period"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyActual_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
+ supplyForecast: {
+ Row: {
+ companyId: string
+ confidence: number | null
+ createdAt: string
+ createdBy: string
+ forecastMethod: string | null
+ forecastQuantity: number
+ itemId: string
+ locationId: string
+ notes: string | null
+ periodId: string
+ updatedAt: string
+ updatedBy: string
+ }
+ Insert: {
+ companyId: string
+ confidence?: number | null
+ createdAt?: string
+ createdBy: string
+ forecastMethod?: string | null
+ forecastQuantity?: number
+ itemId: string
+ locationId: string
+ notes?: string | null
+ periodId: string
+ updatedAt?: string
+ updatedBy: string
+ }
+ Update: {
+ companyId?: string
+ confidence?: number | null
+ createdAt?: string
+ createdBy?: string
+ forecastMethod?: string | null
+ forecastQuantity?: number
+ itemId?: string
+ locationId?: string
+ notes?: string | null
+ periodId?: string
+ updatedAt?: string
+ updatedBy?: string
+ }
+ Relationships: [
+ {
+ foreignKeyName: "supplyForecast_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "supplyForecast_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "supplyForecast_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "supplyForecast_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_periodId_fkey"
+ columns: ["periodId"]
+ isOneToOne: false
+ referencedRelation: "period"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "supplyForecast_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
tableView: {
Row: {
columnOrder: string[] | null
@@ -35867,6 +36330,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobMaterial_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobMaterial_jobMakeMethodId_fkey"
columns: ["jobMakeMethodId"]
@@ -36196,6 +36666,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobOperation_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobOperation_jobMakeMethodId_fkey"
columns: ["jobMakeMethodId"]
@@ -36446,6 +36923,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobOperation_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobOperation_jobMakeMethodId_fkey"
columns: ["jobMakeMethodId"]
@@ -37195,6 +37679,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "jobMaterial_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "jobMaterial_unitOfMeasureCode_fkey"
columns: ["unitOfMeasureCode", "companyId"]
@@ -37204,6 +37695,184 @@ export type Database = {
},
]
}
+ openProductionOrders: {
+ Row: {
+ companyId: string | null
+ dueDate: string | null
+ id: string | null
+ itemId: string | null
+ itemTrackingType:
+ | Database["public"]["Enums"]["itemTrackingType"]
+ | null
+ leadTime: number | null
+ locationId: string | null
+ quantityToReceive: number | null
+ replenishmentSystem:
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | null
+ unitOfMeasureCode: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "job_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "job_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "job_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode", "companyId"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
+ },
+ ]
+ }
+ openPurchaseOrderLines: {
+ Row: {
+ companyId: string | null
+ id: string | null
+ itemId: string | null
+ itemTrackingType:
+ | Database["public"]["Enums"]["itemTrackingType"]
+ | null
+ leadTime: number | null
+ locationId: string | null
+ orderDate: string | null
+ promisedDate: string | null
+ purchaseOrderId: string | null
+ purchaseOrderLineType:
+ | Database["public"]["Enums"]["purchaseOrderLineType"]
+ | null
+ quantityToReceive: number | null
+ replenishmentSystem:
+ | Database["public"]["Enums"]["itemReplenishmentSystem"]
+ | null
+ unitOfMeasureCode: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_purchaseOrderId_fkey"
+ columns: ["purchaseOrderId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrder"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_purchaseOrderId_fkey"
+ columns: ["purchaseOrderId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrderLocations"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_purchaseOrderId_fkey"
+ columns: ["purchaseOrderId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["id"]
+ },
+ ]
+ }
openSalesOrderLines: {
Row: {
companyId: string | null
@@ -37384,14 +38053,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -38045,6 +38714,13 @@ export type Database = {
referencedRelation: "purchaseOrders"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "purchaseInvoiceLines_purchaseOrderLineId_fkey"
+ columns: ["purchaseOrderLineId"]
+ isOneToOne: false
+ referencedRelation: "openPurchaseOrderLines"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "purchaseInvoiceLines_purchaseOrderLineId_fkey"
columns: ["purchaseOrderLineId"]
@@ -38569,6 +39245,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "purchaseOrderLine_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "purchaseOrderLine_jobOperationId_fkey"
columns: ["jobOperationId"]
@@ -38715,14 +39398,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -38929,6 +39612,13 @@ export type Database = {
referencedRelation: "jobs"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "purchaseOrder_jobId_fkey"
+ columns: ["jobId"]
+ isOneToOne: false
+ referencedRelation: "openProductionOrders"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "purchaseOrder_supplierContactId_fkey"
columns: ["supplierContactId"]
@@ -40950,14 +41640,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -44883,6 +45573,7 @@ export type Database = {
| "Cancelled"
| "Overdue"
| "Due Today"
+ | "Planned"
journalLineDocumentType:
| "Receipt"
| "Invoice"
@@ -44999,6 +45690,7 @@ export type Database = {
| "To Invoice"
| "Completed"
| "Closed"
+ | "Planned"
purchaseOrderTransactionType:
| "Edit"
| "Favorite"
@@ -45120,6 +45812,7 @@ export type Database = {
| "Reminder"
| "Refund"
supplierQuoteStatus: "Active" | "Expired"
+ supplySourceType: "Purchase Order" | "Production Order"
tableViewType: "Public" | "Private"
trackedEntityStatus: "Available" | "Reserved" | "On Hold" | "Consumed"
trackingSource: "Purchased" | "Manufactured"
diff --git a/packages/database/supabase/functions/mrp/index.ts b/packages/database/supabase/functions/mrp/index.ts
index ae735dc54b..97cad2d207 100644
--- a/packages/database/supabase/functions/mrp/index.ts
+++ b/packages/database/supabase/functions/mrp/index.ts
@@ -101,6 +101,16 @@ serve(async (req: Request) => {
Map<string, Map<string, number>>
>();
+ const jobSupplyByLocationAndPeriod = new Map<
+ string,
+ Map<string, Map<string, number>>
+ >();
+
+ const purchaseOrderSupplyByLocationAndPeriod = new Map<
+ string,
+ Map<string, Map<string, number>>
+ >();
+
// Initialize locations in map
for (const location of locations.data) {
salesDemandByLocationAndPeriod.set(
@@ -113,6 +123,16 @@ serve(async (req: Request) => {
new Map<string, Map<string, number>>()
);
+ jobSupplyByLocationAndPeriod.set(
+ location.id,
+ new Map<string, Map<string, number>>()
+ );
+
+ purchaseOrderSupplyByLocationAndPeriod.set(
+ location.id,
+ new Map<string, Map<string, number>>()
+ );
+
// Initialize periods for each location
const salesLocationPeriods = salesDemandByLocationAndPeriod.get(
location.id
@@ -134,15 +154,51 @@ serve(async (req: Request) => {
);
}
}
+
+ const jobSupplyLocationPeriods = jobSupplyByLocationAndPeriod.get(
+ location.id
+ );
+ if (jobSupplyLocationPeriods) {
+ for (const period of periods) {
+ jobSupplyLocationPeriods.set(
+ period.id ?? "",
+ new Map<string, number>()
+ );
+ }
+ }
+
+ const purchaseOrderSupplyLocationPeriods =
+ purchaseOrderSupplyByLocationAndPeriod.get(location.id);
+ if (purchaseOrderSupplyLocationPeriods) {
+ for (const period of periods) {
+ purchaseOrderSupplyLocationPeriods.set(
+ period.id ?? "",
+ new Map<string, number>()
+ );
+ }
+ }
}
try {
- const [salesOrderLines, jobMaterialLines] = await Promise.all([
+ const [
+ salesOrderLines,
+ jobMaterialLines,
+ productionLines,
+ purchaseOrderLines,
+ ] = await Promise.all([
client.from("openSalesOrderLines").select("*").eq("companyId", companyId),
client
.from("openJobMaterialLines")
.select("*")
.eq("companyId", companyId),
+ client
+ .from("openProductionOrders")
+ .select("*")
+ .eq("companyId", companyId),
+ client
+ .from("openPurchaseOrderLines")
+ .select("*")
+ .eq("companyId", companyId),
]);
if (salesOrderLines.error) {
@@ -153,6 +209,14 @@ serve(async (req: Request) => {
throw new Error("No job material lines found");
}
+ if (productionLines.error) {
+ throw new Error("No job lines found");
+ }
+
+ if (purchaseOrderLines.error) {
+ throw new Error("No purchase order lines found");
+ }
+
// Group sales order lines into demand periods
for (const line of salesOrderLines.data) {
if (!line.itemId || !line.quantityToSend) continue;
@@ -225,27 +289,123 @@ serve(async (req: Request) => {
}
}
+ // Group job lines into supply periods
+ for (const line of productionLines.data) {
+ if (!line.itemId || !line.quantityToReceive) continue;
+
+ const dueDate = line.dueDate ? parseDate(line.dueDate) : today;
+
+ // If required date is before today, use first period
+ let period;
+ if (dueDate.compare(today) < 0) {
+ period = periods[0];
+ } else {
+ // Find matching period for required date
+ period = periods.find((p) => {
+ return (
+ p.startDate?.compare(dueDate) <= 0 &&
+ p.endDate?.compare(dueDate) >= 0
+ );
+ });
+ }
+
+ if (period) {
+ const locationDemand = jobSupplyByLocationAndPeriod.get(
+ line.locationId ?? ""
+ );
+ if (locationDemand) {
+ const periodDemand = locationDemand.get(period.id ?? "");
+ if (periodDemand) {
+ const currentDemand = periodDemand.get(line.itemId) ?? 0;
+ periodDemand.set(
+ line.itemId,
+ currentDemand + line.quantityToReceive
+ );
+ }
+ }
+ }
+ }
+
+ // Group job lines into supply periods
+ for (const line of purchaseOrderLines.data) {
+ if (!line.itemId || !line.quantityToReceive) continue;
+
+ const dueDate = line.promisedDate
+ ? parseDate(line.promisedDate)
+ : line.orderDate
+ ? parseDate(line.orderDate).add({ days: line.leadTime ?? 7 })
+ : today.add({ days: line.leadTime ?? 7 });
+
+ // If required date is before today, use first period
+ let period;
+ if (dueDate.compare(today) < 0) {
+ period = periods[0];
+ } else {
+ // Find matching period for required date
+ period = periods.find((p) => {
+ return (
+ p.startDate?.compare(dueDate) <= 0 &&
+ p.endDate?.compare(dueDate) >= 0
+ );
+ });
+ }
+
+ if (period) {
+ const locationDemand = purchaseOrderSupplyByLocationAndPeriod.get(
+ line.locationId ?? ""
+ );
+ if (locationDemand) {
+ const periodDemand = locationDemand.get(period.id ?? "");
+ if (periodDemand) {
+ const currentDemand = periodDemand.get(line.itemId) ?? 0;
+ periodDemand.set(
+ line.itemId,
+ currentDemand + line.quantityToReceive
+ );
+ }
+ }
+ }
+ }
+
const demandActualUpserts: Database["public"]["Tables"]["demandActual"]["Insert"][] =
[];
-
// Create a Map to store unique demand actuals by composite key
const demandActualsMap = new Map<
string,
Database["public"]["Tables"]["demandActual"]["Insert"]
>();
+ const supplyActualUpserts: Database["public"]["Tables"]["supplyActual"]["Insert"][] =
+ [];
+ const supplyActualsMap = new Map<
+ string,
+ Database["public"]["Tables"]["supplyActual"]["Insert"]
+ >();
+
// Get existing demand actuals
- const { data: existingDemandActuals, error: demandActualsError } =
- await client
+ const [
+ { data: existingDemandActuals, error: demandActualsError },
+ { data: existingSupplyActuals, error: supplyActualsError },
+ ] = await Promise.all([
+ client
.from("demandActual")
.select("*")
.in(
"periodId",
periods.map((p) => p.id ?? "")
- );
+ ),
+ client
+ .from("supplyActual")
+ .select("*")
+ .in(
+ "periodId",
+ periods.map((p) => p.id ?? "")
+ ),
+ ]);
if (demandActualsError) throw demandActualsError;
+ if (supplyActualsError) throw supplyActualsError;
// First add all existing records with quantity 0
if (existingDemandActuals) {
@@ -309,8 +469,72 @@ serve(async (req: Request) => {
}
}
+ if (existingSupplyActuals) {
+ for (const existing of existingSupplyActuals) {
+ const key = `${existing.itemId}-${existing.locationId}-${existing.periodId}-${existing.sourceType}`;
+ supplyActualsMap.set(key, {
+ itemId: existing.itemId,
+ locationId: existing.locationId,
+ periodId: existing.periodId,
+ actualQuantity: 0,
+ sourceType: existing.sourceType,
+ companyId,
+ createdBy: userId,
+ updatedBy: userId,
+ });
+ }
+ }
+
+ // Then add/update current demand for sales order lines
+ for (const [locationId, periodMap] of jobSupplyByLocationAndPeriod) {
+ for (const [periodId, itemMap] of periodMap) {
+ for (const [itemId, quantity] of itemMap) {
+ if (quantity > 0) {
+ const key = `${itemId}-${locationId}-${periodId}-Production Order`;
+ supplyActualsMap.set(key, {
+ itemId,
+ locationId,
+ periodId: periodId,
+ actualQuantity: quantity,
+ sourceType: "Production Order",
+ companyId,
+ createdBy: userId,
+ updatedBy: userId,
+ });
+ }
+ }
+ }
+ }
+
+ // Then add/update current demand for job material lines
+ for (const [
+ locationId,
+ periodMap,
+ ] of purchaseOrderSupplyByLocationAndPeriod) {
+ for (const [periodId, itemMap] of periodMap) {
+ for (const [itemId, quantity] of itemMap) {
+ if (quantity > 0) {
+ const key = `${itemId}-${locationId}-${periodId}-Purchase Order`;
+ supplyActualsMap.set(key, {
+ itemId,
+ locationId,
+ periodId: periodId,
+ actualQuantity: quantity,
+ sourceType: "Purchase Order",
+ companyId,
+ createdBy: userId,
+ updatedBy: userId,
+ });
+ }
+ }
+ }
+ }
+
+ // Then add/update current supply for job lines
+
// Convert Map values to array for upsert
demandActualUpserts.push(...demandActualsMap.values());
+ supplyActualUpserts.push(...supplyActualsMap.values());
try {
await db.transaction().execute(async (trx) => {
@@ -329,6 +553,22 @@ serve(async (req: Request) => {
)
.execute();
}
+
+ if (supplyActualUpserts.length > 0) {
+ await trx
+ .insertInto("supplyActual")
+ .values(supplyActualUpserts)
+ .onConflict((oc) =>
+ oc
+ .columns(["itemId", "locationId", "periodId", "sourceType"])
+ .doUpdateSet({
+ actualQuantity: (eb) => eb.ref("excluded.actualQuantity"),
+ updatedAt: new Date().toISOString(),
+ updatedBy: userId,
+ })
+ )
+ .execute();
+ }
});
return new Response(JSON.stringify({ success: true }), {
diff --git a/packages/database/supabase/migrations/20250610000433_demand-planning.sql b/packages/database/supabase/migrations/20250610000433_demand-planning.sql
index 12e68dc255..35d00cc49d 100644
--- a/packages/database/supabase/migrations/20250610000433_demand-planning.sql
+++ b/packages/database/supabase/migrations/20250610000433_demand-planning.sql
@@ -1,7 +1,12 @@
+ALTER TABLE "purchaseOrderLine" ADD COLUMN "promisedDate" DATE;
ALTER TABLE "jobOperation" ADD COLUMN "startDate" DATE;
ALTER TABLE "jobOperation" ADD COLUMN "dueDate" DATE;
+ALTER TYPE "jobStatus" ADD VALUE 'Planned';
+ALTER TYPE "purchaseOrderStatus" ADD VALUE 'Planned';
+COMMIT;
+
ALTER TABLE "itemPlanning" ALTER COLUMN "demandAccumulationPeriod" SET DEFAULT 30;
UPDATE "itemPlanning" SET "demandAccumulationPeriod" = 30;
@@ -15,7 +20,6 @@ WHERE "purchasingLeadTime" IS NOT NULL;
ALTER TABLE "itemReplenishment" DROP COLUMN "purchasingLeadTime";
--- Demand Planning Tables
-- Enum types
CREATE TYPE "periodType" AS ENUM ('Week', 'Day', 'Month');
@@ -37,7 +41,7 @@ CREATE TABLE "demandForecast" (
"itemId" TEXT NOT NULL,
"locationId" TEXT,
"periodId" TEXT NOT NULL,
- "forecastQuantity" NUMERIC(15,5) NOT NULL DEFAULT 0,
+ "forecastQuantity" NUMERIC NOT NULL DEFAULT 0,
"forecastMethod" TEXT, -- 'manual', 'statistical', 'ml', etc.
"confidence" NUMERIC(3,2), -- 0.00 to 1.00
"notes" TEXT,
@@ -61,7 +65,7 @@ CREATE TABLE "demandActual" (
"itemId" TEXT NOT NULL,
"locationId" TEXT,
"periodId" TEXT NOT NULL,
- "actualQuantity" NUMERIC(15,5) NOT NULL DEFAULT 0,
+ "actualQuantity" NUMERIC NOT NULL DEFAULT 0,
"sourceType" "demandSourceType" NOT NULL,
"notes" TEXT,
"companyId" TEXT NOT NULL,
@@ -79,6 +83,55 @@ CREATE TABLE "demandActual" (
CONSTRAINT "demandActual_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON DELETE RESTRICT
);
+ -- Supply forecasts table for estimates
+CREATE TABLE "supplyForecast" (
+ "itemId" TEXT NOT NULL,
+ "locationId" TEXT,
+ "periodId" TEXT NOT NULL,
+ "forecastQuantity" NUMERIC NOT NULL DEFAULT 0,
+ "forecastMethod" TEXT, -- 'manual', 'statistical', 'ml', etc.
+ "confidence" NUMERIC(3,2), -- 0.00 to 1.00
+ "notes" TEXT,
+ "companyId" TEXT NOT NULL,
+ "createdBy" TEXT NOT NULL,
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "updatedBy" TEXT NOT NULL,
+
+ CONSTRAINT "supplyForecast_pkey" PRIMARY KEY ("itemId", "locationId", "periodId"),
+ CONSTRAINT "supplyForecast_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE,
+ CONSTRAINT "supplyForecast_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location"("id") ON DELETE CASCADE,
+ CONSTRAINT "supplyForecast_periodId_fkey" FOREIGN KEY ("periodId") REFERENCES "period"("id") ON DELETE CASCADE,
+ CONSTRAINT "supplyForecast_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE,
+ CONSTRAINT "supplyForecast_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON DELETE RESTRICT,
+ CONSTRAINT "supplyForecast_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON DELETE RESTRICT
+);
+
+CREATE TYPE "supplySourceType" AS ENUM ('Purchase Order', 'Production Order');
+
+-- Supply actuals table for historical data
+CREATE TABLE "supplyActual" (
+ "itemId" TEXT NOT NULL,
+ "locationId" TEXT,
+ "periodId" TEXT NOT NULL,
+ "actualQuantity" NUMERIC NOT NULL DEFAULT 0,
+ "sourceType" "supplySourceType" NOT NULL,
+ "notes" TEXT,
+ "companyId" TEXT NOT NULL,
+ "createdBy" TEXT NOT NULL,
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "updatedBy" TEXT NOT NULL,
+
+ CONSTRAINT "supplyActual_pkey" PRIMARY KEY ("itemId", "locationId", "periodId", "sourceType"),
+ CONSTRAINT "supplyActual_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE,
+ CONSTRAINT "supplyActual_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location"("id") ON DELETE CASCADE,
+ CONSTRAINT "supplyActual_periodId_fkey" FOREIGN KEY ("periodId") REFERENCES "period"("id") ON DELETE CASCADE,
+ CONSTRAINT "supplyActual_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE,
+ CONSTRAINT "supplyActual_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON DELETE RESTRICT,
+ CONSTRAINT "supplyActual_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON DELETE RESTRICT
+);
+
-- Indexes for performance
CREATE INDEX "period_startDate_endDate_idx" ON "period" ("periodType", "startDate", "endDate");
@@ -86,14 +139,19 @@ CREATE INDEX "period_startDate_idx" ON "period" ("periodType","startDate");
CREATE INDEX "period_endDate_idx" ON "period" ("periodType", "endDate");
CREATE INDEX "demandForecast_itemId_locationId_periodId_idx" ON "demandForecast" ("itemId", "locationId", "periodId");
-CREATE INDEX "demandForecast_createdAt_idx" ON "demandForecast" ("createdAt");
+
+CREATE INDEX "demandForecast_companyId_idx" ON "demandForecast" ("companyId");
CREATE INDEX "demandActual_itemId_locationId_periodId_idx" ON "demandActual" ("itemId", "locationId", "periodId");
-CREATE INDEX "demandActual_createdAt_idx" ON "demandActual" ("createdAt");
+CREATE INDEX "demandActual_companyId_idx" ON "demandActual" ("companyId");
+
+CREATE INDEX "supplyForecast_itemId_locationId_periodId_idx" ON "supplyForecast" ("itemId", "locationId", "periodId");
+CREATE INDEX "supplyForecast_companyId_idx" ON "supplyForecast" ("companyId");
--- Unique constraints to prevent duplicate forecasts/actuals for same item/location/period
-CREATE UNIQUE INDEX "demandForecast_unique_item_location_period_idx" ON "demandForecast" ("itemId", COALESCE("locationId", ''), "periodId");
+CREATE INDEX "supplyActual_itemId_locationId_periodId_idx" ON "supplyActual" ("itemId", "locationId", "periodId");
+CREATE INDEX "supplyActual_companyId_idx" ON "supplyActual" ("companyId");
+DROP VIEW IF EXISTS "openSalesOrderLines";
CREATE OR REPLACE VIEW "openSalesOrderLines" AS (
SELECT
sol."id",
@@ -119,6 +177,7 @@ CREATE OR REPLACE VIEW "openSalesOrderLines" AS (
AND so."status" IN ('To Ship', 'To Ship and Invoice')
);
+DROP VIEW IF EXISTS "openJobMaterialLines";
CREATE OR REPLACE VIEW "openJobMaterialLines" AS (
SELECT
jm."id",
@@ -138,7 +197,7 @@ CREATE OR REPLACE VIEW "openJobMaterialLines" AS (
INNER JOIN "item" i2 ON j."itemId" = i2."id"
INNER JOIN "itemReplenishment" ir ON i2."id" = ir."itemId"
WHERE j."status" IN (
- 'Draft',
+ 'Planned',
'Ready',
'In Progress',
'Paused'
@@ -146,6 +205,56 @@ CREATE OR REPLACE VIEW "openJobMaterialLines" AS (
AND jm."methodType" != 'Make'
);
+DROP VIEW IF EXISTS "openProductionOrders";
+CREATE OR REPLACE VIEW "openProductionOrders" AS (
+ SELECT
+ j."id",
+ j."itemId",
+ j."productionQuantity" - j."quantityReceivedToInventory" AS "quantityToReceive",
+ j."unitOfMeasureCode",
+ j."companyId",
+ i."replenishmentSystem",
+ i."itemTrackingType",
+ ir."leadTime" AS "leadTime",
+ j."locationId",
+ j."dueDate"
+ FROM "job" j
+ INNER JOIN "item" i ON j."itemId" = i."id"
+ INNER JOIN "itemReplenishment" ir ON i."id" = ir."itemId"
+ WHERE j."status" IN (
+ 'Planned',
+ 'Ready',
+ 'In Progress',
+ 'Paused'
+ )
+ AND j."salesOrderId" IS NULL
+);
+
+DROP VIEW IF EXISTS "openPurchaseOrderLines";
+CREATE OR REPLACE VIEW "openPurchaseOrderLines" AS (
+ SELECT
+ pol."id",
+ pol."purchaseOrderId",
+ pol."itemId",
+ pol."quantityToReceive" * pol."conversionFactor" AS "quantityToReceive",
+ i."unitOfMeasureCode",
+ pol."purchaseOrderLineType",
+ pol."companyId",
+ pol."locationId",
+ po."orderDate",
+ COALESCE(pol."promisedDate", pod."receiptPromisedDate") AS "promisedDate",
+ i."replenishmentSystem",
+ i."itemTrackingType",
+ ir."leadTime" AS "leadTime"
+ FROM "purchaseOrderLine" pol
+ INNER JOIN "purchaseOrder" po ON pol."purchaseOrderId" = po."id"
+ INNER JOIN "purchaseOrderDelivery" pod ON pod."id" = po."id"
+ INNER JOIN "item" i ON pol."itemId" = i."id"
+ INNER JOIN "itemReplenishment" ir ON i."id" = ir."itemId"
+ WHERE
+ pol."purchaseOrderLineType" != 'Service'
+ AND po."status" IN ('To Receive', 'To Receive and Invoice', 'Planned')
+);
DROP FUNCTION IF EXISTS get_inventory_quantities;
CREATE OR REPLACE FUNCTION get_inventory_quantities(company_id TEXT, location_id TEXT)
@@ -182,6 +291,7 @@ WITH
ON pol."purchaseOrderId" = po."id"
WHERE
po."status" IN (
+ 'Planned',
'To Receive',
'To Receive and Invoice'
)
@@ -216,7 +326,7 @@ WITH
FROM "jobMaterial" jm
INNER JOIN "job" j ON jm."jobId" = j."id"
WHERE j."status" IN (
- 'Draft',
+ 'Planned',
'Ready',
'In Progress',
'Paused'
@@ -230,7 +340,7 @@ WITH
SUM(j."productionQuantity" + j."scrapQuantity" - j."quantityReceivedToInventory" - j."quantityShipped") AS "quantityOnProductionOrder"
FROM job j
WHERE j."status" IN (
- 'Draft',
+ 'Planned',
'Ready',
'In Progress',
'Paused'
diff --git a/packages/react/src/SplitButton.tsx b/packages/react/src/SplitButton.tsx
index b215f8e52d..a69a4e09b8 100644
--- a/packages/react/src/SplitButton.tsx
+++ b/packages/react/src/SplitButton.tsx
@@ -1,5 +1,5 @@
-import { LuChevronDown } from "react-icons/lu";
import { forwardRef } from "react";
+import { LuChevronDown } from "react-icons/lu";
import { Button } from "./Button";
import {
DropdownMenu,
@@ -12,12 +12,14 @@ import { cn } from "./utils/cn";
interface SplitButtonProps {
children: React.ReactNode;
- onClick?: () => void;
leftIcon?: React.ReactElement;
variant?: "primary" | "secondary" | "ghost" | "destructive";
size?: "sm" | "md" | "lg";
disabled?: boolean;
className?: string;
+ isLoading?: boolean;
+ isDisabled?: boolean;
+ onClick?: () => void;
dropdownItems: {
label: string;
onClick: () => void;
@@ -33,7 +35,8 @@ const SplitButton = forwardRef<HTMLButtonElement, SplitButtonProps>(
leftIcon,
variant = "primary",
size,
- disabled,
+ isLoading,
+ isDisabled,
className,
dropdownItems,
},
@@ -47,7 +50,8 @@ const SplitButton = forwardRef<HTMLButtonElement, SplitButtonProps>(
leftIcon={leftIcon}
variant={variant}
size={size}
- disabled={disabled}
+ isLoading={isLoading}
+ isDisabled={isDisabled}
className={`rounded-r-none before:rounded-r-none ${className || ""}`}
>
{children}
@@ -57,11 +61,11 @@ const SplitButton = forwardRef<HTMLButtonElement, SplitButtonProps>(
<Button
variant={variant}
size={size}
- disabled={disabled}
+ isDisabled={isDisabled}
className={cn(
- "rounded-l-none border-l px-1 before:rounded-l-none border-none shadow-none hover:shadow-button-base",
+ "rounded-l-none border-l px-1 before:rounded-l-none border-none shadow-none",
variant === "primary" &&
- "shadow-[inset_0px_0.5px_0px_rgb(255_255_255_/_0.32)]"
+ "dark:shadow-[inset_0px_0.5px_0px_rgb(255_255_255_/_0.32)] dark:hover:shadow-button-primary"
)}
>
<LuChevronDown />