Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/erp/app/hooks/useModules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
LuFiles,
LuFolderCheck,
LuLandmark,
LuPrinter,
LuSettings,
LuShield,
LuShoppingCart,
Expand Down Expand Up @@ -93,6 +94,12 @@ export function useModules() {
to: path.to.documents,
icon: LuFiles
},
{
permission: "printing",
name: "Print Manager",
to: path.to.printManager,
icon: LuPrinter
},
{
permission: "users",
name: "Users",
Expand Down
8 changes: 8 additions & 0 deletions apps/erp/app/modules/settings/settings.models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ export const materialUnitsValidator = z.object({
useMetric: zfd.checkbox()
});

export {
assignmentSettingsValidator,
autoPrintSettingsValidator,
locationOverrideValidator,
printerRouteValidator,
workCenterOverrideValidator
} from "@carbon/printing";

export const productLabelSizeValidator = z.object({
productLabelSize: z.enum(
labelSizes.map((size) => size.id) as [string, ...string[]],
Expand Down
7 changes: 7 additions & 0 deletions apps/erp/app/modules/settings/ui/useSettingsSubmodules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
LuImage,
LuKey,
LuLayoutDashboard,
LuPrinter,
LuSheet,
LuShoppingCart,
LuSquareStack,
Expand Down Expand Up @@ -55,6 +56,12 @@ const settingsRoutes: AuthenticatedRouteGroup<{
to: path.to.logos,
role: "employee",
icon: <LuImage />
},
{
name: "Printing",
to: path.to.printingSettings,
role: "employee",
icon: <LuPrinter />
}
]
},
Expand Down
58 changes: 58 additions & 0 deletions apps/erp/app/routes/api+/kanban.$id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { notFound } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { getCarbonServiceRole } from "@carbon/auth/client.server";
import type { Database } from "@carbon/database";
import type { PrintingSettings } from "@carbon/printing";
import { Loading } from "@carbon/react";
import { getLocalTimeZone, today } from "@internationalized/date";
import type { SupabaseClient } from "@supabase/supabase-js";
Expand Down Expand Up @@ -158,6 +159,34 @@ async function handleKanban({
};
}

// Auto-print kanban card if enabled
try {
const { data: cs } = await serviceRole
.from("companySettings")
.select("printing")
.eq("id", companyId)
.single();
const printing = cs?.printing as PrintingSettings | null;
if (printing?.autoPrint?.kanbanCards) {
await tasks.trigger(
"print-job",
{
sourceDocument: "Kanban" as const,
sourceDocumentId: kanban.data.id!,
companyId,
userId,
locationId: kanban.data.locationId ?? undefined
},
{
idempotencyKey: `auto-print-Kanban-${kanban.data.id}`,
idempotencyKeyTTL: "5m"
}
);
}
} catch (e) {
console.error("Auto-print failed:", e);
}

if (!upsertMethod.error && kanban.data.autoRelease) {
await Promise.all([
tasks.trigger("recalculate", {
Expand Down Expand Up @@ -345,6 +374,35 @@ async function handleKanban({
};
}

// Auto-print kanban card if enabled
try {
const serviceRole = getCarbonServiceRole();
const { data: cs } = await serviceRole
.from("companySettings")
.select("printing")
.eq("id", companyId)
.single();
const printing = cs?.printing as PrintingSettings | null;
if (printing?.autoPrint?.kanbanCards) {
await tasks.trigger(
"print-job",
{
sourceDocument: "Kanban" as const,
sourceDocumentId: kanban.data.id!,
companyId,
userId,
locationId: kanban.data.locationId ?? undefined
},
{
idempotencyKey: `auto-print-Kanban-${kanban.data.id}`,
idempotencyKeyTTL: "5m"
}
);
}
} catch (e) {
console.error("Auto-print failed:", e);
}

return {
data: path.to.purchaseOrder(purchaseOrderId!),
error: null
Expand Down
Loading