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.

Merge branch 'main' into feat/custom-fields

Brad Barbinb595dc0d84f6
diff --cc apps/carbon/app/modules/sales/sales.service.ts
index 748a7b24dd,5ae7ce721a..bdeea583e9
--- a/apps/carbon/app/modules/sales/sales.service.ts
+++ b/apps/carbon/app/modules/sales/sales.service.ts
@@@ -1,4 -1,4 +1,5 @@@
-import type { Database } from "@carbon/database";
+import type { Database, Json } from "@carbon/database";
++import { getLocalTimeZone, today } from "@internationalized/date";
import type { SupabaseClient } from "@supabase/supabase-js";
import type { z } from "zod";
import type { GenericQueryFilters } from "~/utils/query";
@@@ -562,22 -573,28 +563,37 @@@ export async function insertQuoteLineQu
]);
}
+ export async function releaseQuote(
+ client: SupabaseClient<Database>,
+ quoteId: string,
+ usedId: string
+ ) {
+ return client
+ .from("quote")
+ .update({
+ status: "Open",
+ updatedAt: today(getLocalTimeZone()).toString(),
+ updatedBy: usedId,
+ })
+ .eq("id", quoteId);
+ }
+
-export async function updateCustomer(
+export async function upsertCustomer(
client: SupabaseClient<Database>,
- customer: Omit<z.infer<typeof customerValidator>, "id"> & {
- id: string;
- updatedBy: string;
- }
+ customer:
+ | (Omit<z.infer<typeof customerValidator>, "id"> & {
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof customerValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
) {
+ if ("createdBy" in customer) {
+ return client.from("customer").insert([customer]).select("*").single();
+ }
return client
.from("customer")
.update(sanitize(customer))