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 pull request #1525 from crbnos/fix/rfq-quote-currency-lookup

BettrCallRaul01c43cfd4b3b
diff --git a/packages/database/supabase/functions/convert/index.ts b/packages/database/supabase/functions/convert/index.ts
index 5099642424..aa6571abb5 100644
--- a/packages/database/supabase/functions/convert/index.ts
+++ b/packages/database/supabase/functions/convert/index.ts
@@ -1084,8 +1084,14 @@ serve(async (req: Request) => {
.from("currency")
.select("*")
.eq("code", currencyCode)
- .eq("companyId", companyId)
+ .eq("companyGroupId", company.data.companyGroupId)
.single();
+ // A missing rate must not fall through to 1 -- that quotes a
+ // foreign-currency customer at par. The base currency is the only
+ // case where 1 is correct by definition.
+ if (currency.error && currencyCode !== company.data.baseCurrencyCode) {
+ throw currency.error;
+ }
const exchangeRate = currency.data?.exchangeRate ?? 1;
const {