feat(MED-86): add db fn to show medipost dispatch error for order in Medusa

This commit is contained in:
2025-08-28 13:36:07 +03:00
parent f723633646
commit b931035c3b
2 changed files with 18 additions and 0 deletions

View File

@@ -2110,6 +2110,14 @@ export type Database = {
medusa_order_id: string medusa_order_id: string
} }
} }
order_has_medipost_dispatch_error: {
Args: {
medusa_order_id: string
}
Returns: {
success: boolean
}
}
} }
Enums: { Enums: {
analysis_feedback_status: "STARTED" | "DRAFT" | "COMPLETED" analysis_feedback_status: "STARTED" | "DRAFT" | "COMPLETED"

View File

@@ -0,0 +1,10 @@
CREATE OR REPLACE FUNCTION medreport.order_has_medipost_dispatch_error(medusa_order_id text)
RETURNS boolean AS $$
SELECT EXISTS (
SELECT 1 FROM medreport.medipost_actions
WHERE medusa_order_id = $1
AND has_error = true
);
$$ LANGUAGE sql STABLE;
grant execute on function medreport.order_has_medipost_dispatch_error(text) to service_role;