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 setting for completing 1 or all with a scan

Brad Barbina4c5d4812126
diff --git a/apps/erp/app/modules/resources/resources.models.ts b/apps/erp/app/modules/resources/resources.models.ts
index b5ddfd4c4f..85f6f74f40 100644
--- a/apps/erp/app/modules/resources/resources.models.ts
+++ b/apps/erp/app/modules/resources/resources.models.ts
@@ -103,6 +103,7 @@ export const processValidator = z
workCenters: z
.array(z.string().min(1, { message: "Invalid work center" }))
.optional(),
+ completeAllOnScan: zfd.checkbox(),
})
.refine((data) => {
if (data.processType !== "Outside" && !data.workCenters) {
diff --git a/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx b/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx
index 98446f9373..1d37462a80 100644
--- a/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx
+++ b/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx
@@ -31,6 +31,7 @@ import {
import type { z } from "zod";
import { SupplierAvatar } from "~/components";
import {
+ Boolean,
CustomFormFields,
Hidden,
Input,
@@ -138,6 +139,11 @@ const ProcessForm = ({
{processType !== "Inside" && (
<SupplierProcesses processId={initialValues.id} />
)}
+ <Boolean
+ name="completeAllOnScan"
+ label=""
+ description="Complete all quantities on barcode scan"
+ />
<CustomFormFields table="process" />
</VStack>
</ModalDrawerBody>
diff --git a/apps/erp/app/modules/resources/ui/Processes/ProcessesTable.tsx b/apps/erp/app/modules/resources/ui/Processes/ProcessesTable.tsx
index f900cba49a..2ccf817353 100644
--- a/apps/erp/app/modules/resources/ui/Processes/ProcessesTable.tsx
+++ b/apps/erp/app/modules/resources/ui/Processes/ProcessesTable.tsx
@@ -4,6 +4,7 @@ import {
AvatarGroupList,
AvatarOverflowIndicator,
Badge,
+ Checkbox,
HStack,
MenuIcon,
MenuItem,
@@ -16,6 +17,7 @@ import {
LuCog,
LuFactory,
LuPencil,
+ LuQrCode,
LuRuler,
LuTrash,
LuTriangleAlert,
@@ -157,6 +159,25 @@ const ProcessesTable = memo(({ data, count }: ProcessesTableProps) => {
icon: <LuUsers />,
},
},
+ {
+ accessorKey: "completeAllOnScan",
+ header: "Complete All",
+ cell: ({ row }) => (
+ <div className="flex w-full items-center justify-center">
+ <Checkbox isChecked={row.original.completeAllOnScan ?? false} />
+ </div>
+ ),
+ meta: {
+ icon: <LuQrCode />,
+ filter: {
+ type: "static",
+ options: [
+ { value: "true", label: "Yes" },
+ { value: "false", label: "No" },
+ ],
+ },
+ },
+ },
{
id: "createdBy",
header: "Created By",
diff --git a/apps/erp/app/routes/x+/resources+/processes.$processId.tsx b/apps/erp/app/routes/x+/resources+/processes.$processId.tsx
index 9f3fde8754..4d1b06be07 100644
--- a/apps/erp/app/routes/x+/resources+/processes.$processId.tsx
+++ b/apps/erp/app/routes/x+/resources+/processes.$processId.tsx
@@ -98,6 +98,7 @@ export default function ProcessRoute() {
// @ts-ignore
suppliers: (process.suppliers ?? []).map((s) => s.id) ?? [],
...getCustomFields(process.customFields),
+ completeAllOnScan: process.completeAllOnScan ?? false,
};
return <ProcessForm initialValues={initialValues} onClose={onClose} />;
diff --git a/apps/erp/app/routes/x+/resources+/processes.new.tsx b/apps/erp/app/routes/x+/resources+/processes.new.tsx
index 911e85b497..1a1d8c0703 100644
--- a/apps/erp/app/routes/x+/resources+/processes.new.tsx
+++ b/apps/erp/app/routes/x+/resources+/processes.new.tsx
@@ -75,6 +75,7 @@ export default function NewProcessRoute() {
name: "",
processType: "Inside" as const,
defaultStandardFactor: "Minutes/Piece" as const,
+ completeAllOnScan: false,
};
return <ProcessForm initialValues={initialValues} onClose={onClose} />;
diff --git a/apps/mes/app/routes/x+/end.$operationId.tsx b/apps/mes/app/routes/x+/end.$operationId.tsx
index c7e145aadd..a707fd4d16 100644
--- a/apps/mes/app/routes/x+/end.$operationId.tsx
+++ b/apps/mes/app/routes/x+/end.$operationId.tsx
@@ -23,7 +23,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const [jobOperation, productionQuantities] = await Promise.all([
serviceRole
.from("jobOperation")
- .select("*")
+ .select("*, ...process(completeAllOnScan)")
.eq("id", operationId)
.maybeSingle(),
serviceRole
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 2095f174e2..4e64fcd908 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -10227,7 +10227,6 @@ export type Database = {
Row: {
assignee: string | null
companyId: string
- completeAllOnScan: boolean
createdAt: string
createdBy: string
customFields: Json | null
@@ -10270,7 +10269,6 @@ export type Database = {
Insert: {
assignee?: string | null
companyId: string
- completeAllOnScan?: boolean
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -10313,7 +10311,6 @@ export type Database = {
Update: {
assignee?: string | null
companyId?: string
- completeAllOnScan?: boolean
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -13358,7 +13355,6 @@ export type Database = {
methodOperation: {
Row: {
companyId: string
- completeAllOnScan: boolean
createdAt: string
createdBy: string
customFields: Json | null
@@ -13388,7 +13384,6 @@ export type Database = {
}
Insert: {
companyId: string
- completeAllOnScan?: boolean
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -13418,7 +13413,6 @@ export type Database = {
}
Update: {
companyId?: string
- completeAllOnScan?: boolean
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -19966,6 +19960,7 @@ export type Database = {
process: {
Row: {
companyId: string
+ completeAllOnScan: boolean
createdAt: string
createdBy: string
customFields: Json | null
@@ -19979,6 +19974,7 @@ export type Database = {
}
Insert: {
companyId: string
+ completeAllOnScan?: boolean
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -19992,6 +19988,7 @@ export type Database = {
}
Update: {
companyId?: string
+ completeAllOnScan?: boolean
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -24765,7 +24762,6 @@ export type Database = {
quoteOperation: {
Row: {
companyId: string
- completeAllOnScan: boolean
createdAt: string
createdBy: string
customFields: Json | null
@@ -24800,7 +24796,6 @@ export type Database = {
}
Insert: {
companyId: string
- completeAllOnScan?: boolean
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -24835,7 +24830,6 @@ export type Database = {
}
Update: {
companyId?: string
- completeAllOnScan?: boolean
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -41388,6 +41382,7 @@ export type Database = {
processes: {
Row: {
companyId: string | null
+ completeAllOnScan: boolean | null
createdAt: string | null
createdBy: string | null
customFields: Json | null
@@ -45492,14 +45487,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 2095f174e2..4e64fcd908 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -10227,7 +10227,6 @@ export type Database = {
Row: {
assignee: string | null
companyId: string
- completeAllOnScan: boolean
createdAt: string
createdBy: string
customFields: Json | null
@@ -10270,7 +10269,6 @@ export type Database = {
Insert: {
assignee?: string | null
companyId: string
- completeAllOnScan?: boolean
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -10313,7 +10311,6 @@ export type Database = {
Update: {
assignee?: string | null
companyId?: string
- completeAllOnScan?: boolean
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -13358,7 +13355,6 @@ export type Database = {
methodOperation: {
Row: {
companyId: string
- completeAllOnScan: boolean
createdAt: string
createdBy: string
customFields: Json | null
@@ -13388,7 +13384,6 @@ export type Database = {
}
Insert: {
companyId: string
- completeAllOnScan?: boolean
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -13418,7 +13413,6 @@ export type Database = {
}
Update: {
companyId?: string
- completeAllOnScan?: boolean
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -19966,6 +19960,7 @@ export type Database = {
process: {
Row: {
companyId: string
+ completeAllOnScan: boolean
createdAt: string
createdBy: string
customFields: Json | null
@@ -19979,6 +19974,7 @@ export type Database = {
}
Insert: {
companyId: string
+ completeAllOnScan?: boolean
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -19992,6 +19988,7 @@ export type Database = {
}
Update: {
companyId?: string
+ completeAllOnScan?: boolean
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -24765,7 +24762,6 @@ export type Database = {
quoteOperation: {
Row: {
companyId: string
- completeAllOnScan: boolean
createdAt: string
createdBy: string
customFields: Json | null
@@ -24800,7 +24796,6 @@ export type Database = {
}
Insert: {
companyId: string
- completeAllOnScan?: boolean
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -24835,7 +24830,6 @@ export type Database = {
}
Update: {
companyId?: string
- completeAllOnScan?: boolean
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -41388,6 +41382,7 @@ export type Database = {
processes: {
Row: {
companyId: string | null
+ completeAllOnScan: boolean | null
createdAt: string | null
createdBy: string | null
customFields: Json | null
@@ -45492,14 +45487,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
diff --git a/packages/database/supabase/migrations/20251001001426_kanban-jobs.sql b/packages/database/supabase/migrations/20251001001426_kanban-jobs.sql
index 438b66c3ec..23034343c5 100644
--- a/packages/database/supabase/migrations/20251001001426_kanban-jobs.sql
+++ b/packages/database/supabase/migrations/20251001001426_kanban-jobs.sql
@@ -26,8 +26,27 @@ LEFT JOIN "supplier" su ON k."supplierId" = su."id"
LEFT JOIN "job" j ON k."jobId" = j."id";
-ALTER TABLE "methodOperation" ADD COLUMN "completeAllOnScan" BOOLEAN NOT NULL DEFAULT FALSE;
-
-ALTER TABLE "quoteOperation" ADD COLUMN "completeAllOnScan" BOOLEAN NOT NULL DEFAULT FALSE;
-
-ALTER TABLE "jobOperation" ADD COLUMN "completeAllOnScan" BOOLEAN NOT NULL DEFAULT FALSE;
\ No newline at end of file
+ALTER TABLE "process" ADD COLUMN "completeAllOnScan" BOOLEAN NOT NULL DEFAULT FALSE;
+DROP VIEW IF EXISTS "processes";
+CREATE OR REPLACE VIEW "processes" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ p.*,
+ wcp."workCenters",
+ sp."suppliers"
+ FROM "process" p
+ LEFT JOIN (
+ SELECT
+ "processId",
+ array_agg("workCenterId"::text) as "workCenters"
+ FROM "workCenterProcess" wcp
+ INNER JOIN "workCenter" wc ON wcp."workCenterId" = wc.id
+ GROUP BY "processId"
+ ) wcp ON p.id = wcp."processId"
+ LEFT JOIN (
+ SELECT
+ "processId",
+ jsonb_agg(jsonb_build_object('id', sp."id", 'name', s.name)) as "suppliers"
+ FROM "supplierProcess" sp
+ INNER JOIN "supplier" s ON sp."supplierId" = s.id
+ GROUP BY "processId"
+ ) sp ON p.id = sp."processId";
\ No newline at end of file