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.

fix: void related shipment on voided sales invoice

Brad Barbina16c74b0913a
diff --git a/packages/database/supabase/functions/post-sales-invoice/index.ts b/packages/database/supabase/functions/post-sales-invoice/index.ts
index 6c38a8e2da..e421aa01bf 100644
--- a/packages/database/supabase/functions/post-sales-invoice/index.ts
+++ b/packages/database/supabase/functions/post-sales-invoice/index.ts
@@ -994,7 +994,13 @@ serve(async (req: Request) => {
.execute();
await trx
- .deleteFrom("shipment")
+ .updateTable("shipment")
+ .set({
+ invoiced: false,
+ status: "Voided",
+ updatedAt: today,
+ updatedBy: userId,
+ })
.where("id", "=", shipment.id)
.execute();
}
diff --git a/packages/database/supabase/migrations/20250827181005_company-bucket-rls.sql b/packages/database/supabase/migrations/20250827181005_company-bucket-rls.sql
index 35385e3431..1dfc968d00 100644
--- a/packages/database/supabase/migrations/20250827181005_company-bucket-rls.sql
+++ b/packages/database/supabase/migrations/20250827181005_company-bucket-rls.sql
@@ -78,6 +78,7 @@ DROP POLICY IF EXISTS "Thumbnail insert requires parts_update" ON storage.object
DROP POLICY IF EXISTS "Thumbnail update requires parts_update" ON storage.objects;
DROP POLICY IF EXISTS "Thumbnail delete requires parts_delete" ON storage.objects;
+DROP POLICY IF EXISTS "Shared Private Bucket" ON storage.objects;
CREATE POLICY "Shared Private Bucket" ON storage.objects
FOR ALL USING (
bucket_id = 'private'
@@ -90,6 +91,7 @@ FOR ALL USING (
);
-- Create comprehensive policy for company buckets
+DROP POLICY IF EXISTS "Company bucket access" ON storage.objects;
CREATE POLICY "Company bucket access" ON storage.objects
FOR ALL USING (
bucket_id = ANY (
@@ -100,5 +102,3 @@ FOR ALL USING (
)
);
-
-CREATE INDEX idx_objects_bucket_id ON storage.objects(bucket_id);
\ No newline at end of file